// JavaScript Document
// nav scripts
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_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;
}
// preload images
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];}}
}

// popup window
function openWin(url,w,h,s,r) {
    var scrl; 
    var resze;
    
    if (s) { scrl="scrollbars=yes,"; w = w+16;} 
    else { scrl="scrollbars=no,"; }
    
    if (r) { resze = "resizable=yes,"; }
    else { resze="resizable=no,"; }
    
    if (!w) w = 350;
    if (!h) h = 270;
    stock = window.open(url,"_blank",scrl+resze+"width="+w+",height="+h+",screenX=200,screenY=50");
    stock.focus();
}

//function openWin(pg,h,w) {
//	popWindow = window.open(pg,'popWin','height=h,width=w,toolbar=no,scrollbars=no');
//	popWindow.focus();
//}
//function openParent(pg) {
//	window.opener.location = pg;
//	window.opener.focus();
//}

// Validation functions ******************
function radioCheck(obj) {
	for(i=0;i<obj.length;i++) {
		if(obj[i].checked)
			return true;
	}
	return false;
}
function trimAll( strValue ) {
if(strValue=="") {return strValue;}
 var objRegExp = /\s/g;

    //check for all spaces
    if(objRegExp.test(strValue)) {
	
	while(objRegExp.test(strValue)) {
       strValue = strValue.replace(objRegExp, '');
	  }
    	if(!strValue.length == 0)
			return strValue;
    }
	
	//check for leading & trailing spaces
   objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
   if(objRegExp.test(strValue)) {
       //remove leading and trailing whitespace characters
       strValue = strValue.replace(objRegExp, '$2');
    }
  return strValue;
}

function isEmpty( strValue ) {
	if(strValue==""){return true;}
   var strTemp = strValue;
   strTemp = trimAll(strTemp);
   if(strTemp.length > 0){
     return false;
   }  
   return true;
}
function validateUSZip( strValue ) {
	var objRegExp  = /(^\d{5}$)|(^\d{5}-\d{4}$)/;
  return objRegExp.test(strValue);
}
function validateAlpha( strValue,min ) {
	var objRegExp  = new RegExp("^[a-zA-Z]{"+min+",}$");
	return objRegExp.test(strValue);
}

function validateEmail( strValue) {
	var objRegExp  = /^[a-z0-9]([a-z0-9_\-\.]*)@([a-z0-9_\-\.]*)(\.[a-z]{2,3}(\.[a-z]{2}){0,2})$/i;
	return objRegExp.test(strValue);
}

// Check that a Canadian postal code is valid
function isValidCanadianPostalcode(postalcode) {
if (!isEmpty(postalcode)) {
	postalcode = postalcode.replace(/ /g, "");
	if (postalcode.length == 6 && postalcode.search(/^[a-zA-Z]\d[a-zA-Z]\d[a-zA-Z]\d$/) != -1) return true;
	else if (postalcode.length == 7 && postalcode.search(/^[a-zA-Z]\d[a-zA-Z]-\d[a-zA-Z]\d$/) != -1) return true;
	else return false;
}
return true;
}

function isUnderLimit(m,d,y) {
	with(document.forms[0]) {
		var ageLimit = 13;
		var year = parseInt(y)+ageLimit
		var bdate = m + "/" + d + "/" + year;
		var bdateObj = new Date(bdate);
		var bdateM = bdateObj.getTime();
		var today = new Date();
		var todayM = today.getTime();
		}	//	end with
		
	if((bdateM) > todayM)
		return true;
	return false;
}

function getNote(n) {
	var url = "sidenote.jsp?n=" + n;
	var noteWin = openwin(url,400,200);
}


<!-- Method to go to Doc Locator Page -->
var prodName = "AIROPTIX";
function jumpToDocLocator(){

  var docLocatorPage = "http://get.cibavision.com/index.shtml?ctry=USA&product=OPTIX";

  document.location=docLocatorPage;
}


<!-- To read cookie -->
function getCookie(name) {
    var start = document.cookie.indexOf(name+"=");
    var len = start+name.length+1;
    if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
    if (start == -1) return "";
    var end = document.cookie.indexOf(";",len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len,end));
}


//-->