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

function check_login($todo)
{
var error='PLEASE CORRECT FOLLOWING ERRORS:';
if(document.getElementById('email').value==''){error=error+'\nEMAIL ADDRESS';}
if($todo=='LOGIN'){if(document.getElementById('password').value==''){error=error+'\nPASSWORD';}}
if(error!='PLEASE CORRECT FOLLOWING ERRORS:'){alert(error);	return false;}
}
function check_pass_update()
{
var error='PLEASE CORRECT FOLLOWING ERRORS:';
if(document.getElementById('email').value==''){error=error+'\nNO EMAIL ADDRESS';}
if(document.getElementById('password').value==''){error=error+'\nNO PASSWORD';}
if(document.getElementById('re_password').value!=document.getElementById('password').value){error=error+'\nPASSWORD REPEATED INCORECTLY';}
if(error!='PLEASE CORRECT FOLLOWING ERRORS:'){alert(error);	return false;}
}
function register()
{
var error='PLEASE CORRECT FOLLOWING ERRORS:';
if(document.getElementById('firstName').value==''){error=error+'\nFIRST NAME';}
if(document.getElementById('lastName').value==''){error=error+'\nLAST NAME';}
if(document.getElementById('address1').value==''){error=error+'\nADDRESS';}
if(document.getElementById('city').value==''){error=error+'\nCITY';}
if(document.getElementById('state').value==''){error=error+'\nSTATE';}
if(document.getElementById('countryid').value==''){error=error+'\nCOUNTRY';}
if(document.getElementById('zip').value==''){error=error+'\nPOSTAL CODE / ZIP';}
if(document.getElementById('password').value==''){error=error+'\nPASSWORD';}
if(document.getElementById('phone').value==''){error=error+'\nPHONE';}
if(document.getElementById('email').value==''){error=error+'\nEMAIL';}
if(error!='PLEASE CORRECT FOLLOWING ERRORS:'){alert(error);	return false;}
}
function ajax_fetch_multi(output, path, return_path,  message )
{
	var url 	= 'http://dev.tundratechnical.ca/pages/job_action.php';
	var params = 'dummy=' + new Date().getTime()+'&'+path;
	if(output){output = document.getElementById(output);}
	if(return_path){return_path = return_path;}
	var xmlHttp=false;
	try {xmlHttp=new XMLHttpRequest();} // Firefox, Opera 8.0+, Safari  
	catch (e)// Internet Explorer  
  {
		try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
  	catch (e)
		{    
		try{xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
    catch (e){ alert("Your browser does not support AJAX!"); return false;}
		}
	}
	xmlHttp.open("POST", url, true); 
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); 
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.onreadystatechange=function()
	{
	if(xmlHttp.readyState==4)
		{
			output.innerHTML = xmlHttp.responseText;
			if(message){alert(message);}
		}
	}
	xmlHttp.send(params);
	if(return_path &&  return_path!='EVAL')
	{
	ajax_fetch_multi('container', return_path)
	}
}

