function randomTop(toLoad) {
	$rand = Math.random();
	$rand = Math.round($rand);
	if($rand) {
		loadFlash('topKids');
		$('top_pic').src = "images/"+$varLang+"/top_childs.jpg"
	} else {
		$('top_pic').src = "images/"+$varLang+"/top_adults.jpg"
	}
	if(toLoad) {
		loadFlash(toLoad);
	}
}

function loadFlash() 
{
	var args = loadFlash.arguments;
	
	if($varLang == "fr") {
		newWidth = "250"; 
		newMargin = "455"
	} else {
		newWidth = "205"
		newMargin = "451"
	}

	for(i=0; i<args.length; i++) {
		switch(args[i]) {
			case 'homeAnim' : 
				var soAnim = new SWFObject("swf/home_video.swf", "home_video", "627", "350", "8", "#FFFFFF");
				soAnim.addParam("wmode", "transparent");
				soAnim.addVariable("page", "what.php");
				soAnim.addVariable("lang", $varLang);
				soAnim.write("home_anim");
				break;
			case 'topKidsHome' :
				var soTop = new SWFObject("swf/" + $varLang + "/kids_write.swf", "anim_top", newWidth, "115", "8", "#FFFFFF");
				soTop.addParam("wmode", "transparent");
				$('flash_top').style.marginLeft = newMargin + "px";
				soTop.write("flash_top");
				$('top_pic').src = "images/"+$varLang+"/top_childs.jpg";
				break;
			case 'topKids' :
				var soTop = new SWFObject("swf/"+ $varLang + "/kids_write.swf", "anim_top", newWidth, "115", "8", "#FFFFFF");
				soTop.addVariable("anim", "0");
				soTop.addParam("wmode", "transparent");
				$('flash_top').style.marginLeft = newMargin + "px";
				soTop.write("flash_top");
				break;
			case 'whatAnim' :
				var soAnim = new SWFObject("swf/" + $varLang + "/what.swf", "what_anim", "622", "394", "8", "#FFFFFF");
				soAnim.addParam("wmode", "transparent");
				soAnim.addVariable("lang", $varLang);
				soAnim.write("flash_what");
				break;
			case 'howto' :
				var soAnim = new SWFObject("swf/video.swf", "how_anim", "479", "360", "8", "#FFFFFF");
				soAnim.addParam("wmode", "transparent");
				soAnim.addVariable("lang", $varLang);
				soAnim.addVariable("lcId", lcId);
				soAnim.addVariable("movie", "introduce");
				soAnim.addVariable("version", version);
				soAnim.write("flash_howto");
				break;
			case 'allergist' :
				var soAnim = new SWFObject("swf/video.swf", "how_anim", "479", "360", "8", "#FFFFFF");
				soAnim.addParam("wmode", "transparent");
				soAnim.addVariable("lang", $varLang);
				soAnim.addVariable("movie", "allergist");
				soAnim.addVariable("version", version);
				soAnim.write("flash_allergist");
				break;
		}
	}
}

function setMenu(section) {
	var soMenu = new SWFObject("swf/" + $varLang + "/menu.swf", "menu_flash", "891", "45", "8", "#FFFFFF");
	soMenu.addVariable("section", section);
	soMenu.addVariable("lang", $varLang);
	
	if (typeof(LOGGED_IN) != "undefined")
	{
		soMenu.addVariable("logged_in", "true");
	}
	
	if (DICT_MODE == '1')
	{
		soMenu.addVariable("dict", "1");
	}
	else
	{
		soMenu.addVariable("dict", "0");
	}
	
	soMenu.addParam("wmode", "transparent");
	soMenu.write("menu");
}

function setType(newItem,texte) 
{
	var txtValue = document.getElementById(newItem);
	if(!txtValue.value || txtValue.value == texte) {
		txtValue.value = "";
	}
}
function resetType(newItem,texte) 
{
	var txtValue = document.getElementById(newItem);
	if(!txtValue.value) {
		txtValue.value = texte;
	} 
}
function showPass() 
{
	var txtValue = document.getElementById('password');
	var txtValue2 = document.getElementById('password_temp');
	txtValue.style.display = "block";
	txtValue2.setAttribute("disabled",true)
	txtValue2.style.display = "none";
	txtValue.focus();
}
function hidePass() 
{
	var txtValue = document.getElementById('password');
	var txtValue2 = document.getElementById('password_temp');
	if(!txtValue.value) {
		txtValue.style.display = "none";
		txtValue.value = "";
		txtValue2.style.display = "block";
		txtValue2.removeAttribute("disabled")
	}
}

/*
function lostpassword() {
	if ($('clearsite_password').style.display == "none")
	{
		$('clearsite_password').style.display = "block";
		$('lost_password').style.display = "block";
		$('clearsite_password').style.width = document.documentElement.scrollWidth + "px";
		$('clearsite_password').style.height = document.documentElement.scrollHeight + "px";
		$('lost_password').style.marginTop = document.body.clientHeight / 2 - 150 + "px";
		//alert();
	}
	else
	{
		$('clearsite_password').style.display = "none";
		$('lost_password').style.display = "none";
		$('clearsite_password').style.width = "0px";
		$('clearsite_password').style.height = "0px";
	}
}
*/

function send_question()
{
	if ($('input_question').value != "" && $('input_iagree').checked == true)
	{
		var req = new AJAX.Request('expert.php',
			{
				method: 'GET',
				parameters: ['action=send_question', 'question=' + encode64($('input_question').value)],
				onComplete : function(e) {ajax_eval(e.responseText)} 
			}			
		);
	}
	else
	{
		if ($('input_question').value == "")
		{
			$('input_question').className = 'field fieldError';
		}
		else
		{
			$('input_question').className = '';
		}
		
		if ($('input_iagree').checked == false)
		{
			$('iagree_text').style.color = '#ff0000';
		}
		else
		{
			$('iagree_text').style.color = '';
		}
		
		return false;
	}
}

function connection_popup()
{
	if ($('connection_popup').style.display == "none")
	{
		if ($('home_security'))
		{
			$('home_security').style.display = "none";
			$('home_real').style.display = "none";
			$('home_security_replacement').style.display = "block";
			$('home_real_replacement').style.display = "block";
		}
		
		$('clearsite').style.display = "block";
		$('clearsite').style.width = document.documentElement.scrollWidth + "px";
		$('clearsite').style.height = document.documentElement.scrollHeight + "px";
		$('connection_popup').style.top = posTop() + ((pageHeight() - 320) / 2) + "px";
		$('connection_popup').style.display = "block";
	}
	else
	{
		if ($('home_security'))
		{
			$('home_security_replacement').style.display = "none";
			$('home_real_replacement').style.display = "none";
			$('home_security').style.display = "block";
			$('home_real').style.display = "block";
		}
		
		$('clearsite').style.display = "none";
		$('connection_popup').style.display = "none";
		$('connection_popup').style.top = "0px";
		$('clearsite').style.width = "0px";
		$('clearsite').style.height = "0px";
	}
}


function password_popup()
{
	if ($('popup_password').style.display == "none")
	{
		if ($('browse_header'))
		{
			$('browse_header').style.display = "none";
		}
		
		$('clearsite').style.display = "block";
		$('clearsite').style.width = document.documentElement.scrollWidth + "px";
		$('clearsite').style.height = document.documentElement.scrollHeight + "px";
		$('popup_password').style.top = posTop() + ((pageHeight() - 320) / 2) + "px";
		$('popup_password').style.display = "block";
	}
	else
	{
		if ($('browse_header'))
		{
			$('browse_header').style.display = "block";
		}
		
		$('clearsite').style.display = "none";
		$('popup_password').style.display = "none";
		$('popup_password').style.top = "0px";
		$('clearsite').style.width = "0px";
		$('clearsite').style.height = "0px";
	}
}


function check_integrity(formulaire, email_field_id)
{
	$(formulaire).submit();
}