/***************************************
* fonction remplissage auto
***************************************/
function fillAdr(check){
	if(check){
		for(i=0;i<document.forms["formClient"].civ_liv.length;i++){
			if(document.forms["formClient"].civ_liv[i].checked) document.forms["formClient"].civ_cli[i].checked=true;
		}
		document.forms["formClient"].nom_cli.value=document.forms["formClient"].nom_liv.value;
		document.forms["formClient"].pre_cli.value=document.forms["formClient"].pre_liv.value;
		document.forms["formClient"].adr_cli.value=document.forms["formClient"].adr_liv.value;
		document.forms["formClient"].cp_cli.value=document.forms["formClient"].cp_liv.value;
		document.forms["formClient"].vil_cli.value=document.forms["formClient"].vil_liv.value;
		document.forms["formClient"].tel_cli.value=document.forms["formClient"].tel_liv.value;
	}
}
/***************************************
* fonction verif form saisie client
***************************************/
function checkFormClient(){
	var strMsg='Merci de vérifier le formulaire :';
	var strErr='';
	
	if(document.forms["formClient"].nom_cli.value=='') strErr +='\n- Votre nom (facturation)';
	if(document.forms["formClient"].pre_cli.value=='') strErr +='\n- Votre prénom (facturation)';
	if(document.forms["formClient"].adr_cli.value=='') strErr +='\n- Votre adresse (facturation)';
	if(document.forms["formClient"].cp_cli.value=='') strErr +='\n- Votre code postale (facturation)';
	if(document.forms["formClient"].vil_cli.value=='') strErr +='\n- Votre ville (facturation)';
	if(document.forms["formClient"].tel_cli.value=='') strErr +='\n- Votre téléphone (facturation)';
	if(document.forms["formClient"].mail_cli.value=='') strErr +='\n- Votre mail (facturation)';
	
	if(document.forms["formClient"].nom_liv.value=='') strErr +='\n- Votre nom (livraison)';
	if(document.forms["formClient"].pre_liv.value=='') strErr +='\n- Votre prénom (livraison)';
	if(document.forms["formClient"].adr_liv.value=='') strErr +='\n- Votre adresse (livraison)';
	if(document.forms["formClient"].cp_liv.value=='') strErr +='\n- Votre code postale (livraison)';
	if(document.forms["formClient"].vil_liv.value=='') strErr +='\n- Votre ville (livraison)';
	if(document.forms["formClient"].tel_liv.value=='') strErr +='\n- Votre téléphone (livraison)';
	
	if(!document.forms["formClient"].validForm.checked) strErr +='\n- Vous devez accepter les conditions générales de ventes !';
	
	if(strErr != '') alert(strMsg+strErr);
	return (strErr=='');	
}
/***************************************
* fonction stock
***************************************/
function loadStock(id){
	var str="idref="+id;
	str+="&signe="+document.forms["formStock"].signe.options[document.forms["formStock"].signe.selectedIndex].value;
	str+="&couleur="+document.forms["formStock"].couleur.options[document.forms["formStock"].couleur.selectedIndex].value;
	str+="&taille="+document.forms["formStock"].taille.options[document.forms["formStock"].taille.selectedIndex].value;
	//alert('/_includes/asp/loadStock.asp?'+str);
	loadAjax('/_includes/asp/loadStock.asp?'+str,'divStock');
}
/***************************************
* fonction verif listes déroulantes
***************************************/
function checkFormAddCadd(){
	var strMsg='Merci de sélectionner :';
	var strErr='';
	if(document.forms["formStock"].signe.selectedIndex==0) strErr +='\n- Un signe astrologique';
	if(document.forms["formStock"].couleur.selectedIndex==0) strErr +='\n- Une couleur';
	if(document.forms["formStock"].taille.selectedIndex==0) strErr +='\n- Une taille';
	if(strErr != '') alert(strMsg+strErr);
	return (strErr=='');	
}
/***************************************
* fonction Ajax
***************************************/
function loadAjax(url,cible)
{
	//Changement du contenu
	var xhr_object = null; 
	document.getElementById(cible).innerHTML = "";
 
	if(window.XMLHttpRequest) // Firefox 
	   xhr_object = new XMLHttpRequest(); 
	else if(window.ActiveXObject) // Internet Explorer 
	   xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
	else { // XMLHttpRequest non supporté par le navigateur 
	   alert("Votre navigateur ne supporte pas l'ajax ..."); 
	   return; 
	} 
	xhr_object.open("GET", url, true); 
	xhr_object.onreadystatechange = function() 
	{ 
	   if(xhr_object.readyState == 4)
	   {
			document.getElementById(cible).innerHTML = xhr_object.responseText;
		}
	} 
	xhr_object.send(null); 
}
/*
	zoom auto
*/
function PopupImage(img) {
	titre="ZOOM";
	w=open("",'image','width=650,height=650,toolbar=no,scrollbars=no,resizable=no');	
	w.document.write("<HTML><HEAD><TITLE>"+titre+"</TITLE></HEAD>");
	w.document.write("<SCRIPT language=javascript>function checksize()  { if (document.images[0].complete) {  window.resizeTo(document.images[0].width+12,document.images[0].height+30); window.focus();} else { setTimeout('check()',250) } }</"+"SCRIPT>");
	w.document.write("<BODY onload='checksize()' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0><IMG src='"+img+"' border=0 onClick='javascript:window.close();' style='cursor:hand'>");
	w.document.write("");
	w.document.write("</BODY></HTML>");
	w.document.close();
}