function UL_acceptsCookies() {
  // This function tests whether the user accepts cookies.
  // Declare variable.
  var answer;
  // Try to set a cookie.
  document.cookie = 'UL_acceptsCookies=yes';
  // If it fails, return false; if it succeeds, return true.
  if(document.cookie == '') answer = false; else answer = true;
  // Then clean up by expiring the cookie.
  document.cookie = 'UL_acceptsCookies=yes; expires=Fri, 13-Apr-1970 00:00:00 GMT';
  return answer;
}


//
// preload Images
//

// onLoad="MM_preloadImages('','',...)"
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];}}
}

//
// popUpload
//
function popUpload(vCaption, vField, vValue, sName, sPath){
	//alert(vValue);
	var iWidth = 500;
	var iHeight = 500	;
	var iLeft = (screen.width - iWidth) / 2;
	var iTop = (screen.height - iHeight) / 2;
	//alert(sPath);
	var strWinProps = "top="+iTop+",left="+iLeft+",width="+iWidth+",height="+iHeight+",resizable=yes,scrollbars=yes,toolbar=no,menubar=no,status=no";
	var nW = window.open("", sName, strWinProps);
	nW.location.href = "../Common/ULWindowInc.asp?caption="+ escape(vCaption) + "&field="+ vField + "&value="+ vValue + "&Name=" + sName + "&Path=" + sPath;
	nW = null;
}



function popGraphic(sImage, sTitle, sCaption,sSSheet)
{

//alert(sImage);

var iWinLeft;
var iWinTop;
var iImgWidth;
var iImgHeight;
var iWinWidth;
var iWinHeight;

//RSvar oImage = new Image();

if (sImage=="") {
return false;
}

iImgHeight=400;
iImgWidth=400;

if (iImgHeight==0) {
	alert('Failed Image Inspection. Please try again.');
	window.close();
	return false;
}

sTitle=unescape(sTitle);
sCaption=unescape(sCaption);
//alert(sTitle);
var iWinWidth = iImgWidth + 50;
var iWinHeight = iImgHeight + 80;

iWinLeft = (window.screen.width/2) - (iWinWidth/2);
iWinTop = (window.screen.height/2) - (iWinHeight/2);
var winprops = 'height='+iWinHeight+',width='+iWinWidth+',top='+iWinTop+',left='+iWinLeft+',scrollbars='+scroll+',resizable,status=yes'
//var sSSheet='';
//alert(sSSheet);
var strPopImageHTML = '<html><head><title>' + sTitle + '</title><link href=' + sSSheet + ' type="text/css" rel="stylesheet"/></head>';
strPopImageHTML = strPopImageHTML + '<body bgcolor=#FFFFFF text=#000000><center><table border=0 width=' + iImgWidth + ' height=' + iImgHeight + ' cellspacing=0 cellpadding=2>';
strPopImageHTML = strPopImageHTML + '<tr><td width=100% align=center><div class="smalltext"><b>'+sTitle+'</b></div><div class="mediumtext">'+sCaption+'</div></td></tr><tr>';
strPopImageHTML = strPopImageHTML + '<td align=center><img border=0 src="'+sImage+'"></td></tr><tr>';
strPopImageHTML = strPopImageHTML + '<td valign=middle align=right><input type=button value=Close name=btnClose OnClick="javascript:window.close();"></td></tr></table>';
strPopImageHTML = strPopImageHTML + '</center></div></body></html>';



var nW = window.open("", "Helper", winprops);
nW.document.write(strPopImageHTML);


if (parseInt(navigator.appVersion) >= 4)
{
nW.window.focus();
}

//nW.location.href = "../Include/ShopPopGraphic.asp?I=" + sImage + "&T=" + sTitle;
//nW = null;

}



function popGraphicOLD(sImage, sTitle)
{

//alert(sImage);

var iWinLeft;
var iWinTop;
var iImgWidth;
var iImgHeight;
var iWinWidth;
var iWinHeight;

var oImage = new Image();

if (sImage=="") {
return false;
}



oImage.src = sImage;
iImgHeight = oImage.height;
iImgWidth = oImage.width ;

//alert(iImgWidth);

var iWinWidth = iImgWidth + 50;
var iWinHeight = iImgHeight + 80;

iWinLeft = (window.screen.width/2) - (iWinWidth/2);
iWinTop = (window.screen.height/2) - (iWinHeight/2);

var winprops = 'height='+iWinHeight+',width='+iWinWidth+',top='+iWinTop+',left='+iWinLeft+',scrollbars='+scroll+',resizable,status=yes'
var displayPage = "../Include/ShopPopGraphic.asp?I=" + sImage + "&T=" + sTitle + "&H=" + iImgHeight + "&W=" + iImgWidth ;
//alert(displayPage);
var nW = window.open(displayPage, "Helper", winprops);

if (parseInt(navigator.appVersion) >= 4)
{
nW.window.focus();
}

//nW.location.href = "../Include/ShopPopGraphic.asp?I=" + sImage + "&T=" + sTitle;
//nW = null;

}


function displayHTML(form, FieldValue) {

	var iMyWidth;
	var iMyHeight;

	//gets top and left positions based on user's resolution so hint window is centered.
	iMyWidth = (window.screen.width/2) - (175 + 10); 
	iMyHeight = (window.screen.height/2) - (125 + 50); 
	
	//document.write (iMyWidth);
	//document.write (iMyHeight);
	var inf = '<font face=Verdana size=1>'+FieldValue+'</font>';
	var strCloseWin = '<br/><br/><div><font face=Verdana size=1><a href="javascript: window.close();">[Close Window]</a></font></div>'
	

	win = window.open(',', 'popup', 'toolbar=no,width=350,height=250,left='+iMyWidth+',top='+iMyHeight+',status=no,resizable=yes');
	win.focus();
	win.document.write("" + inf + strCloseWin + "");
}



function isLowRes() {
   /*
   ** Check if the browser is running in a low-resolution environment
   ** try to use the screen object (in N4 or e4). If not available, try to use Java.
   ** If not available, assume low-res.
   ** returns true if in a low-resolution environment (width < 800 pixels)
   */
   if (self.screen)
     return (screen.width < 800);
   else
     if (navigator.javaEnabled && navigator.javaEnabled())
       return (java.awt.Toolkit.getDefaultToolkit().getScreenSize().width < 800);
     else
       return true;
   }

function toggleImage(ImgName) {

	// alert("toggleImage");
	var sImageOn = '../images/icoMinus_11x11.gif';
	var sImageOff = '../images/icoPlus_11x11.gif';
	
	if (document.getElementById) {

		//var strSrc = document.all.item(ImgName).src;
		var strSrc = document.getElementById(ImgName).src 
		var pos = strSrc.indexOf('icoPlus_11x11');
		// alert(pos);
		 if (pos != -1)
		 {
			document.getElementById(ImgName).src = sImageOn;				 
		}
		else
		{
			document.getElementById(ImgName).src = sImageOff;
		 }
			 
	}
	else if (document.all) {
			
		var strSrc = document.all.item(ImgName).src;
		var pos = strSrc.indexOf('icoPlus_11x11');

		 if (pos != -1)
		 {
			document.all.item(ImgName).src = sImageOn;				 
		 } else {
			document.all.item(ImgName).src = sImageOff;
		 }
		 
	}
	else if (document.layers) {
	
		// this is the way nn4 works
		document.layers[DivName].display = "";
	
		var strSrc = document.layers[DivName].src;
		var pos = strSrc.indexOf('icoPlus_11x11');

		 if (pos != -1)
		 {
			document.layers[DivName].src = sImageOn;				 
		 } else {
			document.layers[DivName].src = sImageOff;
		 }

	}
		

}





//
//
//
function toggleDiv(DivName){


				//alert("Clicked!");

				 /*if (document.all.item(DivName).style.display == "none")
				 {
					 document.all.item(DivName).style.display = "";
				 }
				 else
				 {
					document.all.item(DivName).style.display = "none";
				 }*/


					if (document.getElementById) {
						//alert("Click!");
						// this is the way the standards work
						if (document.getElementById(DivName).style.visibility == "hidden")
						{	document.getElementById(DivName).style.visibility = "visible";
							document.getElementById(DivName).style.display = "";
						} else {
							document.getElementById(DivName).style.visibility = "hidden";
							document.getElementById(DivName).style.display= "none";
						}
						
					}
					else if (document.all) {
			
						// this is the way old msie versions work
						if (document.all[DivName].style.visibility == "hidden")
						{
						document.all[DivName].style.visibility = "visible";
						}else{
							document.all[DivName].style.visibility = "hidden";
						}
					}
					else if (document.layers) {
						// this is the way nn4 works
						
						if (document.layers[DivName].visibility == "hidden"){
							document.layers[DivName].display = "";
						}else{
							document.layers[DivName].visibility = "visible";
						}
					}
}

function Toggle(oDiv, oImage){
	
	toggleDiv(oDiv);
	toggleImage(oImage);

}



//
//
//
function showDiv(DivName){

	//alert(DivName);
	if (document.getElementById) {
						
		// this is the way the standards work
		document.getElementById(DivName).style.visibility = "visible";
		document.getElementById(DivName).style.display = "";
				
	}
	else if (document.all) {
			
		// this is the way old msie versions work
		document.all[DivName].style.visibility = "visible";
	}
	else if (document.layers) {
		// this is the way nn4 works
		document.layers[DivName].display = "";
		document.layers[DivName].visibility = "visible";
	}


}


//
//
//
function hideDiv(DivName){

	if (document.getElementById) {
						
		// this is the way the standards work
		document.getElementById(DivName).style.visibility = "hidden";
		document.getElementById(DivName).style.display = "none";
				
	}
	else if (document.all) {
			
		// this is the way old msie versions work
		document.all[DivName].style.visibility = "hidden";
	}
	else if (document.layers) {
		// this is the way nn4 works
		document.layers[DivName].display = "none";
		document.layers[DivName].visibility = "hidden";
	}


}


//
// ConfirmRedirect
//
function ConfirmRedirect(strPrompt, strURL){

	if (confirm(strPrompt)) {
              location.href=strURL;
       }

}


//
//
//
function popcaltest(vCaption, vField, vDate){
	var iMyWidth;
	var iMyHeight;
	//gets top and left positions based on user's resolution so hint window is centered.
	iMyWidth = (window.screen.width/2) - (150 + 10); 
	iMyHeight = (window.screen.height/2) - (160 + 50); 
	
	//var nW = window.open("", "calendar", "resizable=no,scrollbars=no,width=300,height=360");
	var nW = window.open("", "calendar", "resizable=no,scrollbars=no,width=300,height=350,left="+iMyWidth+",top="+iMyHeight+",status=no");

	
	nW.location.href = "../Common/popcalendar.asp?caption=" + escape(vCaption) + "&field=" + vField + "&date=" + vDate;
	nW = null;
}


//
//
//
function IsDateOK(field) {
	var strDate = field.value;
	//return isValidDate(strDate);
	
	if (!isValidDate(strDate)){
		//alert("Invalid Date!");
		field.focus();
		return false;
	}
}



//
//
//
function IsValidTime(timeStr) {
// Checks if time is in HH:MM:SS AM/PM format.
// The seconds and AM/PM are optional.

var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm))?$/;

var matchArray = timeStr.match(timePat);
if (matchArray == null) {
alert("Time is not in a valid format.");
return false;
}
hour = matchArray[1];
minute = matchArray[2];
second = matchArray[4];
ampm = matchArray[6];

if (second=="") { second = null; }
if (ampm=="") { ampm = null }

if (hour < 0  || hour > 23) {
alert("Hour must be between 1 and 12. (or 0 and 23 for military time)");
return false;
}
if (hour <= 12 && ampm == null) {
if (confirm("Please indicate which time format you are using.  OK = Standard Time, CANCEL = Military Time")) {
alert("You must specify AM or PM.");
return false;
   }
}
if  (hour > 12 && ampm != null) {
alert("You can't specify AM or PM for military time.");
return false;
}
if (minute<0 || minute > 59) {
alert ("Minute must be between 0 and 59.");
return false;
}
if (second != null && (second < 0 || second > 59)) {
alert ("Second must be between 0 and 59.");
return false;
}
return false;
}






//
//
//
function isValidDate(dateStr) {
// Date validation function courtesty of 
// Sandeep V. Tamhankar (stamhankar@hotmail.com) -->

// Checks for the following valid date formats:
// MM/DD/YY   MM/DD/YYYY   MM-DD-YY   MM-DD-YYYY

var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/; // requires 4 digit year

var matchArray = dateStr.match(datePat); // is the format ok?
if (matchArray == null) {
alert(dateStr + " Date is not in a valid format.")
return false;
}
month = matchArray[1]; // parse date into variables
day = matchArray[3];
year = matchArray[4];
if (month < 1 || month > 12) { // check month range
alert("Month must be between 1 and 12.");
return false;
}
if (day < 1 || day > 31) {
alert("Day must be between 1 and 31.");
return false;
}
if ((month==4 || month==6 || month==9 || month==11) && day==31) {
alert("Month "+month+" doesn't have 31 days!")
return false;
}
if (month == 2) { // check for february 29th
var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
if (day>29 || (day==29 && !isleap)) {
alert("February " + year + " doesn't have " + day + " days!");
return false;
   }
}
return true;
}


function ChangeOptions(lstPrimary, lstSecondary, strArray)
{

var arrLen = eval( strArray + ".length");
var listLen = 0;
var strKey = eval("document.forms[0]." + lstPrimary + ".options[document.forms[0]." + lstPrimary + ".selectedIndex].value");

eval("document.forms[0]." + lstSecondary + ".options.length = 0");

for (var i = 0; i < arrLen; i++)
{
   if (eval(strArray + "[i][0] == " + strKey))
      {
      eval("document.forms[0]." + lstSecondary + ".options[listLen] = new Option(" + strArray + "[i][2], " +  strArray + "[i][1])");
      listLen = listLen + 1;
      }
   }

if (listLen > 0)
   {eval("document.forms[0]." + lstSecondary + ".options[0].selected = true");}

   //alert ("document.all is " + document.all);
   //alert ("document.layers is " + document.layers);
   if (document.all == null) //Not using Internet Explorer
      {history.go(0);}
   }
