// JavaScript Document
<!--
var oDoc = document;
var bNS4 = Boolean(oDoc.layers), bIE = Boolean(oDoc.all), bStandard = Boolean(oDoc.getElementById);

function checkit(aForm,aValue) {
	for (i=0;i<document.forms[aForm].orderitem.length;i++) {
		if (document.forms[aForm].orderitem[i].value==aValue) {
			document.forms[aForm].orderitem[i].checked = true;
		}
	}
	//top.location.href='#cb';
}

function disableall(){
	var arrElement = new Array('A','INPUT','SELECT'), i=0, input, count=0;
	for (var n=0;n<arrElement.length;n++) {
		input = document.getElementsByTagName(arrElement[n]);
		count = input.length;
		for (var i=0;i<count;i++) {
		if (arrElement[n]=='A') {
			input[i].removeAttribute("href");
			//input[i].style.cursor='default'; 
		} else if ((arrElement[n]=='INPUT') || (arrElement[n]=='SELECT')) {
			input[i].disabled='true';
		}}
	}
	return true;
} 

function printWindow() {
	if (!bNS4) window.print();
}

function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

//function setCookie(name, value, nDays, path, domain) {
function setCookie(name, value, domain) {
var today = new Date(), expires = new Date(), nDays = 0;
if (nDays==null || nDays==0) nDays=365;
 expires.setTime(today.getTime() + 3600000*24*nDays);

  var curCookie = name + "=" + escape(value) + "; path=/" + 
  	((domain) ? "; domain=" + domain : "") + 
	((expires) ? "; expires=" + expires.toGMTString() : "") + ";";
  document.cookie = curCookie;  
}
function deleteCookie(name, domain) {
  if (getCookie(name)) {
    var curCookie = name + "=; path=/" + 
  	((domain) ? "; domain=" + domain : "") + 
	"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	document.cookie = curCookie;
	//alert(curCookie + '-delete');
  }
}  

function fixDate(date) {
  var base = new Date(0);
  var skew = base.getTime();
  if (skew > 0)
    date.setTime(date.getTime() - skew);
}

function clearText(aObj,aText) {
	if (aObj.value==aText) {aObj.value='';}	
}

function putText(aObj,aText) {
	if (aObj.value=='') {aObj.value=aText;}	
}

function MM_findValue(f,n) {
	var frm=document.forms[f],e=frm.elements[n],t=e.type,v='';
	//alert(t);
	if (t==undefined){
		t = e[0].type;
		if (t=='checkbox') {
			for (i=0;i<e.length;i++){
			if (e[i].checked==true){
				if (v!='') v += ', '
				v += e[i].value;
			}}		
		} else if(t=='radio') {
			for (i=0;i<e.length;i++){
			if (e[i].checked==true){
				v = e[i].value;
				break; //exist for loop, as target acquired.
			}}
		}
	} else if (t=='select-one') {
		if (e.selectedIndex!=-1) v = e.options[e.selectedIndex].value;
	} else if (t=='checkbox') {
		if (e.checked == true) v = e.value;	
	} else if(t=='radio') {
		if (e.checked == true) v = e.value;	
	} else if ((t=='text') || (t=='textarea') || (t=='button') || (t=='password') || (t=='file') || (t=='hidden')) {
		v = e.value;
	}
	return v;	
}
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_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 calcItems(){
	var args=calcItems.arguments;
	var frmName=args[0]; 
	var frm=document.forms[frmName], totalName=args[1], val=0;
	
	frm.elements[totalName].value=0;
	for (var i=2; i<args.length; i++) { 
		val=MM_findValue(frmName,args[i]);
		frm.elements[totalName].value = parseInt(frm.elements[totalName].value) + parseInt(val);
		//test=args[i+2]; 
	}
	//alert(frm.elements[totalName].value);
}

function clearFields() {
	var args = clearFields.arguments;
	var frm=document.forms[args[0]];
	//alert(args[0]);
	//var frm=args[0];
	for(var i=1; i<args.length; i++) { 
	//alert(args[i]);
	//alert(isObject(frm.elements[args[i]]));
	if (isObject(frm.elements[args[i]])) {
			frm.elements[args[i]].value = '';
		}
	}
}
function isAlien(a) {
   return isObject(a) && typeof a.constructor != 'function';
}
function isArray(v) {
     return v && typeof v === 'object' && typeof v.length === 'number' &&
	          !(v.propertyIsEnumerable('length'));
}
function isBoolean(a) {
    return typeof a == 'boolean';
}
function isEmpty(o) {
    var i, v;
    if (isObject(o)) {
        for (i in o) {
            v = o[i];
            if (isUndefined(v) && isFunction(v)) {
                return false;
            }
        }
    }
    return true;
}
function isFunction(a) {
    return typeof a == 'function';
}
function isNull(a) {
    return a === null;
}
function isNumber(a) {
    return typeof a == 'number' && isFinite(a);
}
function isObject(a) {
    return (a && typeof a == 'object') || isFunction(a);
}
function isString(a) {
    return typeof a == 'string';
}
function isUndefined(a) {
    return typeof a == 'undefined';
} 

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,label,errors='',errorsEmail='',errorpwd='',errors2='',errSymbol='',errorsLogin='',args=MM_validateForm.arguments;
  var frm=args[0], blnLoginEmpty=true;
  var frmObj=document.forms[args[0]];
  var arrSymbol = new Array("<", ">", "(", ")", "%", "+" );
  //alert(isObject(frmObj));
		
  for (i=1; i<(args.length-2); i+=3) { test=args[i+2]; 
  	//alert(args[i+1]);
  	val=MM_findValue(frm,args[i]); label=args[i+1];
	nm=args[i];
	
	if ((nm.indexOf('web_password')!=-1 && isObject(frmObj.elements['web_password'])) || (nm.indexOf('LoginPassword')!=-1 && isObject(frmObj.elements['LoginPassword']))) {
		//alert(nm + '-' + isObject(frmObj.elements['LoginPassword']));
		// regular expressions
		var lc = /[a-z]{1}/; // lowercase letters
		var uc = /[A-Z]{1}/; // uppercase letters
		var nm = /[0-9]{1}/; // numbers
		var un = /[^A-Za-z0-9]{1}/; // upper- and lower-case letters and numbers
		
		var score = 0;
		if (val.length < 6 || val.length > 8) errorpwd += '- Password must contain from 6 to 8 characters.';
		
		if (val.match(nm)) score++;
		if (val.match(lc)) score++;
		if (val.match(uc)) score++;
		
		if (score < 2){
			var arrSpecial = new Array('~','!','@','#','$','^','&','*','_','{','}','|',':','"','?','`','-','=','[',']');
			var blnSpecial = false;
			for(var x=0; x < arrSpecial.length; x++ ) {
				if (val.indexOf(arrSpecial[x])!=-1)  blnSpecial = true;  
			}
			if (blnSpecial) score++;
		}
		if (score < 2) errorpwd += '- Password must include at least two of the following four types of characters:\n\t- Lower case letters\n\t- Upper case letters\n\t- Numbers\n\t- Printable keyboard characters, such as punctuation marks';
	}
	
	if (test.indexOf('LG')!=-1) {
		if (frmObj.elements['LoginUsername'].value!=''){
			blnLoginEmpty = false;	
			if(frmObj.elements['LoginPassword'].value==''){
				errorsLogin += '- Please fill in your username and password.\n';
			}
		} else {
			frmObj.elements['LoginUsername'].value='';
			frmObj.elements['LoginPassword'].value='';
		}
		/*if (isObject(frmObj.elements[args[i]])) {
			if (test.indexOf('LGPASS')!=-1) {				
				if ((val=='') && (blnLoginEmpty==false)) errorsLogin += '- Please fill in your username and password.\n';
			} else {
				if (val!='') blnLoginEmpty = false;			
			}
		}*/
	} else if (test.indexOf('isNotEnter')!=-1) {
		if (val=='Enter your Search here') errors2 += label; else if (val=='') errors += '- '+nm+' is required.\n';
	} else if (test.indexOf('OM')!=-1) {
		if (val=='0') errors2 += label;
	} else if (test.indexOf('CKD')!=-1) {
		if (val=='') errors2 += '- Please check "' + label + '"\n';
	} else if ((test.indexOf('isOther')!=-1) && (test.indexOf('R')==-1)) {
	  	if ((val=='Other') && (MM_findValue(frm,args[i]+'Other')=='')) errors2 += '- Please fill in the "Other" textbox.\n';
	}else if (val!='') {
      if (test.indexOf('isOther')!=-1) {
	  	//alert(val +'-'+MM_findValue(frm,args[i]+'Other'));
	  	if ((val=='Other') && (MM_findValue(frm,args[i]+'Other')=='')) errors2 += '- Please fill in the "Other" textbox.\n';
	  } else if (test.indexOf('isMultiOther')!=-1) {
	  	if ((val.indexOf('Other')!=-1) && (MM_findValue(frm,args[i]+'Other')=='')) errors2 += '- Please fill in the "Other" textbox for the '+args[i+1]+'.\n';
	  } else if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
		if (p<1 || p==(val.length-1)) errorsEmail+='- '+label+' must contain an e-mail address.\n';
      } else if (test!='R') {
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    }}} else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; 
	
	for(var x=0; x < arrSymbol.length; x++ ) {
		if (val.indexOf(arrSymbol[x])!=-1)  errSymbol += "- Fields may not contain special characters.\n";  
	}
	
	if ((test.indexOf('LG')!=-1) && !(blnLoginEmpty)) { break; }
	//if ((test.indexOf('LGPASS')!=-1) && (errorsLogin)) { break; }
  } 
  
  if (errors) { 
  	alert('Please complete all required fields.');
  } else if (errSymbol) {
   	alert('Fields may not contain special characters.');
   	//alert(errSymbol);
	errors = 'charerror';
  } else if (errorpwd) {
   	alert(errorpwd);
	errors = 'passworderror';
  }else if (errorsEmail) {
   	alert(errorsEmail);
	errors = 'emailerror';
  }else if (errors2) {
   	alert(errors2);
	errors = 'uniqueerror';
  }else if (errorsLogin) {
   	alert(errorsLogin);
	errors = 'errorsLogin';
  }
  document.MM_returnValue = (errors == '');
}

function selectWhich(aForm) {
	var frmObj=document.forms[aForm];
	if (frmObj.elements['section'].value=='') {
		frmObj.action = 'order_form.jsp';
		//calcItems('form1','itemsSelected','servicekit','brochure','sticker','dosingchart','factcard','servicevideo');
		calcItems('form1','itemsSelected','servicevideodvd','servicevideovhs','dosingadmcard','dosingcard','brochure','catheterbrochure','factcard','slide','servicekit','sticker','insertion');
		
		MM_validateForm('form1','itemsSelected','- Please select at least one of the materials.\n','OM');
		var error = document.MM_returnValue;
		document.MM_returnValue = error;	
		//return document.MM_returnValue;
	} else {
		frmObj.action = 'index.jsp#' + frmObj.elements['group'].value;
		//alert(document.form1.action);
		//return document.MM_returnValue;		
	}
	
}

function openWindow(aURL, aWindow, aProperties){
	if (aProperties=='gene')aProperties='width=785,height=600,resizable=1,scrollbars=1,titlebar=1,directories=1,location=1,menubar=1,toolbar=1;status=1';
	if (aProperties=='popup')aProperties='width=515,height=268';
	if (aProperties=='')aProperties='width=785,height=600,resizable=1,scrollbars=1,titlebar=1';
	
	var childWindow=open(aURL,aWindow,aProperties);
    if (childWindow.opener == null) childWindow.opener = self;
	childWindow.focus();
}

function changeVisible(aObj,aForm,aID) {
	var aVisible='';
	if (aObj.options[aObj.selectedIndex].value=='Other') {
		aVisible = 'visible';
	} else {
		aVisible = 'hidden';
		document.forms[aForm].elements[aID].value='';
	}
	if (!bNS4) {
		if (document.getElementById(aID)) {
			var element = document.getElementById(aID);
			element.style.visibility = aVisible;
		}
	}
}
function onInput() {
	var args=onInput.arguments, frm = document.forms[args[0]], aID='', aValue='';
	for (i=1; i<(args.length-1); i+=2) { 
		aID=args[i],aValue=args[i+1];
		frm.elements[aID].value = aValue;
		//alert(aID + '-' + frm.elements[aID].value);
	}
}
function checkClear(aObj,aForm,aID) {
	if (aObj.checked == false) {
		var aElement = document.forms[aForm].elements[aID];
		for (var i=0;i<aElement.length;i++){
		if (aElement[i].checked==true){
			aElement[i].checked = false;
		}}
	}
}

function changeClass(aID,aClass) {
	if (!bNS4) {
		if (document.getElementById(aID)) {
			var element = document.getElementById(aID);
			element.className = aClass;
		}
	}
}

//function openNewWindow(aURL,aName,aProperty){
function openArticle(aURL){
	alert(aURL);
	openWindow(aURL,'popupWindow','popup');
	//window.open(aURL,'','width=760,height=600,directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes');
}
//-->
