// base scripts for ShoppingCart

// mover footer 



function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) { // IE7 fix
      	oldonload();
      }
      func();
    }
  }
}	

function openPopUp(url, width, height) {
	window.open(url,"","scrollbars=yes,resizable=yes,width=" + width + ",height=" + height);
	return false;
}


function initializeMenu(menuId, actuatorId) {
    var menu = document.getElementById(menuId);
    var actuator = document.getElementById(actuatorId);
    
    if (menu == null || actuator == null) return;    
    
    if(menu.style.display == "block")
    {
    	actuator.parentNode.style.backgroundImage = "url(/admin/images/icon_minus.gif)";
    }
    else
    {
    	actuator.parentNode.style.backgroundImage = "url(/admin/images/icon_plus_01.gif)";
    }
        
    actuator.onclick = function() {
        var display = menu.style.display;        
        this.parentNode.style.backgroundImage =
            (display == "block") ? "url(/admin/images/icon_plus_01.gif)" : "url(/admin/images/icon_minus.gif)";
        menu.style.display = (display == "block") ? "none" : "block";
        if (display == "block") {
        return false;
        }
        else
        return true;
    }
}


function initializeMenuNorepeat(menuId, actuatorId) {
    var menu = document.getElementById(menuId);
    var actuator = document.getElementById(actuatorId);
    
    if (menu == null || actuator == null) return;    
    
    if(menu.style.display == "block")
    {
    	actuator.parentNode.style.background = "url(/admin/images/icon_minus.gif) no-repeat";
    }
    else
    {
    	actuator.parentNode.style.background = "url(/admin/images/icon_plus_01.gif) no-repeat";
    }
        
    actuator.onclick = function() {
        var display = menu.style.display;        
        this.parentNode.style.background =
            (display == "block") ? "url(/admin/images/icon_plus_01.gif) no-repeat" : "url(/admin/images/icon_minus.gif) no-repeat";
        menu.style.display = (display == "block") ? "none" : "block";
        if (display == "block") {
        return false;
        }
        else
        return true;
    }
}
/*function initializeMenuNoParent(menuId, actuatorId) {
    var menu = document.getElementById(menuId);
    var actuator = document.getElementById(actuatorId);
    
    if (menu == null || actuator == null) return;    
    
    if(menu.style.display == "block")
    {
    	actuator.style.backgroundImage = "url(/admin/images/icon_minus.gif)";
    	actuator.style.backgroundRepeat = "no-repeat";
    }
    else
    {
    	actuator.style.backgroundImage = "url(/admin/images/icon_plus_01.gif)";
    	actuator.style.backgroundRepeat = "no-repeat";
    }
        
    actuator.onclick = function() {
        var display = menu.style.display;        
        this.style.backgroundImage =
            (display == "block") ? "url(/admin/images/icon_plus_01.gif); backgroundRepeat: no-repeat;" : "url(/admin/images/icon_minus.gif); backgroundRepeat: no-repeat;";
        menu.style.display = (display == "block") ? "none" : "block";
        if (display == "block") {
        return false;
        }
        else
        return true;
    }
}*/

// BG for Form Fields 
function setListeners(){
inputList = document.getElementsByTagName("INPUT");
for(i=0;i<inputList.length;i++)
inputList[i].attachEvent("onpropertychange",restoreStyles);
selectList = document.getElementsByTagName("SELECT");
for(i=0;i<selectList.length;i++)
selectList[i].attachEvent("onpropertychange",restoreStyles);
}

function restoreStyles(){
//if(event.srcElement.style.backgroundColor != "#FFFFFF")
//event.srcElement.style.backgroundColor = "#FFFFFF";
}

/*  validation functions CD 7/22/2005 */

function showpoperror(objname,errmsg) {	
	if (objname.type=="hidden" || objname.disabled) return;
	var x=AP_getPageOffsetLeft(objname) + "px";
	var y=AP_getPageOffsetTop(objname)  + 20 + "px";		
	if (global_showerrors) {			
		errdiv = warning_begin+errmsg+warning_end;						
		errorpopupdiv.style.left = x;														
		errorpopupdiv.style.top = y;			
		errorpopupdiv.innerHTML=errdiv;
	/*	if (IfrRef) {
		IfrRef.style.width = errorpopupdiv.offsetWidth + "px";
	    IfrRef.style.height = (errorpopupdiv.offsetHeight-30) + "px";
	    IfrRef.style.top = parseInt(errorpopupdiv.style.top)+19 + "px";
	    IfrRef.style.left = errorpopupdiv.style.left;
	    IfrRef.style.zIndex = errorpopupdiv.style.zIndex - 1;
	    //IfrRef.style.display = "block";
	    
		}
		*/										
	}
	else //if user browser does not support this
		alert(errmsg);
}

function AP_getPageOffsetLeft (el) {		
	var ol=el.offsetLeft;
	while ((el=el.offsetParent) != null) { ol += el.offsetLeft; }
	return ol;
}

function AP_getPageOffsetTop (el) {
	var ot=el.offsetTop;
	while((el=el.offsetParent) != null) { ot += el.offsetTop; }
	return ot;
}

function clearmsg(name) {
	if (global_showerrors) {
							
	errorpopupdiv.style.left = 500;				
	errorpopupdiv.style.top = -1500;
	errorpopupdiv.innerHTML="";
	errorpopupdiv.visible=false;
/*	if (IfrRef) {
			IfrRef.visible = false;
			IfrRef.style.display = "none";	
	}*/	
}
}		

function loadpopupdiv() {
	docElements=document.getElementById;
	//alert(document.getElementById);
	if (document.getElementById) {		
		errorpopupdiv = document.getElementById("testlayer");
		//IfrRef = document.getElementById('DivShim');				
		if (errorpopupdiv && errorpopupdiv.style) 
			global_showerrors=1;
		warning_begin = '<div id="warntop"></div><div id="warncontent"><h6>Warning Message</h6><p>';
		warning_end = '</p></div><div id="warnbottom">&nbsp;</div>';							
	}
}


addLoadEvent(loadpopupdiv);
// addLoadEvent(initDynamic);



// JavaScript Document

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_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_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_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 P7_autoLayers() { //v1.4 by PVII
 var g,b,k,f,args=P7_autoLayers.arguments;a=parseInt(args[0]);if(isNaN(a))a=0;
 if(!document.p7setc){p7c=new Array();document.p7setc=true;for(var u=0;u<10;u++){
 p7c[u]=new Array();}}for(k=0;k<p7c[a].length;k++){if((g=MM_findObj(p7c[a][k]))!=null){
 b=(document.layers)?g:g.style;b.visibility="hidden";}}for(k=1;k<args.length;k++){
 if((g=MM_findObj(args[k]))!=null){b=(document.layers)?g:g.style;b.visibility="visible";f=false;
 for(var j=0;j<p7c[a].length;j++){if(args[k]==p7c[a][j]) {f=true;}}
 if(!f){p7c[a][p7c[a].length++]=args[k];}}}
}


function MM_showHideLayers() { //v6.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_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function openzoom() {
	window.open("popup.html","","scrollbars=yes,resizable=yes,width=650");
	return false;
}

function openemail() {
	window.open("email.html","","scrollbars=yes,resizable=yes,width=520,height=600");
	return false;
}

function openstock() {
	window.open("stock.html","","scrollbars=yes,resizable=yes,width=520,height=500");
	return false;
}

sfHover = function() {
    var mainMenu = document.getElementById("main_menu");
    if (mainMenu) {
    	var sfEls = mainMenu.getElementsByTagName("LI");
    	for (var i=0; i<sfEls.length; i++) {
    		sfEls[i].onmouseover=function() {
    			this.className+=" sfhover";
    		}
    		sfEls[i].onmouseout=function() {
    			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
    		}
    	}
    }
}

if (window.attachEvent) window.attachEvent("onload", sfHover);