// JavaScript Document

/*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
*/

// this is the  Rollover Script 

       function swapImage() { //v3.0
	  var i,j=0,x,a=swapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
	   if ((x=findObj(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}
	
	function swapImgRestore() { //v3.0
	  var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}	
	
	
/*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
*/

// this is the Function for linking to outside sites
//   Gives required warning when link is clicked
		
		function OutsideLink(URL)	
		{
		   var siteName = "Ultracet";
		   var writeURL = URL
		   if (URL.length > 60)
		   {
			   writeURL = URL.substr(0, 60) + "...";
		   }
		   if (confirm("\nThank you for visiting www." + siteName + ".com.\n\nBy clicking 'OK' you will be taken to: \n\n" + writeURL +"\n\nA Web site to which our Privacy Policy \ndoes not apply.\n\nYou are solely responsible for your \ninteractions with such Web sites.\n\n"))
		   {
			   window.open(URL,"_blank");
		   }
				
		}
	
	
	/***********************************************/
	//	Function for preloading images
	
	function preloadImages() { //v3.0
	  var d=document; if(d.images){ if(!d.p) d.p=new Array();
		var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
	}
	
/*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
*/

// this is the COOKIE CHECKING / WRITING / CLEARING  SCRIPT
//	


		function checkCookie(cookName)
		{  // THIS WILL RETURN THE COOKIE VALUE OR the String "NoSuchCookie"
			var allcookies = document.cookie;
			//alert("cookie is: " + allcookies);
			var pos = allcookies.indexOf(cookName + "=");
			if(pos != -1)
			{
				var start = pos + cookName.length + 1;
				var end = allcookies.indexOf(";",start);	
				if(end == -1)
				{ 
					end = allcookies.length;
				}
				var value = allcookies.substring(start, end);
				//alert(cookName +  " cookie value is: " + value);
				return value;
				
			}
			else
			{
				//alert("no such cookie as " + cookName);
				return "NoSuchCookie";
			}

		}


		function setCook(name, value, days)
		{
			var nextYear = new Date();
			nextYear.setUTCDate( parseInt( nextYear.getDate() ) + parseInt(days) );
			document.cookie = name + "=" + value + ";expires=" + nextYear.toGMTString() + ";path=/;";
		}



		function deleteCookie(cookName)
		{
			if (checkCookie(cookName) != "NoSuchCookie")
			{
				var xmas = new Date(2001, 11, 25)
				document.cookie= cookName + "=0;expires=" + xmas.toGMTString() + ";path=/;";
				alert("Cookie " + cookName + " deleted succesfully.");
			}
			else
			{
				alert("Could not find cookie " + cookName + ".");
			}

		}







/*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
*/

// these are the basic WINDOW SCRIPTS, Print, Open Browser
//	

		
		function printWindow() 
		{
		   bV = parseInt(navigator.appVersion)
		   if (bV >= 4) window.print()
		}
		
		function openBrWindow(theURL,winName,scrollable,sizable,menus,width,height) 
		{
		  var features  = "fullscreen=no,";
		  features += "toolbar="+menus+",";
		  features += "location="+menus+",";
		  features += "directories=no,";
		  features += "status="+menus+",";
		  features += "menubar="+menus+",";
		  features += "scrollbars=" + scrollable +",";
		  features += "resizable=" + sizable + ",";
		  features += "width=" + width + ",";
		  features += "height=" + height ;
		  openPopUp2(theURL,winName,features);
		}
		
		function openPopUp2(url,name,features)
		{
			var popup;
			popup = window.open(url,name,features); 
		}
		
		
		
/*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
*/
//	Function for looping through form elements
	
	function 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=findObj(n,d.layers[i].document);
	  if(!x && d.getElementById) x=d.getElementById(n); return x;
	}