// ------------------------------------------------------------------------------------------
// Video 4D - www.video4d.com - info@video4d.com
// Copyright © 2009 Video 4D, tous droits réservés - all rigthts reserved.
// 
// Ce script est prétégé par la loi ds Droits d'Auteur. Il est interdit de le copier, de
// l'altérer ou de l'utiliser sans l'accord formel de Video 4D.
// 
// This script is protected by the law of Copyright and is not to be copied, altered or used
// without the formal authorisation of Video 4D.
// ------------------------------------------------------------------------------------------


window.onload = function() {
	banner_preload('../common/images/Banner-Over_02.gif',
				   '../common/images/Banner-Over_03.gif',
				   '../common/images/Banner-Over_04.gif',
				   '../common/images/Banner-Over_05.gif',
				   '../common/images/Banner-Over_06.gif',
				   '../common/images/Banner-Over_07.gif',
				   '../common/images/Banner-Over_08.gif',
				   '../common/images/Banner-Over_09.gif',
				   '../common/images/Banner-Over_10.gif');
	contentMainTableHeight();
	var bannerLinksIdArray = new Array("bannerHrefLinkBiographie",
						   "bannerHrefLinkAteliers",
						   "bannerHrefLinkBoutique",
						   "bannerHrefLinkBulletinInformations",
						   "bannerHrefLinkPublications",
						   "bannerHrefLinkGalerie",
						   "bannerHrefLinkPhotoDuMois");
	var bannerLinksNameArray = new Array("biographie",
									   "ateliers",
									   "boutique",
									   "bulletinInformations",
									   "publications",
									   "galerie",
									   "photoDuMois");
	for (i = 0; i < bannerLinksNameArray.length; i++) {
	   if (bannerLinksNameArray[i] == currentPage) {
			bannerLinksIdArray.splice(i,1);
			bannerLinksNameArray.splice(i,1);
	   }
	}
	for (var i in bannerLinksIdArray) {
		document.getElementById(bannerLinksIdArray[i]).href = bannerLinksNameArray[i] + ".php";
	}
}

window.onresize = function() {
	contentMainTableHeight();
}

function contentMainTableHeight() {
	var pgaeInHeight = document.documentElement.clientHeight;
	var pageInHeightButBanner = pgaeInHeight - 175 /*Banners top*/ - 17 /*Legal Bottom*/;
	document.getElementById('contentMainTable').style.height = pageInHeightButBanner + "px";
	document.getElementById('contentDIVinstance').style.height = pageInHeightButBanner + "px";
}

function banner_preload() {
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=banner_preload.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];}}
}


// ------------------------------------------------------------------------------------------
// ------------------------------------SUBMENU-----------------------------------------------
// ------------------------------------------------------------------------------------------

if (subMenuLength > 0) {

// ------------------------------------ROLLOVER----------------------------------------------

function subMenu_rollovers(button_nb) {
	if (subMenu_eSelection != button_nb) {
		document.getElementById("subMenuIMG" + button_nb).src = "../common/flash/cubeOver.gif";
	}
}


// ------------------------------------ROLLOUT-----------------------------------------------

function subMenu_rollouts(button_nb) {
	if (subMenu_eSelection != button_nb) {
		outGIFloop();
		document.getElementById("subMenuIMG" + button_nb).src = "../common/flash/cubeOut.gif";
	}
}

function outGIFloop() {
	for(i = 1; i <= subMenuLength; i++) {
		if (subMenu_eSelection != i) {
			document.getElementById("subMenuIMG" + i).src = "../common/images/Cube-Normal.gif";
		}
	}
}


// ------------------------------------CLICK-------------------------------------------------

function subMenu_click(button_nb) {
	subMenu_eSelection = button_nb;
	clickBGloop();
	document.getElementById("subMenuTD" + button_nb).className = "subMenuTDselected";
	document.getElementById("subMenuIMG" + button_nb).src = "../common/images/Cube-Selected.gif";
	document.getElementById("subMenuSP" + button_nb).className = "";
	document.getElementById("subMenuTX" + button_nb).style.color = "#336600";
	contentInsertion("contentDIVinstance", "../content/" + currentPage + "/en/" + button_nb + ".html");
}

function clickBGloop() {
	for(i = 1; i <= subMenuLength; i++) {
		document.getElementById("subMenuTD" + i).className = "";
		document.getElementById("subMenuSP" + i).className = "subMenuTDnormal";
		document.getElementById("subMenuIMG" + i).src = "../common/images/Cube-Normal.gif";
		document.getElementById("subMenuTX" + i).style.color = "#000000";
	}
}


// -----------------------------------------CONTENT INSERTION--------------------------------


function contentInsertion(id, url) {
  var req = false;
  // For Safari, Firefox, and other non-MS browsers
  if (window.XMLHttpRequest) {
    try {
      req = new XMLHttpRequest();
    } catch (e) {
      req = false;
    }
  } else if (window.ActiveXObject) {
    // For Internet Explorer on Windows
    try {
      req = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        req = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {
        req = false;
      }
    }
  }
 var element = document.getElementById(id);
 if (!element) {
  alert("Bad id " + id +
   "passed to clientSideInclude." +
   "You need a div or span element " +
   "with this id in your page.");
  return;
 }
  if (req) {
    // Synchronous request, wait till we have it all
    req.open('GET', url, false);
    req.send(null);
    element.innerHTML = req.responseText;
  } else {
    element.innerHTML =
   "Sorry, your browser does not support " +
      "XMLHTTPRequest objects. This page requires " +
      "Internet Explorer 5 or better for Windows, " +
      "or Firefox for any system, or Safari. Other " +
      "compatible browsers may also exist.";
  }
}

}

// ------------------------------------------------------------------------------------------
// ------------------------------------SUBMENU-----------------------------------------------
// ------------------------------------------------------------------------------------------
