var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
 try {
 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
 try {
 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
 } catch (E) {
 xmlhttp = false;
 }
 }
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
 xmlhttp = new XMLHttpRequest();
}

function loadFragmentInToElement(fragment_url, element_id) {
 var element = document.getElementById(element_id);
 element.innerHTML = '<em>Loading ...</em>';
 xmlhttp.open("GET", fragment_url);
 xmlhttp.onreadystatechange = function() {
 if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
 element.innerHTML = xmlhttp.responseText;
 }
 }
 xmlhttp.send(null);
}

function loadurl(dest) {
try {
	// Moz supports XMLHttpRequest. IE uses ActiveX.
	// browser detction is bad. object detection works for any browser
	xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
	// browser doesn't support ajax. handle however you want
}
// the xmlhttp object triggers an event everytime the status changes
// triggered() function handles the events
xmlhttp.onreadystatechange = triggered;
// open takes in the HTTP method and url.
xmlhttp.open("GET", dest);
// send the request. if this is a POST request we would have
// sent post variables: send("name=aleem&gender=male)
// Moz is fine with just send(); but
// IE expects a value here, hence we do send(null);
xmlhttp.send(null);
}
function triggered() {
// if the readyState code is 4 (Completed)
// and http status is 200 (OK) we go ahead and get the responseText
// other readyState codes:
// 0=Uninitialised 1=Loading 2=Loaded 3=Interactive
if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
	// xmlhttp.responseText object contains the response.
	document.getElementById("stats").innerHTML = xmlhttp.responseText;
}
}

function sendcomments() { 

	if (document.commentform.name.value == "" || document.commentform.name.value == "Name") 
	{alert ("Name is a required field."); return false;}  
	if (document.commentform.email.value == "" || document.commentform.email.value == "E-Mail") 
	{alert ("E-Mail is a required field."); return false;} 
	if (document.commentform.message.value == "" || document.commentform.message.value == "Your Message") 
	{alert ("Message is a required field."); return false;}
	
	var name = document.commentform.name.value;
	var emailStr = document.commentform.email.value;
	var message = document.commentform.message.value;
	var thispage = document.commentform.thispage.value;
	 
	var emailPat=/^(.+)@(.+)$/ 
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]" 
	var validChars="\[^\\s" + specialChars + "\]" 
	var quotedUser="(\"[^\"]*\")" 
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/ 
	var atom=validChars + '+' 
	var word="(" + atom + "|" + quotedUser + ")" 
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")  
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
	 
	var matchArray=emailStr.match(emailPat)
	if (matchArray==null) { 
		alert("That doesn't look like a real e-mail address.")
		return false
	}
	var user=matchArray[1]
	var domain=matchArray[2]
	
	// See if "user" is valid 
	if (user.match(userPat)==null) {
		// user is not valid
		alert("That doesn't look like a real e-mail address.")
		return false
	}
	
	/* if the e-mail address is at an IP address (as opposed to a symbolic
	   host name) make sure the IP address is valid. */
	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) {
		// this is an IP address
		  for (var i=1;i<=4;i++) {
			if (IPArray[i]>255) {
				alert("That doesn't look like a real e-mail address.")
			return false
			}
		}
		return true
	}
	
	// Domain is symbolic name
	var domainArray=domain.match(domainPat)
	if (domainArray==null) {
		alert("That doesn't look like a real e-mail address.")
		return false
	}
	 
	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
	if (domArr[domArr.length-1].length<2 || 
		domArr[domArr.length-1].length>3) {
	   // the address must end in a two letter or three letter word.
	   alert("That doesn't look like a real e-mail address.")
	   return false
	}
	
	// Make sure there's a host name preceding the domain.
	if (len<2) {
	   var errStr="That doesn't look like a real e-mail address."
	   alert(errStr)
	   return false
	}
	  
	xmlhttp.open("GET", '@action.php?a=feedback&thispage=' + thispage + '&name=' + name + '&email=' + emailStr + '&message=' + message);
 
	 xmlhttp.onreadystatechange = function() {
		 if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		 document.getElementById('COMMENTS').innerHTML = xmlhttp.responseText;
 		}
	 }
	xmlhttp.send(null); return true; 
 
}
 
function mailsuccess() {
	alert("Your message was sent!");
	return true;
} 
	
function simpletogglediv(whichLayer)
{
	var theElementStyle = document.getElementById(whichLayer);  

	if(theElementStyle.style.display == "block")
		{theElementStyle.style.display = "none";}
	else
		{theElementStyle.style.display = "block";}
}  	

function toggleon(whichLayer){
	document.getElementById('menuone').style.display = "none";
	document.getElementById('menutwo').style.display = "none";
	document.getElementById('menuthree').style.display = "none";
	document.getElementById('menufour').style.display = "none";
	document.getElementById('menufive').style.display = "none";
	document.getElementById('menusix').style.display = "none";
	document.getElementById('menuseven').style.display = "none";
	document.getElementById('menueight').style.display = "none";
	document.getElementById('menunine').style.display = "none";
	document.getElementById('menuten').style.display = "none"; 
	var theElementStyle = document.getElementById(whichLayer);  
	theElementStyle.style.display = "block";
}
	
function toggleoff(whichLayer){
	var theElementStyle = document.getElementById(whichLayer);  
	theElementStyle.style.display = "none";
}
	
function changediv(div,string) {  
	 xmlhttp.open("GET", string);
	 var element = document.getElementById(div);
	 xmlhttp.onreadystatechange = function() {
		 if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		 	element.innerHTML = xmlhttp.responseText;
		 }
	 }
	 xmlhttp.send(null); 
	 return true;
}
function uidcheck(string) {  
	 var element = document.getElementById('usernameResult'); 
	  
	  xmlhttp.open("GET", "/inc/+uidcheck.php?username=" + string);
	  xmlhttp.onreadystatechange = function() {
		 if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		 	 element.innerHTML = xmlhttp.responseText;
		 }  
	 }  
	 
	 xmlhttp.send(null);
	
	 return true;
}
function changestat(div,string) {  
	 var thisSelect = document.statform.stat;
	 var id = thisSelect.options[thisSelect. selectedIndex].value; 
	 xmlhttp.open("GET", string+id);
	 var element = document.getElementById(div);
	 xmlhttp.onreadystatechange = function() {
		 if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		 	element.innerHTML = xmlhttp.responseText;
		 }
	 }
	 xmlhttp.send(null); 
	 return true;
}

function CSPop(url)
{
	newwindow=window.open(url,'peekvid','height=492,width=500,left=100,top=100,resizable=yes,scrollbars=no,toolbar=no,status=no');
	if (window.focus) {newwindow.focus()}
}


function changeratings(div,string) {  
	 var thisSelect = document.ratingsform.sw;
	 var id = thisSelect.options[thisSelect. selectedIndex].value;  
	 xmlhttp.open("GET", string+id);
	 var element = document.getElementById(div);
	 img_src = '/img/headers/h-ratings' + id + '.gif';
	 document.images['ratingshead'].src=img_src;
	 xmlhttp.onreadystatechange = function() {
		 if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		 	element.innerHTML = xmlhttp.responseText;
		 }
	 }
	 xmlhttp.send(null); 
	 return true;
} 

function tourn(div,string) {   
	 var thisSelect = document.tournform.sw;
	 var id = thisSelect.options[thisSelect. selectedIndex].value;  
	 xmlhttp.open("GET", string+id); 
	 var element = document.getElementById(div); 
	 xmlhttp.onreadystatechange = function() {
		 if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		 	element.innerHTML = xmlhttp.responseText;
		 }
	 }
	 xmlhttp.send(null); 
	 return true;
}

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];}
}
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];}}
}  


