function MM_swapImgRestore() { //v3.0  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;}function MM_preloadImages() { //v3.0  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}}function MM_findObj(n, d) { //v4.01  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);  if(!x && d.getElementById) x=d.getElementById(n); return x;}function MM_swapImage() { //v3.0  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}}


//CLEAR FIELDfunction clearIt(field) {field.value="";}

//SHOW HIDE
function showHide(id) {var style = document.getElementById(id).style;if (style.display == "none"){style.display = "";} else {style.display = "none";
}} 

//Birthday Check & Tab
function checkLength(currEl, nextEl) {
      if (currEl.value.length == currEl.maxLength) {
	document.myForm.elements[nextEl].focus();
	} 
     }


// SIGN UP
function SignupCheck(form) {
hasDot = form.email.value.indexOf(".");hasAt = form.email.value.indexOf("@");if (hasDot == -1 || hasAt == -1) {	alert("Please enter your Email Address.");	form.email.focus();	return false;}

//Password Checkvalcheck = document.getElementById("CustomFields_33");if (valcheck.value == "") {	alert("Please enter a Password for this registration");	valcheck.focus();	return false;}

//Password Confirm
valcheck1 = document.getElementById("CustomFields_33");
valcheck2 = form.confirm;

if (valcheck1.value != valcheck2.value) {
	alert("Your Passwords Do Not Match. Try Again");	valcheck2.focus();	return false;}//First Name Checkvalcheck = document.getElementById("CustomFields_27");if (valcheck.value == "") {	alert("Please enter your First Name");	valcheck.focus();	return false;}//Last Name Check			valcheck = document.getElementById("CustomFields_28");if (valcheck.value == "") {	alert("Please enter your Last Name");	valcheck.focus();	return false;} //Zip Check	valcheck = document.getElementById("CustomFields_46");if (valcheck.value == "") {	alert("Please enter your Zip Code");	valcheck.focus();	return false;}

//Birth Month	valcheck = document.getElementById("CustomFields_31");
re2digit= /^\d{2}$/;if(valcheck.value=="" || valcheck.value.search(re2digit) == -1) {	alert("Please enter your Birth Month (mm)");	valcheck.focus();	return false;}

//Birth Day	valcheck = document.getElementById("CustomFields_34");re2digit= /^\d{2}$/;if(valcheck.value=="" || valcheck.value.search(re2digit) == -1) {	alert("Please enter your Birth Day (dd)");	valcheck.focus();	return false;}

//Birth Year	valcheck = document.getElementById("CustomFields_35");
re2digit= /^\d{4}$/;if(valcheck.value=="" || valcheck.value.search(re2digit) == -1) {	alert("Please enter your Birth Year (yyyy)");	valcheck.focus();	return false;}
 else {	return checkAge();}}

// CHECK AGE
function checkAge() {
var d = new Date();
var curryear = d.getFullYear();
var currday = "0"+d.getDay();
var currmonth = "0"+d.getMonth();
var thebyear = document.getElementById("CustomFields_35").value;
var thebmonth = document.getElementById("CustomFields_31").value;
var thebday = document.getElementById("CustomFields_34").value;
var diffyear = curryear - 13;

if (diffyear < thebyear) {
window.location.href = "signup_underage.php";
return false;
} else if(diffyear == thebyear && currmonth < thebmonth) {
window.location.href = "signup_underage.php";
return false;
} else {return true;}}


// OPEN WINDOW
function openWin(url,name,popW,popH) {w = screen.availWidth;
h = screen.availHeight;leftPos = 5;
topPos = 5;window.open(url,name,'width='+popW+',height='+popH+',scrollbars=no,toolbar=no,status=no,resizable=yes,top='+ topPos+',left='+leftPos);}

//AJAX
function ajaxRequest() {var activexmodes=["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] //activeX versions to check for in IEif (window.ActiveXObject){ //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken)  for (var i=0; i<activexmodes.length; i++){   try{    return new ActiveXObject(activexmodes[i])   }   catch(e){    //suppress error   }  } } else if (window.XMLHttpRequest) // if Mozilla, Safari etc  return new XMLHttpRequest() else  return false};

//LOG IN
function LogInHere(form) {var req = ajaxRequest();
if (req==null) {	alert("Browser does not support HTTP Request");	return;}
req.onreadystatechange = function () { if (req.readyState==4) {      if (req.status==200) {           document.getElementById('loginbox').innerHTML=req.responseText; //return value;      } else {   	alert("An error has occured making the request");      } }};
var theemail = form.email.value;
var thepassword = form.pass.value;var fields = "email="+theemail+"&pass=" + thepassword;req.open("POST", "process_login.php", true);req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1");req.send(fields); 
};

//YOUTUBE VIDEO
function YouTubeVid(thefile) {var req = ajaxRequest();
if (req==null) {	alert("Browser does not support HTTP Request");	return;}
req.onreadystatechange = function () {
 if (req.readyState!=4) {
document.getElementById('thevideo').innerHTML="<b>Loading...</b>"; 
} else {      if (req.status==200) {           document.getElementById('thevideo').innerHTML=req.responseText; //return value;      } else {   	alert("An error has occured making the request");      } }}
var fields = "fileid="+thefile;req.open("POST", "process_youtube1.php", true);req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1");req.send(fields); 
};

//YOUTUBE VIDEO
function YouTubeMainVid(thefile) {var req = ajaxRequest();
if (req==null) {	alert("Browser does not support HTTP Request");	return;}
req.onreadystatechange = function () {
 if (req.readyState!=4) {
document.getElementById('thevideo').innerHTML="<b>Loading...</b>"; 
} else {      if (req.status==200) {           document.getElementById('thevideo').innerHTML=req.responseText; //return value;      } else {   	alert("An error has occured making the request");      } }}
var fields = "vidfile="+thefile;req.open("POST", "process_youtubemain.php", true);req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1");req.send(fields); 
};



