// © ATELIER 33 / ALL RIGHTS RESERVED / 2006 / http://www.atelier33.com / contact@atelier33.com
//                                          CLIENT SIDE                                        \\
//=============================================================================================\\
//GLOBAL VAR
	DaCatPath="/shop";
	DaCatPage="/shop/cat_main.asp?";
//----------------------
function AddToBookMark()
{
	browserName = navigator.appName; browserVer = parseInt(navigator.appVersion);
	if (browserName=="Microsoft Internet Explorer" && browserVer>=4){window.external.AddFavorite(location.href, document.title);}
	else {alert(ExpBMK);}
} 
//----------------------
function SelfResizeTo(DaX, DaY){self.resizeTo(DaX, DaY);}
//----------------------
function check_empty(text){return (text.length > 0);}
//----------------------
function check_email(adresse)
{
	if ((adresse == "") || (adresse.indexOf ('@') == -1) || (adresse.indexOf ('.') == -1)){return false;}
    else {return true;}
}
//----------------------
function check_tel(fFrom, IsOblg)
{
	//VARS
	var Dis=document.FormCart; var sMsg=""; var temp=""; var DaAct=""; var bCheck=false;
	var reg=/^\d+$/
	//TO LOWER CASE
	temp=eval("Dis."+fFrom+".value.toLowerCase()"); 
	if(IsOblg)	{bCheck=true;}
	else				{if(temp!=""){bCheck=true;}}
	
	if(bCheck)
		{
		temp=temp.replace(/[abcdefghijklmnopqrstuvwxyz]/gi,"");
		temp=temp.replace(/[ ]/gi,"");
		temp=temp.replace(/[\.]/gi,"");	
		temp=temp.replace(/[\\]/gi,"");
		temp=temp.replace(/[\/]/gi,"");	
		temp=temp.replace(/[\[\]]/gi,"");
		temp=temp.replace(/[-,;?!:&=+#<>]/gi,"");
		temp=temp.replace(/[*°\(\)%]/gi,"");
		DaAct=eval("Dis."+fFrom+".value=temp");
		//REG EXP CHECK	+ OUTPUT		
		if((reg.exec(temp)==null) || (temp.length<10)){return false;}
		else 																					{return true;}
		}
	else
		{return true}
}
//----------------------
function closeit2(){parent.document.getElementById("dwindow").style.display="none"}
//----------------------
function GetDivTxt(DaMsg,which){oWhich=GetDaID(which); window.focus(); oWhich.innerHTML=DaMsg;}
//---------------------- 
function GetDir()
{
	var Dis=document.FormIdxSearch;
	if (Dis.ReqDir.options[Dis.ReqDir.selectedIndex].value!="")
		{eval("top.location='"+DaCatPage+Dis.ReqDir.options[Dis.ReqDir.selectedIndex].value+"'");}
}
//----------------------
function GetDaID(which)
{
	if (!document.getElementById|document.all){return}
	else
		{
		if (document.getElementById){oWhich=eval("document.getElementById('"+which+"')")}
		else												{oWhich=eval("document.all."+which)}
		}
	window.focus(); return oWhich;
}
//---------------------- 
function GetVis(which, DaVis){if(which!=""){oWhich=GetDaID(which); window.focus(); oWhich.style.display=DaVis;}}
//---------------------- 
function ContactCheck()
{
	var Dis=document.FormCont; var bFlag=true;
	//CHECK
	if (!check_empty(Dis.Nom.value)){bFlag=false; alert(ExpNom); Dis.Nom.focus();}	
	if (bFlag && !check_empty(Dis.Prenom.value)){bFlag=false; alert(ExpPre); Dis.Prenom.focus();}	
	if (bFlag && !check_empty(Dis.DateN.value)){bFlag=false; alert(ExpDNaiss); Dis.DateN.focus();}
	if (bFlag && !check_empty(Dis.Tel.value)){bFlag=false; alert(ExpTel); Dis.Tel.focus();}
	if (bFlag && !check_email(Dis.Email.value)){bFlag=false; alert(ExpEmail); Dis.Email.focus();}
	if (bFlag && !check_empty(Dis.Adresse.value)){bFlag=false; alert(ExpAdr); Dis.Adresse.focus();}
	if (bFlag && !check_empty(Dis.Ville.value)){bFlag=false; alert(ExpVille); Dis.Ville.focus();}
	if (bFlag && !check_empty(Dis.CP.value)){bFlag=false; alert(ExpCP); Dis.CP.focus();}
	if (bFlag && !check_empty(Dis.Pays.value)){bFlag=false; alert(ExpPays); Dis.Pays.focus();}
	if (bFlag && !check_empty(Dis.Msg.value)){bFlag=false; alert(ExpMsg); Dis.Msg.focus();}	
	//SEND
	if (bFlag){Dis.ActionType.value="SEND"; Dis.method="post"; Dis.action="contact.asp"; Dis.submit();}		
}
//----------------------
function CheckQte(DaValue)
{
	var validity=false;
	if(isNaN(parseInt(DaValue)) || parseInt(DaValue)<1){alert(ExpIntPos2); validity=false ; return validity;}
	else {validity=true ; return validity;}	
}
//----------------------
function CheckSearch()
{
	var Dis=document.FormSearch; 
	var bFlag=true;
	//CHECK	
	//if(!check_empty(Dis.Expr.value) || Dis.Brand.selectedIndex==0 || !check_empty(Dis.Code.value))
	//	{alert(ExpSearch01); Dis.Code.focus(); bFlag=false;}
	//SEND
	if(bFlag){Dis.method="get"; Dis.target="_self"; Dis.action="/shop/cat_search.asp"; Dis.submit();}	
}
//----------------------
function CataSearchCheck(pvForm)
{
	var Dis=eval(pvForm); var bFlag=false;
	//CHECK	
	if(!check_empty(Dis.Expr.value) && Dis.Brand.selectedIndex==0 && !check_empty(Dis.Code.value))
		{ bFlag=false; alert(ExpSearch01); Dis.Code.focus(); }
	else
		{ bFlag=true; }
	return bFlag;
}
//----------------------	
function ResetSearch()
{
	var Dis=document.FormSearch; 
	Dis.Expr.value=""; Dis.Brand.selectedIndex=0; Dis.Code.value="";
}
//----------------------
function CheckIdxSearch()
{
	var Dis=document.FormIdxSearch; var bFlag=true;
	//CHECK	
	if(!check_empty(Dis.Expr.value) && Dis.Brand.selectedIndex==0)
		{bFlag=false; alert(ExpSearch03); Dis.Brand.focus();}
	//SEND
	if(bFlag){Dis.method="get"; Dis.target="_self"; Dis.action="/shop/cat_search.asp"; Dis.submit();}	
}	
//----------------------
function SubmitCart()
{
	var Dis=document.FormCart;  var bFlag=true;
	if(Dis.ShipType)
		{
		//PAYS
		if(Dis.sPays.selectedIndex==0){bFlag=false; alert(ExpPoPays)}
		//TRANSP
		bFlag=false;
		for (i=0; i<Dis.ShipType.length ; i++){if(eval("Dis.ShipType["+i+"].checked")){bFlag=true; break;}}
		if(!bFlag){alert(ExpPoTrans);}
		//SEND ?
		if(bFlag){Dis.method="get"; Dis.target="_self"; Dis.action="/shop/cat_order.asp";	Dis.submit();}
		}
	else
		{alert(ExpPoPays)}
}	
//----------------------
function BackToCart()
{
	var Dis=document.FormCart; validity=true;
	//var SelPays=Dis.sPays.value;
	//var SelShipType=Dis.ShipType.value;
	//top.location.href="/shop/cat_cart.asp?spays="+SelPays+"&shiptype="+SelShipType;
	Dis.action="cart_back.asp"; Dis.submit(); return validity;
}	
//----------------------
function PrevPort(){Dis=document.FormCart; Dis.method="get"; Dis.target="_self"; Dis.action="/shop/cat_cart.asp"; Dis.submit();}	
//----------------------
function UseBill()
{
	Dis=document.FormCart;
	//FROM BILL TO SHIP
	if (Dis.UseBillBox.checked)
	{	//COORD
		Dis.sNom.value=Dis.bNom.value; Dis.sPre.value=Dis.bPre.value; Dis.sAdr.value=Dis.bAdr.value;
		Dis.sVille.value=Dis.bVille.value; Dis.sCode.value=Dis.bCode.value;
		Dis.sTel.value=Dis.bTel.value; Dis.sFax.value=Dis.bFax.value;
		//Dis.sPays.selectedIndex=Dis.bPays.selectedIndex; 
	}
}
//----------------------
function CheckOrder()
{
	Dis=document.FormCart; AlertMsg=""; bPay=0; validity=true;
	if (Dis.CheckButt.value < 1)
		{
		//Dis.CheckButt.value = 1;	
		//BILL CHECK		
		AlertMsg="Adresse de facturation / Invoicing address :\n\n";
		if (!check_empty(Dis.bNom.value)){alert(AlertMsg+"Indiquez un nom svp.\nPlease enter a last name.");
			Dis.bNom.focus(); Dis.CheckButt.value=0; validity=false; return validity;}
				
		if (!check_empty(Dis.bPre.value))
			{alert(AlertMsg+"Indiquez un prénom svp.\nPlease enter a first name.");
			Dis.bPre.focus(); Dis.CheckButt.value =0; validity = false; return validity;}
		
		if (Dis.bDay.selectedIndex==0)
			{alert(AlertMsg+"Sélectionnez un jour svp.\nPlease select a day.");
			Dis.bDay.focus(); Dis.CheckButt.value =0; validity = false; return validity;}
		
		if (Dis.bMonth.selectedIndex==0)
			{alert(AlertMsg+"Sélectionnez un mois svp.\nPlease select a month.");
			Dis.bMonth.focus(); Dis.CheckButt.value =0; validity = false; return validity;}
		
		if (Dis.bYear.selectedIndex==0)
			{alert(AlertMsg+"Sélectionnez une année svp.\nPlease select a year.");
			Dis.bYear.focus(); Dis.CheckButt.value =0; validity = false; return validity;}
			
		if (!check_empty(Dis.bAdr.value))
			{alert(AlertMsg+"Indiquez un adresse svp.\nPlease enter a address.");
			Dis.bAdr.focus(); Dis.CheckButt.value =0; validity = false; return validity;}
		
		if (!check_empty(Dis.bVille.value))
			{alert(AlertMsg+"Indiquez un ville svp.\nPlease enter a city.");
			Dis.bVille.focus(); Dis.CheckButt.value =0; validity = false; return validity;}

		if (!check_empty(Dis.bCode.value))
			{alert(AlertMsg+"Indiquez un code postal svp.\nPlease enter a postal code.");
			Dis.bCode.focus(); Dis.CheckButt.value =0; validity = false; return validity;}

		if (Dis.bPays.selectedIndex==0)
			{alert(AlertMsg+"Sélectionnez un pays.\nPlease select a country.");
			Dis.bPays.focus(); Dis.CheckButt.value =0; validity = false; return validity;}		

		if (!check_tel("bTel", true))	
			{alert(AlertMsg+"Indiquez un numéro de tél. fixe valide svp.\nPlease enter a valid phone number.\n\n"+ExpTelNum);
			Dis.bTel.focus(); Dis.CheckButt.value =0; validity = false; return validity;}	
			
		if (!check_tel("bFax", false))	
			{alert(AlertMsg+"Indiquez un numéro de tél. mobile valide svp.\nPlease enter a valid cell phone number.\n\n"+ExpTelNum);
			Dis.bFax.focus(); Dis.CheckButt.value =0; validity = false; return validity;}	
		
		if (Dis.bTel.value==Dis.bFax.value)
			{alert(AlertMsg+"N° de tél. fixe et n° de tél. mobile identiques !\nPhone number and cell phone number are the same !.");			
			Dis.bFax.focus(); Dis.CheckButt.value=0; validity = false; return validity; }	
		
		if (!check_email(Dis.bEmail.value))
			{alert(AlertMsg+"Indiquez un email valide svp.\nPlease enter a valid email.");
			Dis.bEmail.focus(); Dis.CheckButt.value =0; validity = false; return validity;}
			
		if (!check_email(Dis.bEmailConf.value))
			{alert(AlertMsg+"Indiquez un email valide svp.\nPlease enter a valid email.");
			Dis.bEmailConf.focus(); Dis.CheckButt.value =0; validity = false; return validity;}
			
		if (Dis.bEmailConf.value!=Dis.bEmail.value)
			{alert(AlertMsg+"Email et confirmation d'email différents.\nEmail and confirmation email not matching.");
			Dis.bEmailConf.focus(); Dis.CheckButt.value =0; validity = false; return validity;}
		
		//SHIP CHECK
		AlertMsg="Adresse de livraison / Delivery address :\n\n";
		if (!check_empty(Dis.sNom.value))
			{alert(AlertMsg+"Indiquez un nom svp.\nPlease enter a last name.");
			Dis.sNom.focus(); Dis.CheckButt.value =0; validity = false; return validity;}
				
		if (!check_empty(Dis.sPre.value))
			{alert(AlertMsg+"Indiquez un prénom svp.\nPlease enter a first name.");
			Dis.sPre.focus(); Dis.CheckButt.value =0; validity = false; return validity;}
			
		if (!check_empty(Dis.sAdr.value))
			{alert(AlertMsg+"Indiquez un adresse svp.\nPlease enter an address.");
			Dis.sAdr.focus(); Dis.CheckButt.value =0; validity = false; return validity;}
		
		if (!check_empty(Dis.sVille.value))
			{alert(AlertMsg+"Indiquez un ville svp.\nPlease enter a city.");
			Dis.sVille.focus(); Dis.CheckButt.value =0; validity = false; return validity;}

		if (!check_empty(Dis.sCode.value))
			{alert(AlertMsg+"Indiquez un code postal svp.\nPlease enter a postal code.");
			Dis.sCode.focus(); Dis.CheckButt.value =0; validity = false; return validity;}

		//if (Dis.sPays.selectedIndex==0)
		//	{alert(AlertMsg+"Sélectionnez un pays.\nPlease select a country.");
		//	Dis.sPays.focus(); Dis.CheckButt.value =0; validity = false; return validity;}
		
		if (Dis.sPays.value==0)
			{alert(AlertMsg+"Sélectionnez un pays.\nPlease select a country.");
			Dis.CheckButt.value =0; validity = false; return validity;}			

		if (!check_tel("sTel", true))	
			{alert(AlertMsg+"Indiquez un numéro de tél. fixe valide svp.\nPlease enter a valid phone number.\n\n"+ExpTelNum);
			Dis.sTel.focus(); Dis.CheckButt.value =0; validity = false; return validity;}	
			
		if (!check_tel("sFax", false))	
			{alert(AlertMsg+"Indiquez un numéro de tél. mobile valide svp.\nPlease enter a valid cell phone number.\n\n"+ExpTelNum);
			Dis.sFax.focus(); Dis.CheckButt.value =0; validity = false; return validity;}	
		
		if (Dis.sTel.value==Dis.sFax.value)
			{alert(AlertMsg+"N° de tél. fixe et n° de tél. mobile identiques !\nPhone number and cell phone number are the same !.");
			Dis.sFax.focus(); Dis.CheckButt.value=0; validity = false; return validity; }	
			
		//PAY TYPE
		AlertMsg="Mode de paiement - Payment method :\n\n";
		//alert(Dis.PayType.length);
		for (i=0; i<Dis.PayType.length ; i++)
		{if(eval("Dis.PayType["+i+"].checked")){bPay=1;}}
		if (bPay==0)
			{alert(AlertMsg+"Sélectionnez un mode de paiement svp.\nPlease select a payment method.");
			Dis.PayType[0].focus(); Dis.CheckButt.value =0; validity = false; return validity;}
			
		//CGV
		if (!Dis.Cgv.checked)
			{alert("- Veuillez cocher la case relative aux conditions\n  générales de vente, svp.\n\n- Please check the terms of use box.");
			Dis.Cgv.focus(); validity = false; return validity;} 

		}
	else
    	{
		alert("Votre requête a déjà été envoyée, patientez svp.\nRequest already sent, please hold on.");
		validity=false; Dis.CheckButt.value=1;
	 	}	

}
//----------------------
function CheckPay(){var Dis=document.FormCart; Dis.method="get"; Dis.target="_self"; Dis.action="/shop/cat_record.asp"; Dis.submit();}
//----------------------
function rating(DaType)
{
	document.write("<FORM action='http://www.fia-net.com/questionnaire/question1.asp' method='post' name='rating' target='rating'>");
	document.write("<INPUT type='hidden' name='siteid' value='2635'>");
	document.write("<INPUT type='hidden' name='typ' value='"+DaType+"'>");
	document.write("</FORM>");
	var win=window.open('','rating','height=350,width=400,menubar=no,location=no,resizable=no,scrollbars=no,toolbar=no');
	document.rating.submit();
}
//----------------------
function PopImg(DaImg, DaType)
{
	titre="Zoom"; xOffSet=30; yOffSet=60;
	DaPath="/a_data/prods/"; if (DaType=="ZOOM"){DaPath="/a_data/prods_zoom/";}
	w=open("",'image','width=400,height=580,toolbar=no,scrollbars=yes,resizable=yes');   
	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+"+xOffSet+",580); window.focus();} else { setTimeout('checksize()',50) } }</"+"SCRIPT>");
	//w.document.write("<SCRIPT language=javascript>function checksize()  { if (document.images[0].complete) {  window.resizeTo(document.images[0].width+"+xOffSet+",document.images[0].height+"+yOffSet+"); window.focus();} else { setTimeout('checksize()',50) } }</"+"SCRIPT>");
	w.document.write("<BODY onload='checksize()' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0><IMG src='"+DaPath+DaImg+"' border=0>");
	w.document.write("");
	w.document.write("</BODY></HTML>");
	w.document.close();
}
//----------------------
function Pop(DaPage, WinName)
{
 if (DaPage!="" && WinName!="") {winView=window.open (DaPage, WinName,'menubar=yes,scrollbars=yes,resizable=yes,status=yes,width=330,height=200');}
 else														{alert(ExpNoParam)}
}
//----------------------
