var imageLoc = '/images/';


var agt=navigator.userAgent.toLowerCase();
var appVer = navigator.appVersion.toLowerCase();
var is_mac = (agt.indexOf("mac")!=-1);
var is_minor = parseFloat(appVer);
var is_major = parseInt(is_minor);
var is_opera = (agt.indexOf("opera") != -1);
var iePos  = appVer.indexOf('msie');
var is_mac_ie = false;
if (iePos !=-1) {
   is_minor = parseFloat(appVer.substring(iePos+5,appVer.indexOf(';',iePos)));
   is_major = parseInt(is_minor);
}
var is_ie = ((iePos!=-1) && (!is_opera));
if (is_mac && is_ie) {
	is_mac_ie = true;
}
var is_ie5up = (is_ie && is_minor >= 5);
var is_ie5_5up =(is_ie && is_minor >= 5.5);
var is_safari = ((agt.indexOf('safari')!=-1)&&(agt.indexOf('mac')!=-1))?true:false;
var nn4 = false;
if (document.layers) {
	nn4 = true;
}



function turnOnMyStore(imgName,imgPath) {
    document[imgName].src = imgPath;
}

function rollOver(imgName) {
	document[imgName].src = eval(imgName + "_over.src");
}

function rollOff(imgName) {
	document[imgName].src = eval(imgName + "_off.src");
}

function navOver(imgNum) {
	imgName = "nav" + imgNum;
	divName = "pos" + imgNum;
	var tmpImg = getImg(imgName, divName);

	tmpImg.src = eval(imgName + "_over.src");
}

function navOff(imgNum) {
	imgName = "nav" + imgNum;
	divName = "pos" + imgNum;
	var tmpImg = getImg(imgName, divName);
	tmpImg.src = eval(imgName + "_off.src");
}

if (document.images) {

	//top nav preloads
    
	nav0_over = new Image();
	nav0_over.src = imageLoc +"nav_affaires.gif";
	nav0_off = new Image();
	nav0_off.src = imageLoc + "nav_affaires.gif";
	
	nav1_over = new Image();
	nav1_over.src = imageLoc +"nav_tourisme.gif";
	nav1_off = new Image();
	nav1_off.src = imageLoc + "nav_tourisme.gif";
    
	nav2_over = new Image();
	nav2_over.src = imageLoc +"nav_vivreanewyork.gif";
	nav2_off = new Image();
	nav2_off.src = imageLoc + "nav_vivreanewyork.gif";
    
	nav3_over = new Image();
	nav3_over.src = imageLoc +"nav_etudes.gif";
	nav3_off = new Image();
	nav3_off.src = imageLoc + "nav_etudes.gif";
    
	nav4_over = new Image();
	nav4_over.src = imageLoc +"nav_forum.gif";
	nav4_off = new Image();
	nav4_off.src = imageLoc + "nav_forum.gif";
    
	nav5_over = new Image();
	nav5_over.src = imageLoc +"nav_pays.gif";
	nav5_off = new Image();
	nav5_off.src = imageLoc + "nav_pays.gif";
}



// menu style vars
var width = 127;
var height = 18;
var border = "#D1B454";
var menubgOn = "#DEDEFF";
var menubgOff = "#FFFFFF";

var menuXoffset = 0;
var menuYoffset = 0;

// functionality variables
var delay = 500;
var delayStart = 250;
var useDHTML = false;
var hideSels = false;
var start;
var hideFlag;
var hideTimer;
var showTimer;
var curMenu;
var curItem;
var curNav;
var activeMenu;
var theMenu;
var theImg;
var thePos;
var theDiv;
var theCont;
var theTable;
var theMask;
var onMenu = false;
var menusWritten = false;

// menu building variables;
var menucount = 0;


sectColor = new Array();
sectColor[0] = "#71D352";
sectColor[1] = "#FFA619";
sectColor[2] = "#FF6375";
sectColor[3] = "#D372E4";
sectColor[4] = "#3560E8";
sectColor[5] = "#4BD9D9";

var menustyle = "width:" + width + "px; text-align:left; background-color:#FFFFFF; cursor: hand;";

var separator = "<div><img src=\""+imageLoc+"shim.gif\" width=\"1\" height=\"1\" alt=\"\" border=\"0\"></div>";

function menuobject (label, url) {
    this.label = label;
    this.url = url;
    return this;
}

function renderdata () {
    menuData[catCount++] = tmpData;
    tmpData = new Array();
    count = 0;
}

// Turn on DHTML for 5+ browsers only
if (is_ie && !is_ie5up) {
    useDHTML = false;
} else if(!nn4) { useDHTML = true; }

function writeMenus() {
    if(useDHTML) {
        for (i = 0; i < menuData.length; i++) {
            document.writeln("<div id=\"menu" + i + "\" style=\"position:absolute; z-index:100; top:0px; left:0px; visibility:hidden;\">");
            for (j = 0; j < menuData[i].length; j++) {
                if (j == 0) {
                    document.write("<div id=\"menuitem" + menucount + "\" onMouseOver=\"startShow('" + i + "'); changebg('menuitem" + menucount + "'); changeStatus('" + menuData[i][j].url + "');\" onMouseOut=\"startHide(); changeStatus('');\" onClick=\"goTo('" + menuData[i][j].url + "');\" style=\"" + menustyle + "border-top:" + sectColor[i] + " 1px solid;" + "border-left:" + sectColor[i] + " 1px solid;" + "border-right:" + sectColor[i] + " 1px solid;" + "border-bottom:" + sectColor[i] + " 1px solid;\"><div class=\"dhtml_menuitem\"><a href=\"" + menuData[i][j].url + "\" class=\"dhtml_menulink" + i + "\"> " + menuData[i][j].label + "</a></div></div>" + separator);
                }
                else if (j < menuData[i].length - 1) {
                    document.write("<div id=\"menuitem" + menucount + "\" onMouseOver=\"startShow('" + i + "'); changebg('menuitem" + menucount + "'); changeStatus('" + menuData[i][j].url + "');\" onMouseOut=\"startHide(); changeStatus('');\" onClick=\"goTo('" + menuData[i][j].url + "');\" style=\"" + menustyle + "border-top:" + sectColor[i] + " 1px solid;" + "border-left:" + sectColor[i] + " 1px solid;" + "border-right:" + sectColor[i] + " 1px solid;" + "border-bottom:" + sectColor[i] + " 1px solid;\"><div class=\"dhtml_menuitem\"><a href=\"" + menuData[i][j].url + "\" class=\"dhtml_menulink" + i + "\"> " + menuData[i][j].label + "</a></div></div>" + separator);
                }
                else {
                    document.write("<div id=\"menuitem" + menucount + "\" onMouseOver=\"startShow('" + i + "'); changebg('menuitem" + menucount + "'); changeStatus('" + menuData[i][j].url + "');\" onMouseOut=\"startHide(); changeStatus('');\" onClick=\"goTo('" + menuData[i][j].url + "');\" style=\"" + menustyle + "border-top:" + sectColor[i] + " 1px solid;" + "border-left:" + sectColor[i] + " 1px solid;" + "border-right:" + sectColor[i] + " 1px solid;" + "border-bottom:" + sectColor[i] + " 1px solid;\"><div class=\"dhtml_menuitem\"><a href=\"" + menuData[i][j].url + "\" class=\"dhtml_menulink" + i + "\"> " + menuData[i][j].label + "</a></div></div>");
                }
                menucount++;
            }
            document.writeln("</div>");
            moveMenu(i);
        }
    }
    menusWritten = true;
}

function moveMenu(num) {
    tmpMenu = "menu" + num;
    thePos = getObj("pos" + num);
    theImg = "nav" + num;
    xPos = offsetLeft(thePos) + menuXoffset;
    yPos = offsetTop(thePos) + height + menuYoffset;
    getObj(tmpMenu).style.left = xPos;
    getObj(tmpMenu).style.top = yPos;
}

function showMenus() {
    onMenu = true;
    theMenu = "menu" + curMenu;
    activeMenu = theMenu;
    moveMenu(curMenu);
    getObj(theMenu).style.visibility = "visible";
}

function startShow(menu) {
    if (curNav) {
        navOff(curNav);
    }
    navOver(menu);
    curNav = menu;
    if (menusWritten && !nn4) {
        curMenu = menu;
        if (activeMenu) {
            getObj(activeMenu).style.visibility = "hidden";
        }
        clearTimer();
        if (!onMenu) {
            if (curItem) {
                curItem.style.backgroundColor = menubgOff;
            }
            showTimer = setTimeout("showMenus()", delayStart);
        }
        else {
            showMenus();
        }
    }
    else {
        return false;
    }
}

function startHide() {
    if (!onMenu) {
        if (curNav) {
            navOff(curNav);
            curNav = null;
        }
    }
    if (menusWritten && !nn4) {
        if (showTimer) clearTimeout(showTimer);
        start = new Date();
        hideFlag = true;
        hideTimer = setTimeout("hideMenus()", delay);
    }
    else {
        return false;
    }
}

function clearTimer() {
    if (hideTimer) clearTimeout(hideTimer);
    hideTimer = null;
    hideFlag = false;
}

function hideMenus() {
    if (!hideFlag) return;
    var elapsed = new Date() - start;
    if (elapsed < delay) {
        hideTimer = setTimeout("hideMenus()", delay - elapsed);
        return;
    }
    hideFlag = false;
    hideAllMenus();
    if (hideSels) {
        showSelect();
    }
}

function hideAllMenus() {
    changeStatus('');
    if (curNav) {
        navOff(curNav);
        curNav = null;
    }
    for (i = 0; i<menuData.length; i++) {
        theMenu = "menu" + i;
        getObj(theMenu).style.visibility = "hidden";
    }
    if (curItem) {
        curItem.style.backgroundColor = menubgOff;
    }
    onMenu = false;
}

function goTo(url) {
    document.location.href = url;
}

//return [object]
function getObj(theId) {
    if (document.getElementById) {
        theObj = document.getElementById(theId); 
    } else if (document.all) { 
        theObj = document.all[theId];
    }
    return theObj;
}

//return [img] object NS4 fix
function getImg(imgName, divName) {
    if (nn4) {
        imgObj = eval("document." + divName + ".document.images." + imgName);
    }
    else {
        imgObj = eval("document.images." + imgName);
    }
    return imgObj;
}

//Mac IE offset fix
function offsetLeft(o){
    var i = 0;
    while (o.offsetParent!=null) {
        i += o.offsetLeft;
        o = o.offsetParent;
    }
    return i + o.offsetLeft;
}
function offsetTop(o){
    var i = 0;
    while (o.offsetParent!=null) {
        i += o.offsetTop;
        o = o.offsetParent;
    }
    return i + o.offsetTop;
}

function changebg(id) {
    if (useDHTML) {
        var tmp = getObj(id);
        if (curItem) {
            if (tmp != curItem) {
                curItem.style.backgroundColor = menubgOff;
                tmp.style.backgroundColor = menubgOn;
            }
        } else { tmp.style.backgroundColor = menubgOn; }
        curItem = tmp;
    }
}

function changeStatus(text) {
    window.status = text;
}

function clearbg() {
    if (curItem) {
        curItem.style.backgroundColor = menubgOff;
    }
    curItem = null;
}

if (document.addEventListener) {
    document.addEventListener("mouseup", mouseUp, false);
}

document.onmouseup = mouseUp;

function mouseUp() {
    hideAllMenus();
    return true;
}


var count = 0;
var catCount = 0;
var menuData = new Array();
var tmpData = new Array();


// AFFAIRES link data

tmpData[count++] = new menuobject("Créer une société", "http://www.voilanewyork.com/001_001_000.html");
tmpData[count++] = new menuobject("Emploi", "http://www.voilanewyork.com/001_002_000.html");

renderdata();

// TOURISME link data

tmpData[count++] = new menuobject("Carte d'identité NY", "http://www.voilanewyork.com/002_004_000.html");
tmpData[count++] = new menuobject("Fêtes traditionnelles", "http://www.voilanewyork.com/002_013_000.html");
tmpData[count++] = new menuobject("Transports", "http://www.voilanewyork.com/002_002_000.html");
tmpData[count++] = new menuobject("Aéroports", "http://www.voilanewyork.com/002_009_000.html");
tmpData[count++] = new menuobject("S'orienter", "http://www.voilanewyork.com/002_003_000.html");
tmpData[count++] = new menuobject("Les quartiers de NY", "http://www.voilanewyork.com/002_008_000.html");
tmpData[count++] = new menuobject("Visites", "http://www.voilanewyork.com/002_001_000.html");
tmpData[count++] = new menuobject("Voir du Sport", "http://www.voilanewyork.com/002_010_000.html");
tmpData[count++] = new menuobject("Cinéma", "http://www.voilanewyork.com/002_011_000.html");
tmpData[count++] = new menuobject("Théâtre, Broadway Shows", "http://www.voilanewyork.com/002_012_000.html");
tmpData[count++] = new menuobject("Restaurants francophones", "http://www.voilanewyork.com/002_005_000.html");
tmpData[count++] = new menuobject("Restaurants non francophones", "http://www.voilanewyork.com/002_015_000.html");
tmpData[count++] = new menuobject("Où sortir ?", "http://www.voilanewyork.com/002_014_000.html");
tmpData[count++] = new menuobject("Hôtels, B&amp;B", "http://www.voilanewyork.com/003_004_004.html");
tmpData[count++] = new menuobject("Location immo", "http://www.voilanewyork.com/003_004_003.html");
tmpData[count++] = new menuobject("Escapades week-end", "http://www.voilanewyork.com/002_006_000.html");
tmpData[count++] = new menuobject("A travers les USA", "http://www.voilanewyork.com/002_007_000.html");

renderdata();

// VIVRE A NEW-YORK link data

tmpData[count++] = new menuobject("Santé", "003_001_000.html");
tmpData[count++] = new menuobject("Voiture", "003_002_000.html");
tmpData[count++] = new menuobject("Pratique", "003_003_000.html");
tmpData[count++] = new menuobject("Logement", "003_004_000.html");
tmpData[count++] = new menuobject("Famille", "003_005_000.html");
tmpData[count++] = new menuobject("Personnes Handicapées", "003_013_000.html");
tmpData[count++] = new menuobject("Sorties", "003_006_000.html");
tmpData[count++] = new menuobject("New York Gay", "003_014_000.html");

tmpData[count++] = new menuobject("Pratiquer un sport", "003_007_000.html");
tmpData[count++] = new menuobject("Musique", "003_008_000.html");
tmpData[count++] = new menuobject("Hobby", "003_009_000.html");
tmpData[count++] = new menuobject("Galeries, Beaux-Arts", "003_010_000.html");
tmpData[count++] = new menuobject("Recettes du monde", "003_011_000.html");
tmpData[count++] = new menuobject("Shopping, Achats", "003_012_000.html");

renderdata();

// ETUDES link data

tmpData[count++] = new menuobject("Etudes", "http://www.voilanewyork.com/004_001_000.html");
tmpData[count++] = new menuobject("Au pair", "http://www.voilanewyork.com/004_002_000.html");
tmpData[count++] = new menuobject("Stages", "http://www.voilanewyork.com/004_003_000.html");

renderdata();

// FRORUM link data

tmpData[count++] = new menuobject("Rencontres", "http://www.voilanewyork.com/mvnforum/index");
tmpData[count++] = new menuobject("Pratique", "http://www.voilanewyork.com/mvnforum/index");
tmpData[count++] = new menuobject("Scolarité", "http://www.voilanewyork.com/mvnforum/index");
tmpData[count++] = new menuobject("Université", "http://www.voilanewyork.com/mvnforum/index");
tmpData[count++] = new menuobject("Immigration", "http://www.voilanewyork.com/mvnforum/index");
tmpData[count++] = new menuobject("Visites", "http://www.voilanewyork.com/mvnforum/index");
tmpData[count++] = new menuobject("Fourre-tout", "http://www.voilanewyork.com/mvnforum/index");
tmpData[count++] = new menuobject("Logement", "http://www.voilanewyork.com/mvnforum/index");
tmpData[count++] = new menuobject("Emploi", "http://www.voilanewyork.com/mvnforum/index");
tmpData[count++] = new menuobject("Evénements business", "http://www.voilanewyork.com/mvnforum/index");

renderdata();

// PAYS link data

tmpData[count++] = new menuobject("Algérie", "http://www.voilanewyork.com/007_015_000.html");
tmpData[count++] = new menuobject("Belgique", "http://www.voilanewyork.com/007_001_000.html");
tmpData[count++] = new menuobject("Bénin", "http://www.voilanewyork.com/007_019_000.html");
tmpData[count++] = new menuobject("Burkina Faso", "http://www.voilanewyork.com/007_017_000.html");
tmpData[count++] = new menuobject("Burundi", "http://www.voilanewyork.com/007_025_000.html");
tmpData[count++] = new menuobject("Cameroun", "http://www.voilanewyork.com/007_014_000.html");
tmpData[count++] = new menuobject("Canada", "http://www.voilanewyork.com/007_011_000.html");
tmpData[count++] = new menuobject("Côte d'Ivoire", "http://www.voilanewyork.com/007_006_000.html");
tmpData[count++] = new menuobject("France", "http://www.voilanewyork.com/007_002_000.html");
tmpData[count++] = new menuobject("Guinée", "http://www.voilanewyork.com/007_022_000.html");
tmpData[count++] = new menuobject("Haïti", "http://www.voilanewyork.com/007_004_000.html");
tmpData[count++] = new menuobject("Liban", "http://www.voilanewyork.com/007_013_000.html");
tmpData[count++] = new menuobject("Luxembourg", "http://www.voilanewyork.com/007_010_000.html");
tmpData[count++] = new menuobject("Mali", "http://www.voilanewyork.com/007_018_000.html");
tmpData[count++] = new menuobject("Mauritanie", "http://www.voilanewyork.com/007_024_000.html");
tmpData[count++] = new menuobject("Maroc", "http://www.voilanewyork.com/007_007_000.html");
tmpData[count++] = new menuobject("Monaco", "http://www.voilanewyork.com/007_012_000.html");
tmpData[count++] = new menuobject("Niger", "http://www.voilanewyork.com/007_023_000.html");
tmpData[count++] = new menuobject("Rép. Dém. du Congo", "http://www.voilanewyork.com/007_016_000.html");
tmpData[count++] = new menuobject("République du Congo", "http://www.voilanewyork.com/007_021_000.html");
tmpData[count++] = new menuobject("Sénégal", "http://www.voilanewyork.com/007_003_000.html");
tmpData[count++] = new menuobject("Suisse", "http://www.voilanewyork.com/007_008_000.html");
tmpData[count++] = new menuobject("Tchad", "http://www.voilanewyork.com/007_020_000.html");
tmpData[count++] = new menuobject("Togo", "http://www.voilanewyork.com/007_026_000.html");
tmpData[count++] = new menuobject("Tunisie", "http://www.voilanewyork.com/007_009_000.html");
tmpData[count++] = new menuobject("Vietnam", "http://www.voilanewyork.com/007_005_000.html");
								  
renderdata();

