$(document).ready(function(){
	$('#search_box').focus(function() {
		if(this.value == this.defaultValue){
        	this.value = "";
   	 }

	});
});

var time_variable;
 
var xmlhttp = new getXMLObject();	//xmlhttp holds the ajax object
 
function ajaxFunction() {
  var getdate = new Date();  //Used to prevent caching during ajax call
  if(xmlhttp) { 
  	var txtname = document.getElementById("member_email");
    xmlhttp.open("POST","affinity_login2.php",true); //calling php using POST method
    xmlhttp.onreadystatechange  = handleServerResponse;
    xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlhttp.send("member_email=" + member_email.value + "&member_password=" + member_password.value ); //Posting txtname to PHP File
  }
}


 
function handleServerResponse() {
   if (xmlhttp.readyState == 4) {
     if(xmlhttp.status == 200) {
       document.getElementById("result").innerHTML=xmlhttp.responseText; //Update the HTML Form element 
       document.getElementById("login").innerHTML="";
     }
     else {
        alert("Error during AJAX call. Please try again - "+xmlhttp.status);
     }
   }
}

function sortFunction(display_num, page_num) {
	
 display_num = typeof(display_num) != 'undefined' ? display_num : 12;
 page_num = typeof(display_num) != 'undefined' ? display_num : 0;
  var getdate = new Date();  //Used to prevent caching during ajax call
  if(xmlhttp) { 
  	var sendorder = document.getElementById("order");
 	var sendneighborhood = document.getElementById("select_neighborhood");
    xmlhttp.open("POST","sort2.php",true); //calling php using POST method
    xmlhttp.onreadystatechange  = handleSortServerResponse;
    xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlhttp.send("order=" + sendorder.value + "&neighborhood_id=" + sendneighborhood.value +"&display_num="+display_num+"&page="+page_num ); //Posting order to PHP File
  }
}

function handleSortServerResponse() {
   if (xmlhttp.readyState == 4) {
     if(xmlhttp.status == 200) {
       document.getElementById("bands_ordered").innerHTML=xmlhttp.responseText; //Update the HTML Form element 
     }
     else {
        alert("Error during AJAX call. Please try again - "+xmlhttp.status);
     }
   }
}





function ytuploadFunction() {
	var getdate = new Date();
	if(xmlhttp)
	 {
	 var send_video_title = document.getElementById("video_title");
 	 var send_video_keywords = document.getElementById("video_keywords");	 
 	 var send_video_description = document.getElementById("video_description");	 	 
	 xmlhttp.open("POST","yt_upload2.php",true);
	 xmlhttp.onreadystatechange  = handleYoutubeServerResponse;
	 xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	 xmlhttp.send("title=" + send_video_title.value + "&keywords=" + send_video_keywords.value + "&description=" + send_video_description.value );
	  }
}

function handleYoutubeServerResponse() {
   if (xmlhttp.readyState == 4) {
     if(xmlhttp.status == 200) {
       document.getElementById("youtube_upload_div").innerHTML=xmlhttp.responseText; //Update the HTML Form element 
     }
     else {
        alert("Error during AJAX call. Please try again - "+xmlhttp.status);
     }
   }
}
