// JavaScript Document

// pour le calendrier 
var gMonths=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];


// Example: obj = findObj("image1");
function findObj(theObj, theDoc)
{
    var p, i, foundObj;
  
    if(!theDoc) theDoc = document;
    if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
    {
        theDoc = parent.frames[theObj.substring(p+1)].document;
        theObj = theObj.substring(0,p);
    }
    if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
    for (i=0; !foundObj && i < theDoc.forms.length; i++)
        foundObj = theDoc.forms[i][theObj];
    for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++)
        foundObj = findObj(theObj,theDoc.layers[i].document);
    if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  
    return foundObj;
}

function changeColor(objName)
{
    obj = findObj(objName);
    // alert(obj.style.backgroundColor);
    if (obj.style.backgroundColor=='' || obj.style.backgroundColor=='#fff')
    {
        obj.style.backgroundColor = '#f9feff';
    } else  if (obj.style.backgroundColor=='#f9feff')
    {
        obj.style.backgroundColor = '#fff';
    }
}
function changeVisibility(objName1,objName2)
{
    obj1 = findObj(objName1);
    if(objName2!='') {
        obj2 = findObj(objName2)
    }else{
        obj2=''
    };
    //alert(obj.style.display);
    if (obj1.style.display=='none' || obj1.style.display=='')
    {
        obj1.style.display = 'block';
        if(obj2!='') obj2.style.display = 'none';
    } else if (obj1.style.display=='block')
    {
        obj1.style.display = 'none';
        if(obj2!='') obj2.style.display = 'none';
    }
}

function changeVisibilityShowBoth(objName1,objName2)
{
    obj1 = findObj(objName1);
    obj2 = findObj(objName2);
    //alert(obj.style.display);
    if (obj1.style.display=='none' || obj1.style.display=='')
    {
        obj1.style.display = 'block';
        obj2.style.display = 'block';
    }
    else if (obj1.style.display=='block' && obj2.style.display=='none')
    {
        obj1.style.display = 'block';
        obj2.style.display = 'block';
    }
    else if (obj1.style.display=='block' && obj2.style.display=='block')
    {
        obj1.style.display = 'none';
        obj2.style.display = 'none';
    }
}

function changeVisibilityShowFirst(objName1,objName2)
{
    obj1 = findObj(objName1);
    obj2 = findObj(objName2);
    //alert(obj.style.display);
    if (obj1.style.display=='none' || obj1.style.display=='')
    {
        obj1.style.display = 'block';
    }
    else if (obj1.style.display=='block' && obj2.style.display=='block')
    {
        obj1.style.display = 'block';
        obj2.style.display = 'none';
    }
    else if (obj1.style.display=='block' && obj2.style.display=='none')
    {
        obj1.style.display = 'none';
        obj2.style.display = 'none';
    }
}

function changeOnglet(objId,origine){
    changeColor('produit'+objId);
    changeVisibility('onglet'+objId);
    obj = findObj('checkbox'+objId);
	
    if(origine=='link'){
        if(obj.checked== false){
            obj.checked=true;
        } else if(obj.checked== true){
            obj.checked=false;
        }
    }
}
function formPost(action,idproduit){
    obj = findObj('formulaire');
    obj.action.value=action;
    obj.display_idProduit.value=idproduit;
    obj.submit();
    return false;
}
var hoArr = new Array(0,0,0,0);

function init(){
    for(x=0;x<4;x++){
        hoArr[x]=getCookie("hotel"+(x+1));
    }
}


function modifPanier(obj,id){
    if(obj.checked==true){
        swapOn(id);
        for(x=0;x<4;x++){
            document.cookie = "hotel"+(x+1)+"=" + hoArr[x]+"; ";
        }
    }
}

function swapOn(hID){
    hiArr[3] = hiArr[2];
    hiArr[2] = hiArr[1];
    hiArr[1] = hiArr[0];
    hiArr[0] = hID;
//setSelected();
/*
	if(document.getElementById('table'+hID)){
		document.getElementById('table'+hID).className = 'bdr1 bdrGrey lpurpleBG';
	}*/
}

function SetCookie (name, value) {
    var argv = SetCookie.arguments;
    var argc = SetCookie.arguments.length;
    var expires = (argc > 2) ? argv[2] : null;
    var path = "/"
    var domain = (argc > 4) ? argv[4] : null;
    var secure = (argc > 5) ? argv[5] : false;
    document.cookie = name + "=" + escape (value) +
    ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
    ((path == null) ? "" : ("; path=" + path)) +
    ((domain == null) ? "" : ("; domain=" + domain)) +
    ((secure == true) ? "; secure" : "");
}

function getCookie(valname) {
    var pgCookies = document.cookie;
    var position = pgCookies.indexOf(valname);
    if (position == -1) {
        return '';
    }else{
        var start = position + valname.length + 1;
        var end = pgCookies.indexOf(';', start);
        if (end == -1) {
            end = pgCookies.length;
        }
        if(pgCookies.charAt(start-1) !=";"){
            return pgCookies.substring(start, end);
        }else{
            return '';
        }
    }
}
function SetTableStatus(trueFalse) {
    tableVisible = trueFalse
    var expdate = new Date ();
    expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000));
    SetCookie("tablestatus", tableVisible, expdate);
}
function toggletable() {
    var temp = document.getElementById('mapTable');
    if (tableVisible=="true") {		//if true, table is visible so hide it
        tableVisible = "false";
        showMap()
    } else {				//table is not visible, so expand it.
        tableVisible = "true";
        hideMap()
    }
    SetTableStatus();
}



//Morceau de code en plein milieu de page

/*
SCRIPT EDITE SUR L'EDITEUR JAVACSRIPT
http://www.editeurjavascript.com

Merci à lord Gunthar
http://www.topweb.cc

domok = document.getElementById;
if (domok)
	{
	skn = document.getElementById("topdecklink").style;
	if(navigator.appName.substring(0,3) == "Net")
		document.captureEvents(Event.MOUSEMOVE);
	document.onmousemove = get_mouse;
	}
*/
function poplink(msg)
{

    var content ="<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 BGCOLOR=#000000><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=1><TR><TD BGCOLOR=#CC3300><FONT COLOR=#FFFFFF SIZE=2 face='Arial'><CENTER>"+msg+"</CENTER></TD></TR></TABLE></TD></TR></TABLE>";

    if (domok)
    {
        document.getElementById("topdecklink").innerHTML = content;
        skn.visibility = "visible";
    }
}

function get_mouse(e)
{
    var x = (navigator.appName.substring(0,3) == "Net") ? e.pageX : event.x+document.body.scrollLeft;
    var y = (navigator.appName.substring(0,3) == "Net") ? e.pageY : event.y+document.body.scrollTop;
    skn.left = x - 60;
    skn.top = y+20;
}

function killlink()
{
    if (domok)
        skn.visibility = "hidden";
}

	

function affnewimm(id,url)
{
    document.getElementById('img'+id).src = url;
}


















