var nickidol="";
var citydio=-1;
var ageuq="";
var typum=2;
var sauvy="";

var townzz="";


var largum;
var hautum;

var decalbras=0;

var cookav=0;

var referenz="0";

var largj=995;
var hautj=600;

var iko;

var huko="";
function tailleur()
{

huko=""+location;

urlprinc="http://www.coco.fr/chat/";	
/*				
if(huko.indexOf('coco')<0)
{
	
	var ugt=huko.indexOf(".com");
	var ugt1=huko.indexOf("www")+4;
	var ugt2=huko.indexOf("//")+2;
	
	if(ugt1<5)
	ugt1=ugt2;
	
	var sito=huko.substring(ugt1,ugt);
	
	document.getElementById("tchater").innerHTML=sito+".com";
	
	document.getElementById("desc").innerHTML="Decouvre qui t'a bloqué sur MSN ... <br><div style='position:absolute;left:0;top:30;width:420;font-weight:bold;font-size:14;z-index:2;'>(rentre d'abord sur le tchat avec un pseudo quelconque)</div>"
	
	urlprinc="http://www."+sito+".com/NEO2/";
	
//location="http://www.coco.fr/";	
}
*/
if(navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPod/i))
{
if(huko.indexOf("iphone")<0)
document.location="iphone.html";
} 

	
	decalbras=0;
	
	//document.getElementById("corprince").style.left=largum/2-460;
	
	
document.getElementById("nicko").focus();

cookav= Math.floor(Math.random()*890000000)+100000000;
	
var infor=LireCookie("coda");
if(infor!=null)
{



var wix1=infor.indexOf('#',0);
var wix2=infor.indexOf('#',wix1+1);
var wix3=infor.indexOf('#',wix2+1);
var wix4=infor.indexOf('#',wix3+1);

document.getElementById("nicko").value=infor.substring(0,wix1);

typum=infor.substring(wix1+1,wix2);
//if(typum==1)
//document.chatform.typeo[0].checked=true;
//if(typum==2)
//document.chatform.typeo[1].checked=true;
ageuq=infor.substring(wix2+1,wix3);
document.getElementById("ageu").value=ageuq;

townzz=infor.substring(wix3+1,wix4);
document.getElementById("zipo").style.width=townzz.length*10+6;
document.getElementById("zipo").value=townzz;



citygood=infor.substring(wix4+1,wix4+6);
citydio=citygood;

/*
if(infor.length>(wix4+9))
{
	cookav=infor.substring(wix4+9,wix4+18);
	//cookpass=infor.substring(wix4+18,wix4+24);
}
*/
decalbras=370;
rafraibras();
document.getElementById("messageo").innerHTML="Appuyez pour Entrer";
document.getElementById("messageo").style.top=371;
document.getElementById("messageo").style.left=222;
}



	
}



function checode(e)
{
	var autorisation=true;
	 var cocode=e.keyCode? e.keyCode : e.charCode;
	 
	 
	 if ((cocode<48)||(cocode>57))
	{
		autorisation=false;
		if (cocode==8)
		autorisation=true;
	}
	return autorisation;

	 
}

function checar(e)
{
	var autorisation=false;
	 var cocode=e.keyCode? e.keyCode : e.charCode;
	if ((cocode>47)&&(cocode<58))
	autorisation=true;
	if (cocode==8)
	autorisation=true;
	if ((cocode>64)&&(cocode<91))
	autorisation=true;
	if ((cocode>96)&&(cocode<123))
	autorisation=true;
	
	return autorisation;

	 
}



function verifPseudo(pseudo)
{
	
	
	if(pseudo.length==5)
	{
		if (pseudo.indexOf("0",0)==0)
		{
		pseudo=pseudo.substring(1,5);
		}
		
		
		
		
		var headTag = document.getElementsByTagName("head").item(0); 
		var scriptTag = document.createElement("script"); 
		scriptTag.src = "http://www.coco.fr/cocoland/"+pseudo+".js";
		//headTag.appendChild( scriptTag );
		headTag.replaceChild( scriptTag, headTag.childNodes[5] );

	}
	
}




function procecodo()
{
	

document.getElementById("validum").focus();

document.getElementById("deroulante").options.length = 0;  //clear all the city list


var arville=new Array();

var comptak=true;
var comptaki=0;
var transius="";
var endino=0;
var startum=0;



while(comptak)
{


endino=cityco.indexOf("*",startum);
transius=cityco.substring(startum,endino);


if (cityco.length<endino+2)
comptak=false;
else
{
startum=endino+1;		
}
if ((comptaki%2)!=0)
{
	document.getElementById("deroulante").options[(comptaki-1)/2]=new Option(transius,arville[(comptaki-1)/2]);
	
}
else
{
	arville[comptaki/2]=transius;
}



comptaki++;
}



if(comptaki<16)
document.getElementById("deroulante").size=comptaki/2+1;
else
document.getElementById("deroulante").size=9;

if(comptaki==2)
{
document.getElementById("zipo").value=transius;
townzz=transius;
document.getElementById("zipo").style.width=transius.length*10+6;

clickvalid();
citydio=arville[0];
refrum();
}
else
document.getElementById("deroulante").style.visibility="visible";



	

	
	



}



function townselecto(kabu)
{

	townzz=document.getElementById("deroulante").options[kabu].text;
	document.getElementById("zipo").value=townzz;
	document.getElementById("zipo").style.width=townzz.length*10+6;
	
	
	document.getElementById("validum").focus();
	citydio=document.getElementById("deroulante").options[kabu].value;
	refrum();
	decalbras=360;
	rafraibras();
	document.getElementById("deroulante").style.visibility="hidden";
	verifok();
	
	
	
	
}


function refrum()
{
	

	//document.getElementById("debugo").innerHTML=nickidol+"#"+typum+"#"+ageuq+"#"+citydio;
	
}

function refrnick()
{
	nickidol=document.getElementById("nicko").value;
	refrum();
	
}

function refrage()
{
	ageuq=document.getElementById("ageu").value;
	if(ageuq.length>1)
	{
		if (ageuq<15)
		{
			alert("vous devez avoir au moins 15 ans pour rentrer");
			document.getElementById("ageu").value="";
		}

		if (ageuq>89)
		document.getElementById("ageu").value=89;	

		
		verifok();
	}
	
}
function refrsex(dno)
{
	
	typum=dno;
	refrum();
	verifok();
	
}

function rafraibras()
{
	document.getElementById("flecho").style.top=decalbras;
}	


function clickage()
{
ageuq=0;
document.getElementById("ageu").value="";
document.getElementById("ageu").focus();

document.getElementById("messageo").innerHTML="Entrez votre age";

document.getElementById("messageo").style.top=271;
document.getElementById("messageo").style.left=250;



decalbras=270;
rafraibras();	
	
}

function clicktown()
{
document.getElementById("zipo").focus();
document.getElementById("zipo").value="";
document.getElementById("zipo").style.width=60;
citydio=-1;
decalbras=320;
rafraibras();


document.getElementById("deroulante").style.visibility="hidden";

document.getElementById("messageo").innerHTML="Entrez votre Code Postal";
document.getElementById("messageo").style.top=322;
document.getElementById("messageo").style.left=190;

	
}

function clickvalid()
{
	decalbras=370;
	rafraibras();	
	document.getElementById("validum").focus();
	document.getElementById("messageo").innerHTML="Appuyez pour Entrer";
	document.getElementById("messageo").style.top=371;
	document.getElementById("messageo").style.left=222;
}
	





function verifok()
{
	if(ageuq<1)
	{
	
	clickage();
	}
	else
	{
		
		if(citydio<0)
		{
			
			clicktown();
		}
		else
		{
			clickvalid();
		}
	}	
	
	
}


function clearaz()
{
EcrireCookie("coda", "");	
document.getElementById("zipo").value="";	
document.getElementById("ageu").value="";
document.getElementById("nicko").value="";
}


function validatio()
{
	
	nickidol=document.getElementById("nicko").value;
	if (nickidol.length>3)
	{
		
		ageuq=document.getElementById("ageu").value;
		
		if (ageuq>14)
		{
			if (citydio>-1)
			{
				refrum();
				var citygood="";
				citygood=citydio;
				if (citygood.length!=5)
				{
					if (citygood.length==1)
					citygood="0000"+citygood;
					if (citygood.length==2)
					citygood="000"+citygood;
					if (citygood.length==3)
					citygood="00"+citygood;
					if (citygood.length==4)
					citygood="0"+citygood;
				}
				
				var sume=0;
				for (i=0; i<nickidol.length; i++) 
				{
					var ujm=nickidol.charCodeAt(i);
					if((ujm<95)&&(ujm>59))
					sume++;
				}
				if(sume>4)
				nickidol=nickidol.toLowerCase();

				var infom=nickidol+"#"+typum+"#"+ageuq+"#"+townzz+"#"+citygood+"#0#"+cookav+"#";
				
				
				EcrireCookie("coda", infom);
				
				
				if(referenz.length>2)
				{
					largj=902;
					hautj=610;
				}
					
				var rff=Math.floor(Math.random()*1000);
				
				
				var operis=true;
				if(navigator.userAgent.indexOf("Opera")!=-1)
				{
					operis=false;
				}
				
				
				if(sauvy.length<2)
				sauvy=cookav;
				
				if(huko.indexOf("iphone")>-1)
				{
					//urlprinc="chat/ifun.html";
					largj=380;
					hautj=450;
				}
				
				
				if(operis)
				iko=window.open(urlprinc+"#"+nickidol+"#"+typum+"#"+ageuq+"#"+citygood+"#0#"+sauvy+"#"+referenz+"#","coco","status=yes ,toolbar=no , location=yes , resizable="+resoz+", width="+largj+", height="+hautj+",scrollbars=yes");
				else
				location=urlprinc+"#"+nickidol+"#"+typum+"#"+ageuq+"#"+citygood+"#0#"+sauvy+"#"+referenz+"#";
				
				iko.focus();
				
				
			}
			else
			alert("Le code postal que vous avez rentré n'est pas valide.");
		}
		else
		alert("vous devez avoir au moins 15 ans pour rentrer");
	}
	else
	alert("votre pseudo doit contenir au moins 4 lettres !");
	
	
	
	
	
}

function opin()
{
	setTimeout("opan()",2000);
	
}
function opan()
{
	alert("eee");
	
}


function EcrireCookie(nom, valeur)
{
var dato=new Date;
dato.setFullYear(dato.getFullYear()+10);
var argv=EcrireCookie.arguments;
var argc=EcrireCookie.arguments.length;
var expires=dato;

document.cookie=nom+"="+escape(valeur)+"; expires="+expires.toGMTString();


}


function getCookieVal(offset)
{

var endstr=document.cookie.indexOf (";", offset);
if (endstr==-1) endstr=document.cookie.length;
return unescape(document.cookie.substring(offset, endstr)); 
}
function LireCookie(nom)
{

var arg=nom+"=";
var alen=arg.length;
var clen=document.cookie.length;
var i=0;
while (i<clen)
{

var j=i+alen;
if (document.cookie.substring(i, j)==arg) return getCookieVal(j);
i=document.cookie.indexOf(" ",i)+1;
if (i==0) break;


}
return null; 
}
	
	
	
	



