//JScript1.js
//new javascripts used on prodinfo page
var isMinNS4 = document.layers
var ie=document.all&&navigator.userAgent.indexOf("Opera")==-1
var dom=document.getElementById&&!ie&&navigator.userAgent.indexOf("Opera")==-1

var drs=0,moving=0,resizing=0,shf,def,rsh,dsh,bdf=0,sht=0,slt=0,ba5=0,pla,nd9,absl=1,ism3=0;
var fia=0,foa=100,fis=15,fii=8,fos=5,foi=2,ddp=0,bp3=0,dis=15,sis=10,sp7=0,fp5=0,fo4=0,tid1,tid2,tid3,tid4,isc,cth,ctw;
var lhg=0,dmt=document,nbl='none',ibl='block',nvi='hidden',ivi='visible',sct,isScri,na=navigator.userAgent;

function de7(id)
{
    return dmt.getElementById(id)
}
var w37=(de7)?true:false, mie=(w37 && dmt.all)?true:false, ns=(w37 && !dmt.all)?true:false, op=(na.indexOf('Opera')!=-1);
if(op)
{
    var otmp=na.indexOf("Opera")+6;
    opv=parseInt(na.charAt(otmp));
    var op9=(opv==9)?true:false;
}
if(mie)
{
    mtmp=na.split("MSIE");
    miv=parseFloat(mtmp[1]);
    var ieh=(miv>=5.5)?true:false;
}

window.onerror=function(){return true};

	function ShowPopup(itemID,hoveritem, xVal , yVal )
	{
		var imgLocation=new Object();
		var obj = document.getElementById(itemID);
		
		if( hoveritem == '')
		{
			imgLocation.x = 0;
			imgLocation.y = 0;
		}
		else
		{
			imgLocation = getAnchorPosition(hoveritem);
		}
		 	
		if(obj != null)
		{
			// Set popup to visible
			obj.style.top = imgLocation.y+(yVal*1);
			obj.style.left = imgLocation.x+(xVal*1) ;
			obj.style.visibility = "Visible";
		}	
	}
	
	function MovePopup(itemID,hoveritem, xVal , yVal )
	{
		var imgLocation=new Object();
		var obj = document.getElementById(itemID);
		
		if( hoveritem == '')
		{
			imgLocation.x = 0;
			imgLocation.y = 0;
		}
		else
		{
			imgLocation = getAnchorPosition(hoveritem);
		}
		 	
		if(obj != null)
		{
			// Set popup to visible
			obj.style.top = imgLocation.y+(yVal*1);
			obj.style.left = imgLocation.x+(xVal*1) ;
		}	
	}
	
	function HidePopup(itemID)
	{
		var obj = document.getElementById(itemID);
		if(obj != null)
		{
			obj.style.visibility = "Hidden";	
		}		
	}
	
	function buttonClick(elId) 
	{
		var evt;
		var el = document.getElementById(elId);
		if (document.createEvent)
		{
			evt = document.createEvent("MouseEvents");

			if (evt.initMouseEvent)
			{
				evt.initMouseEvent("click", true, true, window,0, 0, 0, 0, 0, false, false, false, false, 0, null);
			} 
			else 
			{
				evt = false;
			}
		}
		(evt)? el.dispatchEvent(evt):(el.click && el.click());
	} 

	function divLinkHover(el,newColor)
	{
		if( el != null)
		{
			el.style.color = newColor;
		}
	}
	
	
	function pausecomp(millis) 
	{
		var date = new Date();
		var curDate = null;
		do 
		{ 
			curDate = new Date();
		} 
		while(curDate-date < millis);
	} 

	function addLoadEvent(func) 
	{
    	var oldonload = window.onload;
	    if (typeof window.onload != 'function') 
		{
        	window.onload = func;
	    }
		else
		{
			window.onload = function() 
			{
            	if (oldonload) 
				{
                	oldonload();
	            }
    	        func();
        	}
    	}
	}
	
/*function findPosX(obj)
{
    var curleft = 0;
    curleft = obj.x;
    return curleft;
}

function findPosY(obj)
{
    var curtop = 0;
    curtop += obj.y;
    return curtop;
}*/

function getAnchorPosition(anchorname) {
	// This function will return an Object with x and y properties
	var useWindow=false;
	var coordinates=new Object();
	var x=0,y=0,width=0,height=0;
	// Browser capability sniffing
	var use_gebi=false, use_css=false, use_layers=false;
	if (document.getElementById) { use_gebi=true; }
	else if (document.all) { use_css=true; }
	else if (document.layers) { use_layers=true; }
	// Logic to find position
 	if (use_gebi && document.all) {
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
		width=AnchorPosition_getPageOffsetWidth(document.all[anchorname]);
		height=AnchorPosition_getPageOffsetHeight(document.all[anchorname]);
		}
	else if (use_gebi) {
		var o=document.getElementById(anchorname);
		x=AnchorPosition_getPageOffsetLeft(o);
		y=AnchorPosition_getPageOffsetTop(o);
		width=AnchorPosition_getPageOffsetWidth(o);
		height=AnchorPosition_getPageOffsetHeight(o);
		}
 	else if (use_css) {
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
		width=AnchorPosition_getPageOffsetWidth(document.all[anchorname]);
		height=AnchorPosition_getPageOffsetHeight(document.all[anchorname]);

		}
	else if (use_layers) {
		var found=0;
		for (var i=0; i<document.anchors.length; i++) {
			if (document.anchors[i].name==anchorname) { found=1; break; }
			}
		if (found==0) {
			coordinates.x=0; coordinates.y=0; return coordinates;
			}
		x=document.anchors[i].x;
		y=document.anchors[i].y;
		width=document.anchors[i].width;
		width=document.anchors[i].height;
		}
	else {
		coordinates.x=0; coordinates.y=0;coordinates.width=0;  return coordinates;
		}
	coordinates.x=x;
	coordinates.y=y;
	coordinates.width=width;
	coordinates.height=height;
	return coordinates;
	}

// getAnchorWindowPosition(anchorname)
//   This function returns an object having .x and .y properties which are the coordinates
//   of the named anchor, relative to the window
function getAnchorWindowPosition(anchorname) {
	var coordinates=getAnchorPosition(anchorname);
	var x=0;
	var y=0;
	if (document.getElementById) {
		if (isNaN(window.screenX)) {
			x=coordinates.x-document.body.scrollLeft+window.screenLeft;
			y=coordinates.y-document.body.scrollTop+window.screenTop;
			}
		else {
			x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
			y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
			}
		}
	else if (document.all) {
		x=coordinates.x-document.body.scrollLeft+window.screenLeft;
		y=coordinates.y-document.body.scrollTop+window.screenTop;
		}
	else if (document.layers) {
		x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
		y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
		}
	coordinates.x=x;
	coordinates.y=y;
	return coordinates;
	}

// Functions for IE to get position of an object
function AnchorPosition_getPageOffsetLeft (el) {
	var ol=el.offsetLeft;
	while ((el=el.offsetParent) != null) { ol += el.offsetLeft; }
	return ol;
	}
function AnchorPosition_getWindowOffsetLeft (el) {
	return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;
	}	
function AnchorPosition_getPageOffsetTop (el) {
	var ot=el.offsetTop;
	while((el=el.offsetParent) != null) { ot += el.offsetTop; }
	return ot;
	}
function AnchorPosition_getPageOffsetWidth (el) {
	return el.offsetWidth;
	}
function AnchorPosition_getPageOffsetHeight (el) {
	return el.offsetHeight;
	}
	
function AnchorPosition_getWindowOffsetTop (el) {
	return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;
	}
	
function getPageWidthHeight(){

	var coordinates=new Object();
    if(ns || op)
	{
         coordinates.width = document.body.clientWidth ;
		 coordinates.height = document.body.clientHeight ;
		 //alert("ns op" + document.body.clientWidth +" "+ document.body.clientHeight);
		 return coordinates ;
	}
    else
        coordinates.width = document.documentElement.clientWidth ;
		coordinates.height = document.documentElement.clientHeight ;
		//alert("else" + document.documentElement.clientWidth +" "+ document.documentElement.clientHeight);
		return coordinates;
    }
	
function getCenter(objItem, XYWcoordinat){
    var pageSize = getPageWidth();
    
    var itemCenter = XYWcoordinat.width/2
    }



//this is migrated code 

var WRInitTime=(new Date()).getTime();

function PopUpWindow(url, width, height)
{
   var StockInfoWin = window.open(url,"popup","width=" + width + ",height=" + height + ",resizable=0,status=0,menubar=0,scrollbars=yes");
   StockInfoWin.focus();
}

//this is from include_rollover
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 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];}}
}

//this is from leftside-new
function emailCS( e_add, subject ) 
{
   window.location = "mailto:" + e_add + "?subject=" + subject
}

//this is from
//carthelp.asp
//checkout-ordertotal.asp

function popItUp(url) 
{
    var StockInfoWin=window.open(url,"stockinfo","width=650,height=550,resizable=0,status=0,menubar=0,scrollbars=yes");
}

//this is from carthelp.asp
function e_friend(e_add,subject1,body) 
{ 
    window.location="mailto:"+e_add+"?subject="+subject1+"&body="+body; 
} 

//this is from checkout-ordertotal.asp
function popItUp(url, title,w,h) {
   var StockInfoWin=window.open(url,title,"width="+w+",height="+h+",resizable=0,status=0,menubar=0,scrollbars=yes");
}
function popItUp(url, title,w,h,resizeA) {
   var StockInfoWin=window.open(url,title,"width="+w+",height="+h+",resizable="+resizeA+",status=0,menubar=0,scrollbars=yes");
}

//proderror.asp
function popItUp2(url) {
    var StockInfoWin=window.open(url,"stockinfo","width=700,height=600,resizable=0,status=0,menubar=0,location=0,scrollbars=yes");
}

//this is from checkout-payments.asp
function popItUpW(url, type){
	var StockInfoWin=window.open(url,"stockinfo", type);
}

//this is from checkout-shipping.asp
/*function popItUp(url) {
   var StockInfoWin=window.open(url,"stockinfo","width=600,height=175,resizable=0,status=0,menubar=0,scrollbars=yes");
   }*/

function popItUp5(url) {
   var StockInfoWin=window.open(url,"stockinfo","width=500,height=300,resizable=0,status=0,menubar=0,scrollbars=yes");
   }

function disablebutton(obj){
	document.getElementById("cbut").disabled = true;
}

function popItUpHome(url) {
    var StockInfoWin=window.open(url,"freeshipping","width=750,height=600,resizable=1,status=1,location=1,menubar=1,scrollbars=1");
}

//this is from bottom-sub.asp
function Pcertify() { 
popupWin = window.open
('http://www.bbbonline.org/cks.asp?id=6032000112938', 'Participant', 'location=yes,scrollbars=yes,width=450,height=300') 
window.name = 'opener'; 
} 

function EMWS_RemoveEnterEmailAddress(obj)
{
    if ( obj.value == "Your E-mail" )
    {
        obj.value = "";
    }
    return true;
}

//this is from pages04202006
function setvalues(cval, pval, mval, jval, listtime)
{
	eval("document.sortselect"+listtime+".clearance.value = cval;");
	eval("document.sortselect"+listtime+".premium.value = pval;");
	eval("document.sortselect"+listtime+".nm.value = mval;");
	eval("document.sortselect"+listtime+".justone.value = jval;"); 
	eval("document.sortselect"+listtime+".SearchOrder.value = document.sortselect"+listtime+".SearchOrder.value + \"mis\";");
	//SubmitListForm();
	return false;
}
function setvalues2(listtime){
	eval("val = document.sortselect"+listtime+".filter.value;");
	if(val == 1){
		setvalues(0,0,1,0,listtime);
	}else if(val == 2){
		setvalues(0,1,0,0,listtime);
	}else if(val == 3){
		setvalues(1,0,0,0,listtime);
	}else if(val == 4){
		setvalues(0,0,0,1,listtime);
	}else{
		setvalues(0,0,0,0,listtime);
	}
	return false;
}
function formSubmitcomp(listtime,isfilter,collect,theme,premium,nm,coming,sclearance,justone){
    eval("document.sortselect"+listtime+".SearchOrder.value = \""+isfilter+"\"+\"com\";");
    eval("document.sortselect"+listtime+".collect.value = \""+collect+"\";");
    eval("document.sortselect"+listtime+".theme.value = \""+theme+"\";");
    eval("document.sortselect"+listtime+".premium.value = \""+premium+"\";");
    eval("document.sortselect"+listtime+".nm.value = \""+nm+"\";");
    eval("document.sortselect"+listtime+".coming.value = \""+coming+"\";");
    eval("document.sortselect"+listtime+".clearance.value = \""+sclearance+"\";");
    eval("document.sortselect"+listtime+".justone.value = \""+justone+"\";");
    eval("document.sortselect"+listtime+".submit();");
    return false;
}

function formSubmitthm(listtime,isfilter,collect,company,premium,nm,coming,sclearance,justone){
    eval("document.sortselect"+listtime+".SearchOrder.value = \""+isfilter+"\"+ \"thm\";");
    eval("document.sortselect"+listtime+".collect.value = \""+collect+"\";");
    eval("document.sortselect"+listtime+".company.value = \""+company+"\";");
    eval("document.sortselect"+listtime+".premium.value = \""+premium+"\";");
    eval("document.sortselect"+listtime+".nm.value = \""+nm+"\";");
    eval("document.sortselect"+listtime+".coming.value = \""+coming+"\";");
    eval("document.sortselect"+listtime+".clearance.value = \""+sclearance+"\";");
    eval("document.sortselect"+listtime+".justone.value = \""+justone+"\";");
    eval("document.sortselect"+listtime+".submit();");
    return false;
}
function formSubmitcol(listtime,isfilter,company,theme,premium,nm,coming,sclearance,justone){
    eval("document.sortselect"+listtime+".SearchOrder.value = \""+isfilter+"\"+ \"col\";");
    eval("document.sortselect"+listtime+".company.value = \""+company+"\";");
    eval("document.sortselect"+listtime+".theme.value = \""+theme+"\";");
    eval("document.sortselect"+listtime+".premium.value = \""+premium+"\";");
    eval("document.sortselect"+listtime+".nm.value = \""+nm+"\";");
    eval("document.sortselect"+listtime+".coming.value = \""+coming+"\";");
    eval("document.sortselect"+listtime+".clearance.value = \""+sclearance+"\";");
    eval("document.sortselect"+listtime+".justone.value =  \""+justone+"\";");
    eval("document.sortselect"+listtime+".submit();");
	return false;
}

function SubmitListForm(listtime,isfilter,company,theme,collect){
	eval("document.sortselect"+listtime+".SearchOrder.value = \""+isfilter+"\";");
	eval("document.sortselect"+listtime+".company.value = \""+company+"\";");
	eval("document.sortselect"+listtime+".theme.value = \""+theme+"\";");
	eval("document.sortselect"+listtime+".collect.value = \""+collect+"\";");
	eval("document.sortselect"+listtime+".submit();");
	return false;
}
/*
function checkvalues(){
	alert("<%=listtime%>: "+document.sortselect<%=listtime %>.theme.value+" "+document.sortselect<%=listtime %>.collect.value+" "+document.sortselect<%=listtime %>.company.value)
	return false;
}*/


//######################################################################################
// Author: ricocheting.com
// For: public release (freeware)
// Date: 4/24/2003 (update: 6/26/2009)
// Description: displays the amount of time until the "dateFuture" entered below.


// NOTE: the month entered must be one less than current month. ie; 0=January, 11=December
// NOTE: the hour is in 24 hour format. 0=12am, 15=3pm etc
// format: dateFuture = new Date(year,month-1,day,hour,min,sec)
// example: dateFuture = new Date(2003,03,26,14,15,00) = April 26, 2003 - 2:15:00 pm




// TESTING: comment out the line below to print out the "dateFuture" for testing purposes



//###################################
//nothing beyond this point
function GetCount(){
    var container;
	dateNow = new Date();									//grab current date

	amount = dateFuture.getTime() - dateNow.getTime();		//calc milliseconds between dates
	amount += DateDiff
	delete dateNow;

	// time is already past
	if(amount < 0){
		document.getElementById('countbox').innerHTML="Now!";
	}
	// date is still good
	else{

		days=0;hours=0;mins=0;secs=0;out="";
		
		out = "Hurry!  Only <span style=\"background-color: yellow; font-size: 13pt;\">"
		amount = Math.floor(amount/1000);//kill the "milliseconds" so just secs

		days=Math.floor(amount/86400);//days
		amount=amount%86400;

		hours=Math.floor(amount/3600);//hours
		amount=amount%3600;

		mins=Math.floor(amount/60);//minutes
		amount=amount%60;

		secs=Math.floor(amount);//seconds
		
		hours = hours + days*24

		//if(days != 0){out += days +" day"+((days!=1)?"s":"")+" + ";}
		//if(days != 0 || hours != 0){out += hours +" hour"+((hours!=1)?"s":"")+", ";}
		//if(days != 0 || hours != 0 || mins != 0){out += mins +" minute"+((mins!=1)?"s":"")+", ";}
		//out += secs +" seconds";

		
	
		
		out += hours + ":" 

		if (mins<10)
		{ out += "0" + mins;}
		else
		{out += mins;}	
        out += ":"

		if (secs<10)
		{ out += "0" + secs;}
		else
		{out += secs;}
		
		out += "</span>"

	    var objHd = parent.document.getElementById('countbox');
	    //alert("hdid" + hdID + ", value: " +hdValue);

	    if (objHd != null)
	    {
		 document.getElementById('countbox').innerHTML=out; 
		//alert("1hdid" + hdID + ", value: " +hdValue);
	    }

	    //alert('made it to the else branch'+out);
		setTimeout("GetCount()", 1000);
	}
}






