var rotatorInterval;		//how many milliseconds a page should be displayed before switching to 
var rotatorCountDown;										//screen rotator function (if enabled in Kiosk Mode)

//handles on-screen keyboard for KIOSK mode
var currentControl
function activeControl(me){
	currentControl = me;
}


// functions to handle closing of child windows
var childIsOpen
var w	

function closeMe(){
	if (childIsOpen == true){
		w.close();
	}
}

function childWindowClose() {
	childIsOpen = false;
}

function newWLWindow() {
	if (childIsOpen == true) {
			w.close();
		}
}

function CallItemWindow(ItemNo, SeriesNo, SeriesName, Group, SFQRY){
	var URL 
		
	newWLWindow()
	URL = 'notepad.asp?ItemNo='+ItemNo+'&SeriesNo='+SeriesNo+'&SeriesName='+SeriesName+'&Group='+Group+'&'+SFQRY;
	w = window.open(URL, 'Child', "scrollbars,HEIGHT=300,WIDTH=300,LEFT="+GetCookie('SCREENLEFT')+",TOP="+GetCookie('SCREENTOP'))
	childIsOpen=true;
	w.parentWindowOpen = true;
	w.focus(); 
}

function OldBrowserWL(SeriesNo, SeriesName, Group, SFQRY){
	var URL	
	URL = 'wishlist.asp?SeriesNo='+SeriesNo+'&SeriesName='+SeriesName+'&Group='+Group+'&'+SFQRY;
	window.location = URL;
}

// timer functions

var timerID = 0;
var tStart  = null;

function UpdateTimer() {
   if(timerID) {
      clearTimeout(timerID);
      clockID  = 0;
   }

   if(!tStart)
      tStart   = new Date();

   var   tDate = new Date();
   var   tDiff = tDate.getTime() - tStart.getTime();

   tDate.setTime(tDiff);

	if (tDiff > 3000)		//remove after 3  seconds
	{
	Stop('Y','Layer1');
	MM_showHideLayers('lyrGroupings','','hide')
	}
	

   timerID = setTimeout("UpdateTimer()", 1000);
}

function Start() {
   tStart   = new Date();
   timerID  = setTimeout("UpdateTimer()", 1000);
}

function Stop(Clear, lyr) {
	if (Clear=='Y')
	{
		MM_setTextOfLayer(lyr,"","");
	}
   if(timerID) {
      clearTimeout(timerID);
      timerID  = 0;
   }

   tStart = null;
}

function Reset() {
   tStart = null;
}




//==============

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}




<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
//MM_reloadPage(true);
// -->

function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

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_nbGroup(event, grpName) { //v3.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : args[i+1];
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    if ((nbArr = document[grpName]) != null)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = args[i+1];
      nbArr[nbArr.length] = img;
  } }
}




// CREDITS:
// Print This Page
// Copyright (c) 2000 ZDnet. All rights reserved.
// Permission given to use the script provided that this notice remains as is.
// Additional scripts can be found at http://www.zdnet.com/developer
// devhead@zdnet.com
// 12/07/2000

/*
This script is written by Eric (Webcrawl@usa.net)
For full source code, installation instructions,
100's more DHTML scripts, and Terms Of
Use, visit dynamicdrive.com
*/

function printit(){  
if (window.print) {
    window.print() ;  
} else {
    var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
    WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box    WebBrowser1.outerHTML = "";  
}
}


function openFindStoreWindow(FromPage, url, basePath) 
{
	/* if this is called from the main menu, display the dealer locater
	if called from a series page, go directly to HSitemDetail if there has been a default HS defined */

	window.name = "opener";

	if (FromPage == "SeriesDetail.asp")
	{
		if (GetCookie("DefaultHS") > 0)		//if there is a default store, route directly to it
		{
			window.location = "HS"+FromPage + url
		}
		else
		{
			PopUpDL(url, basePath)
		}
	}
	else
	{	
		PopUpDL(url, basePath)
	}
}


function PopUpDL(url, basePath)
{
	popupWin = window.open(basePath + "/DealerLocator/getstore.asp"+url,"remote","width=540,height=400,scrollbars");
}


function openImageWindow(url, kioskMode) 
{
	if (kioskMode == 1){
		window.location = url
	}
	else{
		window.name = "opener";
		//popupWin = window.open(url,"remote","height=500, width=700, scrollbars, resizable");
		LargepopupWin = window.open(url,"remote","scrollbars, resizable");
		LargepopupWin.focus()
	}
}

function MM_checkBrowser(NSvers,NSpass,NSnoPass,IEvers,IEpass,IEnoPass,OBpass,URL,altURL) { //v4.0
  var newURL='', verStr=navigator.appVersion, app=navigator.appName, version = parseFloat(verStr);
  if (app.indexOf('Netscape') != -1) {
    if (version >= NSvers) {if (NSpass>0) newURL=(NSpass==1)?URL:altURL;}
    else {if (NSnoPass>0) newURL=(NSnoPass==1)?URL:altURL;}
  } else if (app.indexOf('Microsoft') != -1) {
    if (version >= IEvers || verStr.indexOf(IEvers) != -1)
     {if (IEpass>0) newURL=(IEpass==1)?URL:altURL;}
    else {if (IEnoPass>0) newURL=(IEnoPass==1)?URL:altURL;}
  } else if (OBpass>0) newURL=(OBpass==1)?URL:altURL;
  if (newURL) { window.location=unescape(newURL); document.MM_returnValue=false; }
}


function MM_setcookie(cookieValue, expiry, cookieName) 
{ //v1.0
	var expDate = new Date();
	if(expiry)
	{
		expDate.setDate (expDate.getDate() + expiry);
		document.cookie = cookieName + "=" + escape (cookieValue) + "; expires=" + expDate.toGMTString();
	}
	else
    	{
        	document.cookie = cookieName + "=" + escape (cookieValue);
        }
}

function GetCookie(CookieName)
{
	var cookies = document.cookie;
	var value;
	
	//look for start of cookie
	var pos = cookies.indexOf(CookieName);
	var start = pos + CookieName.length+1;
	var end = cookies.indexOf(";", start);
	
	if (end==-1) end = cookies.length;
	
	value = cookies.substring(start,end);
	
	value = unescape(value);
	return value;
}

function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

function MM_setTextOfLayer(objName,x,newText) { //v3.0
  if ((obj=MM_findObj(objName))!=null) with (obj)
    if (navigator.appName=='Netscape') {document.write(unescape(newText)); document.close();}
    else innerHTML = unescape(newText);
}


function CheckViewItem(a,b,c)
{
/*
	var value;
	var windowValue
	var allcookies = document.cookie;
	var pos= allcookies.indexOf("ViewItemFlag=");
	if (pos != -1)
	{
		var start = pos + 13
		var end = allcookies.indexOf(";",start);
		if (end == -1) end = alllcookies.length;
		value = allcookies.substring(start,end);
		value = unescape(value);
		
	}
	else
	{
		value = "Didn't find ViewItemFlag cookie!!"
	}	
	
	var pos2= allcookies.indexOf("NotepadWindow=");
	if (pos2 != -1)
	{
		var start2 = pos2 + 14
		var end2 = allcookies.indexOf(";",start2);
		if (end2 == -1) end2 = alllcookies.length;
		windowValue = allcookies.substring(start2,end2);
		windowValue = unescape(windowValue);
		
	}
	else
	{
		windowValue = "Didn't find windowopen cookie!!"
	}	

	if ((value == "Y") && (windowValue == "open"))
	{
		document.cookie = "ViewItemFlag=N";
		CallItemWindow(a,b,c)
		//NewWindow = window.open("Notepad.asp", 'Child', "HEIGHT=300,WIDTH=300,scrollbars")
	}
*/			
}






function closeme()
{
	closeMe();
	return;
	//in order to not change all pages in site, this function now just redirects to closeMe

	//closes the child window, if there is one open
	/*if (GetCookie("CHILDOPEN")=="Y")
	{
		//alert(<%=request.cookies("ChildLeft")%>)
		MM_setcookie(NewWindow.screenTop-22, 1, "SCREENTOP") 
		MM_setcookie(NewWindow.screenLeft-3, 1, "SCREENLEFT") 
		NewWindow.close();
	}*/
}



function isEmail(str) {
   // EMAIL address validity checker
  // are regular expressions supported?
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}






/*
function numbersonly(myfield, e, dec){
					// copyright 1999 Idocs, Inc. http://www.idocs.com
					// Distribute this script freely but keep this notice in place
	//function allows numbers only in text box

	var key;
	var keychar;

	if (window.event)
	   key = window.event.keyCode;
	else if (e)
	   key = e.which;
	else
	   return true;
	keychar = String.fromCharCode(key);

	// control keys
	if ((key==null) || (key==0) || (key==8) || 
	    (key==9) || (key==13) || (key==27) )
	   return true;

	// numbers
	else if ((("0123456789").indexOf(keychar) > -1))
	   return true;

	// decimal point jump
	else if (dec && (keychar == "."))
	   {
	   myfield.form.elements[dec].focus();
	   return false;
	   }
	else
	   return false;
}

*/


/*
function fnDisableKeys(){
	// CTRL combination
	if (event.ctrlKey == true){
		switch(event.keyCode){
			case 65: // CTRL+A
			case 66: // CTRL+B
			case 68: // CTRL+D
			case 69: // CTRL+E<BR>  
			case 70: // CTRL+F<BR>  
			case 72: // CTRL+H    <BR>  
			case 73: // CTRL+I<BR>  
			case 82: // CTRL+R<BR>  
			case 76: // CTRL+L<BR>  
			case 78: // CTRL+N  <BR>  
			case 79: // CTRL+O  <BR>  
			case 80: // CTRL+P
			case 87: // CTRL+W
				event.keyCode=0;
				event.returnValue=false;
				event.cancelBuble=true;
			break;
		}
	}
}

*/

/*
============================================================
Capturing The Mouse Position in IE4-6 & NS4-6
(C) 2000 www.CodeLifter.com
Free for all users, but leave in this  header
*/


//NOT USING THIS RIGHT NOW
/*

// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
//document.onmousemove = getMouseXY;
document.onmousemove = checkMousePos;

// Temporary variables to hold mouse x-y pos.s
var tempX = 0
var tempY = 0
var loading = true

// Main function to retrieve mouse x-y pos.s
function checkMousePos(e) {
	var oldTempX = tempX;	//hold old positions for comparison
	var oldTempY = tempY;
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  

	//look for change
	if((tempX != oldTempX) || (tempY != oldTempY)){
		if (loading == true){
			loading=false;
			return;
		}

		//if in Kiosk Mode

		if (GetCookie("kiosk") == "y" && GetCookie("rotatoron") == "y"){
			//reset timer with xx seconds to go before redirection
			Start1(rotatorInterval);	//this value determines the period of inactivity before screens take over
			return true;
		}
		
	}
}

*/





