﻿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 MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
} 

function validateRequiredFieldsResume(){
				post			= document.aspnetForm.positionnames.value;
				fname 			= document.aspnetForm.firstname.value;
				lname 			= document.aspnetForm.lastname.value;
				homephone		= document.aspnetForm.homephone.value;
				homeemail		= document.aspnetForm.homeemail.value;
				workemail		= document.aspnetForm.workemail.value;
				contact			= ((document.aspnetForm.contact[0].checked) ||(document.aspnetForm.contact[1].checked)||
									(document.aspnetForm.contact[2].checked) ||(document.aspnetForm.contact[3].checked))
				contactcurr		= ((document.aspnetForm.contactcurrent[0].checked) || (document.aspnetForm.contactcurrent[1].checked))
				resume = document.aspnetForm.resumetext.value;
			    //regExp = '<(.*?)>';
				
				strErr = new String() //error string
				
				if(post.length == 0){
					strErr = "Please provide the post you are applying to. \n";
				}
				
				if(fname.length == 0){
					strErr += "Please provide your First Name. \n";
				}
				
				/*if(resume.search(regExp)>=0){
		            strErr += "Your resume text field should not contain HTML. \n";
		        }*/
		        
		        if(resume.length ==0){
				    strErr += "Please provide your resume. \n";
				}
				
				if(homeemail.length > 0){
					if(!IsValidEMail(homeemail)){
						strErr += "Please provide valid Home Email address. \n";
					}
				}
				
				if(workemail.length > 0){
					if(!IsValidEMail(workemail)){
						strErr += "Please provide valid Work Email address. \n";
					}
				}
				
				if(lname.length == 0){
					strErr += "Please provide your Last Name. \n";
				}
				
				
				if(homephone.length == 0){
					strErr += "Please provide your Home Phone Number. \n";
				}
				
				if(!contact){
					strErr += "Please provide your method of contact. \n"
				}
				
				if(!contactcurr){
					strErr += "Please provide your contact preference. \n"
				}
				
				if(strErr.length > 0){
					alert(strErr);
					return false;
				}else{
					document.aspnetForm.submit()
					return true;
				}
			}
			
			function checktype(){
			    
			    switch(getQueryVariable("product"))
                {
                  case "HN4000_Product_Data_Sheet": document.getElementById("HN4000").checked=true
                    break
                  case "HN4000VN_Product_Data_Sheet":document.getElementById("HN4000VN").checked=true
                    break
                  case "HN400-U_Product_Data_Sheet": document.getElementById("HN400-U").checked=true
                    break
                  case "HN400-CP_Product_Data_Sheet": document.getElementById("HN400-CP").checked=true
                    break
                  case "FacilityManagement_Product_Data_Sheet": document.getElementById("AdvancedFacilityManagement").checked=true
                    break
                  case "ApplicationNote_Product_Data_Sheet": document.getElementById("ApplicationNote").checked=true
                    break
                }

			}
			
			function getQueryVariable(variable) {
                var query = window.location.search.substring(1);
                var vars = query.split("&");
                for (var i=0;i<vars.length;i++) 
                {
                var pair = vars[i].split("=");
                if (pair[0] == variable) 
                    {
                    return pair[1];
                    }
                } 
            }

function validateRequiredFieldsPartners(){

        name 			= document.aspnetForm.name.value;
		lastname 		= document.aspnetForm.lastname.value;
		countrycode     = document.aspnetForm.countrycode.value;
		phone			= document.aspnetForm.phone.value;
		email 			= document.aspnetForm.email.value;
		title			= document.aspnetForm.title.value;
		company		    = document.aspnetForm.company.value;
		country			= document.aspnetForm.country.value;
		areaofbusiness  = document.aspnetForm.areaofbusiness.value;
		areaofbusinessexist= document.aspnetForm.areaofbusinessexist.value;
		city			= document.aspnetForm.city.value;
		url			    = document.aspnetForm.url.value;
		url             =url.replace( /^\s+/g, "" );// strip leading
		regExp  = /^(http:\/\/www.|https:\/\/www.|www.){1}([\w]+)(.[\w]+){1,2}$/;

		
		
		strErr = new String() //error string
		
		if(name.length == 0){
			strErr = "Please provide your first/given name. \n";
		}
		
		if(lastname.length == 0){
			strErr += "Please provide your last/surname. \n";
		}
		
		if(countrycode.length == 0){
			strErr += "Please provide your Country Code. \n";
		}
		
		var charpos = countrycode.search("[^0-9]"); 
		if (countrycode.length > 0 &&  charpos >= 0){
			strErr += "Country Code only accepts numeric values. \n";
		}
		
		if(phone.length == 0){
			strErr += "Please provide your Telephone Number. \n";
		}

		if(email.length == 0){
			strErr += "Please provide your Email address. \n";
		}
		
		if (!IsValidEMail(email)){
			strErr += "Please provide valid Email address. \n";
		}
		
		if(title.length == 0){
			strErr += "Please provide your Title. \n";
		}
		
		if(company.length == 0){
			strErr += "Please provide your Company Name. \n";
		}
		
		if(city.length == 0){
			strErr += "Please provide your City. \n";
		}
		
		if(country.length == 0){
			strErr += "Please provide your current Country Information. \n";
		}
		
		if(url.length == 0){
			strErr += "Please provide your Company URL. \n";
		}
		
		if(url.search(regExp)==-1){
		    strErr += "Please enter a valid URL. \n";
		}
		
		if (areaofbusiness.length == 0) {
		strErr += "Please provide the description about becoming a partner. \n";
		}
		if (areaofbusinessexist.length == 0) {
		strErr += "Please provide the description purchasing products or obtaining information. \n";
		}
		
//		if(((email.indexOf("aol.com") != -1) || (email.indexOf("hotmail.com") != -1) || (email.indexOf("yahoo.com") != -1))){
//			alert("You are not allowed to download the pdf")
//			return false
//		}
		
		
		if(strErr.length > 0)
		{
			alert(strErr);
			return false;
		}
		else
		{
			document.aspnetForm.submit()
			return true;
		}	
	} 
			
function validateRequiredFieldsProductData(){
		name 			= document.aspnetForm.name.value;
		lastname 		= document.aspnetForm.lastname.value;
		countrycode     = document.aspnetForm.countrycode.value;
		citycode        = document.aspnetForm.citycode.value;
		phone			= document.aspnetForm.phone.value;
		email 			= document.aspnetForm.email.value;
		title			= document.aspnetForm.title.value;
		company		    = document.aspnetForm.company.value;
		country			= document.aspnetForm.country.value;
		city			= document.aspnetForm.city.value;
		areaofbusiness  = document.aspnetForm.areaofbusiness.value;
		url			    = document.aspnetForm.url.value;
		url             = url.replace( /^\s+/g, "" );// strip leading
		regExp  = /^(http:\/\/www.|https:\/\/www.|www.){1}([\w]+)(.[\w]+){1,2}$/;
		//product         = document.aspnetForm.product.value;
		
		
		strErr = new String() //error string
		
		if(name.length == 0){
			strErr = "Please provide your first/given name. \n";
		}
		
		if(lastname.length == 0){
			strErr += "Please provide your last/surname. \n";
		}
		
		if(countrycode.length == 0){
			strErr += "Please provide your Country Code. \n";
		}
		
		var charpos = countrycode.search("[^0-9]"); 
		if (countrycode.length > 0 &&  charpos >= 0){
			strErr += "Country Code only accepts numeric values. \n";
		}
		
		if(citycode.length == 0){
			strErr += "Please provide your City Code. \n";
		}
		
		var charpos2 = citycode.search("[^0-9]"); 
		if (citycode.length > 0 &&  charpos2 >= 0){
			strErr += "City Code only accepts numeric values. \n";
		}
		
		if(phone.length == 0){
			strErr += "Please provide your Telephone Number. \n";
		}

		if(email.length == 0){
			strErr += "Please provide your Email address. \n";
		}
		
		if (!IsValidEMail(email)){
			strErr += "Please provide valid Email address. \n";
		}
		
		if(title.length == 0){
			strErr += "Please provide your Title. \n";
		}
		
		if(company.length == 0){
			strErr += "Please provide your Company Name. \n";
		}
		
		if(city.length == 0){
			strErr += "Please provide your City. \n";
		}
		
		if(country.length == 0){
			strErr += "Please provide your current Country Information. \n";
		}
		
		if(url.length == 0){
			strErr += "Please provide your Company URL. \n";
		}
		
		if(url.search(regExp)==-1){
		    strErr += "Please enter a valid URL. \n";
		}
		
		if (areaofbusiness.length == 0) {
		strErr += "Please provide your area of business. \n";
		}
//		if(product.length == 0) {
//		    strErr += "Please choose a product. \n";
//		}
		
	//	alert(email.indexOf("aol.com"))
		if(((email.indexOf("aol.com") != -1) || (email.indexOf("hotmail.com") != -1) || (email.indexOf("yahoo.com") != -1))){
			alert("You are not allowed to download the pdf")
			return false
		}
		
		
		if(strErr.length > 0){
			alert(strErr);
			return false;
		}
		else if (document.aspnetForm.chkTerms.checked == false)
		{
		    alert("Please check the box to agree to our Terms & Conditions");
		    return false;
		}
		else{
			document.aspnetForm.submit()
			return true;
		}	
	}
				
function validateRequiredFieldsContactUs(){
				name 			= document.aspnetForm.name.value;
				phone			= document.aspnetForm.phone.value;
				email 			= document.aspnetForm.email.value;
				title			= document.aspnetForm.title.value;
				company			= document.aspnetForm.company.value;
				address1		= document.aspnetForm.address1.value;
				city			= document.aspnetForm.city.value;
				state			= document.aspnetForm.state.value;
				zipcode			= document.aspnetForm.zipcode.value;
				country			= document.aspnetForm.country.value;				
				
				strErr = new String() //error string
				
				if(name.length == 0){
					strErr = "Please provide your Name. \n";
				}
				
				if(phone.length == 0){
					strErr += "Please provide your Telephone Number. \n";
				}

				if(email.length == 0){
					strErr += "Please provide your Email address. \n";
				}
				
				if(!IsValidEMail(email)){
					strErr += "Please provide a valid Email address. \n";
				}
				
				if(title.length == 0){
					strErr += "Please provide your Title. \n";
				}
				
				if(company.length == 0){
					strErr += "Please provide your Company Name. \n";
				}
				
				if(address1.length == 0){
					strErr += "Please provide a valid Address. \n";
				}
				
				if(city.length == 0){
					strErr += "Please provide a valid City. \n";
				}
				
				if(state.length == 0){
					strErr += "Please provide a valid State. \n";
				}
				
				if(zipcode.length == 0){
					strErr += "Please provide a valid Zipcode. \n";
				}
				
				if(country.length == 0){
					strErr += "Please provide your current Country information. \n";
				}

				if(strErr.length > 0){
					alert(strErr);
					return false;
				}else{
					document.aspnetForm.submit()
					return true;
				}	
			}
			
function validateRequiredFieldsCashCow(){
                name 			= document.aspnetForm.name.value;
				phone			= document.aspnetForm.phone.value;
				email 			= document.aspnetForm.email.value;
				title			= document.aspnetForm.title.value;
				company			= document.aspnetForm.company.value;
				address1		= document.aspnetForm.address1.value;
				city			= document.aspnetForm.city.value;
				state			= document.aspnetForm.state.value;
				zipcode			= document.aspnetForm.zipcode.value;
				country			= document.aspnetForm.country.value;				
				
				strErr = new String() //error string
				
				if(name.length == 0){
					strErr = "Please provide your Name. \n";
				}
				
				if(phone.length == 0){
					strErr += "Please provide your Telephone Number. \n";
				}

				if(email.length == 0){
					strErr += "Please provide your Email address. \n";
				}
				
				if(!IsValidEMail(email)){
					strErr += "Please provide a valid Email address. \n";
				}
				
				if(title.length == 0){
					strErr += "Please provide your Title. \n";
				}
				
				if(company.length == 0){
					strErr += "Please provide your Company Name. \n";
				}
				
				if(address1.length == 0){
					strErr += "Please provide a valid Address. \n";
				}
				
				if(city.length == 0){
					strErr += "Please provide a valid City. \n";
				}
				
				if(state.length == 0){
					strErr += "Please provide a valid State. \n";
				}
				
				if(zipcode.length == 0){
					strErr += "Please provide a valid Zipcode. \n";
				}
				
				if(country.length == 0){
					strErr += "Please provide your current Country information. \n";
				}

				if(strErr.length > 0){
					alert(strErr);
					return false;
				}else{
					document.aspnetForm.submit()
					return true;
				}   
            }

function IsValidEMail(strValue)
			{
				nNoOfArguments = IsValidEMail.arguments.length;
				//if no parameter is supplied
				if(nNoOfArguments < 1)
				{
					return false;
				}	
			
				var strVal	= new String(strVal);
				var bReturn1 = false;
				var bReturn2 = false;
				var bReturn3 = false;
				var bReturn4 = false;
				var bReturn5 = false;
				var bReturn6 = false;
				var bReturn7 = true;
				var bReturn8 = true;
				
				//if '@' comes after first character then true
				bReturn1	=	(strValue.indexOf("@") > 0);							
				
				//if '.' comes after first character then true
				bReturn2	=	(strValue.indexOf(".") > 0);							
				
				//if single '@' exist in string then true
				bReturn3	=	(strValue.indexOf("@") == strValue.lastIndexOf("@"));	
				
				//if '.' exist after @ in string then true
				bReturn4	=	(strValue.indexOf(".",strValue.indexOf("@")) > (strValue.indexOf("@")));		
				
				//if '.' does not comes immediatly after @ then true
				bReturn5	=	(strValue.indexOf(".",strValue.indexOf("@")) != (strValue.indexOf("@")+1));		
				
				//if '.' does not comes immediatly before @ then true
				bReturn6	=	(strValue.lastIndexOf(".",strValue.indexOf("@")) != (strValue.indexOf("@")-1)); 
				
				//if two '.' occurs simultaneously then false
				bReturn7	=	!((strValue.indexOf(".",strValue)+1) == (strValue.lastIndexOf(".")));
				
				//if nothing occurs after the '.' then false
				bReturn8 = !(strValue.indexOf(".")+1 == strValue.length);
				
				//if all values are true return true else false.
				return(bReturn1 && bReturn2 && bReturn3 && bReturn4 && bReturn5 && bReturn6 && bReturn8)	
			}

//flash version detect stuff
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
jsVersion = 1.1;
// JavaScript helper required to detect Flash Player PlugIn version information
function JSGetSwfVer(i){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
      		var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			descArray = flashDescription.split(" ");
			tempArrayMajor = descArray[2].split(".");
			versionMajor = tempArrayMajor[0];
			versionMinor = tempArrayMajor[1];
			if ( descArray[3] != "" ) {
				tempArrayMinor = descArray[3].split("r");
			} else {
				tempArrayMinor = descArray[4].split("r");
			}
      		versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
            flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
      	} else {
			flashVer = -1;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	// Can't detect in all other cases
	else {
		
		flashVer = -1;
	}
	return flashVer;
} 
// If called with no parameters this function returns a floating point value 
// which should be the version of the Flash Player or 0.0 
// ex: Flash Player 7r14 returns 7.14
// If called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) 
{
 	reqVer = parseFloat(reqMajorVer + "." + reqRevision);
   	// loop backwards through the versions until we find the newest version	
	for (i=25;i>0;i--) {	
		if (isIE && isWin && !isOpera) {
			versionStr = VBGetSwfVer(i);
		} else {
			versionStr = JSGetSwfVer(i);		
		}
		if (versionStr == -1 ) { 
			return false;
		} else if (versionStr != 0) {
			if(isIE && isWin && !isOpera) {
				tempArray         = versionStr.split(" ");
				tempString        = tempArray[1];
				versionArray      = tempString .split(",");				
			} else {
				versionArray      = versionStr.split(".");
			}
			versionMajor      = versionArray[0];
			versionMinor      = versionArray[1];
			versionRevision   = versionArray[2];
			
			versionString     = versionMajor + "." + versionRevision;   // 7.0r24 == 7.24
			versionNum        = parseFloat(versionString);
        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
			if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) {
				return true;
			} else {
				return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false );	
			}
		}
	}	
	return (reqVer ? false : 0.0);
}