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_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_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 next_page_submit(menucode)
  {
	  next_page_input = document.getElementById("next_page");
	  next_page_input.value = menucode;
	  document.maincontentform.submit();
  }

function ourpeople_submit()
  {
	  next_page_input = document.getElementById("next_page");
	  next_page_input.value = 21;
	  pid_input = document.getElementById("pid");
	  practice_group_input = document.getElementById("practice_group");
	  pid_input.value = practice_group_input.value;
	  document.maincontentform.submit();
  }
  
function enter_submit(e, menucode)
  {
	  if (window.event) // IE
        {
			keynum = e.keyCode
        }
      else if(e.which) // Netscape/Firefox/Opera
	    {
			keynum = e.which
	    }
	  if (keynum == 13)
	    {
	  next_page_input = document.getElementById("next_page");
	  next_page_input.value = menucode;
	  pid_input = document.getElementById("pid");
	  sid_input = document.getElementById("bio");
	  keyword_input = document.getElementById("searchkeywords");
	  if (keyword_input.value == "Type Keywords")
	    {
		    keyword_input.value = "";
	    }
	  keyword_input2 = document.getElementById("searchkeywords2");
      selIndex = keyword_input2.selectedIndex;
  	  keyword_input2_real = keyword_input2.options[selIndex].value;

	  if (keyword_input2_real == "0")
	    {
		    keyword_input2_real = "";
	    }
	  pid_input.value = keyword_input.value;
	  sid_input.value = keyword_input2_real;
	  if (pid_input.value == "")
	    {
		    pid_input.value = keyword_input2_real;
	        sid_input.value = "";
	    }
	  document.maincontentform.submit();
		}
  }

function search_submit(menucode)
  {
	  next_page_input = document.getElementById("next_page");
	  next_page_input.value = menucode;
	  pid_input = document.getElementById("pid");
	  sid_input = document.getElementById("bio");
	  keyword_input = document.getElementById("searchkeywords");
	  if (keyword_input.value == "Type Keywords")
	    {
		    keyword_input.value = "";
	    }
	  keyword_input2 = document.getElementById("searchkeywords2");
      selIndex = keyword_input2.selectedIndex;
  	  keyword_input2_real = keyword_input2.options[selIndex].value;
	  if (keyword_input2_real == "0")
	    {
		    keyword_input2_real = "";
	    }

	  pid_input.value = encodeMyHtml(keyword_input.value);
	  sid_input.value = keyword_input2_real;
	  if (pid_input.value == "")
	    {
		    pid_input.value = keyword_input2_real;
	        sid_input.value = "";
	    }
	  document.maincontentform.submit();
  }
function encodeMyHtml(input_string) {
     encodedHtml = escape(input_string);
     encodedHtml = encodedHtml.replace(/\//g,"%2F");
     encodedHtml = encodedHtml.replace(/\?/g,"%3F");
     encodedHtml = encodedHtml.replace(/=/g,"%3D");
     encodedHtml = encodedHtml.replace(/&/g,"%26");
     encodedHtml = encodedHtml.replace(/@/g,"%40");
     return encodedHtml;
 } 

function bio_check(sid, bio_control, next_page, pid)
  {
	  sid_input = document.getElementById("sid");
	  bio_input = document.getElementById("bio");
	  pid_input = document.getElementById("pid");
	  next_page_input = document.getElementById("next_page");
	  bio_input.value = bio_control;
	  pid_input.value = pid;
	  sid_input.value = sid;
	  next_page_input.value = next_page;
	  document.maincontentform.submit();
  }

function document_check(sid, next_page)
  {
	  sid_input = document.getElementById("sid");
	  next_page_input = document.getElementById("next_page");
	  sid_input.value = encodeMyHtml(sid);
	  next_page_input.value = next_page;
	  document.maincontentform.submit();
  }

function paging(sid, bio_control, next_page, current_page)
  {
	  sid_input = document.getElementById("sid");
	  bio_input = document.getElementById("bio");
	  next_page_input = document.getElementById("next_page");
	  current_page_input = document.getElementById("current_page");
	  sid_input.value = sid;
	  bio_input.value = bio_control;
	  next_page_input.value = next_page;
	  current_page_input.value = current_page;
	  document.maincontentform.submit();
  }

function solution_click(block, actionid)
  {
	  block1 = block+"_more";
	  block2 = block+"_less";
	  if (actionid == 1)
	    {
            document.getElementById(block1).style.display = 'block';
		    document.getElementById(block2).style.display = 'none';
        }
      if (actionid == 2)
	    {
            document.getElementById(block1).style.display = 'none';
		    document.getElementById(block2).style.display = 'block';
        }
  }

function ssubmit(next_page, sid)
  {
	  sid_input = document.getElementById("sid2");
	  next_page_input = document.getElementById("next_page");
	  sid_input.value = encodeMyHtml(sid);
	  next_page_input.value = next_page;
	  document.maincontentform.submit();
  }
  
function wsubmit(next_page, sid)
  {
	  sid_input = document.getElementById("wid");
	  next_page_input = document.getElementById("next_page");
	  sid_input.value = encodeMyHtml(sid);
	  next_page_input.value = next_page;
	  document.maincontentform.submit();
  }
function addToCartleft(currentcount, precount) {
  document.getElementById('change'+ precount).style.display = 'block';
  document.getElementById('change'+ currentcount).style.display = 'none';
  }
function addToCartright(currentcount, nextcount) {
  document.getElementById('change'+ nextcount).style.display = 'block';
  document.getElementById('change'+ currentcount).style.display = 'none';
  }
function addToCart1() {
  document.getElementById('change2').style.display = 'block';
  document.getElementById('change1').style.display = 'none';
  }
function addToCart2() {
  document.getElementById('change3').style.display = 'block';
  document.getElementById('change2').style.display = 'none';
  }
function addToCart3() {
  document.getElementById('change1').style.display = 'block';
  document.getElementById('change2').style.display = 'none';
  }
function addToCart4() {
  document.getElementById('change2').style.display = 'block';
  document.getElementById('change3').style.display = 'none';
  }
function search_clear() {
  searchword = document.getElementById('searchkeywords');
  if (searchword.value == "Type Keywords")
    {
	    searchword.value = "";
    }
  }
function search_clear_full() {
  searchword = document.getElementById('content_search');
  if (searchword.value == "Search all site")
    {
	    searchword.value = "";
    }
  }
function search_restore() {
  searchword = document.getElementById('searchkeywords');
  if (searchword.value == "")
    {
	    searchword.value = "Type Keywords";
    }
  }
function search_restore_full() {
  searchword = document.getElementById('content_search');
  if (searchword.value == "")
    {
	    searchword.value = "Search all site";
    }
  }
function qconnect_restore1() {
  searchword = document.getElementById('qcname');
  if (searchword.value == "")
    {
	    searchword.value = "Your Name";
    }
  }
function qconnect_restore2() {
  searchword = document.getElementById('qcemail');
  if (searchword.value == "")
    {
	    searchword.value = "Email";
    }
  }
function qconnect_clear1() {
  searchword = document.getElementById('qcname');
  if (searchword.value == "Your Name")
    {
	    searchword.value = "";
    }
  }
function qconnect_clear2() {
  searchword = document.getElementById('qcemail');
  if (searchword.value == "Email")
    {
	    searchword.value = "";
    }
  }
function form_validation(){
	name1 = document.getElementById("firstname").value;
	name2 = document.getElementById("lastname").value;
	jobtitle = document.getElementById("jobtitle").value;
	company = document.getElementById("company").value;
	address1 = document.getElementById("address1").value;
	city = document.getElementById("city").value;
	stateprovince = document.getElementById("stateprovince").value;
	zip = document.getElementById("zip").value;
	country = document.getElementById("country").value;
	phone = document.getElementById("phone").value;
	email = document.getElementById("email").value;
	vcode = document.getElementById("vcode").value;
	
	if ((name1 == '')||
	    (name2 == '')||
	    (jobtitle == '')||
	    (company == '')||
	    (address1 == '')||
	    (city == '')||
	    (stateprovince == '')||
	    (zip == '')||
	    (country == '')||
	    (phone == '')||
	    (email == '')||
	    (vcode == '')){
		alert("Please complete all fields and ensure that the agreement box is ticked.");	
		form_submit = 0;
		return false;	
    }	    
	
	form_submit = 1;
	agreement = document.getElementById("agreement");
	
	if (!(agreement.checked)){
		alert("Please complete all fields and ensure that the agreement box is ticked.");	
		form_submit = 0;
		return false;	
	}
	
	if (!(character_check(name1))){
		alert("Invalid First Name!");
		form_submit = 0;
		return false;
	}
	if (!(character_check(name2))){
		alert("Invalid Last Name!");
		form_submit = 0;
		return false;
	}
	if (!(numeric_check(phone))){
		alert("Please ensure that the phone is numeric only!");
		form_submit = 0;
		return false;
	}
        var finalresult = "";
		var date = new Date();
		xmlhttp.open("GET", "content/check_email_registration.php?email_verification="+email+"&timestamp="+date);
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				finalresult = xmlhttp.responseText;
				if (finalresult != 1) {
					alert(finalresult);
					form_submit = 0;
					return false;
				}
    	if (finalresult== 1){
	    	form_submit = 1 ;
		}
		if (form_submit == 1){
			document.forms["registration"].submit();
		}
			}
		}
		xmlhttp.send(null);
}

function character_check(character){
	  var character_checking = 0;
	  character = character.toUpperCase();
      for (var i = 0; i < character.length; i++)
        {
	        if (!(((character.charCodeAt(i)>=65) && (character.charCodeAt(i)<=90)) || (character.charCodeAt(i)==39) || (character.charCodeAt(i)==40) || (character.charCodeAt(i)==41) || (character.charCodeAt(i)==44) || (character.charCodeAt(i)==45) || (character.charCodeAt(i)==46) || (character.charCodeAt(i)==47) || (character.charCodeAt(i)==60) || (character.charCodeAt(i)==62) || (character.charCodeAt(i)==64) || (character.charCodeAt(i)==32)))
		      {character_checking = 1;}
	  
        }

  	  if (character_checking == 1)
        {return false;}
      else
        {return true;}
}    
  
function numeric_check(character){
	  var character_checking = 0;
	  character = character.toUpperCase();
      for (var i = 0; i < character.length; i++)
        {
	        if (!(((character.charCodeAt(i)>=48) && (character.charCodeAt(i)<=57)) || (character.charCodeAt(i)==32)))
		      {character_checking = 1;}
	  
        }

  	  if (character_checking == 1)
        {return false;}
      else
        {return true;}
}    
  
function refresh_image(){
	document.getElementById("security_code_download_image").src = "CaptchaSecurityImages3.php?"+Date();
}    
  

