function testfunc()
{
	alert("Test");
}

function loadPic(strid,abPath)
{
	if (abPath!=2)
	{
		path = 'images/Regional Representatives/';
	}
	else 
	{
		path = 'images/Central representatives/';
	}
	$('#txtPicture').html('<p><center><img src="images/loadingAnimation.gif" width="25" height="19" /></center></p>');
	if (strid=="")
	{
		$('#txtPicture').html('<h4>No Preview</h4>');
	}
	else
	{
			$('#txtPicture').html("<img src = '"+path+strid+"' width ='110' height='114'>"); 
	}
}


function popupCal(title, details, hh,mm,details)
{
	$.ajaxSetup({cache:false});
alert("Details: "+details+"\nTime: "+hh+":"+mm+"\nDetails: "+details);
}

function transHint(target, source)
{
	document.getElementById(target).value = source;
}

function getHintExeContact(str,element)
{
	//AJAX function to populate suggestions of company names
var xmlhttp;
//loading graphic
 $('#txtHint').html('<p><center><img src="images/loadingAnimation.gif" width="25" height="19" /></center></p>');
if (str.length==0)
  {
  document.getElementById(element).innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById(element).innerHTML=xmlhttp.responseText;
    }
  }
   
  
  
//xmlhttp.open("GET","AJAX_getCompany.php?q="+str,true);
$('#txtHint').load("AJAX_getECon.php?q="+str);
//xmlhttp.send();
}

function getHintRegContact(str,element)
{
	//AJAX function to populate suggestions of company names
var xmlhttp;
//loading graphic
 $('#txtHint').html('<p><center><img src="images/loadingAnimation.gif" width="25" height="19" /></center></p>');
if (str.length==0)
  {
  document.getElementById(element).innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById(element).innerHTML=xmlhttp.responseText;
    }
  }
   
  
  
//xmlhttp.open("GET","AJAX_getCompany.php?q="+str,true);
$('#txtHint').load("AJAX_getCon.php?q="+str);
//xmlhttp.send();
}

function getSchool(str,element)
{
	//AJAX function to populate suggestions of company names
var xmlhttp;
//loading graphic
 $('#schoolDets').html('<p><center><img src="images/loadingAnimation.gif" width="25" height="19" /></center></p>');
if (str.length==0)
  {
  document.getElementById(element).innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById(element).innerHTML=xmlhttp.responseText;
    }
  }
   
  
  
//xmlhttp.open("GET","AJAX_getCompany.php?q="+str,true);
$('#schoolDets').load("AJAX_getSchool.php?q="+str);
//xmlhttp.send();
}

function getHint(str,element)
{
	//AJAX function to populate suggestions of company names
var xmlhttp;
//loading graphic
 $('#hintBorder').html('<p><center><img src="images/loadingAnimation.gif" width="25" height="19" /></center></p>');
if (str.length==0)
  {
  document.getElementById(element).innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById(element).innerHTML=xmlhttp.responseText;
    }
  }
   
  
  
//xmlhttp.open("GET","AJAX_getCompany.php?q="+str,true);
$('#txtCatHint').load("AJAX_getCat.php?q="+str);
//xmlhttp.send();
}

function loadCal(element,calmonth, calyear)
{ //this function populates the calendar object
	region = document.getElementById('cmbRegion').value;
	$("#calrefresh").load("getCal.php?calmonth="+calmonth+"&calyear="+calyear+"&region="+region);
	$("#E_Script").load('<script src="js/coda.js" type="text/javascript"> </script>');
}

function verify(value, returnelement)
{
			
	if (value=="")
	{
		document.getElementById(returnelement).innerHTML='<p><center><img src="images/cross.gif" width="25" height="17" /></center></p>';
	}
	else
	{
		document.getElementById(returnelement).innerHTML='<p><center><img src="images/tick.gif" width="25" height="17" /></center></p>';
	}
		buttonpop(1);
		
}

function buttonpop(source)
{
	elements=11;
	count=0;
	for (i=0;i<elements;i++) 
		{
			box = document.forms["frmregister"].elements[i];
			if (box.name!="txtAddL2")
			{
				if (box.value)
				{
					count++;			
				}
			}
		}	
	if (source ==1) //Call from email checker
	{
		str= document.getElementById("txtEmail").value;
		if ((count==10) && (verifyemail(str)))
			{
				document.getElementById("subButton").innerHTML='<input type = "image" src="images/buttonsubmit.png" id="btnsubmit" alt="Submit" width="95" height="33" align="top"/>';
			}
		else
			{
				document.getElementById("subButton").innerHTML='<input type = "image" src="images/buttonSubmitdisabled.png" id="btnsubmit" alt="Submit" width="95" height="33" align="top" disabled = "true"/>';
			}	
	}
	if (source==2) //call from password checker
	{
		if ((count==10) && (checkpassword()))
			{
				document.getElementById("subButton").innerHTML='<input type = "image" src="images/buttonsubmit.png" id="btnsubmit" alt="Submit" width="95" height="33" align="top"/>';
			}
		else
			{
				document.getElementById("subButton").innerHTML='<input type = "image" src="images/buttonSubmitdisabled.png" id="btnsubmit" alt="Submit" width="95" height="33" align="top" disabled = "true"/>';
			}	
	}	
	if (source==0) //call from any other element
	{
	if ((count==10) && (verifyemail(str)) && (checkpassword()))
			{
				document.getElementById("subButton").innerHTML='<input type = "image" src="images/buttonsubmit.png" id="btnsubmit" alt="Submit" width="95" height="33" align="top"/>';
			}
		else
			{
				document.getElementById("subButton").innerHTML='<input type = "image" src="images/buttonSubmitdisabled.png" id="btnsubmit" alt="Submit" width="95" height="33" align="top" disabled = "true"/>';
			}		
	}
}

function loadlevents(element,value)

{//this function dynamically loads the events
var xmlhttp;
//loading graphic
document.getElementById(element).innerHTML='<p><center><img src="images/loadingAnimation.gif" width="25" height="19" /></center></p>';
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById(element).innerHTML=xmlhttp.responseText;
    }
  }
  if (value == 'more')
  {xmlhttp.open("GET","localfeed.php?type=a",true);}
  else
  {xmlhttp.open("GET","localfeed.php",true);}
xmlhttp.send();
}

function loadCEB(element)

{//this function dynamically loads the region based on the selection a user makes
var xmlhttp;
//loading graphic
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById(element).innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","LoadCEB.php",true);
xmlhttp.send();
xmlhttp.stop();
}


function loadinfo(region,target,element)

{//this function dynamically loads the region based on the selection a user makes
var xmlhttp;
  document.getElementById(element).innerHTML='<p><center><img src="images/loadingAnimation.gif" width="25" height="19" /></center></p>';
//loading graphic
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById(element).innerHTML=xmlhttp.responseText;
    }
  }
   
  target=target+"?region="+region;
xmlhttp.open("GET",target,true);
xmlhttp.send();
}

function loadquest(value)
{
	var xmlhttp;
//loading graphic
 $('#question1').html('<p><center><img src="images/loadingAnimation.gif" width="25" height="19" /></center></p>');

if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById(element).innerHTML=xmlhttp.responseText;
    }
  }
   
  
  
//xmlhttp.open("GET","AJAX_getCompany.php?q="+str,true);
$('#schoolDets').load("AJAX_getSchool.php?q="+str);
}

function countChars(str,target)
{
	var counter;
	var message;
	//AJAX function to count number of characters in a given field
  document.getElementById(target).innerHTML='<p><center><img src="images/loadingAnimation.gif" width="25" height="19" /></center></p>';
//loading graphic
if (str.length==0)
  {
  document.getElementById(target).innerHTML='255';
  return;
  }
  else
  {
	  counter = 255-str.length;
	  message="";
	  document.getElementById("Warnnotification").innerHTML="";
	  if (counter<0)
	  {
		  counter=counter*-1;
		  message="<b><font color = 'red'><br>You have reached the limit of 255 characters, you are over by: "+counter+" characters</font></b>";
		  document.getElementById("Warnnotification").innerHTML="<img src='images/loadingAnimation.gif' width='25' height='19' /><br>"+message;
		  counter=0;
	  }
	  document.getElementById(target).innerHTML=counter;
  }
}

function verifyForm()
{
	if ((verifyemail()) && (checkpassword()))
	{
		document.getElementById("submitbutton").innerHTML= '<input type = "image" src="images/buttonsubmit.png" id="btnsubmit" alt="Submit" width="95" height="33" align="top" />';
	}
	else
	{
		document.getElementById("Endmessage").innerHTML='<b>Some fields have not been filled out correctly, please fix these errors before you continue!</b>';
	}
}


function verifyemail(str)
{//Function to validate emails
  document.getElementById("emailverify").innerHTML='<p><center><img src="images/loadingAnimation.gif" width="25" height="17" /></center></p>';
//loading graphic
var x=str;
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
  {
	document.getElementById("emailverify").innerHTML='<p><center><img src="images/cross.gif" width="25" height="17" /></center></p>';
	document.getElementById("subButton").innerHTML='<input type = "image" src="images/buttonSubmitdisabled.png" id="btnsubmit" alt="Submit" width="95" height="33" align="top" disabled = "true"/>';
  return false;
  }
	else
	{
		document.getElementById("emailverify").innerHTML='<p><center><img src="images/tick.gif" width="25" height="17" /></center></p>';
		return true;

	}
}


function checkpassword()
{
	
	//AJAX function to populate suggestions of company names
	pwd=document.getElementById("txtPassword").value;
	cpwd=document.getElementById("txtConfirm").value;
  document.getElementById("confirmpwd").innerHTML='<p><center><img src="images/loadingAnimation.gif" width="25" height="17" /></center></p>';
//loading graphic

if ((pwd=="") || (cpwd==""))
{
	document.getElementById("subButton").innerHTML='<input type = "image" src="images/buttonSubmitdisabled.png" id="btnsubmit" alt="Submit" width="95" height="33" align="top" disabled = "true"/>';
	return false;
}

  document.getElementById("confirmpwd").innerHTML="";
   if (pwd!=cpwd)
   {
	   document.getElementById("confirmpwd").innerHTML='<p><center><img src="images/cross.gif" width="25" height="17" /></center></p>';
	   document.getElementById("subButton").innerHTML='<input type = "image" src="images/buttonSubmitdisabled.png" id="btnsubmit" alt="Submit" width="95" height="33" align="top" disabled = "true"/>';
	   return false;
   }
   else
   {
	   document.getElementById("confirmpwd").innerHTML='<p><center><img src="images/tick.gif" width="25" height="17" />';
	   return true;
   }

}

function checkform(pagelink,elements,formName) {//this one creates the page link passing all elements
	flag=true;
	for (i=0;i<elements;i++) {
		box = document.forms[formName].elements[i] 
		if (i==0)
		{
			pagelink=pagelink+"?"+box.name+'='+box.value;
		}
		else
		{
			pagelink=pagelink+'&'+box.name+'='+box.value;
		}
		if (box.name!='txtAddL2')
		{
				if (!box.value) {
					alert('You haven\'t filled in ' + box.name + '!');
					box.focus();
					flag=false;
				}
		}
	}
	if (flag) 
	{
			 document.getElementById("txtContents").innerHTML='<p><center><img src="images/loadingAnimation.gif" width="25" height="19" /></center></p>';
		if (window.XMLHttpRequest)
		  {// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
		  }
		else
		  {// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		xmlhttp.onreadystatechange=function()
		  {
		  if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
			document.getElementById("txtContents").innerHTML=xmlhttp.responseText;
			}
		  }
		xmlhttp.open("GET",pagelink,true);
		xmlhttp.send();
	}//Flag
}

function timedRefresh(timeoutPeriod) {
	setTimeout("location.reload(true);",timeoutPeriod);
}

function Loadcontent(str)
{
	//AJAX function to populate suggestions of company names
var xmlhttp;
  document.getElementById("txtContents").innerHTML='<p><center><img src="images/loadingAnimation.gif" width="25" height="19" /></center></p>';
//loading graphic
if (str.length==0)
  {
  document.getElementById("txtContents").innerHTML='<p><center><img src="images/loadingAnimation.gif" width="25" height="19" /></center></p>';
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtContents").innerHTML=xmlhttp.responseText;
	
	  	if (str=="calendar.php")
{
	var currmonth = new Date();
	calmonth =currmonth.getMonth();
	var curryear = new Date();
    calyear=curryear.getFullYear();
	calmonth++;
	$("#calrefresh").load("getCal.php?calmonth="+calmonth+"&calyear="+calyear);
$("#E_Script").load('<script src="js/coda.js" type="text/javascript"> </script>');	
return;
}
    }
  }
$.ajaxSetup({cache:false});
xmlhttp.open("GET",str,true);
xmlhttp.send();


}

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];}
}
