function movewin(win, width, height) {
		var fullWidth = screen.availWidth;
		var fullHeight = screen.availHeight;
		var x = (fullWidth/2)-(width/2);
		var y = (fullHeight/2)-(height/2);
		win.moveTo(x,y); 
	}
			
function viewWin(filenames,width,height)
{
	
	filenames=filenames;
			
	var newwin = window.open(filenames, 'mydoc', 'toolbar=0,location=0,directories=0,status=0,fullscree=yes,menubar=0,scrollbars=1,resizable=1,maximize=0,width='+width+',height='+height);
	
	movewin(newwin, width, height);
	    if (navigator.appName=="Netscape") 
	        newwin.location=url;
		
		newwin.opener=window;
		newwin.focus();
		return false;
}
function verifForm(){
	var propriete = document.getElementById("propriete").checked;
	var certifier = document.getElementById("certifier").checked;
	
	if( (propriete==true) && (certifier==true) ){
		
		var newwin = window.open('index.php?name=printorder', 'mydoc', 'toolbar=0,location=0,directories=0,status=0,fullscree=yes,menubar=0,scrollbars=1,resizable=1,maximize=0,width=800,height=800');
		
		movewin(newwin, 800, 800);
		    if (navigator.appName=="Netscape") 
		        newwin.location=url;
			
			newwin.opener=window;
			newwin.focus();
			
		document.unform.submit();
		return true;
	}else{
		window.alert("Vous devez cocher les champs obligatoires.");
		return false;
	}
}
function show_pic(id,pic_name)
{
	var obj=document.getElementById(id);
	obj.src="./product/thumb/"+pic_name;
}

function working_handset()
{
	var obj=document.getElementById("working_mobile");
	obj.style.display="block";
	obj.style.visibility="visible";
	var obj1=document.getElementById("non_working_mobile");
	obj1.style.display="none";
	obj1.style.visibility="hidden";
}


function non_working_handset()
{
	var obj=document.getElementById("working_mobile");
	obj.style.display="none";
	obj.style.visibility="hidden";
	var obj1=document.getElementById("non_working_mobile");
	obj1.style.display="block";
	obj1.style.visibility="visible";
}

function show_imei()
{
	
	var obj=document.getElementById("imei");
	obj.style.display="block";
	obj.style.visibility="visible";
	//document.getElementById("working_mobile").disabled=true;
	//document.getElementById("non_working_mobile").disabled=true;
	
}

function submit_form()
{
	var frm=document.mobile;
	var checked = false;
	
	for (var cpt = 0 ; (cpt < document.getElementsByName("mobile_condition").length) && !checked ; cpt++) {
	checked = checked || document.getElementsByName("mobile_condition")[cpt].checked;
	}
	
	if (!checked) {
		alert("Selectionnez l'etat du mobile");
		return false;
	} 
	
	if(frm.mobile_imei.value=="")
	{
		alert("Entrer l'IMEI du mobile");
		frm.mobile_imei.focus();
		return false;
	}
	else
	{
		var str=frm.mobile_imei.value;
		if(str.length!=15)
		{
			alert("Entrer un IMEI Valide");
			frm.mobile_imei.focus();
			return false;
		}
		else
			 document.mobile.submit();
	}
}

function copy_uname()
{
		var frm=document.ufrm;
		frm.username.value=frm.email.value;
}

function chg_image1()
{
	var img_obj=document.getElementById("confirm_image");
	var obj=document.getElementById("chk_term");
	
	if(obj.checked==false)
	{
	   img_obj.src="./images/confirmer.gif"	;
	   var tdobj=document.getElementById("tdconfirm");
	   tdobj.style.visibility="visible";
	   tdobj.style.display="";
	   var tdobj1=document.getElementById("tdconfirm1");
	   tdobj1.style.visibility="hidden";
	   tdobj1.style.display="none";
	}
	else
		{
			img_obj.src="./images/confirmer.gif";
			 var tdobj=document.getElementById("tdconfirm");
	   tdobj.style.visibility="hidden";
	   tdobj.style.display="none";
	   var tdobj1=document.getElementById("tdconfirm1");
	   tdobj1.style.visibility="visible";
	   tdobj1.style.display="";
		}
	
}

function clearText(thefield) {
	if (thefield.defaultValue==thefield.value);
	thefield.value = "";
}
	
	
function cancel_eufrm()
{
	window.location.href='./myaccount.php';
}


function chg_image(id,img)
{
	 var obj=document.getElementById(id);
	 obj.src='./images/'+img;
}
	
// V�rification de l'email
function chk_signup1()
{
	var frm=document.signup1;
	
	 if(frm.email.value=="")
	{
	     alert("Merci de saisir un email valide");
	     frm.email.focus();
	     return false;
	 }
	document.frm.submit();
}

//EG
function add_don(){	

	var price=document.infos_mobile.price_mobile;
	var don=document.ajout_don.montant_don;
	var valeur_don=document.frm_recap_cmd.valeur_don;
	var champ_total=document.frm_recap_cmd.total;
	
	//test si le don n'est pas un nombre et n'est pas vide
	if ((isNaN(don)==true) && (don!='')){
		window.alert("Veuillez saisir un nombre entier pour votre don.");
		window.document.getElementById('montant_don').value=0;
		return false;
		exit;
	}

	//test si le don est vide
	if (don==''){
		//mettre la valeur du don a 0 pour le calcul du total
		don = 0;
	}
	
	//traitement des valeurs
	var prix=parseInt(price.value);
	var val_don=parseInt(don.value);
		
	//controle de la saisie du montant du don
	if (val_don>prix){
		alert ("La valeur du don ne doit pas etre superieure a la valeur du mobile");
		don.value=0;
		exit;
	}
	//calcul du total
	var total=prix;
	var val_BOA=prix-val_don;
	//Affectation de la valeur du don
	valeur_don.value=val_don;
	document.getElementById('valeur_don_aff').innerHTML = val_don+' &euro;';
	//Affectation du total
	champ_total.value=total.toFixed(2);
	document.getElementById('total_aff').innerHTML = total.toFixed(2)+' &euro;';
	//Affectation du BOA
	document.getElementById('valeur_BOA').innerHTML = val_BOA.toFixed(2)+' &euro;';
	
	alert ("Prise en compte du don");
	
	
}

//RG
function add_don_plusieurs(){	
	
	var price=window.document.getElementById('total_price').value;
	var don=window.document.getElementById('montant_don').value;
	
	//test si le don n'est pas un nombre et n'est pas vide
	if ((isNaN(don)==true) && (don!='')){
		window.alert("Veuillez saisir un nombre entier pour votre don.");
		window.document.getElementById('montant_don').value=0;
		return false;
		exit;
	}


	//test si le don est vide
	if (don==''){
		//mettre la valeur du don a 0 pour le calcul du total
		don = 0;
	}
	

	//converti les variable en nombre
	don = parseInt(don);
	price = parseInt(price);
	
	//controle que le don ne soit pas supérieur au total
	if (price<don){
		window.alert("Vous ne pouvez pas faire un don sup\351rieur \340 "+price+" euros.");
		//initialisation du don a 0
		window.document.getElementById('montant_don').value=0;
		exit;
	}
	
	
	
	//on recalcule le montant du bon d'achat en fonction du don
	var total_price = price - don;
	
	//on affiche le nouveau total et le don
	document.getElementById('valeur_total_aff').innerHTML = total_price.toFixed(2);
	document.getElementById('valeur_don_aff').innerHTML = '<b>'+don.toFixed(2)+' &euro;</b>';

	//on affecte le don pour le passé en parametre
	document.getElementById('total_don').value = don.toFixed(2);

	//window.alert ("Don pris en compte, d'une valeur de "+don.toFixed(2)+" euros");
	
}


