function gourl(varchar) {
//	window.location.replace(""+varchar+"");
	window.location.href = ""+varchar+""; 
}

function gourl2(varchar) {
	window.open(""+varchar+"");
}

function checksearch() {
	var theForm = document.form_search;
	if (theForm.q.value=="") {
		theForm.q.value = "Veuillez remplir ce champ.";
		theForm.q.focus();
		return;
	}
	theForm.action="/jeux-video-cherche/"+theForm.q.value+".html";
	theForm.submit();
}

function checkcomp() {
	var theForm = document.form_comp;
	if (theForm.r.value=="") {
		theForm.r.value = "Veuillez remplir ce champ.";
		theForm.r.focus();
		return;
	}
	theForm.action="/comparateur-jeu-video/"+theForm.r.value+",1,0.html";
	theForm.submit();
}

function checkcomp2() {
	var theForm = document.form_comp2;
	if (theForm.prix.value>0) {
		theForm.action="/comparateur-jeu-video/"+theForm.r.value+","+theForm.prix.value+",0.html";
	}
	else {
		theForm.action="/comparateur-jeu-video/"+theForm.r.value+",0,0.html";
	}
	theForm.submit();
	document.getElementById("actu1").innerHTML = '<p align="center"><img src="/_img/loading.gif" width="32" height="32" /></p>';
}



function checkcomp3() {
	var theForm = document.form_comp3;
	if (theForm.r.value=="") {
		theForm.r.value = "Veuillez remplir ce champ.";
		theForm.r.focus();
		return;
	}
	theForm.action="/comparateur-jeu-video/"+theForm.r.value+",1,0.html";
	theForm.submit();
}

function createQCObject() { 
   var req; 
   if(window.XMLHttpRequest){ 
      // Firefox, Safari, Opera... 
      req = new XMLHttpRequest(); 
   } else if(window.ActiveXObject) { 
      // Internet Explorer 5+ 
      req = new ActiveXObject("Microsoft.XMLHTTP"); 
   } else { 
      alert('Problem creating the XMLHttpRequest object'); 
   } 
   return req; 
} 

var http = createQCObject(); 

function handleMailInputOver(o,t) {
	if(t==o.value) {
		o.value = "";
	}
	o.focus();
}

function handleMailInputOut(o,t) {
	if(o.value=="") {
		o.value = t;
	}
}


function verif_champ(champ) {
	var chiffres = new RegExp("[-a-zA-Z0-9_'éèçàù@,;:!?.$£¤*=+})°@|('{#&%^ ]");
	var verif;

	for(x = 0; x < champ.value.length; x++) {
		verif = chiffres.test(champ.value.charAt(x));
		if(verif == false){champ.value = champ.value.substr(0,x) + champ.value.substr(x+1,champ.value.length-x+1); x--;}
	}
}


function verif_nombre(champ) {
	var chiffres = new RegExp("[0-9\+]");
	var verif;
	var points = 0;

	for(x = 0; x < champ.value.length; x++) {
		verif = chiffres.test(champ.value.charAt(x));
		if(champ.value.charAt(x) == "."){points++;}
		if(points > 1){verif = false; points = 1;}
		if(verif == false){champ.value = champ.value.substr(0,x) + champ.value.substr(x+1,champ.value.length-x+1); x--;}
	}
}




/* Compte */
function checkFormCompte2(ci,cp,no,pr,lo,pa,em,ne) {
	http.open('GET', '/ajax.compte2.php?ci='+ci+'&cp='+cp+'&no='+no+'&pr='+pr+'&lo='+lo+'&pa='+pa+'&em='+em+'&ne='+ne+'');
	http.onreadystatechange = function() {
		if(http.readyState == 4 && http.status == 200) { 
			var response = http.responseText;
			if(response) {
				document.getElementById("compte_error").innerHTML = http.responseText;
			} 
		} 
	} 
	http.send(null);
}

function affichecompte(o,n) {
	if (o==1) {
		document.getElementById('calque2').style.display = "block";
		http.open('GET', 'http://www.consollection.com/ajax.compte1.php?n='+n);
		http.onreadystatechange = function() {
			if(http.readyState == 4 && http.status == 200) { 
				var response = http.responseText;
				if(response) {
					document.getElementById('popin2').innerHTML = response;
				} 
			} 
		} 
		http.send(null);
	}
	if (o==2) {
		document.getElementById('calque2').style.display = "none";
		document.getElementById('popin2').innerHTML = "";
	}
	
}

function checkFormCompte(){
	var civ2;
	var targetContainer = document.getElementById('compte_error');
	var theForm = document.form_compte;
	if ((theForm.civ[0].checked==false) && (theForm.civ[1].checked==false) && (theForm.civ[2].checked==false))  {
		txt = "Veuillez sélectionner votre 'civilité'";
		targetContainer.innerHTML = txt;
		return;
	}
	if (theForm.cp.value=="") {
		txt = "Veuillez remplir le champ 'Code postal'";
		targetContainer.innerHTML = txt;
		theForm.cp.focus();
		theForm.cp.style.border = '1px solid #FF0000';
		return;
	}
	else {
		theForm.cp.style.border = '1px solid #424242';
	}
	if (theForm.cp.value.length<5) {
		txt = "Veuillez modifier votre 'Code postal'";
		targetContainer.innerHTML = txt;
		theForm.cp.focus();
		theForm.cp.style.border = '1px solid #FF0000';
		return;
	}
	else {
		theForm.cp.style.border = '1px solid #424242';
	}
	if (theForm.nom.value=="") {
		txt = "Veuillez remplir le champ 'Nom'";
		targetContainer.innerHTML = txt;
		theForm.nom.focus();
		theForm.nom.style.border = '1px solid #FF0000';
		return;
	}
	else {
		theForm.nom.style.border = '1px solid #424242';
	}
	if (theForm.prenom.value=="") {
		txt = "Veuillez remplir le champ 'Prénom'";
		targetContainer.innerHTML = txt;
		theForm.prenom.focus();
		theForm.prenom.style.border = '1px solid #FF0000';
		return;
	}
	else {
		theForm.prenom.style.border = '1px solid #424242';
	}
	if (theForm.login.value=="") {
		txt = "Veuillez remplir le champ 'Login'";
		targetContainer.innerHTML = txt;
		theForm.login.focus();
		theForm.login.style.border = '1px solid #FF0000';
		return;
	}
	else {
		theForm.login.style.border = '1px solid #424242';
	}
	if (theForm.login.value.length<3) {
		txt = "Veuillez choisir un 'Login' de plus 3 caracteres";
		targetContainer.innerHTML = txt;
		theForm.login.focus();
		theForm.login.style.border = '1px solid #FF0000';
		return;
	}
	else {
		theForm.login.style.border = '1px solid #424242';
	}
	if (theForm.pass.value=="") {
		txt = "Veuillez remplir le champ 'Mot de passe'";
		targetContainer.innerHTML = txt;
		theForm.pass.focus();
		theForm.pass.style.border = '1px solid #FF0000';
		return;
	}
	else {
		theForm.pass.style.border = '1px solid #424242';
	}
	if (theForm.pass.value.length<5) {
		txt = "Veuillez choisir un 'Mot de passe' de plus 5 caracteres";
		targetContainer.innerHTML = txt;
		theForm.pass.focus();
		theForm.pass.style.border = '1px solid #FF0000';
		return;
	}
	else {
		theForm.pass.style.border = '1px solid #424242';
	}
	if (theForm.email.value!="") {
		var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
		var check=/@[\w\-]+\./;
		var checkend=/\.[a-zA-Z]{2,3}$/;
		var bEmailCheck = true ;
		if(((theForm.email.value.search(exclude) != -1)||(theForm.email.value.search(check)) == -1)||(theForm.email.value.search(checkend) == -1)){
			txt = "L'adresse \'E-mail\' est incorrecte !";
			targetContainer.innerHTML = txt;
			theForm.email.focus();
			theForm.email.style.border = '1px solid #FF0000';
			return;
		}
		else {
			theForm.email.style.border = '1px solid #424242';
		}
	} 
	if (theForm.email.value=="") {
		txt = "Veuillez remplir le champ 'e-mail'";
		targetContainer.innerHTML = txt;
		theForm.email.focus();
		theForm.email.style.border = '1px solid #FF0000';
		return;
	}
	else {
		theForm.email.style.border = '1px solid #424242';
	}
	for (var i=0; i<3;i++) {
		if (theForm.civ[i].checked) {
			civ2 = theForm.civ[i].value;
		}
	}

	checkFormCompte2(civ2,theForm.cp.value,theForm.nom.value,theForm.prenom.value,theForm.login.value,theForm.pass.value,theForm.email.value,theForm.newsletter.value);
}

/* Connextion */

function checkFormConnexion2(lo,pa,u) {
	http.open('GET', '/ajax.connexion2.php?lo='+lo+'&pa='+pa+'&u='+u+'');
	http.onreadystatechange = function() {
		if(http.readyState == 4 && http.status == 200) { 
			var response = http.responseText;
			if(response) {
				document.getElementById("compte_error2").innerHTML = http.responseText;
			} 
		} 
	} 
	http.send(null);
}

function afficheconnexion(o,u) {
	if (o==1) {
		document.getElementById('calque2').style.display = "block";
		http.open('GET', 'http://www.consollection.com/ajax.connexion1.php?u='+u+'');
		http.onreadystatechange = function() {
			if(http.readyState == 4 && http.status == 200) { 
				var response = http.responseText;
				if(response) {
					document.getElementById('popin2').innerHTML = response;
				} 
			} 
		} 
		http.send(null);
	}
	if (o==2) {
		document.getElementById('calque2').style.display = "none";
		document.getElementById('popin2').innerHTML = "";
	}
	
}

function checkFormConnexion(){
	var targetContainer = document.getElementById('compte_error2');
	var theForm = document.form_connexion;
	if (theForm.login.value=="") {
		txt = "Veuillez remplir le champ 'Login'";
		targetContainer.innerHTML = txt;
		theForm.login.focus();
		theForm.login.style.border = '1px solid #FF0000';
		return;
	}
	else {
		theForm.login.style.border = '1px solid #424242';
	}
	if (theForm.pass.value=="") {
		txt = "Veuillez remplir le champ 'Mot de passe'";
		targetContainer.innerHTML = txt;
		theForm.pass.focus();
		theForm.pass.style.border = '1px solid #FF0000';
		return;
	}
	else {
		theForm.pass.style.border = '1px solid #424242';
	}

	checkFormConnexion2(theForm.login.value,theForm.pass.value,theForm.u.value);
}

/* Perdu */
function checkFormPerdu2(em) {
	http.open('GET', '/ajax.connexion3.php?em='+em+'');
	http.onreadystatechange = function() {
		if(http.readyState == 4 && http.status == 200) { 
			var response = http.responseText;
			if(response) {
				document.getElementById("compte_error3").innerHTML = http.responseText;
			} 
		} 
	} 
	http.send(null);
}

function checkFormPerdu(){
	var targetContainer = document.getElementById('compte_error3');
	var theForm = document.form_connexion2;
	
	if (theForm.email.value!="") {
		var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
		var check=/@[\w\-]+\./;
		var checkend=/\.[a-zA-Z]{2,3}$/;
		var bEmailCheck = true ;
		if(((theForm.email.value.search(exclude) != -1)||(theForm.email.value.search(check)) == -1)||(theForm.email.value.search(checkend) == -1)){
			txt = "L'adresse \'E-mail\' est incorrecte !";
			targetContainer.innerHTML = txt;
			theForm.email.focus();
			theForm.email.style.border = '1px solid #FF0000';
			return;
		}
		else {
			theForm.email.style.border = '1px solid #424242';
		}
	} 
	if (theForm.email.value=="") {
		txt = "Veuillez remplir le champ 'e-mail'";
		targetContainer.innerHTML = txt;
		theForm.email.focus();
		theForm.email.style.border = '1px solid #FF0000';
		return;
	}
	else {
		theForm.email.style.border = '1px solid #424242';
	}

	checkFormPerdu2(theForm.email.value);
}

function checkFormCommentaire() {
	var targetContainer = document.getElementById('compte_error4');
	var theForm = document.form_commentaire;
	if (theForm.com.value=="") {
		txt = "Veuillez ajouter votre commentaire.";
		targetContainer.innerHTML = txt;
		theForm.com.focus();
		theForm.com.style.border = '1px solid #FF0000';
		return;
	}
	else {
		theForm.com.style.border = '1px solid #424242';
	}
	theForm.action=""+theForm.goform.value+"";
	theForm.submit();
}



gLoadSpinnerUrl = '/_img/loading.gif';
gFailImage = '/_img/loading.gif';

function LoadImage(pSelector, pCallback) {
	var loader = $(pSelector);
	loader.html('<img src="' + gLoadSpinnerUrl + '" />');
	LoadThisImage($(img), loader, pCallback);
}

function LoadThisImage(loader, pCallback) {
	image_src = loader.attr('src');
	img = new Image();
	$(img).hide();
	$(img).load( function() {
		cb_js = loader.get(0).getAttribute('onload');
		onload_cb = function() {
			eval(cb_js);
		}
		loader.html(this);
		loader.removeClass('loadable-image');
		loader.removeAttr('src');
		loader.removeAttr('onload');
		$(this).show();

		if (onload_cb) {
			onload_cb($(this));
		}
		if (pCallback) {
			cb = pCallback;
			cb($(this));
		}
	}).error( function() {
		$(this).attr('src', gFailImage).show();
	});
	if ( $(img).innerWidth() > $(img).innerHeight() ) {
		$(img).attr('src', image_src).show().addClass("imageboutique1");
/*		var temp1 = $(img).innerWidth();
		$(img).attr('src', image_src).show().css("width","140px").attr("width","140px");
		
		var temp1 = $(img).innerWidth();
		var temp  = (temp1/140);
//		alert(temp);
		var temp2 = Math.round( ($(img).innerHeight()/temp) );
		$(img).attr('src', image_src).show().css("height",""+temp2+"px");
	*/
	}
	else {
		$(img).attr('src', image_src).show().addClass("imageboutique2");
/*		var temp  =($(img).innerHeight()/120);
		$(img).attr('src', image_src).show().css("height","120px").attr("height","120px");
		alert(temp);
		var temp2 = Math.round(($(img).innerWidth()/temp));
		alert(temp2);
		
		$(img).attr('src', image_src).show().css("width",""+temp2+"px");
	*/}
	
}

function LoadAllImages() {
	$('.loadable-image').each( function() {
		var loader = $(this);
		loader.html('<img src="' + gLoadSpinnerUrl + '" />');
		LoadThisImage(loader);
	});
}

