function clientSideInclude(id, url) {
  var req = false;
  // For Safari, Firefox, and other non-MS browsers
  if (window.XMLHttpRequest) {
    try {
      req = new XMLHttpRequest();
    } catch (e) {
      req = false;
    }
  } else if (window.ActiveXObject) {
    // For Internet Explorer on Windows
    try {
      req = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        req = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {
        req = false;
      }
    }
  }
 var element = document.getElementById(id);
 if (!element) {
  alert("Bad id " + id + 
   "passed to clientSideInclude." +
   "You need a div or span element " +
   "with this id in your page.");
  return;
 }
  if (req) {
    // Synchronous request, wait till we have it all
    req.open('GET', url, false);
    req.send(null);
    element.innerHTML = req.responseText;
  } else {
    element.innerHTML =
   "Sorry, your browser does not support " +
      "XMLHTTPRequest objects. This page requires " +
      "Internet Explorer 5 or better for Windows, " +
      "or Firefox for any system, or Safari. Other " +
      "compatible browsers may also exist.";
  }
}

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 changeImage(path,imgId)
{
		document.getElementById(imgId).src=path;
}


function changeImgLady(imgId,path)
{
		
		document.getElementById(imgId).src=path;
		document.getElementById(imgId).width=215;
		document.getElementById(imgId).height=315;
		document.getElementById(imgId).border=4;
}
function changeImgrooms(imgId,path)
{
		
		document.getElementById(imgId).src=path;
		document.getElementById(imgId).width=250;
		document.getElementById(imgId).height=196;
		document.getElementById(imgId).border=2;
}
function changeImgssixrooms(imgId,path)
{
		
		document.getElementById(imgId).src=path;
		document.getElementById(imgId).width=56;
		document.getElementById(imgId).height=198;
		document.getElementById(imgId).border=0;
}

function check_ajax()
{
	var ajaxRequest;  // The variable that makes Ajax possible!	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
		return ajaxRequest;
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
			return ajaxRequest;
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
				return ajaxRequest;
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return "";
			}
		}
	}
}




function paging2(name1,page1)
{
	 
	    document.getElementById("deep2").innerHTML='<img src="../loading.gif" border="0"  id="main_loaders1" />';
		document.getElementById("main_loaders1").style.display="block";
	
		var check = check_ajax();
		if(check)
		{
			var ajaxRequest = check;
			ajaxRequest.onreadystatechange = function()
			{
				if(ajaxRequest.readyState == 4)
				{
					values = ajaxRequest.responseText;	
					//alert(values);
					document.getElementById("deep2").innerHTML=values;
					document.getElementById("main_loaders1").style.display="none";
					
				}
			}
				ajaxRequest.open("GET", "linksave.php?name="+name1+"&page="+page1, true);
				ajaxRequest.send(null); 
		}		
}

function deletelink(name1)
{   var con = confirm("Are you sure..");
if(con==true)
	{
		var check = check_ajax();
		if(check)
		{
			var ajaxRequest = check;
			ajaxRequest.onreadystatechange = function()
			{
				if(ajaxRequest.readyState == 4)
				{
					values = ajaxRequest.responseText;	
					//alert(values);
					document.getElementById("deep2").innerHTML=values;
					document.getElementById("main_loaders1").style.display="none";
					
				}
			}
				ajaxRequest.open("GET", "linksave.php?delname="+name1, true);
				ajaxRequest.send(null); 
		}	
	}
}













function pop(id)
{
   swapContent("idpara" + id);
   swapImages("Link" + id, "/test/cwnp.com/img/certifications/thumb-" + id + "-on.gif",
      "/test/cwnp.com/img/certifications/thumb-" + id + ".gif");
   changeImages("FeatureImage", "/test/cwnp.com/img/certifications/box_feature_" + id + ".gif");
}

function newImage(arg)
{
	if (document.images)
   {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeText(elementname, newtext)
{
	document.getElementById(elementname).innerHTML = newtext;
}

function changeImages()
{
	if (document.images && (preloadFlag == true))
   {
		for (var i = 0; i < changeImages.arguments.length; i += 2)
      {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

function hideDiv(id)
{
   document.getElementById(id).style.display = 'none';
   document.getElementById(id).style.height = 250;
}

function swapContent(id)
{
   for (i = 0; i <= 4; i++)
   {
      hideDiv("idpara" + i);
   }
   var elem = document.getElementById(id);
   elem.style.display = "block";
}

function swapImages(oldIm,newIm,oldImRep)
{
   changeImages(lastLoadImage, lastLoadImageInitialSource);
   changeImages(oldIm, newIm);
   lastLoadImage = oldIm;
   lastLoadImageInitialSource=oldImRep;
}

var preloadedImages = new Array();
var preloadFlag = false;
var lastLoadImage = 'Link0';
var lastLoadImageInitialSource = "/img/certifications/thumb-0.gif";

function preloadImages()
{
   var i = 0;
   if (document.images)
   {
      for (i = 0; i <= 4; i++)
      {
         preloadedImages[i]= newImage("/img/certifications/thumb-" + i + ".gif");
      }
      preloadFlag = true;
   }
}

preloadImages();






   function echeck(str)
   {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Please enter a valid email address")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Please enter a valid email address")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		   alert("Please enter a valid email address")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		   alert("Please enter a valid email address")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		   alert("Please enter a valid email address")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		   alert("Please enter a valid email address")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		   alert("Please enter a valid email address")
		    return false
		 }

 		 return true					
	}

      function f_onSubmit()
      {
         var emailID = document.forms["contactForm"].email;
         
         if ((emailID.value == null) || (emailID.value == ""))
         {
            alert("Please enter your email address")
            emailID.focus()
            return false
         }
         if (echeck(emailID.value) == false)
         {
            emailID.focus()
            return false
         }

      	if (document.contactForm.elements["00N70000002LOQ5"].value == "")
      	{
      		alert("Please select the type of training you are interested in");
      		return(false);
      	}
      	if (document.contactForm.elements["00N70000002LOQA"].value == "")
      	{
      		alert("Please select when you are planning to be trained");
      		return(false);
      	}
      	if (document.contactForm.elements["00N70000002LOQF"].value == "")
      	{
      		alert("Please select how many people need to be trained");
      		return(false);
      	}
      	if (document.forms["contactForm"].first_name.value == "")
      	{
      		alert("Please enter your first name");
      		return(false);
      	}
      	if (document.forms["contactForm"].last_name.value == "")
      	{
      		alert("Please enter your last name");
      		return(false);
      	}
      	if (document.forms["contactForm"].email.value == "")
      	{
      		alert("Please enter your email address");
      		return(false);
      	}
      	if (document.forms["contactForm"].phone.value == "")
      	{
      		alert("Please enter your phone");
      		return(false);
      	}
      	if (document.forms["contactForm"].address.value == "")
      	{
      		alert("Please enter your street address");
      		return(false);
      	}
      	if (document.forms["contactForm"].company.value == "")
      	{
      		alert("Please enter your company");
      		return(false);
      	}
      	if (document.forms["contactForm"].city.value == "")
      	{
      		alert("Please enter your city");
      		return(false);
      	}
      	if (document.forms["contactForm"].country.value == "")
      	{
      		alert("Please select your country");
      		return(false);
      	}
      	if (document.forms["contactForm"].zip.value == "")
      	{
      		alert("Please enter your zipcode");
      		return(false);
      	}
      	return(true);
      }
function select12()
{
// ON selection of category this function will work


 if(document.getElementById("country").value !='United States')
{

//document.write('<input name="state" type="text">');
document.getElementById("state1").innerHTML = '<input name="state" style="width:210px;" type="text">';

}
else if(document.getElementById("country").value =='United States')
{

document.getElementById("state1").innerHTML = '<select name="state" style="width:210px;"><option value="" selected="selected">Select a State</option><option value="AL">Alabama</option><option value="AK">Alaska</option><option value="AZ">Arizona</option><option value="AR">Arkansas</option><option value="CA">California</option><option value="CO">Colorado</option><option value="CT">Connecticut</option><option value="DE">Delaware</option><option value="DC">District Of Columbia</option><option value="FL">Florida</option><option value="GA">Georgia</option><option value="HI">Hawaii</option><option value="ID">Idaho</option><option value="IL">Illinois</option><option value="IN">Indiana</option><option value="IA">Iowa</option><option value="KS">Kansas</option><option value="KY">Kentucky</option><option value="LA">Louisiana</option><option value="ME">Maine</option><option value="MD">Maryland</option><option value="MA">Massachusetts</option><option value="MI">Michigan</option><option value="MN">Minnesota</option><option value="MS">Mississippi</option><option value="MO">Missouri</option><option value="MT">Montana</option><option value="NE">Nebraska</option><option value="NV">Nevada</option><option value="NH">New Hampshire</option><option value="NJ">New Jersey</option><option value="NM">New Mexico</option><option value="NY">New York</option><option value="NC">North Carolina</option><option value="ND">North Dakota</option><option value="OH">Ohio</option><option value="OK">Oklahoma</option><option value="OR">Oregon</option><option value="PA">Pennsylvania</option><option value="RI">Rhode Island</option><option value="SC">South Carolina</option><option value="SD">South Dakota</option><option value="TN">Tennessee</option><option value="TX">Texas</option><option value="UT">Utah</option><option value="VT">Vermont</option><option value="VA">Virginia</option><option value="WA">Washington</option><option value="WV">West Virginia</option><option value="WI">Wisconsin</option><option value="WY">Wyoming</option></select>';
}

}	  
	  
  
    function select13()
{
// ON selection of category this function will work

 if(document.getElementById("country").value !='UNITED STATES')
{

//document.write('<input name="state" type="text">');
document.getElementById("state1").innerHTML = '<input name="state" style="width:210px;" type="text">';

}
else if(document.getElementById("country").value =='UNITED STATES')
{

document.getElementById("state1").innerHTML = '<select name="state" style="width:210px;"><option value="" selected="selected">Select a State</option><option value="AL">Alabama</option><option value="AK">Alaska</option><option value="AZ">Arizona</option><option value="AR">Arkansas</option><option value="CA">California</option><option value="CO">Colorado</option><option value="CT">Connecticut</option><option value="DE">Delaware</option><option value="DC">District Of Columbia</option><option value="FL">Florida</option><option value="GA">Georgia</option><option value="HI">Hawaii</option><option value="ID">Idaho</option><option value="IL">Illinois</option><option value="IN">Indiana</option><option value="IA">Iowa</option><option value="KS">Kansas</option><option value="KY">Kentucky</option><option value="LA">Louisiana</option><option value="ME">Maine</option><option value="MD">Maryland</option><option value="MA">Massachusetts</option><option value="MI">Michigan</option><option value="MN">Minnesota</option><option value="MS">Mississippi</option><option value="MO">Missouri</option><option value="MT">Montana</option><option value="NE">Nebraska</option><option value="NV">Nevada</option><option value="NH">New Hampshire</option><option value="NJ">New Jersey</option><option value="NM">New Mexico</option><option value="NY">New York</option><option value="NC">North Carolina</option><option value="ND">North Dakota</option><option value="OH">Ohio</option><option value="OK">Oklahoma</option><option value="OR">Oregon</option><option value="PA">Pennsylvania</option><option value="RI">Rhode Island</option><option value="SC">South Carolina</option><option value="SD">South Dakota</option><option value="TN">Tennessee</option><option value="TX">Texas</option><option value="UT">Utah</option><option value="VT">Vermont</option><option value="VA">Virginia</option><option value="WA">Washington</option><option value="WV">West Virginia</option><option value="WI">Wisconsin</option><option value="WY">Wyoming</option></select>';
}

}	  
	  
