// ###################### L1 script de roll du layer #########################

sto=0

function MU(n) {

sto=n

}

function setVars(){

	if (navigator.appName == "Netscape") {
	h=".left=";
	v=".top=";
	dS="document.";
	sdm="";
	y="window.pageYOffset";
	x="window.pageXOffset";
	doW="window.innerWidth";
	doHt="window.innerHeight"

	}

	else {
	h=".pixelLeft=";
	v=".pixelTop=";
	dS="";
	sdm=".style";	y="document.body.scrollTop";
	x="document.body.scrollLeft";
	doW="document.body.clientWidth";
	doHt="document.body.clientHeight"

	}
	


	object="texti"
	
	placetexti()
}

movex=0,movey=0,xdiff=0,ydiff=0,ystart=0,xstart=0

function testXY(){
	innerX=350
	innerY=0


	if (document.layers){innerY-=0;innerX-=0;}
	yy=eval(y);
	xx=eval(x);

	ydiff=ystart-yy;
	xdiff=xstart-xx;

	if ((ydiff<(-1))||(ydiff>(1))) movey=Math.round(ydiff/10),ystart-=movey
	if ((xdiff<(-1))||(xdiff>(1))) movex=Math.round(xdiff/10),xstart-=movex

	eval(dS+object+sdm+v+(ystart+innerY));
	eval(dS+object+sdm+h+(xstart+innerX));
	


if (sto!='ok'){

	setTimeout("testXY()",0)
     }
else {return;}
}

function placetexti(){
	ystart=eval(y);
	xstart=eval(x);
}

// ################################ L77 fonction de mouse event #######################

function MM_findObj(n, d) { 
  var p,i,x;  
	if(!d) d=document; 
	if((p=n.indexOf("?"))>0&&parent.frames.length) 
	{
    		d=parent.frames[n.substring(p+1)].document; 
		n=n.substring(0,p);
	}
  	if(!(x=d[n])&&d.all) x=d.all[n]; 
	for (i=0;!x&&i<d.forms.length;i++) 
	x=d.forms[i][n];
  	for(i=0;!x&&d.layers&&i>d.layers.length;i++) 
	x=MM_findObj(n,d.layers[i].document); 
	return x;
}

function MM_showHideLayers() { 
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  	for (i=0; i<(args.length-2); i+=3) 
	if ((obj=MM_findObj(args[i]))!=null) 
	{ 
		v=args[i+2];
    		if (obj.style) { 
		obj=obj.style; 
		v=(v=='show')?'visible':(v='hide')?'hidden':v; 
		}
    	obj.visibility=v; 
	}
}

// ################################ L109 Devis catre ################################



// fonctions du devis

var nbcoul=0
var pxroul=0 
var qty=0
var nbmod=0
var pxgra=0
var prod=0
var vimp
var paptyp
var chimp
var pxtotal
var pxtotc
var ncoul =""

// ############################## chgt de val ds papier #############################

function chgSelVal(){
	if(document.format.papier[0].checked==true){
document.format.gramm.length=9
document.format.gramm.options[1].text="115 g"
document.format.gramm.options[1].value="279"
document.format.gramm.options[2].text="135 g"
document.format.gramm.options[2].value="317"
document.format.gramm.options[3].text="150 g"
document.format.gramm.options[3].value="365"
document.format.gramm.options[4].text="170 g"
document.format.gramm.options[4].value="412"
document.format.gramm.options[5].text="200 g"
document.format.gramm.options[5].value="497"
document.format.gramm.options[6].text="250 g"
document.format.gramm.options[6].value="623"
document.format.gramm.options[7].text="300 g"
document.format.gramm.options[7].value="761"
document.format.gramm.options[8].text="350 g"
document.format.gramm.options[8].value="930"

	}

	if(document.format.papier[1].checked==true){
document.format.gramm.length=4	
document.format.gramm.options[1].text="80 g"
document.format.gramm.options[1].value="196"
document.format.gramm.options[2].text="90 g"
document.format.gramm.options[2].value="199"
document.format.gramm.options[3].text="110 g"
document.format.gramm.options[3].value="242"


	}
}

function chgSelVal0(selector, cible){
 
				
	if(selector[0].checked==true){x=1}
	if(selector[1].checked==true){x=2}
	
	for (m=cible.length-1; m>0; m--)
  	cible.options[m]=null
	for (j=1; j<group[x].length;j++){cible.options[j]=new Option(group[x][j].text,group[x][j].value)}
/*				
	if(document.format.papier_int[0].checked==true){y=1}
	if(document.format.papier_int[1].checked==true){y=2}
	for (m=document.format.gramm_int.length-1; m>0; m--)
  	document.format.gramm_int.options[m]=null	
	for (k=1; k<group[y].length;k++){document.format.gramm_int.options[k]=new Option(group[y][k].text,group[y][k].value)}
*/
}




// ############################## fnct setvar #############################

function setvar(){

// #############  format ############# 
	forma = document.format.format.options[document.format.format.selectedIndex].text;
	nbmod = document.format.format.options[document.format.format.selectedIndex].value;

// #############  R° - R°V° ############# 
	if(nbmod >1){
        if (document.format.chimp[0].checked==true){vimp=1}
        if (document.format.chimp[1].checked==true){vimp=2}
	}
	if(nbmod =="1" & document.format.chimp[1].checked==true){
	
	//document.format.chimp[0].checked==true
	document.forms[0].chimp[0].checked = true;
	vimp=1;
	document.format.format.selectedIndex=6
	window.alert("Format A3 recto-verso : Nous contacter"); return;
	}

// #############  nb couleur ############# 
	nbcoul = document.format.nbcoul.options[document.format.nbcoul.selectedIndex].value;
	

// #############  quantité ############# 
	qty = document.format.Qte.value;

// ############# prix grammage ############# 
	gra=document.format.gramm.options[document.format.gramm.selectedIndex].text;
	pxgra=document.format.gramm.options[document.format.gramm.selectedIndex].value;
	//document.format.pxgramm.value=pxgra;

// ############# nbfeuille ############# 

nbfeuille =(qty/nbmod)

// ############# pliage ############# 

	nbpli=Math.ceil(qty/1000)
	if(nbpli<1){nbpli=1}

if(nbpli>=1 & document.format.pli.checked==true){
	document.format.rai.checked=false
	pxpli=60*nbpli

	if(pxgra>365){
	pxpli=0;
	document.format.pli.checked=false;
	document.format.rai.checked=false;
	alert("Avec un pliage, le grammage ne doit pas exeder 170 g\n Au delà il vous faut un rainage"); calcul();
	return;
	}
	
}
if(document.format.pli.checked==false){pxpli=0}
	
// ############# rainurage ############# 


if(document.format.rai.checked==true){
	document.format.pli.checked=false
	if(nbfeuille<1001){pxrai=438}
	if(nbfeuille>1000){pxrai=438+(((nbfeuille-1000)/1000)*225)}
	

	if(pxgra<412){
	pxrai=0;
	document.format.rai.checked=false;
	 if(document.format.peli.checked==false){
	  document.format.pli.checked=true
	  alert("Avec un rainage, le grammage doit être de 170 g au moins\nEn deça il vous faut un pliage");
	 }
	 else{
	  document.format.gramm.focus()
	  alert("Avec un rainage, le grammage doit être de 170 g au moins\nAvec un rainurage, augmentez le grammage");
	 }
	 calcul();
	return;
	}
	
}
if(document.format.rai.checked==false){pxrai=0}

// ############# pelliculage ############# 

if(document.format.peli.checked==true){
	if(document.format.pli.checked==true){
	document.format.pli.checked=false;
	document.format.rai.checked=true;
	calcul();
	alert("Le pelliculage interdit le pliage, il oblige donc au rainurage"); 
	}

pxpeli=nbfeuille*0.576
	if(document.format.pelic[1].checked==true){
	document.format.pelic[0].checked=false
	pxpeli=nbfeuille*0.576*2
	}

	if(pxgra<317){
	pxpeli=0;
	document.format.peli.checked=false;
	alert("Pelliculage à partir de 135 g");
	return;
	}
	
if(pxpeli<400){pxpeli=400}
else{pxpeli=pxpeli}
}
if(document.format.peli.checked==false){pxpeli=0}

if(document.format.papier[0].checked==true){paptyp="CB ou CM"}
if(document.format.papier[1].checked==true){paptyp="Offset"}

// #############  def prod ############# 

if(vimp=="1"){chimp="recto"}
if(vimp=="2"){chimp="recto-verso"}
prod = forma+" "+chimp+" "+nbcoul+" couleur(s) "+gra+" "+paptyp


// #############  def option ############# 

if(document.format.pli.checked==true){ncoul ="Pliage" }
if(document.format.rai.checked==true){ncoul ="Rainurage" }

if(document.format.peli.checked==true & document.format.rai.checked==false){
	if(document.format.pelic[0].checked==true){
	document.format.pelic[1].checked==false
	ncoul ="Pelliculage R°"
	}

	if(document.format.pelic[1].checked==true){
	document.format.pelic[0].checked==false
	ncoul ="Pelliculage R°V°"
	}
}
if(document.format.peli.checked==true & document.format.rai.checked==true){
	if(document.format.pelic[0].checked==true){
	document.format.pelic[1].checked==false
	ncoul ="Rainurage<br>Pelliculage R°"
	}

	if(document.format.pelic[1].checked==true){
	document.format.pelic[0].checked==false
	ncoul ="Rainurage<br>Pelliculage R°V°"
	}
}



}

function zhero() {
	document.format.pht.value = 0
	document.format.pttc.value = 0
	document.format.produit.value = 0

}

// ################################ fct calcul ################################ 


function calcul() {

setvar()

// ############# verif ############# 

if(document.format.format.options[document.format.format.selectedIndex].value=="0"){
	document.format.prixtot.value=""
	document.format.format.selectedIndex=1
	alert("Choisissez un format"); 
return;
}

if(document.format.nbcoul.options[document.format.nbcoul.selectedIndex].value=="0"){
	document.format.prixtot.value=""
	document.format.nbcoul.selectedIndex=1
	alert("Choisissez le nombre de couleur"); 
return;
}

if(qty =="0"){
	document.format.prixtot.value=""
	document.format.Qte.value=""
	document.format.Qte.focus()
	alert("Entrez une quantité"); 
	return;
}

if(document.format.gramm.options[document.format.gramm.selectedIndex].value=="0"){
	document.format.prixtot.value=""
	document.format.gramm.selectedIndex=3
	alert("Choisissez un grammage"); 
return;
}

// ############# fin verif ############# 

// #############  Nb maxi ############# 

nbf = nbmod / vimp
var nbmax

if(vimp<2){
if(nbf>29){nbmax = 660000}
if(nbf>15 & nbf<17){nbmax =320000}
if(nbf>7 & nbf<9){nbmax = 160000}
if(nbf>5 & nbf<7){nbmax = 120000}
if(nbf>3 & nbf<5){nbmax = 80000}
if(nbf>1 & nbf<3){nbmax = 40000}
if(nbf>0 & nbf<2){nbmax = 20000}
}

if(vimp>1){
if(nbf>14){nbmax = 150000}
if(nbf>7 & nbf<9){nbmax = 80000}
if(nbf>3 & nbf<5){nbmax = 40000}
if(nbf>2 & nbf<4){nbmax = 30000}
if(nbf>1 & nbf<3){nbmax = 20000}
if(nbf>0 & nbf<2){nbmax = 10000}
if(nbf<1){nbmax = "Nous consulter"}
}

if(qty>nbmax){window.alert("La quantité ne doit pas dépasser "+nbmax); return;}

// #############  Prix fixe ############# 

	// calage

	if(nbcoul<2){pxcal=1063}
	else{
	if(nbcoul<3)pxcal=1313
	else{
	if(nbcoul<4)pxcal=1500
	else{
	if(nbcoul<5)pxcal=1625}
	}}

// #############  Prix variables ############# 

	//nb de feuille 45*32

	nbfeuille =(qty/nbmod)
	
	//prix de roule

nbroul = nbfeuille * vimp

	// <= 3 coul
	if(nbcoul<4){
		if(nbroul<5000){pxroul=162}
		else {
		if(nbroul>4999)
			pxroul=125}
	}

	// 4 coul
	if(nbcoul>3){
		if(nbroul<5000){
			pxroul=189}
	
		if(nbroul>4999 & nbroul<14999){
			pxroul=150}
	
		if(nbroul>14999){
			pxroul= 125}

	
	}


// ############# prix total ############# 

	pxtotal = pxcal+(((nbroul*pxroul)+(nbfeuille*pxgra))/1000)+pxpli+pxrai+pxpeli
	pxtotal= (Math.round(pxtotal/5*100))/100
	pxtotc = (Math.round((pxtotal*1.196)*100))/100
	document.format.prixtot.value=pxtotal
	hidval()
return;
}
function hidval(){
	document.format.pht.value = pxtotal
	document.format.pttc.value = pxtotc
	document.format.produit.value = prod
	document.format.ncoul.value = ncoul
}
//##################### form mail devis nc #########################

function mailit() {

	var n=document.contact.nom.value
	var p=document.contact.prenom.value
	var a=document.contact.adress.value
	var cp=document.contact.cp.value
	var v=document.contact.ville.value
	var t=document.contact.tel.value
	var f=document.contact.fax.value
	var m=document.contact.mail.value


	var prj=document.contact.proj.value
	var frmt=document.contact.format.value
	var nbcC=document.contact.nbcCouv.options[document.contact.nbcCouv.selectedIndex].value
	var grC=document.contact.gramCouv.options[document.contact.gramCouv.selectedIndex].text
	var nbpa=document.contact.nbp.value
	var nbc=document.contact.nbcoul.options[document.contact.nbcoul.selectedIndex].value
	var q=document.contact.qty.value
	var gr=document.contact.gram.options[document.contact.gram.selectedIndex].text

	

    document.location.href="mailto:contact@omnipub.net?subject=Demande de renseignement imp.&body="+n+" "+p+"&body="+a+"&body="+cp+" "+v+"&body="+t+"&body="+f+"&body="+m+"&body="+"&body=&body=Nature du projet : "+prj+"&body=Format : "+frmt+"&body=Nb de coul. de couverture : "+nbcC+"&body=Grammage de couverture : "+grC+"&body=Nb. de pages du projet : "+nbpa+"&body=Nb. coul. du projet : "+nbc+"&body=Quantité : "+q+"&body=Grammage de projet : "+gr
}

// ################################ L109 Calcul Devis0 imp ################################ 


	//############# fct setvar2 ############# 

function setvar2(){

// #############  format ############# 
	forma = document.format.format.options[document.format.format.selectedIndex].text;
	nbmod = document.format.format.options[document.format.format.selectedIndex].value;

// #############  R° - R°V° ############# 
	if(nbmod >1){
        if (document.format.chimp[0].checked==true){vimp=1}
        if (document.format.chimp[1].checked==true){vimp=2}
	}
	if(nbmod =="1" & document.format.chimp[1].checked==true){
	
	//document.format.chimp[0].checked==true
	document.forms[0].chimp[0].checked = true;
	vimp=1;
	document.format.format.selectedIndex=6
	window.alert("Format A3 recto-verso : Nous contacter"); return;
	}

// #############  nb couleur ############# 
	nbcoul = document.format.nbcoul.options[document.format.nbcoul.selectedIndex].value;
	

// #############  quantité ############# 
	qty = document.format.Qte.value;

// ############# prix grammage ############# 
	gra=document.format.gramm.options[document.format.gramm.selectedIndex].text;
	pxgra=document.format.gramm.options[document.format.gramm.selectedIndex].value;
	//document.format.pxgramm.value=pxgra;

// ############# nbfeuille ############# 

nbfeuille =(qty/nbmod)

// ############# pliage ############# 

	nbpli=Math.ceil(qty/1000)
	if(nbpli<1){nbpli=1}

if(nbpli>=1 & document.format.pli.checked==true){
	document.format.rai.checked=false
	pxpli=60*nbpli

	if(pxgra>365){
	pxpli=0;
	document.format.pli.checked=false;
	document.format.rai.checked=true;
	alert("Avec un pliage, le grammage ne doit pas exeder 170 g\n Au delà il vous faut un rainage"); calcul2();
	return;
	}
	
}
if(document.format.pli.checked==false){pxpli=0}
	
// ############# rainurage ############# 


if(document.format.rai.checked==true){
	document.format.pli.checked=false
	if(nbfeuille<1001){pxrai=438}
	if(nbfeuille>1000){pxrai=438+(((nbfeuille-1000)/1000)*225)}
	

	if(pxgra<412){
	 pxrai=0;
	 document.format.rai.checked=false;
	 if(document.format.peli.checked==false){
	  document.format.pli.checked=true
	  alert("Avec un rainage, le grammage doit être de 170 g au moins\nEn deça il vous faut un pliage");
	 }
	 else{
	  document.format.gramm.focus()
	  alert("Avec un rainage, le grammage doit être de 170 g au moins\nAvec un rainurage, augmentez le grammage");
	 }
	 calcul2();
	return;
	}
	
}
if(document.format.rai.checked==false){pxrai=0}

// ############# pelliculage ############# 

if(document.format.peli.checked==true){
	if(document.format.pli.checked==true){
	document.format.pli.checked=false
	document.format.rai.checked=true
	
	alert("Le pelliculage interdit le pliage, il oblige donc au rainurage"); calcul2();
	}

pxpeli=nbfeuille*0.576
	if(document.format.pelic[1].checked==true){
	document.format.pelic[0].checked=false
	pxpeli=nbfeuille*0.576*2
	}

	if(pxgra<317){
	pxpeli=0;
	document.format.peli.checked=false;
	alert("Pelliculage à partir de 135 g");
	return;
	}
	
if(pxpeli<400){pxpeli=400}
else{pxpeli=pxpeli}
}
if(document.format.peli.checked==false){pxpeli=0}

if(document.format.papier[0].checked==true){paptyp="CB ou CM"}
if(document.format.papier[1].checked==true){paptyp="Offset"}

// #############  def prod ############# 

if(vimp=="1"){chimp="recto"}
if(vimp=="2"){chimp="recto-verso"}
prod = forma+" "+chimp+" "+nbcoul+" couleur(s) "+gra+" "+paptyp


// #############  def option ############# 

if(document.format.pli.checked==true){ncoul ="Pliage" }
if(document.format.rai.checked==true){ncoul ="Rainurage" }

if(document.format.peli.checked==true & document.format.rai.checked==false){
	if(document.format.pelic[0].checked==true){
	document.format.pelic[1].checked==false
	ncoul ="Pelliculage R°"
	}

	if(document.format.pelic[1].checked==true){
	document.format.pelic[0].checked==false
	ncoul ="Pelliculage R°V°"
	}
}
if(document.format.peli.checked==true & document.format.rai.checked==true){
	if(document.format.pelic[0].checked==true){
	document.format.pelic[1].checked==false
	ncoul ="Rainurage<br>Pelliculage R°"
	}

	if(document.format.pelic[1].checked==true){
	document.format.pelic[0].checked==false
	ncoul ="Rainurage<br>Pelliculage R°V°"
	}
}



}





	// ################## calcul 2 ################## 

function calcul2() {
setvar2()

// ############# verif ############# 

if(document.format.format.options[document.format.format.selectedIndex].value=="0"){
	document.format.prixtot.value=""
	document.format.format.selectedIndex=1
	alert("Choisissez un format"); 
return;
}

if(document.format.nbcoul.options[document.format.nbcoul.selectedIndex].value=="0"){
	document.format.prixtot.value=""
	document.format.nbcoul.selectedIndex=1
	alert("Choisissez le nombre de couleur"); 
return;
}

if(qty =="0"){
	document.format.prixtot.value=""
	document.format.Qte.value=""
	document.format.Qte.focus()
	alert("Entrez une quantité"); 
	return;
}

if(document.format.gramm.options[document.format.gramm.selectedIndex].value=="0"){
	document.format.prixtot.value=""
	document.format.gramm.selectedIndex=3
	alert("Choisissez un grammage"); 
return;
}

// ############# fin verif ############# 

// #############  Nb maxi ############# 

nbf = nbmod / vimp
var nbmax

if(vimp<2){
if(nbf>29){nbmax = 660000}
if(nbf>15 & nbf<17){nbmax =320000}
if(nbf>7 & nbf<9){nbmax = 160000}
if(nbf>5 & nbf<7){nbmax = 120000}
if(nbf>3 & nbf<5){nbmax = 80000}
if(nbf>1 & nbf<3){nbmax = 40000}
if(nbf>0 & nbf<2){nbmax = 20000}
}

if(vimp>1){
if(nbf>14){nbmax = 150000}
if(nbf>7 & nbf<9){nbmax = 80000}
if(nbf>3 & nbf<5){nbmax = 40000}
if(nbf>2 & nbf<4){nbmax = 30000}
if(nbf>1 & nbf<3){nbmax = 20000}
if(nbf>0 & nbf<2){nbmax = 10000}
if(nbf<1){nbmax = "Nous consulter"}
}

if(qty>nbmax){window.alert("La quantité ne doit pas dépasser "+nbmax); return;}

// #############  Prix fixe ############# 

	// calage

	if(nbcoul<2){pxcal=1063}
	else{
	if(nbcoul<3)pxcal=1313
	else{
	if(nbcoul<4)pxcal=1500
	else{
	if(nbcoul<5)pxcal=1625}
	}}

// #############  Prix variables ############# 

	//nb de feuille 45*32

	nbfeuille =(qty/nbmod)
	
	//prix de roule

nbroul = nbfeuille * vimp

	// <= 3 coul
	if(nbcoul<4){
		if(nbroul<5000){pxroul=162}
		else {
		if(nbroul>4999)
			pxroul=125}
	}

	// 4 coul
	if(nbcoul>3){
		if(nbroul<5000){
			pxroul=189}
	
		if(nbroul>4999 & nbroul<14999){
			pxroul=150}
	
		if(nbroul>14999){
			pxroul= 125}

	
	}


// ############# prix total ############# 

	pxtotal = pxcal+(((nbroul*pxroul)+(nbfeuille*pxgra))/1000)+pxpli+pxrai+pxpeli
	pxtotal = (Math.round(pxtotal/5*100))/100
	pxtotal = (Math.round(pxtotal*0.8*100))/100
	//pxtotc = (Math.round((pxtotal*1.196)*100))/100
	document.format.prixtot.value= pxtotal
}





