// © ATELIER 33 / ALL RIGHTS RESERVED / 2005 / http://www.atelier33.com / contact@atelier33.com
//                                          CLIENT SIDE
//document.FormFaq.Type.options[document.FormFaq.Type.selectedIndex].value
//----------------------------
// COMMON
//----------------------------
function GetAdrEma(DaName, DaID, DaClass)
{
	var DaDomaine;
	if (DaID!="" && DaName!="" && DaClass!="")
		{
		switch (DaID.toString())
			{
			case "0"	: DaDomaine=""; break;
			default		: DaDomaine="phpdev.fr"; break;
			}
		document.write("<a href='mailto:"+DaName+"@"+DaDomaine+"' class='"+DaClass+"'>"+DaName+"@"+DaDomaine+"&nbsp;»</a>");
		}
	 else {alert(ExpNoParam);}
}
//----------------------------
function ManageSelect(SelSourceIndex, SelTarget, ArName)
{
	var ArVal=eval(ArName+SelSourceIndex);
	SelTarget.length=ArVal.length;
	for (i=0; i<ArVal.length; i++)
	{SelTarget.options[i].value=ArVal[i][0]; SelTarget.options[i].text=ArVal[i][1];}	
}
//----------------------------
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 ManageLocation(DaVal, DaPage, DaParam){top.location.href=DaPage+"?"+DaParam+"="+DaVal;}
//-----------------------------
function PopImg(DaImg, DaType)
{
	titre="Zoom"; xOffSet=20; yOffSet=40;
	w=open("",'image','width=400,height=400,toolbar=no,scrollbars=no,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+",document.images[0].height+"+yOffSet+"); window.focus();} else { setTimeout('checksize()',250) } }</"+"SCRIPT>");
	w.document.write("<BODY onload='checksize()' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0>");
	w.document.write("<table width='100%' border='0' cellspacing='0' cellpadding='0' height='100%'>");
	w.document.write("<tr><td align='center' valign='middle'>");
	w.document.write("<IMG src='"+DaImg+"' align='center' border='0'>");
	w.document.write("</td></tr>");
	w.document.write("</table>");
	w.document.write("</BODY></HTML>");
	w.document.close();
}
//----------------------------
// DIV
//----------------------------
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 HideDiv(which){oWhich=GetDaID(which); window.focus(); oWhich.style.display="none";}
//----------------------------
function ShowDiv(which){oWhich=GetDaID(which); window.focus(); oWhich.style.display="";}
//----------------------------
function GetDivContent(which, DaPage, DaType, DaWidth, DaHeight)
{	
	//CHECK	
	if (!DaWidth>0){DaWidth=320;}
	if (!DaHeight>0){DaHeight=250;}
	//INIT
	DaContent="<center>";
	DaContent+="<b class='txt01w'>[ Aide ]</b> - ";
	DaContent+="[<a href='javascript:HideDiv(\"Div1\");' class='txt01w'>Fermer</a>]";
	DaContent+="</center>";
	DaContent+="<iframe id=HELP name='HELP' src='"+DaPage+"?reqtype="+DaType+"' width='100%' height='100%' scrolling='auto' frameborder='0' marginwidth='0' marginheight='0'></iframe>";
	//ACTION	
	oWhich=GetDaID(which);
	oWhich.style.width=DaWidth+20; oWhich.style.height=DaHeight+20;
	oWhich.innerHTML=DaContent;
	ShowDiv(which);
}
//----------------------------
function SwitchView(DaNum, DaMax)
{	
	for (i=1; i<=DaMax ; i++)
		{
			if(i==DaNum)	{HideDiv("SHORT"+i); ShowDiv("LONG"+i)}
			else					{ShowDiv("SHORT"+i); HideDiv("LONG"+i)}
		}
}
//----------------------------
// CONTACT 
//----------------------------
function CheckContact()
{	
	var Dis=document.FormCont; var bFlag=true
	if (!check_empty(Dis.Nom.value)){alert(ExpNom); Dis.Nom.focus(); bFlag=false;} 
	if (!check_empty(Dis.Prenom.value) && bFlag){alert(ExpPre); Dis.Prenom.focus(); bFlag=false;}
	if (!check_email(Dis.Email.value) && bFlag){alert(ExpEmail); Dis.Email.focus(); bFlag=false;}
	if (!check_empty(Dis.Msg.value) && bFlag){alert(ExpMsg); Dis.Msg.focus(); bFlag=false;}
	if (bFlag){Dis.submit();}
}
//----------------------------
function ResetContact()
{var Dis=document.FormCont; Dis.Nom.value=""; Dis.Prenom.value=""; Dis.Tel.value=""; Dis.Email.value=""; Dis.Msg.value="";}
//----------------------------
