/* funct.js */

/* AJAX Method Check */
function checkAJAX()
{
 try { ajaxTMP=new XMLHttpRequest(); }// FF, Op8+, Safari
 catch(e) {
  try { ajaxTMP=new ActiveXObject("Msxml2.XMLHTTP"); }// IE6+
  catch(e) {
   try { ajaxTMP=new ActiveXObject("Microsoft.XMLHTTP"); }// IE5+
   catch(e) {
    alert("Your browser does not support AJAX!");
    return false;
   }
  }
 }
 return ajaxTMP;
}
/**/

function ajaxGig(gigID)
{
 var ajaxReq=checkAJAX();
 document.getElementById("date_info").innerHTML="<br><br><img src='/img/loading.gif' style='border:0;' alt='Loading...'>";
 ajaxReq.onreadystatechange=function() { if(ajaxReq.readyState==4) { document.getElementById("date_info").innerHTML=ajaxReq.responseText; } }

 ajaxReq.open("GET","inc/calendar.ajax.php?gigID="+gigID,true);
 ajaxReq.send(null);
}

function ajaxMP3(use_file,use_title)
{
 var ajaxReq=checkAJAX();
 ajaxReq.onreadystatechange=function() { if(ajaxReq.readyState==4) { document.getElementById("mp3_player").innerHTML=ajaxReq.responseText; } }

 ajaxReq.open("GET","/inc/music.ajax.php?file="+use_file+"&title="+use_title,true);
 ajaxReq.send(null);
}

function ajax_photo(use_photo)
{
	var ajaxReq=checkAJAX();
	ajaxReq.onreadystatechange=function() { if(ajaxReq.readyState==4) { document.getElementById("photo_viewer").innerHTML=ajaxReq.responseText; } }

	ajaxReq.open("GET","/inc/photos.ajax.php?photo="+use_photo,true);
	ajaxReq.send(null);
}

function ajax_test(input1,input2)
{
	var ajaxReq=checkAJAX();
	ajaxReq.onreadystatechange=function() { if(ajaxReq.readyState==4) { document.getElementById("bio_content").innerHTML=ajaxReq.responseText; } }

	ajaxReq.open("GET","/inc/test.ajax.php?bio="+input1+"&switch="+input2,true);
	ajaxReq.send(null);
}

function submit_contact_form()
{
	var edit_form=document.contact_form;
	var pass_vars_form=document.pass_vars;

	var errors=0;
	var errorStr="You must correct the following errors before continuing:\n\n";

	if(edit_form.contact_name.value=="")
	{
		errors=errors+1;
		errorStr+=errors+". You must enter a name.\n";
	}

	if(edit_form.contact_message.value=="")
	{
		errors=errors+1;
		errorStr+=errors+". You must enter a message.\n";
	}

	if(errors>0)
	{
		alert(errorStr);
	} else {
		pass_vars_form.name.value=escape(edit_form.contact_name.value);
		pass_vars_form.phone.value=escape(edit_form.contact_phone.value);
		pass_vars_form.email.value=escape(edit_form.contact_email.value);
		pass_vars_form.message.value=escape(edit_form.contact_message.value);

		pass_vars_form.submit();
	}
}

function switch_pics(use_date)
{
	if(use_date!="0")
	{
		location.replace('?v=fanpics&id='+use_date);
	}
}
