function addToBasket(strSKU, strOrigin,quanti,stringVari, currentPrice, anc){
	var strOrigin = strOrigin;
	strOrigin = strOrigin.replace("&", "*")
	var strURL = "processing/addToBasketProcessing.asp?strProductSKU=" + strSKU;
	strURL += "&intQTY="+quanti;
	strURL += "&strOrigin=" + strOrigin;
	strURL += "&strVariations=" + stringVari;
	strURL += "&cPrice=" + currentPrice;
	strURL += "&anc=" + anc;
	//alert(stringVari); 
	window.location.href= strURL ;
}
function addToBasketb(strSKU, strOrigin,quanti,stringVari, currentPrice, intCat, intPage, intItems, anc){
	var strOrigin = strOrigin;
	strOrigin = strOrigin.replace("&", "*")
	var strURL = "processing/addToBasketProcessing.asp?strProductSKU=" + strSKU;
	strURL += "&intQTY="+quanti;
	strURL += "&strOrigin=" + strOrigin;
	strURL += "&strVariations=" + stringVari;
	strURL += "&cPrice=" + currentPrice.replace("L","");
	strURL += "&intCat=" + intCat;
	strURL += "&intPage=" + intPage;
	strURL += "&intItems=" + intItems;
	strURL += "&anc=" + anc;
	
	
	//if(confirm('Do you want add this product into your shopping cart?')){
	window.location.href= strURL ;
	//}
} 

function addToBasketa(strSKU, strOrigin,quanti,stringVari, currentPrice, intCat){
	var strOrigin = strOrigin;
	strOrigin = strOrigin.replace("&", "*")
	var strURL = "processing/addToBasketProcessing.asp?strProductSKU=" + strSKU;
	strURL += "&intQTY="+quanti;
	strURL += "&strOrigin=" + strOrigin;
	strURL += "&strVariations=" + stringVari;
	strURL += "&cPrice=" + currentPrice.replace("L","");
	strURL += "&intCat=" + intCat;
	
	//if(confirm('Do you want add this product into your shopping cart?')){
	window.location.href= strURL ;
	//}
}


function fn_addToBasket(strSKU, strOrigin, intQuantity,attName,cPrice,cLevel,cQty , anc){
	var strOrigin = strOrigin;
	strOrigin = strOrigin.replace("&", "*")
	//var strProductQTY = "QTY-" + intId;
	var arrAttName        =new Array();
	var arrVari        =new Array();
	var totalPriceHtml    =document.getElementById("totalPrice"); 
	var currentPrice = cPrice;
	arrAttName = attName.split(",");
	stringVari ="0";
	//alert(cQty); 
	if (arrAttName.length>1){
				for(p=1;p<=arrAttName.length-1;p++){
					//alert(arrAttName[p]);
						
					elementAtt = document.getElementById(arrAttName[p]);
					stringVari = stringVari+','+elementAtt.value;
					
						 
						
					}
			}
			
	//alert(attName+oPrice);
	var intQTY = document.getElementById(intQuantity).value;

	if(intQTY <= 0 || intQTY != parseInt(intQTY)){
		alert('Please add a valid quantity');
		return false;
	}else{
		//alert(parseInt(intQTY)+parseInt(cQty));
		if (parseInt(intQTY)+parseInt(cQty)>parseInt(cLevel)){
			//alert('Only '+cLevel+' items in stock!') ;
					if(parseInt(cQty)>parseInt(cLevel)){
						//intQTY = 0;
					//	return false;
						}
						else{
					//intQTY = parseInt(cLevel)-parseInt(cQty);
					}
			// alert(intQTY);
			}	
		intQTY = parseInt(intQTY)+parseInt(cQty);
		}
	
		var strURL = "processing/addToBasketProcessing.asp?strProductSKU=" + strSKU;
		strURL += "&intQTY=" + intQTY;
		strURL += "&strOrigin=" + strOrigin;
		strURL += "&strVariations=" + stringVari;
		strURL += "&cPrice=" + currentPrice;
		strURL += "&anc=" + anc;	
       //alert(strURL);
		 
		window.location.href= strURL ;
	
}
function fn_addToBasketC(strSKU, strOrigin, intQuantity,attName,cPrice){
	var strOrigin = strOrigin;
	strOrigin = strOrigin.replace("&", "*")
	//var strProductQTY = "QTY-" + intId;
	
	
	var currentPrice = cPrice;
	
	//alert(attName+oPrice);
	var intQTY = document.getElementById(intQuantity).value;

	if(intQTY <= 0 || intQTY != parseInt(intQTY)){
		alert('Please add a valid quantity');
		return false;  
	}else{
		//alert(parseInt(intQTY)+parseInt(cQty));
	//if (intQTY>cLevel){
	//	alert('Only '+cLevel+' items in stock!') ;
		//intQTY = cLevel;
	//	}	
		}
	
		var strURL = "processing/addToBasketProcessing.asp?strProductSKU=" + strSKU;
		strURL += "&intQTY=" + intQTY;
		strURL += "&strOrigin=" + strOrigin;
		strURL += "&strVariations=" + attName;
		strURL += "&cPrice=" + currentPrice;
		window.location.href= strURL ;
	
	
}

function fn_addToBasketai(strSKU, strOrigin, intQuantity,attName,cPrice,cLevel,cIntCat){
	var strOrigin = strOrigin;
	strOrigin = strOrigin.replace("&", "*")
	//var strProductQTY = "QTY-" + intId;
	
	
	var currentPrice = cPrice;
	
	//alert(attName+oPrice);
	var intQTY = document.getElementById(intQuantity).value;

	if(intQTY <= 0 || intQTY != parseInt(intQTY)){
		alert('Please add a valid quantity');
		return false;  
	}else{
		//alert(parseInt(intQTY)+parseInt(cQty));
	if (intQTY>cLevel){
		alert('Only '+cLevel+' items in stock!') ;
		intQTY = cLevel;
		}	
		}
	
		var strURL = "processing/addToBasketProcessing.asp?strProductSKU=" + strSKU;
		strURL += "&intQTY=" + intQTY;
		strURL += "&strOrigin=" + strOrigin;
		strURL += "&strVariations=" + attName;
		strURL += "&cPrice=" + currentPrice;
		strURL += "&intCat=" + cIntCat;
		window.location.href= strURL ;
	
	
}

function fn_typeID(obj){
	//this function is called when the user enters four characters in the property id field   
  
	if(obj != parseInt(obj)){
		alert('The Quantity field must be numeric');
		document.getElementById('intBedsQuantity').select();
		
		return false;
	}
	
}
function getDetails(strSKU){
	var strURL = "pc_ideas_details.asp?strSKU=" + strSKU;	
	window.location = strURL;
}

function removeItem(strSKU,strVari){
	strURL = "processing/removeFrombasket.asp?strSKU=" + strSKU+"&strVariations="+strVari;
	window.location = strURL;
}

function showFullImage(arg){
	var strImagePath = arg;
	//alert(strImagePath);
	window.open(strImagePath,'','')
}
function validationForm(){
	
	
	if(document.shippingForm.strEmail.value==''){document.shippingForm.strEmail.focus();alert('please input email');return false}
	
	
	document.shippingForm.submit();
}

function getAttributValue(attName,oPrice,strSku){
	var arrAttName        =new Array();
	var arrVari        =new Array();
	var totalPriceHtml    =document.getElementById("totalPrice"); 
	var currentPrice = oPrice;
	
	arrAttName = attName.split(",");
	mainImage = document.getElementById('mainLargeImage');
  var 	shVstock = document.getElementById('hiddenVstock');
    var 	shVQty = document.getElementById('hiddenVQty');
			if (arrAttName.length>1){
					
					for(p=1;p<=arrAttName.length-1;p++){
					elementAtt = document.getElementById(arrAttName[p]);
					
					//alert(arrAttName[p]);
					arrVari = elementAtt.value.split(",");
					//alert(currentPrice);
						if (arrVari[1]==1){//1 operation
						currentPrice = (parseFloat(currentPrice)+parseFloat(arrVari[2])).toFixed(2);
						totalPriceHtml.innerHTML = currentPrice;
						imgHidden = document.getElementById(strSku+'_'+arrVari[4]);
							imgPath = imgHidden.value;
							vstock   = document.getElementById('vstock'+strSku+'_'+arrVari[4]);
							 shVstock.value = vstock.value;
							 
							 vQty   = document.getElementById('vQty'+strSku+'_'+arrVari[4]);
							 shVQty.value = vQty.value;
							mainImage.src=imgPath;
							
						}else if(arrVari[1]==2){//2 operation
						currentPrice = (parseFloat(currentPrice)-parseFloat(arrVari[2])).toFixed(2);
							totalPriceHtml.innerHTML = currentPrice;
							imgHidden = document.getElementById(strSku+'_'+arrVari[4]);
							imgPath = imgHidden.value;
							vstock   = document.getElementById('vstock'+strSku+'_'+arrVari[4]);
							 shVstock.value = vstock.value;
							  vQty   = document.getElementById('vQty'+strSku+'_'+arrVari[4]);
							 shVQty.value = vQty.value;
							mainImage.src=imgPath;
							

							//mainImage.src='images/1/100001_14_l.jpg';
							}
							else if(arrVari[1]==0){//0 operation
							
						     currentPrice = (parseFloat(arrVari[2])).toFixed(2);
							 //alert(currentPrice);
							totalPriceHtml.innerHTML = currentPrice;
							imgHidden = document.getElementById(strSku+'_'+arrVari[4]);
							//alert(currentPrice);
							imgPath = imgHidden.value;
							vstock   = document.getElementById('vstock'+strSku+'_'+arrVari[4]);
							 shVstock.value = vstock.value;
							  vQty   = document.getElementById('vQty'+strSku+'_'+arrVari[4]);
							 shVQty.value = vQty.value;
							mainImage.src=imgPath;
							
							//mainImage.src='images/1/100001_14_l.jpg';
							}
					}
			}
		
	}
function setVariValue(variValue){
	var arrVari        =new Array();
	
	var totalPriceHtml    =document.getElementById("totalPrice"); 
	var currentPrice = totalPriceHtml.innerHTML;
	arrVari = variValue.split(","); 
	if (arrVari[1]==1){
		currentPrice = (parseFloat(currentPrice)+parseFloat(arrVari[2])).toFixed(2);
						totalPriceHtml.innerHTML = currentPrice;	
						//alert(currentPrice);
						}else if(arrVari[1]==2){
						currentPrice = (parseFloat(currentPrice)-parseFloat(arrVari[2])).toFixed(2);
							totalPriceHtml.innerHTML = currentPrice;		}
	}	
	
	function fn_changeClass(id, class1, class2){
//get the id of the element you wish to change
	identity=document.getElementById(id);
	//check what the current class is and swap it for the alternate class
	if(identity.className==class1){
		className=class2;
	}else{
		className=class1;
	};

	identity.className=className;
	
	
		
}
	function fn_emptyBasket(){
	if(confirm('Do you really want to delete all items from your shopping basket?'))
			   { 
			   window.location.href='../processing/emptyBasket.asp';
    }else{
			   return false;}
	}
	
	
	function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{
    if(document.layers)	   //NN4+
    {
       document.layers[szDivID].visibility = iState ? "show" : "hide";
    }
    else if(document.getElementById)	  //gecko(NN6) + IE 5+
    {
        var obj = document.getElementById(szDivID);
        obj.style.visibility = iState ? "visible" : "hidden";
    }
    else if(document.all)	// IE 4
    {
        document.all[szDivID].style.visibility = iState ? "visible" : "hidden";
    }
}

function getPositionLeft(This){
var el = This;var pL = 0;
while(el){pL+=el.offsetLeft;el=el.offsetParent;}
return pL
}

// To find the top position, add this snippet to your code:

function getPositionTop(This){
var el = This;var pT = 0;
while(el){pT+=el.offsetTop;el=el.offsetParent;}
return pT
}
function changeOrderByPrice(intCat,intPage ,intItemsPerPage,strOrderBY,cType){
//alert(intCat+','+intPage +','+intItemsPerPage+','+strOrderBY+','+cType);
if(cType=='Price'){
window.location.href='pcideas.asp?strOrderBYPrice=Price Desc&intCat='+intCat+'&intPage='+intPage+'&intItems='+intItemsPerPage+'&strOrderBYBrand='+strOrderBY;
}else{
window.location.href='pcideas.asp?strOrderBYPrice=Price&intCat='+intCat+'&intPage='+intPage+'&intItems='+intItemsPerPage+'&strOrderBYBrand='+strOrderBY;
}
}
function changeOrderBy(intCat,intPage ,intItemsPerPage,strOrderBY,cType){
//alert(intCat+','+intPage +','+intItemsPerPage+','+strOrderBY+','+cType);
if(strOrderBY=='homePageSortOrder'){
window.location.href='pcideas.asp?strOrderBYPrice='+cType+'&intCat='+intCat+'&intPage='+intPage+'&intItems='+intItemsPerPage+'&strOrderBY=Manufacturer';
}else{
window.location.href='pcideas.asp?strOrderBYPrice='+cType+'&intCat='+intCat+'&intPage='+intPage+'&intItems='+intItemsPerPage+'&strOrderBY=homePageSortOrder';
}
}

function getPageScroll(){
    var xScroll,yScroll;
    if (self.pageXOffset) {
        xScroll = self.pageXOffset;
    } else if (document.documentElement && document.documentElement.scrollLeft){
        xScroll = document.documentElement.scrollLeft;
    } else if (document.body) {
        xScroll = document.body.scrollLeft;
    }
    if (self.pageYOffset) {
        yScroll = self.pageYOffset;
    } else if (document.documentElement && document.documentElement.scrollTop){
        yScroll = document.documentElement.scrollTop;
    } else if (document.body) {
        yScroll = document.body.scrollTop;
    }
	arrayPageScroll=xScroll+','+yScroll;
     //alert(arrayPageScroll);
    return arrayPageScroll;
}