function _(o) {
	if (!o) return false;
	if (!document.getElementById) return false;
	if (!document.getElementById(o)) return false;
	return document.getElementById(o);
}

function init() {

}

function xhrRequest(type) {
	var xhrSend;
	if (!type) {
		type = 'text';
	}
	if (window.ActiveXObject) {
		try {
			xhrSend = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xhrSend = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	} else if (window.XMLHttpRequest) {
		xhrSend = new XMLHttpRequest();
		if (xhrSend.overrideMimeType) {
			xhrSend.overrideMimeType('text/' + type);
		}
	}
	return (xhrSend);
}

function save_stats_openForm(lng) {
	var xhrRec = xhrRequest('html');
	xhrRec.onreadystatechange = function() {
		if(xhrRec.readyState == 4 && xhrRec.status == 200) {
			return;
		}
	}
	xhrRec.open("POST","ajax_jaguar.php",true);
	xhrRec.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhrRec.send("lng="+lng);
}

function openMentions(lng) {
	v_w=600; v_h=800; v_t=0; v_l=100;
	myUrl = 'vinclude/mentions_legales_'+lng+'.html';
	if (lng=='fr') { myTitle = "Jaguar :: Mentions légales"; }
	if (lng=='nl') { myTitle = "Jaguar :: Wettelijke bepalingen"; }
	if (document.all) { myTitle='_blank'; v_w=600; }
	myStats = "toolbar=no,location=no,directories=no,status=no,scrollbars=no,menubar=yes,resizable=0,width="+v_w+",height="+v_h+",left="+v_l+",top="+v_t;
	mywin=window.open(myUrl,myTitle,myStats);
	mywin.focus();	
}
function openForm(lng) {	
	v_w=605; v_h=685; v_t=0; v_l=100;
	if (lng=='fr') {
		myUrl = 'https://forms.jaguar.com/testdrive.aspx?marketid=10&langid=14';
		myTitle = "Jaguar XF :: Essayez-la !";
	} else if (lng=='nl') {
		myUrl = 'https://forms.jaguar.com/testdrive.aspx?marketid=10&langid=13';
		myTitle = "Jaguar XF :: Test Drive";
	} else {
		return false;
	}
	save_stats_openForm(lng);
	if (document.all) myTitle='_blank';
	myStats = "toolbar=no,location=no,directories=no,status=no,scrollbars=yes,menubar=no,resizable=yes,width="+v_w+",height="+v_h+",left="+v_l+",top="+v_t;
	mywin=window.open(myUrl,myTitle,myStats);
	mywin.focus();	
}
