// ==============================================================================
// Mamore Technologies Cactushop Customization Scripts
// (c) 2007 Mamore technologies
// ==============================================================================
// This script should be placed in the templatescripts directory in your skin directory. 
//

var orderList = new Array()
var orderListCount = 0

function printDaysOrders(){
for (i=0;i<orderList.length;i++)
  {
	window.open(orderList[i],'new' + i)
  }
}

function autoPrint(){
  window.print()
  window.close()
}

function setNav(){
  pageId = getQueryVariable('id')
  fullpagename = document.location.pathname
  split_array = fullpagename.split("/")
  pagename = split_array[split_array.length -1] 

  //If this is not an asp page then it must be using fakelinks for the products and categories
  // in which case set the tab to categories
  if(pagename.indexOf('.asp')>0 || fullpagename.length==1){
	  if(pagename=='page.asp'){
          	if(pageId.indexOf('about')>-1){
	      		pageId = 'about'
	  	}
		pagename = pagename + '.' + pageId +'.' 
	  }
	  if(pagename=='checkout.asp'){
	    	getElement('basket.aspnav' ).className = 'selected'
	  }
	  else if(pagename=='customer_modifycode.asp'){
	    	getElement('customer_account.aspnav' ).className = 'selected'
	  }
	  else if(pagename=='customer_home.asp'){
	    	getElement('customer_account.aspnav' ).className = 'selected'
	  }
	  else if(pagename=='product.asp'){
	    	getElement('prodtype.aspnav' ).className = 'selected'
	  }
	  else if(!getElement(pagename + 'nav' )){
	    	getElement('default.aspnav' ).className = 'selected'
	  }
	  else 	getElement(pagename + 'nav' ).className = 'selected'
	  }
  else
  {
    	getElement('prodtype.aspnav' ).className = 'selected'
  }  
}



function getElement(id){
	//fetch elements in line with IE and NS protocols
	if (document.all) {
	  element=document.all[id];
	}

	if (document.getElementById) {
		element=document.getElementById(id);
	}
	return element;
}

function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  } 
}

