/* <![CDATA[ */

//var global_SERVER_HOST = "www.blackmovie.ch";


//var global_SERVER_HOST = "steph.local/BLACKMOVIE";




function openPop(theURL, myWidth, myHeight, myScrolls) {
	myWin=window.open(theURL,'pop','toolbar=no,directories=no,menubar=no,scrollbars='+myScrolls+',resizable=no,width='+myWidth+',height='+myHeight);
	myWin.moveTo(50,50);
	myWin.focus();
}

// SEARCH
function checkForm(frm,field,origValue,error,type) {
	var nextUrl = 'http://'+global_SERVER_HOST;
	var strErrorDiv;
	var strThisUrl = "" + window.location;
	var ipos=strThisUrl.indexOf('/fr/');
	var strCodLang = (ipos > 0)?"fr":"en";
	if(type=="press"){
		nextUrl += '/'+strCodLang+'/presse.php';
		strErrorDiv = 'errorMsg';
	}
	else if (type=="school"){
		nextUrl += '/'+strCodLang+'/seances-scolaires.php';
		strErrorDiv = 'errorMsg';
	}
	else if (type=="homesearch"){
		strErrorDiv = 'errorSearch';
	}
	else return false;
	
	if ($(strErrorDiv)){
		var myFx = new Fx.Style(strErrorDiv, 'opacity').set(0); 
	}
	
	
	if (document[frm][field].value=="" || document[frm][field].value==origValue) {
		if ($(strErrorDiv)!=null){
			$(strErrorDiv).innerHTML = error;
			var myEffects = new Fx.Styles(strErrorDiv, {duration: 400, transition: Fx.Transitions.linear});
			myEffects.start({
					'opacity': [0, 1]
			});
		}
	}
	else {
		if(type=="press" || type=="school"){
			var url = "http://"+global_SERVER_HOST+"/includes/login.php";
			
			var loader = new Ajax(url, {
														method: 'post',
														data: 'type='+type+'&pass='+document[frm][field].value,
														onSuccess:function(){
																				if(this.response['text']=="ok"){
																					window.location=nextUrl;
																				}
																				else {
																					if ($(strErrorDiv)!=null){
																						$(strErrorDiv).innerHTML = "Mot de passe incorrect.";
																						var myEffects = new Fx.Styles(strErrorDiv, {duration: 400, transition: Fx.Transitions.linear});
																						myEffects.start({
																								'opacity': [0, 1]
																						});
																					}
																				}
																			}
														});
			loader.request();
		}
		else {
			document[frm].submit();
		}
	}
}


function showGrid(lang){
	var htmlContent = "";
	
	var url = "http://"+global_SERVER_HOST+"/archives/2009/"+lang+"/grille-horaire.php";
	
	var divContent = $('horaireGrid');
	var divContentBg = $('horaireGridBackground');
	var loader = new Ajax(url, {method: 'get',
												onSuccess:function(){
													var strContent = this.response['text'];
													divContent.innerHTML = strContent;
													divContentBg.style.height=window.getScrollHeight()+"px";
													divContentBg.style.height=window.getScrollHeight()+"px";

													divContentBg.style.display="block";
													
													divContent.style.display="block";
													
													var myEffects = new Fx.Styles('horaireGrid', {duration: 900, transition: Fx.Transitions.linear});
													myEffects.start({
															'opacity': [0, 1],
															'margin-left':[-1000,20]
													});
													/*
													var myEffects = new Fx.Styles('horaireGridBackground', {duration: 400, transition: Fx.Transitions.linear});
													myEffects.start({
															'opacity': [0, 0.5]
													});
													
													divContentBg.style.height=window.getScrollHeight()+"px";
													*/
												}
												}
												);
	loader.request();
}

function hideGrid(){
	var divContent = $('horaireGrid');
	var divContentBg = $('horaireGridBackground');
	
	var myEffects = new Fx.Styles('horaireGrid', {duration: 400, 
																transition: Fx.Transitions.linear, 
																onComplete:	function(){
																							divContent.style.display = "none";
																						}
																});
	myEffects.start({
			'opacity': [1, 0]
	});
	divContentBg.style.display="none";
	/*
	var myEffects = new Fx.Styles('horaireGridBackground', {duration: 400, 
																transition: Fx.Transitions.linear, 
																onComplete:	function(){
																							divContentBg.style.display = "none";
																						}
																});
	myEffects.start({
			'opacity': [0.5, 0]
	});
	*/
}

/*  ]]> */
