// JavaScript Document

function win_open(link){

	window.open(link, "_blank");

}


<!-- // Hide script from older browsers 
// script by http://www.hypergurl.com 


function addBookmark(title,url) {
	if (window.sidebar) { 
		window.sidebar.addPanel(title, url,""); 
	} else if( document.all ) {
		window.external.AddFavorite( url, title);
	} else if( window.opera && window.print ) {
		return true;
	}
}

function switchLanguage(switch_to){
	var actual_language = Cookie.get("LANGUAGE");
/*
	if(actual_language == "false" || actual_language == "false" || actual_language == ""){
		actual_language = "EN";
		Cookie.set("LANGUAGE", actual_language,{duration:7});
	}
	
	if(actual_language == "EN"){*/
		Cookie.set("LANGUAGE", switch_to,{duration:7});
		var lng_add = switch_to;
//		document.location = "http://www.tropdimagination.ca";
/*	}else{
		Cookie.set("LANGUAGE", "EN",{duration:7});
		var lng_add = "EN";
//		document.location = "http://www.toomuchimagination.ca";
	}
*/	
	document.location = "http://209.44.99.163/debut.php?lng_add=" + lng_add;
}

function page_reload(){
	document.location.reload();
}

function save_xml_score(){
	var my_step = $( zones[active_zone][active_step] );
	var forms = my_step.getElementsByTagName("form");
	
	
	var actual_score = 0, step_score;
		
	if(typeof(score_points[active_zone - 1]) != "undefined"){
		for(i = 0; i < score_points[active_zone - 1].length; i++){
			step_score = parseInt(score_points[active_zone - 1][i]);
			if(!isNaN(step_score) )
				actual_score = actual_score + step_score;
		}
	}
	
	var url = "player_score.php?zone=" + active_zone + "&score=" + actual_score;

	if(forms.length> 0){
		var form = forms[0];
		//alert(url + " : " + form.innerHTML);
		var myAjax = new Ajax(url, {data:form, method: 'post', onSuccess: confirm_score} );
		myAjax.request();
	}
	
}

function confirm_score(response, xmlDoc){

	var my_step = $( zones[active_zone][active_step] );
	var forms = my_step.getElementsByTagName("form");
	var actual_language = LANGUAGE;//Cookie.get("LANGUAGE");
	
	if(forms.length> 0){
		
		var form = forms[0];
		if(response.indexOf("OK") > -1){
			if(actual_language == "FR")
				form.innerHTML = "<span style=\"color:#7FA085;\">Merci!<br />Bonne chance pour la prochaine zone!</span>";
			else
				form.innerHTML = "<span style=\"color:#7FA085;\">Thank you!<br />Good luck for the next zone!</span>";
			delete_cookies_from_zone(active_zone);
		}else{
			form.innerHTML = "<span style=\"color:#C04211;\">Une erreur s'est produite, veuillez essayer de nouveau</span>";
		}
	}
}

function delete_cookies_from_zone(id_zone){
	var steps_available = zones[id_zone];
	
	if(steps_available.length > 0){
	
		var i = 0, form;
		for(i = 0;  i < steps_available.length; i++){

			Cookie.set("z" + id_zone + "s" + i, "",{duration:7});
			Cookie.set("z" + id_zone + "s" + i + "color", "",{duration:7});
			Cookie.set("z" + id_zone + "s" + i + "score", "",{duration:7});
			
		}
	
	}
	
}


function send_xml_to_a_friend(){
	
	var form = $( "staf_form" );
	var mb = $( "message_back" );	
	
	var url = "mailer.php";

	if(typeof form != "undefined"){
		var myAjax = new Ajax(url, {data:form, method: 'post', onSuccess: send_xml_to_a_friend_confirmed} );
		myAjax.request();

		mb.style.visibility = "hidden";
	}
	
}

function send_xml_to_a_friend_confirmed(response, xmlDoc){

	var form = $( "staf_form" );
	var mb = $( "message_back" );
	var actual_language = LANGUAGE;
	
	if(typeof form != "undefined"){
		
		
		if(response.indexOf("OK-EMAIL") > -1){
			form.reset();
			//mb.style.visibility = "visible";
			if(actual_language == "FR")
				form.innerHTML = "<span style=\"color:#7FA085;\">Merci</span>";
			else
				form.innerHTML = "<span style=\"color:#7FA085;\">Thank you</span>";
		}else{

		}
	}
	
}
