var curr;
var con_disp = 0;
var col_disp = 0;
var thisfocus = '';

var cssdropdown={
disappeardelay: 250, //set delay in miliseconds before menu disappears onmouseout
dropmenuobj: null, ie: document.all, firefox: document.getElementById&&!document.all,
getposOffset:function(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
},

showhide:function(obj, e, visible, hidden){
if (this.ie || this.firefox){
this.dropmenuobj.style.left=this.dropmenuobj.style.top="-500px";
}
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}
,

iecompattest:function(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
},

clearbrowseredge:function(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=this.ie && !window.opera? this.iecompattest().scrollLeft+this.iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetWidth
if (windowedge-this.dropmenuobj.x < this.dropmenuobj.contentmeasure)  //move menu to the left?
edgeoffset=this.dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=this.ie && !window.opera? this.iecompattest().scrollTop : window.pageYOffset
var windowedge=this.ie && !window.opera? this.iecompattest().scrollTop+this.iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetHeight
if (windowedge-this.dropmenuobj.y < this.dropmenuobj.contentmeasure){ //move up?
edgeoffset=this.dropmenuobj.contentmeasure+obj.offsetHeight
if ((this.dropmenuobj.y-topedge)<this.dropmenuobj.contentmeasure) //up no good either?
edgeoffset=this.dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
},
dropit:function(obj, e, dropmenuID){

//if(dropmenuID=='dropmenuint'){document.images['smarrow'].src='/retail2002/images/sm_arrow_on.gif';}

if (this.dropmenuobj!=null) //hide previous menu
this.dropmenuobj.style.visibility="hidden"
this.clearhidemenu()
if (this.ie||this.firefox){
obj.onmouseout=function(){cssdropdown.delayhidemenu()}
//this.dropmenuobj=document.getElementById(dropmenuID)
this.dropmenuobj = getObject(dropmenuID);
this.dropmenuobj.onmouseover=function(){cssdropdown.clearhidemenu()}


//this.dropmenuobj.onmouseout=function(){cssdropdown.dynamichide(e)}
this.dropmenuobj.onmouseout=function(){cssdropdown.delayhidemenu()}

this.dropmenuobj.onclick=function(){cssdropdown.delayhidemenu()}
this.showhide(this.dropmenuobj.style, e, "visible", "hidden")
this.dropmenuobj.x=this.getposOffset(obj, "left")
this.dropmenuobj.y=this.getposOffset(obj, "top")

switch(dropmenuID){

case 'currentcategorynav':
	this.dropmenuobj.style.top = '230px';
	this.dropmenuobj.style.left=this.dropmenuobj.x-this.clearbrowseredge(obj, "rightedge")+"px";
	break;
case 'concernnav':
	this.dropmenuobj.style.top = 340 - con_disp +'px';
	this.dropmenuobj.style.left=this.dropmenuobj.x-this.clearbrowseredge(obj, "rightedge")+"px";
	break;
case 'collectionnav':
	this.dropmenuobj.style.top = 450 - col_disp + 'px';
	this.dropmenuobj.style.left=this.dropmenuobj.x-this.clearbrowseredge(obj, "rightedge")+"px";
	break;

default:
	this.dropmenuobj.style.top=this.dropmenuobj.y-this.clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+1+"px"
	this.dropmenuobj.style.left=this.dropmenuobj.x-this.clearbrowseredge(obj, "rightedge")+"px"
	break;

}
}
},

contains_firefox:function(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
},

dynamichide:function(e){
var evtobj=window.event? window.event : e;
if (this.ie&&!this.dropmenuobj.contains(evtobj.toElement))
this.delayhidemenu()
else if (this.firefox&&e.currentTarget!= evtobj.relatedTarget&& !this.contains_firefox(evtobj.currentTarget, evtobj.relatedTarget))
this.delayhidemenu()
},

delayhidemenu:function(){
this.delayhide=setTimeout("cssdropdown.dropmenuobj.style.visibility='hidden';document.images['smarrow'].src='/retail2002/images/sm_arrow.gif';contract();",this.disappeardelay)
//this.delayhide=setTimeout("cssdropdown.dropmenuobj.style.visibility='hidden';document.images['smarrow'].src='/retail2002/images/holiday_images/2008/sm_arrow1.gif';contract();",this.disappeardelay)
},

clearhidemenu:function(){
if (this.delayhide!="undefined")
clearTimeout(this.delayhide)
}
}

function getObject( obj ) {
  if ( document.getElementById ) {
    obj = document.getElementById( obj );
  } else if ( document.all ) {
    obj = document.all.item( obj );
  } else {
    obj = null;
  }
  return obj;
 }



function openwin(theURL,winName,features) {
  	window.open(theURL,winName,features);
}

/*

function showcurrentcategorynav(){
 var ln = getObject('currentcategorynav');
 ln.style.visibility='visible';
}

function hidecurrentcategorynav(){
 var ln = getObject('currentcategorynav');
 ln.style.visibility='hidden';
}
*/
function expand(tag){
var ln = getObject(tag);
if(null!=ln){
ln.style.clip='rect( 0 144 700 0 )';
}
}

function contract(){

var ln = getObject('currentcategorynav');
if(null!=ln){
ln.style.clip='rect( 0 144 57 0 )';
}
ln = getObject('concernnav');
if(null!=ln){
ln.style.clip='rect( 0 144 57 0 )';
}
ln = getObject('collectionnav');
if(null!=ln){
ln.style.clip='rect( 0 144 57 0 )';
}
}


function zoom(){
	var obj = getObject('mask');
	obj.style.visibility = 'visible';
	obj = getObject('zoom');
	obj.style.visibility = 'visible';
	obj = getObject('skuhider')
	if(null!=obj){
		obj.style.visibility = 'hidden';
	}
}
function unzoom(){
	var obj = getObject('mask');
	obj.style.visibility = 'hidden';
	obj = getObject('zoom');
	obj.style.visibility = 'hidden';
	obj = getObject('skuhider')
	if(null!=obj){
		obj.style.visibility = 'visible';
	}
}

function info(tag){
	var obj;
	var str = new Array();
	str[0] = 'benefits';
	str[1] = 'usage';
	str[2] = 'ingredients';
	str[3] = 'reviews';
	curr=tag;

	 var th = getObject('infocontainer');

	if(tag=='reviews'){
	 th.style.height= 264 + (90 * rev_height);
	}else{
	 th.style.height= 264;
	}


	for(i=0; i<4; i++){
	if(str[i]==tag){
	obj=getObject('tr_'+str[i]);
	obj.style.visibility='visible';
	document.images[tag+'btn'].src='images/' + tag + '_on.gif';

	}
	else{
	obj=getObject('tr_' + str[i]);
	obj.style.visibility = 'hidden';
	document.images[str[i] + 'btn'].src='images/' + str[i] + '.gif';
	} 
	}
}
function infobtnoff(btn){
	if( btn!=curr) {
		document.images[btn+'btn'].src='images/' + btn + '.gif';
	}		
}

function more(tag){
	var obj;
	for (var i=0;i<revs.length;i++)
	{
		obj = getObject(revs[i]);
		obj.style.display='block';
		obj.style.height=30;

		obj =  getObject('morelink' +revs[i]);
		obj.style.visibility='visible';

	}
	 var th = getObject('infocontainer');

		obj =  getObject('size' + tag);
		var sz = obj.value;		
		var addl = 0;
		addl = parseInt(sz / 70);

		obj = getObject(tag);
		obj.style.display='block';
		obj.style.height = 30 + (addl * 16);
		th.style.height = 264 + (90 * rev_height) + (addl * 16);
			
		obj =  getObject('morelink' + tag);
		obj.style.visibility='hidden';
	}



function open_window(url,x,y) 
			{
			if(x==null){x=580;}
			if(y==null){y=350;}

			        mywin = window.open(url,"win",'scrollbars=yes,resizable=0,width='+x+',height='+y);

			mywin.moveTo(200,200);
			}

function buttonhack(){
	if(thisfocus!=''){
	__doPostBack(thisfocus,'');
}
}


