// ****
// MAIN
// ****


function mainGetNumber(element){

	if("" + parseInt(element) == element){ return parseInt(element) }
	else if("" + parseFloat(element) == element){ return parseFloat(element) }
	else{ return 0 }

}

// ****
// SHOP
// ****

function shopProductsUpdate(product){
	
	var objForm = document.getElementById("aspForm");

	if(objForm){
		
		objForm.action = "produits.asp" + (product?"#"+product:"");
		objForm.submit();

	}
	
}

function shopCardUpdate(product){
	
	var objForm = document.getElementById("aspForm");

	if(objForm){
		
		objForm.action = "panier.asp" + (product?"#"+product:"");
		objForm.submit();

	}
	
}

function shopCardDelete(id){

	var objForm = document.getElementById("aspForm");
	var objInput = document.getElementById("quantity" + id);

	if(objForm && objInput){
		
		objInput.value = "0";
		objForm.action = "panier.asp";
		objForm.submit();

	}
	
}

function shopCardCustomer(){
	
	var objForm = document.getElementById("aspForm");

	if(objForm){
		
		objForm.action = "coordonnees.asp";
		objForm.submit();

	}
	
}

function shopPayment(){
	
	var objForm = document.getElementById("aspForm");

	if(objForm){
		
		objForm.action = "resume.asp";
		objForm.submit();

	}
	
}

function shopSetBillingDatas(){
	
	var objDiv = document.getElementById("formLAdress");

	if(objDiv && !document.getElementById("frmdoublon").checked){
		
		objDiv.style.display = "inline";

		var arrSourceInputs = new Array("frmlivnom","frmlivprenom","frmlivadresse1","frmlivadresse2","frmlivcpostal","frmlivville");
		var arrDestinationInputs = new Array("frmfacnom","frmfacprenom","frmfacadresse1","frmfacadresse2","frmfaccpostal","frmfacville");

		for(key in arrSourceInputs){

			var objSource = document.getElementById(arrSourceInputs[key]);
			var objDestination = document.getElementById(arrDestinationInputs[key]);

			if(objSource && objDestination){

				objDestination.value = objSource.value;
				
			}

		}

	}
	else if(objDiv && document.getElementById("frmdoublon").checked){

		objDiv.style.display = "none";

	}

	
}

function shopCardQuantity(id,amount){

	var objForm = document.getElementById("aspForm");
	var objInput = document.getElementById("quantity" + id);

	if(objForm && objInput){
		
		amount = mainGetNumber(objInput.value) + mainGetNumber(amount);
		
		if(amount <= 0){ amount = 0 };
		if(amount >= 1000){ amount = 999 };

		objInput.value = amount

	}
	
}

function shopCGV(){

	popup = window.open("cgv.html", "cgv", "width=600,height=400,scrollbars=1,toolbar=0,titlebar=0,status=1,menubar=0,location=0,resizable=0");

	popup.focus();

	
}

function shopPrint(){

	popup = window.open("impression.asp", "daddy", "width=800,height=600,scrollbars=1,toolbar=1,titlebar=0,status=1,menubar=1,location=0,resizable=0");

	popup.focus();

	
}