// © ATELIER 33 / ALL RIGHTS RESERVED / 2006 / http://www.atelier33.com / contact@atelier33.com
//                                          CLIENT SIDE                                        \\
//=============================================================================================\\
//GLOBAL VAR

//----------------------
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 GetAdrEma(DaMail, DaClass)
{
	if (DaMail!="" && DaClass!="")
	{
		DaMail=DaMail.replace("nospam", "@");
		document.write("<a href='mailto:"+DaMail+"' class='"+DaClass+"'>"+DaMail+"&nbsp;»</a>");		
	}
	else {alert(ExpNoParam);}
}
//----------------------
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 GetDivTxt(DaMsg,which){oWhich=GetDaID(which); window.focus(); oWhich.innerHTML=DaMsg;}
//----------------------
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.FormContact; 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_email(Dis.Email.value)){bFlag=false; alert(ExpEmail); Dis.Email.focus();}
	if (bFlag && !check_empty(Dis.Message.value)){bFlag=false; alert(ExpMsg); Dis.Message.focus();}	
	
	//if (bFlag && !check_empty(Dis.Tel.value)){bFlag=false; alert(ExpTel); Dis.Tel.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();}
		
	//SEND
	if (bFlag){Dis.ActionType.value="SEND"; Dis.method="post"; Dis.action="/contact.asp"; Dis.submit();}		
}
//----------------------
function ContactReset()
{
	var Dis=document.FormContact; Dis.reset();
}
//----------------------
function SearchCheck()
{
	var Dis=document.FormSearch;  var bFlag=true;
	//CHECK	
	//&& Dis.PrixID.selectedIndex==0
	if(!check_empty(Dis.Kw.value)  && Dis.FamID.selectedIndex==0 && Dis.OccID.selectedIndex==0)
		{alert(ExpSearch01); Dis.FamidID.focus(); bFlag=false;}
	//SEND
	if(bFlag){Dis.method="get"; Dis.target="_self"; Dis.action="catalogue.asp"; Dis.submit();}	
}	
//----------------------
function SearchReset()
{
	var Dis=document.FormSearch;
	//Dis.PrixID.selectedIndex=0;
	Dis.Kw.value=""; Dis.FamID.selectedIndex=0 ; Dis.OccID.selectedIndex=0;
}	

//----------------------
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)}
}
//----------------------
