function selectTab (selectedTab)
{
    var butArray = new Array("butSupport","butDescription","butSpecification","butCompatibility","butOptions","butSimilar","butDownloads","butRange","butHelp","butRefurbished");
    var tabArray = new Array("tabSupport","tabDescription","tabSpecification","tabCompatibility","tabOptions","tabSimilar","tabDownloads","tabRange","tabHelp","tabRefurbished");
    var item;
	for( item in butArray )
	{
	    if( butArray[item] == selectedTab )
	    {
	        document.getElementById(butArray[item]).className = 'selected';
	        document.getElementById(tabArray[item]).className = '';
	    }
	    else
	    {
	        document.getElementById(butArray[item]).className = '';
	        document.getElementById(tabArray[item]).className = 'hidden';
	    }
	}
}
function isObject(a) {
    return (a && typeof a == 'object');
}

function AddToBasket(counterType, inBasket, SupportID, productType) {
	var addThis
	addThis = "1"
	if(SupportID != "-1"){
	  if (inBasket == "false") {
		if(confirm("This product is not in your basket would you like to add it?")){
          // if the main product has no quantity (no price) then don't add it
          if (!isObject(document.forms['addtobasket'].quantity)){alert("Please call for a price on this product.")
            addThis = "0";
			document.getElementById('supportFrm').warranty.value = "0";
			document.getElementById('supportFrm').SupportID.value = SupportID;
			document.getElementById('supportFrm').submit();
          }		
		}else{
			addThis = "0";
			document.getElementById('supportFrm').warranty.value = "0";
			document.getElementById('supportFrm').SupportID.value = SupportID;
			document.getElementById('supportFrm').submit();
		}
	}
  }
  if(addThis == "1"){
	  
	  var type_id;
	  if(productType == "Z"){
	    type_id = getCheckedValue(document.getElementById('addtobasket').elements['prodPrice1'])
	}else{
	    type_id = productType
	}
	  document.getElementById('addtobasket').parent_type_id.value = "";
	  document.getElementById('addtobasket').type_id.value = type_id;
	  if(SupportID != "-1"){
  		document.getElementById('addtobasket').wquantity.value = document.forms['addtobasket'].quantity.value;  
		document.getElementById('addtobasket').wSupportID.value = SupportID;
    	document.getElementById('addtobasket').wwarranty.value = "1";
	    document.getElementById('addtobasket').addWarranty.value = "1";
	  }
 	  if (document.getElementById('addtobasket').quantity.value != '' && document.forms['addtobasket'].quantity.value != 0) {
		 if(parseInt(document.getElementById('addtobasket').quantity.value)!=document.forms['addtobasket'].quantity.value-0){
		   alert ("Quantity must be numeric, please enter a numeric quantity.");
		   document.getElementById('addtobasket').quantity.focus();
		 }else{
			document.getElementById('addtobasket').submit();
		  }
	   }else{ 
			document.getElementById('addtobasket').quantity.value = 1;
			document.getElementById('addtobasket').submit();
	   }
  }
}

function addItem(prod_id,parent_id,addtobasket, type_id, product_type) {
    <!-- removed the parent bit and add products individually -->
	document.getElementById('addtobasket2').type_id.value = type_id;
	document.getElementById('addtobasket2').quantity2.value = document.getElementById('addtobasket').quantity.value;
	var basketadd = "false";
	if (addtobasket == "false") {
        basketadd = "true";
	}
	if (basketadd == "true") {
		if (document.getElementById('addtobasket').quantity.value != '' && document.getElementById('addtobasket').quantity.value != 0) {
		  if (isInt(document.getElementById('addtobasket').quantity.value)) {
		  document.getElementById('addtobasket2').quantity2.value = 1;
	   	  document.getElementById('addtobasket2').quantity.value = 1;
	      document.getElementById('addtobasket2').prod_id.value = prod_id;
	      document.getElementById('addtobasket2').parent_id.value = parent_id;
		  document.getElementById('addtobasket2').submit();
		  } else {
			alert ("Quantity must be numeric, please re-enter");
			document.getElementById('addtobasket').quantity.focus();
		  }
	    } else {
		  document.getElementById('addtobasket2').quantity2.value = 0;
	   	  document.getElementById('addtobasket2').quantity.value = 1;
	      document.getElementById('addtobasket2').prod_id.value = prod_id;
	      document.getElementById('addtobasket2').parent_id.value = parent_id;
		  document.getElementById('addtobasket2').submit();
	  }
	}else{
		if (addtobasket == "false"){
			document.getElementById('addtobasket2').quantity2.value = -1;
  			document.getElementById('addtobasket2').quantity.value = 1;
			document.getElementById('addtobasket2').prod_id.value = prod_id;
	  		document.getElementById('addtobasket2').parent_id.value = parent_id;
	  		document.getElementById('addtobasket2').submit();
		}else{
			document.getElementById('addtobasket2').quantity2.value = 0;
  			document.getElementById('addtobasket2').quantity.value = 1;
			document.getElementById('addtobasket2').prod_id.value = prod_id;
	  		document.getElementById('addtobasket2').parent_id.value = parent_id;
	  		document.getElementById('addtobasket2').submit();
			
		}
	}
}

var Product_win = null;
function showAccessories(itm,parent,prod_type,addtobasket, type_id) {
document.getElementById('addtobasket').type_id.value = type_id;
	var basketadd = "false";
	if (addtobasket == "false") {
		if (confirm("Do you wish to add this product to your order before configuring it?")) {
			basketadd = "true";
		}
	}
	if (basketadd == "true") {
		if (document.getElementById('addtobasket').quantity.value != '' && document.getElementById('addtobasket').quantity.value != 0) {
		  if (isInt(document.getElementById('addtobasket').quantity.value)) {
			document.getElementById('addtobasket').submit();
		  } else {
			alert ("Quantity must be numeric, please re-enter");
			document.getElementById('addtobasket').quantity.focus();
		  }
	    }else{
		  document.getElementById('addtobasket').quantity.value = 1;
		  document.getElementById('addtobasket').submit();
	    }
	}
	if (Product_win && Product_win.open && !Product_win.closed){
//		if (Product_win.name==parent){
//			Product_win.focus();
//		}else{
//			Product_win.close();
//			showAccessories(itm,parent,prod_type);
//		}
	}else{
		if (parent == '') {
			Product_win = window.open('product_accessories.asp?family_id='+itm+'&prod_type='+prod_type+'&type_id='+type_id+'&start_page=1&this_page=1','accessories','width=820,height=670,scrollbars=yes,resizable=yes')
		} else {
			Product_win = window.open('product_accessories.asp?family_id='+itm+'&parent_id='+parent+'&prod_type='+prod_type+'&type_id='+type_id+'&start_page=1&this_page=1','accessories','width=820,height=670,scrollbars=yes,resizable=yes')
		}
	}
}


function prodDetails(id, parent_id, type_id){
 window.open('product_accessories_details.asp?id='+id+'&parent_id='+parent_id + '&type_id='+type_id,'accessories','width=815,height=550,scrollbars=yes')
}

function swapDatasheet(dsLoc,dsName){
    var loc,datasheetTitle,obj,emb,frmDatasheetName,frmDatasheetLoc;
    dsLoc = dsLoc.replace("|","'");
    loc = "http://www.hardware.com/downloads/datasheets/"+dsLoc+"#toolbar=0&navpanes=0&scrollbar=0";
    datasheetTitle = document.getElementById("datasheetTitle");
    dsName = dsName.replace("|","'");
    datasheetTitle.innerHTML = unescape(dsName);
    obj = document.getElementById("productDatasheetHolder");
    obj.innerHTML = writeDatasheetObject(loc);
    frmDatasheetName = document.getElementById("frmDatasheetName");
    frmDatasheetLoc = document.getElementById("frmDatasheetLoc");
    frmDatasheetName.value=dsName;
    frmDatasheetLoc.value=dsLoc;
}

function writeDatasheetObject(loc){
    var tmpText;
    tmpText = "<OBJECT id=%22datasheetObjID%22 CLASSID=%22clsid:CA8A9780-280D-11CF-A24D-444553540000%22 WIDTH=670 HEIGHT=600>"
    tmpText = tmpText + " <PARAM NAME=%22SRC%22 VALUE=%22"+loc+"%22> <EMBED WIDTH=670 HEIGHT=600 SRC=%22"+loc+"%22>"
    tmpText = tmpText + " <NOEMBED> Your browser does not support embedded PDF files. </NOEMBED> </EMBED></OBJECT>";
    return unescape(tmpText);
}

function viewPDF(pdfLoc, pdfName){
    pdfWin = window.open('/downloads/datasheets/' + pdfLoc);
}

function accessoriesShow(divID, imageBt){
	// show/hide services menu
	divID = document.getElementById(divID);
	//imageBt = document[imageBt];
	imageBt = document.getElementById(imageBt);
	if(divID.style.display == 'block'){
		divID.style.display = "none";
	    // plus/minus image toggle
		imageBt.src = "http://www.hardware.com/images/plus.gif";
		imageBt.alt = "Click here to show the accessories for this category";
		imageBt.style.height = 12;
		imageBt.style.width = 13;
	}else{
		divID.style.display = "block";
	    // plus/minus image toggle
		imageBt.src = "http://www.hardware.com/images/minus.gif";
		imageBt.alt = "Click here to hide the accessories for this category";
		imageBt.style.height = 12;
		imageBt.style.width = 13;
	}
}

function addSupport(inBasket, SupportID){
	
	document.getElementById('supportFrm').SupportID.value = SupportID;
	document.getElementById('supportFrm').submit();
}
	
function warrantyClick(aItem, type_id){
	if (aItem){
		if(confirm('You have this item in your quote at the moment.\nDo you want to add the warranty to that item?')){
			document.getElementById('addtobasket').type_id.value = type_id;
			document.getElementById('addtobasket').quantity.value = "0";
    	    document.getElementById('addtobasket').submit();
    	}
	}else{
		if(confirm('To add this warranty, you will need to add the item to your quote.\nDo you want to do that now?')){
    	    AddToBasket();
    	}
	}
}