// JavaScript Document
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];}
}

//testimonials

function embedFlash(ele, flashvars){
	var params = { };
	var attributes = {};
	swfobject.embedSWF("assets/media/vid_player.swf", ele, "482", "315", "9.0.115.0", "expressInstall.swf", flashvars, params, attributes);
}

// LOGIN

function showLoginBox(){
	document.getElementById('navLinks').style.display = 'none';
	document.getElementById('loginOptions').style.display = 'none';
	document.getElementById('searchBox').style.display = 'none';
	document.getElementById('socialmedia').style.display = 'none';
	document.getElementById('loginBox').style.display = 'block';
}

function closeLoginBox(){
	document.getElementById('navLinks').style.display = 'inline';
	document.getElementById('loginOptions').style.display = 'block';
	document.getElementById('searchBox').style.display = 'block';
	document.getElementById('socialmedia').style.display = 'inline';
	document.getElementById('loginBox').style.display = 'none';
}

function disableEle(id, disabled){
	var ele = document.getElementById(id);
	if(disabled){
		ele.className = 'disable';
	}else{
		ele.className = '';
	}
}
// end LOGIN //

//emailSignup//

function GetXmlHttpObject(){
	var xmlHttp=null;
	try{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e){
	// Internet Explorer
		try{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e){
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}


function email_signup(){
	var emailAddress = document.getElementById("email_signup_email").value;
	if(emailAddress==""){
		alert("You must provide a valid email address");
	}else{
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null){
		  alert ("Your browser does not support AJAX!");
		  return;
		} 
		var url="processEmailSignup.php";
		var params="email=" + emailAddress;
		params=params+"&sid="+Math.random(); //used to force no cache of URL
	
		url = url + "?" + params;
//		alert(url + "\n" + params);
	
		//alert(url);
	//	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	//	xmlHttp.setRequestHeader("Content-length", params.length);
	//	xmlHttp.setRequestHeader("Connection", "close");
		xmlHttp.onreadystatechange=email_signup_done;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(params);
	}
}

function email_signup_done(){
	if (xmlHttp.readyState==4){ 
		var ele = document.getElementById("emailSignup");
		ele.innerHTML = "<p>" + xmlHttp.responseText + "</p>";
	}
}
//end emailSignup

//effects//

function flashArea(ele_id){
	var img_url = document.getElementById(ele_id).style.backgroundImage;
	
	document.getElementById(ele_id).style.backgroundImage = "none";
	
	$("#" + ele_id).animate( { backgroundColor: '#ccc' }, 1000)
    .animate( { backgroundColor: '#fff' }, 1000, null, function(){document.getElementById(ele_id).style.backgroundImage = img_url;});
	//document.getElementById(ele_id).style.backgroundImage = img_url;
}

function resetBgImg(ele_id, img_url){
	document.getElementById(ele_id).style.backgroundImage = img_url;
}
//end effects//