// JavaScript Document
var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;
var strCode;
var strSUP, strUL, strLI, gCatId

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 WindowOnload(f) {
    var prev=window.onload;
    window.onload=function(){ if(prev)prev(); f(); }
  }


function formCheck(strAction)
{
	var intCount = document.forms[0].length;
	var i = 0;
	var bSendFlag = true;
	
	while(i != intCount)
	{
		if(document.forms[0].elements[i].value == "" || document.forms[0].elements[i].value == "null")
		{
				var strName = document.forms[0].elements[i].name;
				
				if(strName.indexOf("*") != -1)
				{
					var iLength = strName.length;
					strName = strName.substring(1, iLength);
					strName = strName.replace("_", " ");
					strName = strName.replace("_", " ");
					strName = strName.replace("_", " ");
					strName = strName.replace("_", " ");
					strName = strName.replace("_", " ");
					
					var obj = window.parent.document.getElementById("error_message");
	
						obj.innerHTML = '<span class="error">Please enter a ' + strName + '.</span>';
						
						document.forms[0].elements[document.forms[0].elements[i].name].focus();
						bSendFlag = false;
						break;
				}
				i = i+1;
		}
		else
		{
			i = i+1;
		}
		
	}
	if(bSendFlag == true)
	{
		
			if(strAction == "referral")
			{
				document.forms[0].action = "../ASP/submit.asp?request=referral&return=../section_3/thankyou.asp";
				document.forms[0].submit();
			}
			if(strAction == "login")
			{
				document.forms[0].action = "html/ASP/submit.asp?request=login&return=../../default.asp";
				document.forms[0].submit();
			}

	}
}



function OpenPopup(strPopupName)
{
	document.getElementById(strPopupName).style.visibility = "visible";
}	
	
function ClosePopup(strPopupName)
{
	document.getElementById(strPopupName).style.visibility = "hidden";
}


function DisplayLargeImage(strProdCode)
{
	var strCode = "../global/popup.asp?prodcode=" + strProdCode
	
	window.open(strCode, "LargeImage", "height=448, width=400, toolbars=no, status=no");
}


function ShowFinderSub(iVal)
{
	var strName = "searchvalueform" + iVal
	 DisplayError("");
	
	gCatId = iVal;
	
	if(iVal != 0)
	{
		document.getElementById('searchvalueform1').style.visibility = "hidden";
		document.getElementById('searchvalueform2').style.visibility = "hidden";
		document.getElementById('searchvalueform3').style.visibility = "hidden";
		document.getElementById('searchvalueform4').style.visibility = "hidden";
		document.getElementById(strName).style.visibility = "visible";		
	}
	else
	{
		document.getElementById('searchvalueform1').style.visibility = "hidden";
		document.getElementById('searchvalueform2').style.visibility = "hidden";
		document.getElementById('searchvalueform3').style.visibility = "hidden";
		document.getElementById('searchvalueform4').style.visibility = "hidden";
	}
}



function SearchFor(iVal)
{
	var strVAL_1 = document.data1.namevalue.value;
	var strVAL_2 = document.data1.codevalue.value;
	
	//0 = name search, 1 = code search
	if(iVal == 0)
	{
		if(strVAL_1 != "")
		{
			document.data1.action = "default.asp?type=name&value=" + strVAL_1;
			document.data1.submit();
		}
		else
		{
			DisplayError("Please enter a product name");
		}
	}
	else
	{
		if(strVAL_2 != "")
		{
			document.data1.action = "default.asp?type=code&value=" + strVAL_2;
			document.data1.submit();
		}
		else{DisplayError("Please enter a product code");}
	}


}

function SearchForEye(iSub)
{

	document.data1.action = "default.asp?type=eye&catid=" + gCatId + "&prodid=" + iSub;
	document.data1.submit();
}

function SearchForSub(iSub)
{

	document.data1.action = "default.asp?type=sub&catid=" + gCatId + "&prodid=" + iSub;
	document.data1.submit();
}


function LocateByState(strVal)
{

	document.data1.action = "default.asp?type=state&value=" + strVal;
	document.data1.submit();
}

function LocateByCountry(strVal)
{
	document.data1.action = "default.asp?type=country&value=" + strVal;
	document.data1.submit();
}

function SearchByName()
{
	strVal = document.data1.namesearch.value;
	
	if(strVal == "")
	{
		DisplayError("Please fill in distributor name");
	}
	else
	{
		document.data1.action = "default.asp?type=justname&value=" + strVal;
		document.data1.submit();	
	}
}




function DisplayError(strMessage)
{
	var obj = document.getElementById('error_message');
		obj.innerHTML = '<span class="error">' + strMessage + '</span>';
}


function OpenChart(iVal)
{
	if(iVal == 1)
	{
		window.open('OI-SP_Chart.asp', 'Chart', 'height=768px, width=1024, toolbars=0, scrollbars=1');		
	}
	
	if(iVal == 2)
	{
		window.open('OPR-120_Chart.asp', 'Chart', 'height=665px, width=730, toolbars=0, scrollbars=0');		
	}
	
	

}


function LogIn()
{
	alert("asd");
	//var obj = document.getElementById('login2')
		//obj.style.display = "block";
		
	//var obj2 = document.getElementById('login')
		//obj2.style.display = "none";

}


function ShowColors()
{
	window.open("../global/colors.asp", "colors", "height=271, width=248, toolbar=0, scrollbar=0");
}


function DisplaySearchDiv(intNum)
{
	if(intNum == "0")
	{
		var obj0 = document.getElementById('distributor_name_container')
			obj0.style.display = "block";

		var obj1 = document.getElementById('state_search_container')
			obj1.style.display = "none";
			
		var obj2 = document.getElementById('international_search_container')
			obj2.style.display = "none";
	}

	if(intNum == "1")
	{
		var obj0 = document.getElementById('distributor_name_container')
			obj0.style.display = "none";

		var obj1 = document.getElementById('state_search_container')
			obj1.style.display = "block";
			
		var obj2 = document.getElementById('international_search_container')
			obj2.style.display = "none";
	}
	if(intNum == "2")
	{
		var obj0 = document.getElementById('distributor_name_container')
			obj0.style.display = "none";

		var obj1 = document.getElementById('state_search_container')
			obj1.style.display = "none";
			
		var obj2 = document.getElementById('international_search_container')
			obj2.style.display = "block";
	}
}




function escramble_ocular(name)
{
	 var a,b,c,d,e,f,g,h,i
	 
	 a='<a href=\"mai'
	 b= name
	 c='\">'
	 a+='lto:'
	 b+='@'
	 e='</a>'
	 f=''
	 b+='ocular-instruments.com'
	 g='<img src=\"'
	 h=''
	 i='\" alt="Email us." border="0">'
	
	 if (f) d=f
	 else if (h) d=g+h+i
	 else d=b
	
	 document.write(a+b+c+d+e)
}


