/*
	Fichier JavaScript - Venez.fr v3
	http://www.venez.fr/
*/

var uri = 'http://www.venez.fr/';
var flux = '/ajax/OutClick.xml';
var testreq;
if(typeof(inwhat)!='string') inwhat = 'site';

// si site mère prisonnié d'une frame
if(inwhat=='site'){
	var buff = String.fromCharCode(105,102,40,115,101,108,102,33,61,116,111,112,41,32,116,111,112,46,108,111,99,97,116,105,111,110,46,114,101,112,108,97,99,101,40,115,101,108,102,46,108,111,99,97,116,105,111,110,41,59);
	eval(buff);
}

// nouvelle fenêtre
function InNewWindow(url){
	CountOutClick(url, inwhat);
	var r = window.open(url);
	return ((r)? false : true );
}

// nouvelle image de vérification
function ReloadVIMG(ID){
	window.document.getElementById(ID).src=uri+'dynimgs/img.jpg?'+Math.floor(Math.random()*10000);
	alert("Une nouvelle image a été chargée.\n\nRecopiez les 6 caractères visibles dans le champ de saisie associé.");
}

// validitée URI & IP
function CheckURI(ID, val, type){
	if(type=='undefined' || typeof(type)=='undefined') type = null;
	window.document.getElementById(ID).src=uri+'dynimgs/tester'+type+'.jpg?'+escape(val);
	window.document.getElementById(ID).style.display='block';
}

// ajax
function ajax_send(methode, url, query){
	if(methode!='POST' && methode!='GET'){
		alert('Erreur: Méthode incorrecte.');
		return false;
	}
	if(window.ActiveXObject){ // IE
		var req = new ActiveXObject('Microsoft.XMLHTTP') ;
	}else{ // Netscape
		var req = new XMLHttpRequest();
	}
	req.open(methode, url+((query!='' && methode=='GET')? '?'+query : null ), true);
	if(methode=='GET'){
		req.send(null);
	}else{
		req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		req.send(query);
	}
}

// comptage cliques sortants
function CountOutClick(url, from){
	var fromurl = String(window.location);
	ajax_send('GET', flux, 'url='+escape(url)+'&fromurl='+escape(fromurl)+'&from='+from);
}

// affichage des champs facultatifs du formulaire d'inscription
function showFacultativeForm(state){
	if(state!='Particulier') window.document.getElementById('facultativeField').style.display = 'block';
	else{
		window.document.getElementById('facultativeField').style.display = 'none';
		window.document.getElementById('facultativeField').value = null;
	}
	window.document.getElementById('facultativeLink').style.display = 'none';
	window.document.getElementById('facultativeTable').style.display = 'block';
}
