function openLightBox(file, div) 
{
	$('#'+div).html('');
	display_lightbox();
	$.get(file, function(data){
		$('#'+div).append($(data));
	});
}
function send(civility,token,name,firstname,address,postcode,city,phone,email,buycity,captcha) {
	for(var i=0;i<3;i++){
		if(civility[i].checked) var civility_value=civility[i].value;
	}
	makePOSTRequest("submit_form.php", "civility="+civility_value+"&token="+token+"&name="+name+"&firstname="+firstname+"&address="+address+"&postcode="+postcode+
	"&phone="+phone+"&email="+email+"&buycity="+buycity+"&captcha="+captcha+"&city="+city);
}

function callRequest(civility,name,firstname,address,city,postcode,phone,email,buycity,token,captcha,is_OK) 
{
	var civilities = ["M.","Mme","Mlle"];
	var civility_value = civilities[civility];
	tb_show(null, "index.php?no_html=true&is_OK="+is_OK+"&civility="+civility_value+"&token="+token+"&name="+name+"&firstname="+firstname+"&address="+address+"&postcode="+postcode+
"&phone="+phone+"&email="+email+"&buycity="+buycity+"&captcha="+captcha+"&city="+city+"&keepThis=true&TB_iframe=true&height=400&width=600",null);
}
function makePOSTRequest(url, params) {
	http_request = false;
	if (window.XMLHttpRequest) { 
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/html');
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			}
		}
		if (http_request==null) {
			alert('Cannot create XMLHTTP instance');
			return false;
		}
		http_request.onreadystatechange = alertContents;
		http_request.open('POST', url, true);
		if (params!=null){ 
			http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			http_request.setRequestHeader("Content-length", params.length);
			http_request.setRequestHeader("Connection", "close");
			http_request.send(params);
		}
	else {
		http_request.send(null);
	}
	return 1;
}
function alertContents() {
	if (http_request==null) {alert('Petit probl&egrave;me...');return false;}
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			var dataText = http_request.responseText;
			document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block';
			document.getElementById('light_msg').innerHTML=dataText;
		} 
	}
}
function align() {
	var container = document.documentElement;
	if(container)
	{
		var containerHeight;var containerWidth;
		if (container.innerWidth)
		{
			containerWidth = container.innerWidth;
			containerHeight = container.innerHeight;
		}
		else
		{
			containerWidth = container.clientWidth;
			containerHeight = container.clientHeight;
		}
		var x = Math.ceil((containerWidth - 600) / 2);
		var y = Math.ceil((containerHeight - 370) / 2);
		document.getElementById("light").style.position = "absolute";
		document.getElementById("light").style.top = y + "px";
		document.getElementById("light").style.left = x + "px";
	}
}
function display_lightbox() {
	document.getElementById('light').style.display='block';
	document.getElementById('fade').style.display='block';
	align();
}
function getFileContent(file)
{
    if(window.XMLHttpRequest) obj = new XMLHttpRequest(); //Pour Firefox, Opera,...
    else if(window.ActiveXObject) obj = new ActiveXObject("Microsoft.XMLHTTP"); //Pour Internet Explorer 
    else return(false);
   
    if (obj.overrideMimeType) obj.overrideMimeType("text/xml"); //Évite un bug de Safari

    obj.open("GET", file, false);
    obj.send(null);
   
    if(obj.readyState == 4) return(obj.responseText);
    else return(false);
}
