$(document).ready(function() {   
           
    // Toggle comments
    $('a#togglecomments').click(function(){
        $('div#commentbulk').slideToggle('slow');
    });  
    
    // Hide who's attending
    $('.live_content').hide();
    
    // Toggle who's attending
    $('a.who').click(function(){
        $('div#live_content_' + this.id).slideToggle('slow');
    });
    
    // Mark attending
    $('a.markattending').click(function(){
        var thisId = this.id;
        $.post("./packages/members/data/attend.php", {item: thisId}, function(data){
            $("#live_content_" + thisId).html(data);
            $('div#live_content_' + thisId).slideDown('slow');    
          });
    });
    
    // Toggle members bits 
    
    //$("div.slideBody").each(function(){
        //alert($(this).height());    
        //$(this).css("height:", $(this).height() + "px");
    //});
       
    $('a.togglemembercontent').click(function(){   
        if($('div#container_' + this.id).is(':visible')){
            $('img#img_' + this.id).attr({src : "../../images/icon_panel_expand.jpg"}); 
        } 
        else{
            $('img#img_' + this.id).attr({src : "../../images/icon_panel_collapse.jpg"}); 
        }
        $('div#container_' + this.id).slideToggle('slow');
        
    });
    
    // Reporting
    $('a.reportcomment').click(function(){
        var thisId = this.id;
        $.post("./packages/members/data/report.php", {item: thisId}, function(data){
            Boxy.alert("<p>Thank you for reporting this content.  A moderator will look at it, and remove or edit if deemed inappropriate.</p>", null, {title: 'Report Content'});
        });
    });
    
    $('a.reportmembercomment').click(function(){
        var thisId = this.id;
        $.post("../../packages/members/data/report.php", {item: thisId}, function(data){
            Boxy.alert("<p>Thank you for reporting this content.  A moderator will look at it, and remove or edit if deemed inappropriate.</p>", null, {title: 'Report Content'});
        });
    });
    
    // Popout player
    $('a.popoutplayer').click(function(){
        var thisId = this.id;
        var offset = '';
        if(thisId == 'members'){
            offset = '../../';
        }
        window.open(offset + "popoutplayer.php", 'popoutplayer', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=300,height=164,left = 322,top = 183');
    });
        
    // Boxy stuff
    $(function() {
       
      
         
      // Not logged in alert
      $('.notlogged').click(function() {
        Boxy.alert("<p><strong>You need to be logged in to do this</strong></p><p><a href='members.php#login'>Click here to log in</a></p>", null, {title: 'Log in'});
        return false;
      });
      
      // Points explanation
      $('a.whatpoints').click(function() {
        Boxy.alert("<p><strong>What are these?</strong></p><p>Member points are reward when users contribute to the site.  The more you contribute (for example, by adding photos, reviewing shows, rating other member content), the more points you receive!</p>", null, {title: 'Member Points'});
        return false;
      });
      
       // Show map
      $('a.showmap').click(function() {
        Boxy.load('./packages/members/viewshowmap.php?id=' + this.id, {title: 'Show Location', modal: true});  
        return false;
      });
      
      // My marker position
      $('a.showfanmarker').click(function() {
        Boxy.load('../../packages/members/fanloc.php?id=' + this.id, {title: 'My Location', modal: true});  
        return false;
      });
      
      // Edit my tags
      $('a.edittags').click(function() {
        Boxy.load('../../packages/members/edittags.php', {title: 'My Tags', modal: true});  
        return false;
      });
      
      // Edit my music
      $('a.editmusic').click(function() {
        Boxy.load('../../packages/members/editmusic.php', {title: 'My Music List', modal: true});  
        return false;
      });

      // Log out
      $('a.domemberlogout').click(function() {
          var thisId = this.id;
          Boxy.confirm("Are you sure you wish to log out?", function() { 
              if(thisId == 'memberspage'){
                  window.location = ("../../login/processmemberlogout.php");
              }
              else{
                  window.location = ("login/processmemberlogout.php");
              } 
          }, {title: 'Logout'});
          return false;

      });
      
      // Send to a friend
      $('a.sendtofriend').click(function() {
        thisUrl = encodeURIComponent(location.href);
        Boxy.load('packages/members/send2friend.php?url=' + thisUrl, {title: 'Send To A Friend', modal: true}); 
        return false;
      });
      
      // Delete item
      
      
      $('a.deleteitem').click(function() {
          var thisId = this.id;
          var thisIdParts = thisId.split('_');
          var subId = thisIdParts[1];
          var subType = thisIdParts[0];
          var subHash = thisIdParts[2];
          Boxy.confirm("Are you sure you wish to permanently delete this item?", function() { 
              $.get("./data/deleteItem.php", { id: subId, type: subType, user: subHash } );
              location.reload(); 
          }, {title: 'Delete'});
          return false;

      });
      
      
      
    });
    
    /*
    function deleteComment(type, id, user){
        var confirmTxt = "Are you sure you want to permanently delete this item?";
        if(confirm(confirmTxt)){ 
            myTimeStamp = timestamp();
            if(type == 'myphotos' || type == 'photos'){
                var modurl = "../../data/deleteItem.php" + "?time=" + myTimeStamp + "&id=" + id + "&type=" + type + "&user=" + user;
            }
            else{
                var modurl = "./data/deleteItem.php" + "?time=" + myTimeStamp + "&id=" + id + "&type=" + type + "&user=" + user;
                }
            http.open("POST", modurl, true);
            http.onreadystatechange = function() {useHttpResponse('refresh', '', false);};
            http.send(''); 
            }   
    }
    */
    
    /*function confirmMemberLogout(isSite){
          if(confirm("Are you sure you wish to log out?")){
              if(isSite == false){
                  window.location = ("../../login/processmemberlogout.php");
              }
              else{
                  window.location = ("login/processmemberlogout.php");
              }
          }
      }*/
    
         
});

<!--

// Ajax functions...
function getXMLHTTPRequest() {
    try {
        req = new XMLHttpRequest();
    } 
        catch(err1) {
        try {
            req = new ActiveXObject("Msxml2.XMLHTTP");
        } 
                catch (err2) {
            try {
                req = new ActiveXObject("Microsoft.XMLHTTP");
            }
                        catch (err3) {
                req = false;
            }
        }
    }
    return req;
}

var http = getXMLHTTPRequest();

function useHttpResponse(type, div, loading) {
   if (http.readyState == 4) {
    if(http.status == 200) {
           if (type == 'text'){
                 // Return simple text output
           var myText = http.responseText;
           document.getElementById(div).innerHTML = myText;
             }
             if (type == 'alert'){
                 // Return an alert box
           var myText = http.responseText;
           alert(myText);
                     window.location.reload();
             }
             if (type == 'refresh'){
                 // Just refresh the page
                     window.location.reload();
             }
             if (type == 'xml'){
                 // Return XML
                     
             }
             if (type == 'none'){
                 // Return nothing
             }
    }
  } 
    else {
        if(loading == true){
          document.getElementById(div).innerHTML = '<div align="center"><img src="./images/loading.gif"></div>';
      }
    }
}

/* Function doCallback
*  parameters;
*  formName - the id of our form
*  validate - array of id's of fields we want to validate (false if none, 'all' if all)
*  doAjax - php script if yes, false if no
*  callbackType - text, alert, xml, none
*  div - div to update if callback is text/xml
*/
function doCallback(formName, validate, doAjax, callbackType, div){
    // Remove last element (always should be a button)
    var formLength = (document.getElementById(formName).elements.length)-1;
    // Validate required fields if we wanna 
        if(validate != false){
            if(validate == 'all'){
                    // Validate everything in the form
                    for(i=0; i<=formLength; i++){
                            var isEmail = document.getElementById(formName).elements[i].id.search(/email/);
                                var isPassword = document.getElementById(formName).elements[i].id.search(/password/);
                                if(isEmail != -1){
                                  // If we detect an email, perform a check on it
                                        if(isValidEmail(document.getElementById(formName).elements[i].value) == false){
                                            alert("Please enter a valid email.");                                        
                                            return false;
                                        }
                                }
                                else if(isPassword != -1){
                                  // If we detect a password, perform a check on it
                                        if(document.getElementById(formName).elements[i].value.length < 6){
                                            alert("Passwords must be at least 6 characters in length.");                                        
                                            return false;
                                        }
                                }
                            else if(document.getElementById(formName).elements[i].value == ''){
                                    alert("Please make sure to fill out all required fields.");
                                        return false;
                                }
                                
                        }
                }
                else{
                    // Only validate those fields specified in the array
                for(x=0; x<validate.length; x++){
                            var isEmail = document.getElementById(formName).elements[x].id.search(/email/);
                                var isPassword = document.getElementById(formName).elements[x].id.search(/password/);
                                if(isEmail != -1){
                                  // If we detect an email, perform a check on it
                                        if(isValidEmail(document.getElementById(formName).elements[x].value) == false){
                                            alert("Please enter a valid email.");                                        
                                            return false;
                                        }
                                }
                                else if(isPassword != -1){
                                  // If we detect a password, perform a check on it
                                        if(document.getElementById(formName).elements[x].value.length < 6){
                                            alert("Passwords must be at least 6 characters in length.");                                        
                                            return false;
                                        }
                                }
                    else if(document.getElementById(validate[x]).value == ''){
                            alert("Please make sure to fill out all required fields.");
                                return false;
                        }
                }
                }
        }      
        // Process ajax if we wanna
    if(doAjax != false){
          myTimeStamp = timestamp();
        var modurl = doAjax + "?time=" + myTimeStamp;
                for(i=0; i<formLength; i++){
                    modurl += "&" + document.getElementById(formName).elements[i].id + "=" + document.getElementById(formName).elements[i].value;
                }
                http.open("POST", modurl, true);
          http.onreadystatechange = function() {useHttpResponse(callbackType, div, false);};
        http.send('');
        }
        else{
            return true;
        }
}

function locationFields(country, div){
    var page = './packages/signup/forms/extraSignupElements.php';
      myTimeStamp = timestamp();
    var modurl = page + "?time=" + myTimeStamp + "&country=" + country;
    http.open("POST", modurl, true);
      http.onreadystatechange = function() {useHttpResponse('text', div, false);};
    http.send('');
}


function insertSmilie(myValue, myField){
    if (!myField){
            myField = document.messageForm.message;
      }

    if(document.selection) {
        myField.focus();
        sel = document.selection.createRange();
        sel.text = myValue;
        }
    else if(myField.selectionStart || myField.selectionStart == '0'){
        var startPos = myField.selectionStart;
        var endPos = myField.selectionEnd;
        myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length);
    } 
      else{
        myField.value += myValue;
  }
}

function checkAll(field){
    var isChecked = 0;
    for (i = 0; i < field.length; i++){
          if(field[i].checked == true){
                    isChecked++;
                }
        }
        if(isChecked == 0){
            for (i = 0; i < field.length; i++){
            field[i].checked = true;
            }
        }
        else{
            for (i = 0; i < field.length; i++){
            field[i].checked = false;
            }
        }
}


function swfMovie(url_cont, vidwidth, vidheight){
  document.write ('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="' + vidwidth + '" height="' + vidheight + '" id="' + url_cont + '" align="center">');
  document.write ('<param name="movie" value="' + url_cont + '">');
  document.write ('<param name="quality" value="high">');
  document.write ('<embed src="' + url_cont + '" width="' + vidwidth + '" height="' + vidheight + '" quality="high" name="' + url_cont + '" align="center" type="application/x-shockwave-flash" pluginspace="http://www.macromedia.com/go/getflashplayer">');
  document.write ('</embed>');
  document.write ('</object>');
}

function swfMovieTs(url_cont, vidwidth, vidheight, sessionId, pageId){
  var d = new Date();
  var timestamp = d.getTime();
  document.write ('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="' + vidwidth + '" height="' + vidheight + '" id="' + url_cont + '" align="center">');
  document.write ('<param name="movie" value="' + url_cont + '?timestamp=' + timestamp + '&sid=' + sessionId + '&pid=' + pageId + '">');
  document.write ('<param name="quality" value="high">');
  document.write ('<embed src="' + url_cont + '?timestamp=' + timestamp + '&sid=' + sessionId + '&pid=' + pageId + '" width="' + vidwidth + '" height="' + vidheight + '" quality="high" name="' + url_cont + '" align="center" type="application/x-shockwave-flash" pluginspace="http://www.macromedia.com/go/getflashplayer">');
  document.write ('</embed>');
  document.write ('</object>');
}

function popUp(url) {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(url, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=200,height=200,left = 322,top = 183');");
}

function popUpMap(url) {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(url, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=620,height=360,left = 322,top = 183');");
}

function liveNotes(div, notes){
    document.getElementById(div).innerHTML = "<div class=\"liveInfoNotes\"><div align=\"right\"><a href=\"javascript: clearNotes('" + div + "');\">X</a></div><br />" + notes.replace(/\n/g, '<br />') + "</div>";
}

function clearNotes(div){
    document.getElementById(div).innerHTML = "";
}



function addTags(hash, curr, tags){
    document.getElementById('tags').innerHTML = "<p>Seperate multiple tags with spaces</p><p><form id=\"tagForm\" onSubmit=\"return false;\"><input type=\"hidden\" name=\"id\" id=\"id\" value=\"" + hash + "\" /><input type=\"text\" name=\"tag\" id=\"tag\" value=\"" + tags.replace("\"", "&quot;") + "\" /><br /><br /><input type=\"button\" value=\"tag\" onClick=\"return doCallback('tagForm', false, '../../packages/members/tags/processTag.php', 'text', 'tags');\" /> <input type=\"button\" value=\"cancel\" onClick=\"window.location = 'index.php'\" /></form></p>";
}

function addMusic(hash, curr, tags){
    document.getElementById('music').innerHTML = "<p>Seperate multiple artists with spaces</p><p><form id=\"musicForm\" onSubmit=\"return false;\"><input type=\"hidden\" name=\"mid\" id=\"mid\" value=\"" + hash + "\" /><input type=\"text\" name=\"music\" id=\"music\" value=\"" + tags.replace("\"", "&quot;") + "\" /><br /><br /><input type=\"button\" value=\"add\" onClick=\"return doCallback('musicForm', false, '../../packages/members/music/processMusic.php', 'text', 'music');\" /> <input type=\"button\" value=\"cancel\" onClick=\"window.location = 'index.php'\" /></form></p>";
}

function newAvatar(hash){
    document.getElementById('avatar').innerHTML = "<p><form id=\"avatarForm\" enctype=\"multipart/form-data\" action=\"?page=misc&subpage=upload\" method=\"POST\"><input type=\"hidden\" name=\"id\" id=\"id\" value=\"" + hash + "\" /><input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"856000\"><input name=\"avatar\" type=\"file\" size=\"10\"/><br /><br /><input type=\"submit\" value=\"upload\" /> <input type=\"button\" value=\"cancel\" onClick=\"window.location = 'index.php'\" /></form></p><br />";
}

function showItem(type, id){
    window.location = ("./index.php?page=" + type + "&subpage=list&shows=" + id);
}

function rateUserContent(id, type, user, rating){
    myTimeStamp = timestamp();
    switch(type){
        case 'news':
        case 'music':
        case 'gallery':
            var modurl = "./packages/members/data/rating.php" + "?time=" + myTimeStamp + "&id=" + id + "&user=" + user + "&type=" + type + "&rating=" + rating; 
            break;
        default:
            var modurl = "../../packages/members/data/rating.php" + "?time=" + myTimeStamp + "&id=" + id + "&user=" + user + "&type=" + type + "&rating=" + rating;
    }
    http.open("POST", modurl, true);
    http.onreadystatechange = function() {useHttpResponse('refresh', '', false);};
    http.send('');  
}

function rateNewsContent(id, type, user, rating){
    myTimeStamp = timestamp();
    var modurl = "./packages/members/data/rating.php" + "?time=" + myTimeStamp + "&id=" + id + "&user=" + user + "&type=" + type + "&rating=" + rating;
    http.open("POST", modurl, true);
    http.onreadystatechange = function() {useHttpResponse('refresh', '', false);};
    http.send('');  
}

function attend(user, showId, attend){
    myTimeStamp = timestamp();
    var modurl = "./packages/members/data/attend.php" + "?time=" + myTimeStamp + "&id=" + showId + "&user=" + user + "&attend=" + attend;
        http.open("POST", modurl, true);
    http.onreadystatechange = function() {useHttpResponse('refresh', '', false);};
    http.send('');    
}


function getMemberMarker(id, multi){
    myTimeStamp = timestamp();
    var modurl = "markerdetails.php" + "?time=" + myTimeStamp + "&id=" + id + "&multi=" + multi;
    http.open("POST", modurl, true);
    http.onreadystatechange = function() {useHttpResponse('alert', '', false);};
    http.send('');    
}


function deleteMemberItem(type, id, user){
    var confirmTxt = "Are you sure you want to permanently delete this item?";
    if(confirm(confirmTxt)){ 
        myTimeStamp = timestamp();
        var modurl = "../../packages/members/data/deleteItem.php" + "?time=" + myTimeStamp + "&id=" + id + "&type=" + type + "&user=" + user;
            http.open("POST", modurl, true);
        http.onreadystatechange = function() {useHttpResponse('refresh', '', false);};
        http.send(''); 
        }   
}

// Check for a valid email
function isValidEmail(str) {
    return (str.indexOf(".") >= 0) && (str.indexOf("@") >= 0);
}

function popUpMap(url) {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(url, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=620,height=360,left = 322,top = 183');");
}

function timestamp(){
    var currentTime = new Date();
    var year = currentTime.getFullYear();
    var month = currentTime.getMonth() + 1;
    var day = currentTime.getDate();
    var hour = currentTime.getHours();
    var minute = currentTime.getMinutes();
    var second = currentTime.getSeconds();
    if (month < 10){
        month = "0" + month;
    }
    if (day < 10){
        day = "0" + day;
    }
    if (hour < 10){
        hour = "0" + hour;
    }
    if (minute < 10){
        minute = "0" + minute;
    }
    if (second < 10){
        second = "0" + second;
    }
        return(year + "" + month + "" + day + "" + hour + "" + minute + "" + second);
}
-->


