/* Javascript - Panach */

/***** Sommaire *****/
// 05 - autoRoll
// 10 - Write Flash
// 15 - Screeny Checker
// 20 - pngRulesIE
// 25 - Field Limit
// 30 - upDatePartnerList
// 35 - changeChanne
// 40 - popContactl
// 45 - popMentions
// 98 - onResize
// 99 - onLoad
/*******************/


/***** 05 - autoRoll *****/
var onAdd="-on";
function autoRoll(Img){
	if(!Img.onmouseout) Img.onmouseout = function(){ autoRoll(Img) };
	if(Img.src.indexOf('spacer.gif') != -1){
		filterEnd = Img.style.filter.substring(Img.style.filter.lastIndexOf("."));
		filterStart = Img.style.filter.substring(0,Img.style.filter.lastIndexOf("."));
		filterOn = filterStart+onAdd+filterEnd;
		if(filterStart.indexOf(onAdd) != -1) filterStart = filterStart.substring(0,filterStart.length-onAdd.length);
		filterOff = filterStart+filterEnd;
		if(Img.style.filter.indexOf(onAdd) != -1) Img.style.filter = filterOff;
		else Img.style.filter = filterOn;
	} else {
		imgExt = Img.src.substring(Img.src.lastIndexOf("."));
		imgName = Img.src.substring(0,Img.src.lastIndexOf("."));
		imgOn = imgName+onAdd+imgExt;
		if(imgName.indexOf(onAdd) != -1) imgName = imgName.substring(0,imgName.length-onAdd.length);
		imgOff = imgName+imgExt;
		if(Img.src.indexOf(onAdd) != -1) Img.src = imgOff;
		else Img.src = imgOn;
	}
}

function autoRollEvents(){
	var imgTable = arguments[0].getElementsByTagName('img');
	for(var i=0; i<imgTable.length; i++){
		if(imgTable[i].src.indexOf('spacer.gif') != -1){
			if(imgTable[i].style.filter.indexOf(onAdd) == -1) imgTable[i].onmouseover = function(){autoRoll(this)};
		} else {
			if(imgTable[i].src.indexOf(onAdd) == -1) imgTable[i].onmouseover = function(){autoRoll(this)};
		}
	}
}

/***** 10 - Write Flash *****/
function writeFlash(url,id,w,h,o){
	document.write('\n<object id="'+id+'" type="application/x-shockwave-flash" data="'+url+'" width="'+w+'" height="'+h+'">\n');
	document.write('\t<param name="movie" value="'+url+'" />\n');
	if(o != ''){
		var flashOptionsTab = new Array();
		flashOptionsTab = o.split('|');
		for(i=0; i<flashOptionsTab.length; i++){
			var tempParam = flashOptionsTab[i].split('#')[0];
			var tempValue = flashOptionsTab[i].split('#')[1];
			document.write('\t<param name="'+tempParam+'" value="'+tempValue+'" />\n');
		}
	}
	document.write('</object>\n');
}

/***** 15 - Screeny Checker *****/
function isScreeny(){
	if(document.documentElement.clientWidth < 995){
		$S('add',$('body',0),'screeny');
	} else {
		$S('del',$('body',0),'screeny');
	}
}

/*****25 - Field Limit *****/
var limitTimer;
function limitField(field,length){
	field = $(field);
	if(field.value.length > length){
		field.value = field.value.substr(0,length);
	}
}

/***** 30 -upDatePartnerList *****/
function upDatePartnerList(index){
	// Masque tout
	var campTab = $('partnerListing','div',-1);
	for(i=0; i<campTab.length; i++){
		campTab[i].style.display = 'none';
	}
	// Check si match
	for(i=0; i<campTab.length; i++){
		if(campTab[i].id == 'part'+index || index == 00){
			campTab[i].style.display = 'block';
		}
	}
}

/***** 35 - changeChannel *****/
var lastVideo = '';
function changeChannel(date){
	$('pubPlayer').SetVariable('movieDate',date);
	if(lastVideo != ''){
		$('date'+lastVideo).onmouseout = null;
		autoRoll($('date'+lastVideo));
		$('date'+lastVideo).onmouseover = function(){ autoRoll(this); };
	}
	$('date'+date).onmouseout = function(){ dummy = true; };
	$('date'+date).onmouseover = function(){ dummy = true; };
	lastVideo = date;
}

/***** 40 - popContact *****/
function popContact(){
	window.open(URLBHDB+'/C_formulaire_conso/formulaire.asp?id_site=5','FormConso','width=618,height=500,scrollbars=yes');
}

/***** 45 - popMentions *****/
function popMentions(){
	window.open('mentions.htm','Mentions','width=601,height=419,scrollbars=no');
}
function openMentionsOpeTerrasse(){
	window.open('mentions-terrasse.htm','Mentions','width=601,height=419,scrollbars=no');
}
function openEtapesOpeTerrasse(){
	window.open('etapes-terrasse.htm','Etapes','width=617,height=680,scrollbars=yes');
}
function openMagsOpeTerrasse(){
	window.open('magasins-participants.htm','Etapes','width=601,height=419,scrollbars=no');
}
function openMagsOpeTerrasse2009(){
	window.open('magasins-participants-2009.htm','Magasins2009','width=601,height=419,scrollbars=no');
}
function openListeEtapes2009() {
    window.open('etapes-terrasse-2009.htm', 'Etapes2009', 'width=601,height=680,scrollbars=yes');
}
function openListeEtapes2010() {
    window.open('etapes-terrasse-2010.htm', 'Etapes2010', 'width=601,height=680,scrollbars=yes');
}
function popReglement () {
	window.open('reglement.htm','Reglement','width=601,height=419,scrollbars=no');
}
function popReglement2008 () {
	window.open('reglement-2008.htm','Reglement2008','width=601,height=419,scrollbars=no');
}

/***** 98 - onResize *****/
window.onresize = function(){
    // 15 - Screeny Checker
    isScreeny();
}

/***** 99 - onLoad *****/
window.onload = function(){
	// 05 - autoRoll
	autoRollEvents($$('div','navigation')[0]);
	if($('videoLinks')){
		autoRollEvents($('videoLinks'));
	}
}

/***** redirect game caravane ***/
function playGame(){
	document.location.href = "caravane.asp";
}