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];}}
}

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];}
}
                /*<![CDATA[*/
                function IEHoverPseudo() {

                        var navItems = document.getElementById("primary-nav").getElementsByTagName("li");

                        for (var i=0; i<navItems.length; i++) {
                                if(navItems[i].className == "menuparent") {
                                        navItems[i].onmouseover=function() { this.className += " over"; }
                                        navItems[i].onmouseout=function() { this.className = "menuparent"; }
                                }
                        }

                }


                function window_onload() {
                        IEHoverPseudo();
                        MM_preloadImages('includes/templates/waterfilter-usa/images/shipping_order2.gif','includes/templates/waterfilter-usa/images/view_cart2.gif','includes/templates/waterfilter-usa/images/checkout2.gif');
                }

                window.onload = window_onload;
                /*]]>*/
function ShowArticle(num) {
        if (document.getElementById('article'+num).style.display == 'none') {
                document.getElementById('article'+num).style.display = 'block';
        } else {
                document.getElementById('article'+num).style.display = 'none';
        }
}
function take_there()
{
    var destination = document.pages.pg_choice.value;
    var version = navigator.appVersion;
    // sets variable == browser version
    if(destination != "no_page")
    {
      if (version.indexOf("MSIE") >= -1)
      // checks to see if using IE
      {
         window.location.href=destination;
      }
      else
      {
         window.open(destination, target="_self");
      }
    }
}

/***********************************************
* DD Tab Menu II script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

//Set tab to intially be selected when page loads:
//[which tab (1=first tab), ID of tab content to display]:
var initialtab=[1, "sc1"]

//Turn menu into single level image tabs (completely hides 2nd level)?
var turntosingle=0 //0 for no (default), 1 for yes

//Disable hyperlinks in 1st level tab images?
var disabletablinks=0 //0 for no (default), 1 for yes

////////Stop editting////////////////

var previoustab=""

if (turntosingle==1)
document.write('<style type="text/css">\n#tabcontentcontainer{display: none;}\n</style>')

function expandcontent(cid, aobject){
if (disabletablinks==1)
aobject.onclick=new Function("return false")
if (document.getElementById && turntosingle==0){
highlighttab(aobject)
if (previoustab!="")
document.getElementById(previoustab).style.display="none"
document.getElementById(cid).style.display="block"
if (aobject == 'vid' || aobject == 'cert') {
	document.getElementById('productMainImage').scrollIntoView(true);
}
previoustab=cid

}
}

function highlighttab(aobject){
if (typeof tabobjlinks=="undefined")
collectddimagetabs()
for (i=0; i<tabobjlinks.length; i++)
tabobjlinks[i].className=""
if (aobject != null)
 {
  aobject.className="current"
  if (aobject == 'vid') {
  tabobjlinks[1].className="current"
  } else if (aobject == 'cert') {
	tabobjlinks[2].className="current"
  }
 } 
}

function collectddimagetabs(){
var tabobj=document.getElementById("slidetabsmenu")
tabobjlinks=tabobj.getElementsByTagName("a")
}


function do_onload(){
if (document.getElementById("slidetabsmenu") != null)
{
collectddimagetabs()
expandcontent(initialtab[1], tabobjlinks[initialtab[0]-1])
}
//do_tabmagic()
//ShowTabs()
}

function do_tabmagic() {
	
	
	//Hack for Attribs to be default checked
	var attribcontainer = document.getElementById('productAttributes_tab')
	if (attribcontainer != undefined) {
		var attritems = attribcontainer.getElementsByTagName("input");
	}
	if (attritems != undefined) {
		for (var n = 0; n<attritems.length; n++){
			if (attritems[n].getAttribute('checked') == "checked") {
			  attritems[n].checked=true;
			}
		}	
	}
	// Hide real versions and remove _tab suffix to replace real versions.
	var tabmain= document.getElementById('tabcontentcontainer')
	if (tabmain != undefined) {
		var tabContainer= tabmain.getElementsByTagName("*");
	}
	var productDetails= document.getElementById('productDetailsList');
	var productDetailstab= document.getElementById('productDetailsList_tab');
	if (tabContainer != undefined) {
		var hackArr = new Array();
		var NewArr = new Array();
		
		hackArr[0] = document.getElementById('cartAdd');
		hackArr[1] = document.getElementById('productDetailsList');
		hackArr[2] = document.getElementById('productAttributes');
		hackArr[3] = document.getElementById('productQuantityDiscounts');
		hackArr[4] = document.getElementById('productAdditionalImages');
		hackArr[5] = document.getElementById('alsoPurchased');
		hackArr[6] = document.getElementById('crossSell');
		hackArr[7] = document.getElementById('reviewsDefault');
		hackArr[8] = document.getElementById('productDescription');
		hackArr[9] = document.getElementById('attribsOptionsText');
		hackArr[10] = document.getElementById('productMainImage');
		hackArr[11] = document.getElementById('productName');
		hackArr[12] = document.getElementById('productPrices');
		hackArr[13] = document.getElementById('freeShippingIcon');
		
		NewArr[0] = document.getElementById('cartAdd_tab');
		NewArr[1]  = document.getElementById('productDetailsList_tab');
		NewArr[2] = document.getElementById('productAttributes_tab');
		NewArr[3]  = document.getElementById('productQuantityDiscounts_tab');
		NewArr[4]  = document.getElementById('productAdditionalImages_tab');
		NewArr[5] = document.getElementById('alsoPurchased_tab');
		NewArr[6] = document.getElementById('crossSell_tab');
		NewArr[7]  = document.getElementById('reviewsDefault_tab');
		NewArr[8]  = document.getElementById('productDescription_tab');
		NewArr[9]  = document.getElementById('attribsOptionsText_tab');
		NewArr[10] = document.getElementById('productMainImage_tab');
		NewArr[11] = document.getElementById('productName_tab');
		NewArr[12] = document.getElementById('productPrices_tab');
		NewArr[13] = document.getElementById('freeShippingIcon_tab');
		

		for (var j = 0; j<hackArr.length; j++){
			if (hackArr[j] != undefined) {
				 for (var i = 0; i<tabContainer.length; i++){
				 sTmp = tabContainer[i].id.split("_");
					 if(hackArr[j].id == sTmp[0]) {
						////alert(sTmp[0] + '(' + j + ') = ' + hackArr[j].id + '(' + j + ')');
						////alert(hackArr[j].innerHTML);
						 hackArr[j].style.display="none";
						 hackArr[j].innerHTML='';
						 hackArr[j].outerHTML='';
						 break;
					 }
				 }	
			}
		}

		if (hackArr[8] != undefined) {
			hackArr[8].style.display="none";
		}				

		for (var j = 0; j<NewArr.length; j++){
			if (NewArr[j] != undefined) {
				for (var i = 0; i<tabContainer.length; i++){
					if(tabContainer[i].id == NewArr[j].id)  {
						sTmp = NewArr[j].id.split("_");
						NewArr[j].id=sTmp[0];
						break;
					}
				}	
			}
		}
	}
	
	
}

function ShowTabs() {
	var tppblock = document.getElementById('tpptabBlock')
	if (tppblock != undefined) {
		tppblock.style.display = 'block';
	}
}

if (window.addEventListener)
window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
window.attachEvent("onload", do_onload)
else if (document.getElementById)
window.onload=do_onload
