var ims=new Array;var nbims=0;
function preload(imname)	{	ims[nbims]=new Image(); ims[nbims++].src="Data/Img/"+imname;}
function preloadImg(imname)	{	ims[nbims]=new Image(); ims[nbims++].src=imname;}	


var toto0=-136;
var toto=toto0;
var animationAngle=0;
var chupaRolover=false;
var chupAilleursOver=false;
var chupAilleursDelay=0;
var sIsPageCinema=false;
var userLogged=false;
var sUnlockParam="";
function loginMessageShow()
{
	$("#loginAndInfoBox").fadeIn("fast");
	
}

function loginUserLogged(first)
{
	if( first)
		$("#userBox").css({"opacity":"0","left":0,"display":"block"}).animate({"opacity":1,"left":16},400);

}





// search box
///----------
function focusSearchInput(obj,m)
{
	if(obj)
	{ 
		if(m)
		{	obj.value="";
			//obj.style.background="#DFE0CC";			
		}
		else
		{	//obj.style.background="#ffffff";			
		}
	}
}





$(document).ready(onDomInit);

function onDomInit()
{

	$("#loginAndInfoBox").css({"opacity":"1","display":"none"});


	if(sIsPageCinema)
	{
		InitCinema();
	}
}


function sendFormCreateUser()
{	var o;
	var strError=null;
	if( o=getObj('FormCreateUser'))
	{	if(o.usrPsswd.value.length<2)
			strError = "Vous devez entrer un mot de passe suffisamment long";
		else if( o.usrPsswd.value != o.usrPsswdConfirm.value)
		{
			strError = "Les deux champs de saisie diffèrent. Veuillez vérifier les mots de passe. ";
		}
		else
		{
			o.userpsswd.value = hex_md5(o.usrPsswd.value)
			//alert(o.userpsswd.value);	
			o.submit();
		}
	}
	if(strError)
	{
		$("#errorMessage").html(strError);
	}
}


// Evenements
function showEventCommentsList()
{
	$('#articleCommentsDiv').slideToggle("slow");
}


// emptyTextedit
// plugged on the onfocus event of the te
function emptyTextedit(te)
{	te.value="";
	te.onfocus=function(){};		// avoid erasing the content next time
}



/* Blog in admin*/
function blogSeeLocationCombo(id)
{
	RQSiteAdminAjaxCall("action=getComboLocation",cbBlogSeeLocationCombo)

}
function cbBlogSeeLocationCombo(message,isOk)
{
	$("#inputPlaceDiv").show();
	var cb
	if( cb = getObj("place"))
	{	
		cb.options.length=0;
		eval(message);
	}


}


function alaUneCategorie(cat,id)
{
	if( cat && id)
		RQSiteAdminAjaxCall("action=setALaUneCat&cat="+cat+"&id="+id,cbAlaUneCategorie);
	
}
function cbAlaUneCategorie(message,isErr)
{
	if( (!isErr) && message=='ok')
	{
		window.setTimeout(refreshListBlog,100);
		$('#btnALaUneCategory').after("<b id=\"btnALaUneCategory\" style=\"float:right;\">A la Une de la catégorie</b>");
		$('a#btnALaUneCategory').hide();
	}
}
function refreshListBlog()
{
		blogAdminPostCalendarAction('refreshList');
}


function alaUneGenerale(id)
{
	if( id)
		RQSiteAdminAjaxCall("action=setALaUneGenerale&id="+id,cbAlaUneGenerale);
	
}
function cbAlaUneGenerale(message,isErr)
{
	if( (!isErr) && message=='ok')
	{
		window.setTimeout(refreshListBlog,100);
		$('#btnALaUneGenerale').after("<b id=\"btnALaUneGenerale\" style=\"float:right;\">Une Globale</b>");
		$('a#btnALaUneGenerale').hide();
	}
}



/* ------  front Calendar navigation  ---------- */
function CalendarNavMonth(year,month)
{
	//RQAjaxCall('Custom/myAjax.php?action=calendarNav&year='+year+'&month='+month,cbCalendarNav);
	var params = 'action=calendarNav&year='+year+'&month='+month+sUnlockParam;
	RQAjaxCallPlugin('Evenements',params,cbCalendarNav);
}

function cbCalendarNav(message,isErr)
{
	if(!isErr)
	{	eval(message);
	}
	else
		alert("error");
}


function myshowBBCodeInfo()
{
	$("#BBCodeInfo").slideToggle("fast");
}

/* ------  Password  ---------- */
function forgottenPasswordClick()
{
	$("#chupsContent").html("<b id=\"boxMessage\">Entrez votre email</b>"+"<div id='forgottenFormDiv'><form id='formForgottenPsswd' method='post' onSubmit='postForgottenPsswdForm();return false;' enctype='multipart/form-data' action='#'><input name='email' id='emailPsswdForgotten' /><input type='hidden' name='action' value='forgotPassword' /></form>"+"<a href='javascript:postForgottenPsswdForm();'>Envoyer</a></div>");
}
function postForgottenPsswdForm()
{	var o,email;
	if( o=getObj("formForgottenPsswd"))
	{
		expreg = new RegExp("^([a-zA-Z0-9_\.\-]+)@([a-zA-Z0-9_\.\-]+)\.([a-zA-Z]+)$", "g");
		email = RQGetVariableValue('email');
		if( email.length<1)
		{
			$("#boxMessage").hide().html("Veuillez saisir votre email").fadeIn("slow");
		}
		else if( expreg.test(email))
		{
			var url='async.php?code='+sRqSessionCode+'&module='+"UserLogin";
			RQAjaxPost(url,'formForgottenPsswd',cbPasswdForgottenPost);			
		}
		else
		{
			$("#boxMessage").hide().html("format d'email incorrect. Réeesayez").fadeIn("slow");
		}
	}
}
function cbPasswdForgottenPost(message,isErr)
{
	if(!isErr)
	{
		eval(message);
	}
}
function bonPlanNotLogged()
{
	alert("Pour accéder aux Bons Plans il vous faut vous identifier, ou créer un compte gratuitement.");
}

function printBonPlan(id)
{
	popup('print'+id,sURL_SITE+'async.php?module=ListBonsPlans&action=print&id='+id,800,600,"yes");

}