function showCart(){

var cookies=document.cookie;  //read in all cookies
var start = cookies.indexOf("ss_cart_" + serialNumber + "="); 
var cartvalues = "";
var linecount = 0;
var start1;
var end1;
var tmp;

if (start == -1)  //No cart cookie
{
  document.write("<span id=\"items\">0 items<\/span>");
  document.write("<span id=\"price\">$00.00<\/span>");
}
else   //cart cookie is present
{
  start = cookies.indexOf("=", start) +1;  
  var end = cookies.indexOf(";", start);  

  if (end == -1)
  {
    end = cookies.length;
  }

  cartvalues = unescape(cookies.substring(start,end)); //read in just the cookie data

  start = 0;
  while ((start = cartvalues.indexOf("|", start)) != -1)
  {
    start++;
    end = cartvalues.indexOf("|", start);
    if (end != -1)
    {
      linecount++;

      if (linecount == 2) // Total Quantity of Items
      {
        tmp = cartvalues.substring(start,end);
        colon = tmp.indexOf(":", 0);
         document.write("<span id=\"items\">");
        document.write(tmp.substring(colon+1,end - start));
        if ((tmp.substring(colon+1,end - start)) == 1 )
        {
          document.write(" Item");
        }
        else
        {
          document.write(" Items");
        }
        document.write("<\/span>")
      }
     

      if (linecount == 3)  // Product Subtotal
      {
        tmp = cartvalues.substring(start,end);
        colon = tmp.indexOf(":", 0);
        document.write("<span id=\"price\">");
        document.write(tmp.substring(colon+1,end - start));
        document.write("<\/span>");
      }

      start = end;
    }
    else
      break;
    }
  } // end while loop

  //close minicart HTML
}
/* end showCart() */

function fixSearchResults(){
	$$('.search-pipeline').each(function(element){
		if(element.next().nodeName == "DIV"){
			element.remove();
		}
	})
}
function initPage(){
	Event.observe(document.body, "mousemove", hideTopNav);
}
function BasicPop(loc, w, h){
	newwindow=window.open(loc,"PopWin","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width="+w+",height="+h);
}

var currentLeftNav = null;
function processMenuClick(h3){
	var ul = $(h3).next("ul");
	if(currentLeftNav == ul){
		return;
	}
	if(currentLeftNav){
		currentLeftNav.slideUp({duration: 0.2});
	}
	currentLeftNav = ul
	currentLeftNav.slideDown({duration: 0.2});
}

function processMenuClick2(h3){
	var subnav = $(h3).next("ul.level3")
	if(subnav.visible()){
		subnav.slideUp({duration: 0.2})
	}else{
		subnav.slideDown({duration: 0.2})
	}
}


var currentTopNav = null;
function showTopNav(event, liObj){	
	liObj = $(liObj);
	if(liObj == currentTopNav){
		return;
	}
	if(currentTopNav){
		hideTopNavigation()
	}
	
	liObj.addClassName("active");
	currentTopNav = liObj;
	var scope = liObj.select("h3")[0].innerHTML
	
	Effect.Queues.get(scope).invoke('cancel');
	
	liObj.down("div.subnav").appear({duration: 0.3, queue: {position: 'end', scope: scope}});
	
}
function hideTopNav(event){
	if(currentTopNav == null){
		return;
	}	
	var element = event.element()		
	
	if(element.up("#topnav2") == null){
		hideTopNavigation()
		currentTopNav = null;
	}	
}
function hideTopNavigation(){
	$$("#topnav2 > li.active").each(function(obj){
		
		var scope = obj.select("h3")[0].innerHTML
		Effect.Queues.get(scope).invoke('cancel');
		
		obj.down("div.subnav").hide();
		obj.removeClassName("active");
	})
}



var activeTabIndex = -1;

function initTabs(){
	var length = $$("#tabs > li").length
	var tabIndex = 1;
	$$("#tabs > li").each(function(li){		
		if(tabIndex == 1){
			li.addClassName("active");
			activeTabIndex = 1;
		}
		if(tabIndex == length){
			li.addClassName("tab_" + tabIndex + "last")
		}
		li.writeAttribute("id", "tab_" + tabIndex)
		li.addClassName("tab_" + (tabIndex++));		
	})
	
	var index = 1;
	$$(".tabscontainer > div").each(function(div){
		if(index == activeTabIndex){
			div.setStyle({display: "block"});
		}else{
			div.setStyle({display: "none"});
		}
		div.addClassName("tab_" + (index++))
	})
}

function processTabClick(div){
	$$("#tabs li.tab_" + activeTabIndex)[0].removeClassName("active")
	$$(".tabscontainer > div.tab_" + activeTabIndex)[0].setStyle({display: "none"})
	if(activeTabIndex > 1){
		$$("#tabs li.tab_" + (activeTabIndex-1))[0].removeClassName("nextactive")
	}
	
	div = $(div);
	
	activeTabIndex = parseInt(div.up("li").readAttribute("id").substring(4));
	$$(".tabscontainer > div.tab_" + activeTabIndex)[0].setStyle({display: "block"})
	
	div.up("li").addClassName("active")
	if(activeTabIndex > 1){
		$$("#tabs li.tab_" + (activeTabIndex-1))[0].addClassName("nextactive")
	}
}
function gotoTab(tabName){
	processTabClick($("tab_" + tabName))
	return true;
}

