var Base="http://www.valloire.net/";

//--------------------------------------------------------
//---------------------RollOver fonction-------------------

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


/************************ Infolive ****************/
function SelectionListe(NomChamp,Valeur) {
	if(document.getElementById(NomChamp)){
		var NomCombo=document.getElementById(NomChamp);
		for (i=0; i<NomCombo.length;i++){
			if(NomCombo[i].value==Valeur){				
				NomCombo.selectedIndex=i;			
			}
		}
	}	
}


function SelectionCheckbox(NomForm,NomChamp,Valeur) {
	var tval=Valeur.split(',');
	var collection=eval("document.forms."+NomForm+"."+NomChamp)

	if (collection!=null){
		for(i=0;i<tval.length;i++){
			if(collection.length==null){ // on est dans le cas d'une seule case à cocher 		
				if (collection.value==tval[i]) collection.checked=true;	
			} else{
				for (c=0;c<collection.length;c++){1
					if (collection[c].value==tval[i]) collection[c].checked=true;
				}
			}
		}	
	}	
}




/************************************************
Utilisation des cookies
************************************************/

function getCookie(NameOfCookie)
{
if (document.cookie.length > 0) 
{ 

begin = document.cookie.indexOf(NameOfCookie+"="); 
if (begin != -1) // Note: != means "is not equal to"
{ 
begin += NameOfCookie.length+1; 
end = document.cookie.indexOf(";", begin);
if (end == -1) end = document.cookie.length;
return unescape(document.cookie.substring(begin, end)); } 
}
return null; 
}


function setCookie(NameOfCookie, value, expiredays) 
{

var ExpireDate = new Date ();
ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
document.cookie = NameOfCookie + "=" + escape(value) + 
((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}


/************************************************
Gestion des votes
************************************************/
function initvote(cat,id){
	var aa=getCookie(cat);
	if (aa==1){	// à déjà voté
		document.getElementById(id).disabled=true;
		document.getElementById(id).style.display="none";
	} else { //on doit afficher le bouton
		document.getElementById(id).disabled=false;
	}
}


function controlevote(id,cat){
 var ok=true;
 var i;
 var err=false;
 var msgerr="";
 var errradio=true

var aa=getCookie(cat);
if (aa==1){err=true;msgerr+="Vous ne pouvez voter qu'une seule fois par catégorie !\n";}

if (err==true){alert(" "+msgerr);}
else {setCookie(cat,1,10);}

ok=!err;
return ok;
}
/******************************************
	Affichage sur Googlemaps
******************************************/
function OuvreGoogleMaps(Id,Lat,Lon){
	window.open(Base+"voirgooglemaps.asp?Id="+Id+"&Lat="+Lat+"&Lon="+Lon,'Popup','width=450,height=350,scrollbars=no,toolbar=yes')
}
/******************************************
	Bandeau Flash
******************************************/

function afficheanimation(){
	var bandeau="<div class='bt-anim'><a href='javascript:;'><img src='../images/fr/bt-masquer-video.png' class='png' border='0'/></a></div><div id='AnimFlash' style='height:397px;'></div>";
	$('#Entete').html(bandeau);
	$('#AnimFlash').flash({
		width:950,
		height: 397,
		src :'../swf/chargement-aleatoire-bandeau.swf',
		allowFullScreen: 'no',
		allowScriptAccess:'always',
		wmode:'transparent'
	});
	$('.bt-anim a').click(function(){
		masqueanimation();
		setCookie("AnimVideo",0,10)
		return false;
	});
}


function masqueanimation(){
//	var bandeau="<div class='bt-anim'><a href='javascript:;' id='bandeauon'><img src='../images/fr/bt-afficher-video.png' class='png' border='0'/></a></div><div style='height:150px;'><img src='../images/bandeau-ete.jpg' width='950' height='150'/></div>";
	var bandeau="<div class='bt-anim'><a href='javascript:;' id='bandeauon'><img src='../images/fr/bt-afficher-video.png' class='png' border='0'/></a></div><div id='AnimFlashPapillon' style='height:60px; background-color:#4D4D4D'></div>";
	$('#Entete').html(bandeau);
	$('#AnimFlashPapillon').flash({
		width:950,
		height:60,
		src :'../swf/papillon-load.swf',
		allowFullScreen: 'no',
		allowScriptAccess:'always',
		wmode:'transparent'
	});
	setCookie("AnimVideo",0,10)
	$('.bt-anim a').click(function(){
		afficheanimation();
		setCookie("AnimVideo",1,10)
		return false;
	});
}

function affichebandeau(){
	var aa=getCookie("AnimVideo");
	if(aa==0){masqueanimation();}
	else{afficheanimation();}
}
/******************************************
	Bandeau Flash UK
******************************************/

function afficheanimationuk(){
	var bandeau="<div class='bt-anim'><a href='javascript:;'><img src='../images/uk/bt-masquer-video.png' class='png' border='0'/></a></div><div id='AnimFlash' style='height:397px;'></div>";
	$('#Entete').html(bandeau);
	$('#AnimFlash').flash({
		width:950,
		height: 397,
		src :'../swf/chargement-aleatoire-bandeau.swf',
		allowFullScreen: 'no',
		allowScriptAccess:'always',
		wmode:'transparent'
	});
	$('.bt-anim a').click(function(){
		masqueanimationuk();
		setCookie("AnimVideoUk",0,10)
		return false;
	});
}


function masqueanimationuk(){
//	var bandeau="<div class='bt-anim'><a href='javascript:;' id='bandeauon'><img src='../images/fr/bt-afficher-video.png' class='png' border='0'/></a></div><div style='height:150px;'><img src='../images/bandeau-ete.jpg' width='950' height='150'/></div>";
	var bandeau="<div class='bt-anim'><a href='javascript:;' id='bandeauon'><img src='../images/uk/bt-afficher-video.png' class='png' border='0'/></a></div><div id='AnimFlashPapillon' style='height:60px; background-color:#4D4D4D'></div>";
	$('#Entete').html(bandeau);
	$('#AnimFlashPapillon').flash({
		width:950,
		height:60,
		src :'../swf/papillon-load.swf',
		allowFullScreen: 'no',
		allowScriptAccess:'always',
		wmode:'transparent'
	});
	setCookie("AnimVideoUk",0,10)
	$('.bt-anim a').click(function(){
		afficheanimationuk();
		setCookie("AnimVideoUk",1,10)
		return false;
	});
}

function affichebandeauuk(){
	var aa=getCookie("AnimVideoUk");
	if(aa==0){masqueanimationuk();}
	else{afficheanimationuk();}
}
/******************************************
	Bandeau Flash Hiver FR
******************************************/

function afficheanimationhiver(){
	var bandeau="<div class='bt-anim'><a href='javascript:;'><img src='../images/fr/bt-masquer-video.png' class='png' border='0'/></a></div><div id='AnimFlash' style='height:397px;'></div>";
	$('#Entete').html(bandeau);
	$('#AnimFlash').flash({
		width:950,
		height: 397,
		src :'../swf/chargement-aleatoire-bandeau-hiver.swf',
		allowFullScreen: 'no',
		allowScriptAccess:'always',
		wmode:'transparent'
	});
	$('#offrespeciale').click(function(){
	//	window.open("http://www.resavalloire.com/fr/il4-hiver,offre_i32_p6-promo-vacances-de-noel.aspx");
	});	
	$('.bt-anim a').click(function(){
		masqueanimationhiver();
		setCookie("AnimVideo",0,10)
		return false;
	});
}


function masqueanimationhiver(){
//	var bandeau="<div class='bt-anim'><a href='javascript:;' id='bandeauon'><img src='../images/fr/bt-afficher-video.png' class='png' border='0'/></a></div><div style='height:150px;'><img src='../images/bandeau-ete.jpg' width='950' height='150'/></div>";
	var bandeau="<div class='bt-anim'><a href='javascript:;' id='bandeauon'><img src='../images/fr/bt-afficher-video.png' class='png' border='0'/></a></div><div id='AnimFlashPapillon' style='height:60px; background-color:#4D4D4D'></div>";
	$('#Entete').html(bandeau);
	$('#AnimFlashPapillon').flash({
		width:950,
		height:60,
		src :'../swf/papillon-hiver-fr.swf',
		allowFullScreen: 'no',
		allowScriptAccess:'always',
		wmode:'transparent'
	});
	setCookie("AnimVideo",0,10)
	$('.bt-anim a').click(function(){
		afficheanimationhiver();
		setCookie("AnimVideo",1,10)
		return false;
	});
}

function affichebandeauhiver(){
	var aa=getCookie("AnimVideo");
	if(aa==0){masqueanimationhiver();}
	else{afficheanimationhiver();}
}

/******************************************
	Bandeau Flash Hiver UK
******************************************/
<!--<div id='offrespeciale' style='height:397px;z-index:99;position:absolute;top:0px;width:100%;cursor:pointer;'><img src='../images/spacer.gif' style='width:100%; height:100%;'/></div>-->


function afficheanimationhiveruk(){
	var bandeau="<div class='bt-anim'><a href='javascript:;'><img src='../images/uk/bt-masquer-video.png' class='png' border='0'/></a></div><div id='AnimFlash' style='height:397px;'></div>";
	$('#Entete').html(bandeau);
	$('#AnimFlash').flash({
		width:950,
		height: 397,
		src :'../swf/chargement-aleatoire-bandeau-hiver-uk.swf',
		allowFullScreen: 'no',
		allowScriptAccess:'always',
		wmode:'transparent'
	});
	$('#offrespeciale').click(function(){		//window.open("http://www.resavalloire.com/uk/il4-winter,offer_i32_p6-special-promotion-christmas-holidays.aspx");
	});	
	$('.bt-anim a').click(function(){
		masqueanimationhiveruk();
		setCookie("AnimVideoUk",0,10)
		return false;
	});
}


function masqueanimationhiveruk(){
//	var bandeau="<div class='bt-anim'><a href='javascript:;' id='bandeauon'><img src='../images/fr/bt-afficher-video.png' class='png' border='0'/></a></div><div style='height:150px;'><img src='../images/bandeau-ete.jpg' width='950' height='150'/></div>";
	var bandeau="<div class='bt-anim'><a href='javascript:;' id='bandeauon'><img src='../images/uk/bt-afficher-video.png' class='png' border='0'/></a></div><div id='AnimFlashPapillon' style='height:60px; background-color:#4D4D4D'></div>";
	$('#Entete').html(bandeau);
	$('#AnimFlashPapillon').flash({
		width:950,
		height:60,
		src :'../swf/papillon-hiver-uk.swf',
		allowFullScreen: 'no',
		allowScriptAccess:'always',
		wmode:'transparent'
	});
	setCookie("AnimVideoUk",0,10)
	$('.bt-anim a').click(function(){
		afficheanimationhiveruk();
		setCookie("AnimVideoUk",1,10)
		return false;
	});
}

function affichebandeauhiveruk(){
	var aa=getCookie("AnimVideoUk");
	if(aa==0){masqueanimationhiveruk();}
	else{afficheanimationhiveruk();}
}
/******************************************
	Popups pré-définis
******************************************/
function RadioHome(url){
	window.open(url,'RadioHome','height=270,width=285,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no')
}
function PlanPopup(url){
	window.open(url,'Popup','height=710,width=1000,scrollbars=yes')
}
function BrochurePopup(url){
	window.open(url,'Popup','height=700,width=980,scrollbars=no')
}

/******************************************
	eCatalogue (eBrochure dans répertoire Catalogue à la racine)
******************************************/

var WidthCata = screen.width;
var HeightCata = screen.height;
var redim=true;
var page = "";
var onglet = "";
var idprod = "";
var urlSuppl = "";
var ns4 = (document.layers)? true:false;
var ie4 = (document.all)? true:false;
var dom = (document.getElementById)? true:false;
var DefaultWidth = 1024;
var DefaultHeight = 768;
var ssuppl=window.location.search;

if (ie4 || dom)	{
	xMax = screen.width;
	yMax = screen.height;
} else if (ns4) {
	xMax = window.outerWidth;
	yMax = window.outerHeight;
} else {
	xMax = DefaultWidth;
	yMax = DefaultHeight;
}

function launchwin(winurl,winname,winWidth,winHeight)
	{
	var xMax, yMax, xOffset, yOffset;
	if (ie4 || dom)
		{
		xMax = screen.width;
		yMax = screen.height;
		}
	else if (ns4)
		{
		xMax = window.outerWidth;
		yMax = window.outerHeight;
		}
	else
		{
		xMax = 800;
		yMax = 600;
		}
	xOffset = (xMax - winWidth)/2;
	yOffset = (yMax - winHeight)/2;
	ktawin=window.open(winurl,winname,'width='+winWidth
+',height='+winHeight
+',screenX='+xOffset
+',screenY='+yOffset
+',top='+yOffset
+',left='+xOffset
+',scrollbars=no,resizable=yes,status=no,menubar=no');
	ktawin.focus();
	//ktawin.redim=redim;
	//ktawin.resizeTo(winWidth,winHeight);
}

function launch_catalogue(urlbasekta,param,WidthCataClient,HeightCataClient) {
	if(WidthCataClient!=undefined) WidthCata=WidthCataClient;
	if(HeightCataClient!=undefined) HeightCata=HeightCataClient;
	if(!urlbasekta) urlbasekta="appli.htm";
	if (urlbasekta.indexOf("appli")<0) urlbasekta=urlbasekta+"appli.htm";
	if(!param){ 
		launchwin(urlbasekta+ssuppl,'catalogue',WidthCata,HeightCata); 
		}
	else{
		launchwin(urlbasekta+'?'+param,'catalogue',WidthCata,HeightCata);
	}
}


//--------------------- Sélection onglets grange actus -------------------
function SelectionMenu(IdCell) {
 if((IdCell!='')&&(document.getElementById(IdCell)!=null)){
  document.getElementById(IdCell).className="SelectMenu";
 }
}
