function xLoaded() {
	if (currentSection!="") {
		goSection(currentSection);
	}
	stopVideo_frame();
}


function keyPressed(e) {
	if(e.type=="keypress") {
		switch(e.keyCode) {
			case 37: break; // left
			case 38: break; // up
			case 39: break; // right
			case 40: break; // down
		}
	}

}

currentNewsItem = null;

function showNewsItem(vId) {
	// close last item
	if(currentNewsItem!=null) {
		var divData_last = xGetObject("news_"+currentNewsItem+"_data");
		xSetDisplay(divData_last,"none");
	}
	// open new item
	if (vId!=null) {
		var divData = xGetObject("news_"+vId+"_data");
		xSetDisplay(divData,"block");

		//xSetDisplay(xGetObject("news_retour"),"block");
		//xSetDisplay(xGetObject("news_pager"),"none");
	}
	currentNewsItem=vId;
}
function closeNewsItem() {
	showNewsItem(null);
	//xSetDisplay(xGetObject("news_retour"),"none");
	//xSetDisplay(xGetObject("news_pager"),"block");

}

function showSection_static(vNum,vCode,vId) {
	var vBase=sectionClientPath+vNum+"_section_Panel";

	xShowSection(vBase,vCode,vId);
}

function showSection(vCode,vId) {
	xShowSection("s_"+vCode+"_",vCode,vId);
}

function xShowSection(vBase,vCode,vId) {
	if (!aSections[vCode]) aSections[vCode]=1;
	if(aSections[vCode]==vId) return;

	var xSection = xGetObject(vBase+vId);
	if(xSection) xSetDisplay(xSection,"block");
	var divMenu = xGetObject("sMenu_"+vCode+"_"+vId);
	if(divMenu) divMenu.className = "item_a";

	var vLast = aSections[vCode];
	var xLastSection = xGetObject(vBase+vLast)
	if (xLastSection)  xSetDisplay(xLastSection,"none");
	var lastMenu = xGetObject("sMenu_"+vCode+"_"+vLast);
	if(lastMenu) lastMenu.className = "item";

	aSections[vCode]=vId;
}

currentSection=null;

function goSection(vId) {
	var vY = yGetCurrentScroll();

	if (vId=="top") {
		scrollTo(0,0,Tween.strongEaseOut,1);
	} else {
		var xAnchor = xGetObject("a_"+vId);
		var vYd = xAnchor.offsetTop;
		if (!window.scrollY) vYd -= 30;
		if (vY<= 50) {
			scrollTo(0,vYd,Tween.strongEaseInOut,1.5);
		} else {
			scrollTo(0,vYd,Tween.strongEaseInOut,1);
		}

	}
	currentSection=vId;
	scrollDone = goSectionDone;
	//hideSplash();

}

function hideSplash() {
	goSection('portfolio');
}

function goSplash() {
	showNewsItem('99');
	goSection('nouvelles');
}

function goSectionDone() {
	//stopVideo_frame();
	//top.location="#"+currentSection;
	//if (!window.scrollY) window.scrollBy(0,-30);
}



function playVideo_frame(video,width,height) {
	langue=xLg;
	if(!width) width=640;
	if(!height) height=480;

	var xiFrame = xGetObject("ifVideos");
	var xiFDoc = xiFrame.contentDocument;
	if (xiFrame.contentWindow ) xiFDoc = xiFrame.contentWindow;

	xiFDoc.location = "/medias/player.aspx?file=/videos/"+video+"&width="+width+"&height="+height+"&langue="+langue;

	hidePlayBtn();
}

function hidePlayBtn() {
    var hVideo = xGetObject("playBtn");
    hVideo.style.display = 'none';
}

/*ThickBox*/
if(xLg == "fr"){ var tb_closeCaption = "Fermer"; var tb_closeCaption2 = "";}

function showMedia(vFile,vTitre,vWidth,vHeight) {
	if(!vWidth) vWidth= 450;
	if(!vHeight) vHeight= 340;
	if(!vTitre) vTitre = "";
	//vWidth-=30;
	//vHeight-=10;
	tb_show(vTitre,"/medias/player.aspx?file="+vFile+"&TB_iframe=true&width="+vWidth+"&height="+vHeight+"&modal=false&scrolling=no");
}

function showFrame(vUrl,vTitre,vWidth,vHeight) {
	var paramSep="?";
	if(vUrl.indexOf("?")>0) paramSep="&";
	tb_show(vTitre,vUrl+paramSep+"s=1&TB_iframe=true&width="+vWidth+"&height="+vHeight+"&modal=false&scrolling=no");
}

function stopVideo_frame() {
	var xiFrame = xGetObject("ifVideos");
	var xiFDoc = xiFrame.contentDocument;
	if (xiFrame.contentWindow ) xiFDoc = xiFrame.contentWindow;
	xFDiv = xiFDoc.xGetObject("content");
	xSetDisplay(xFDiv,"none");

	var hVideo = xGetObject("playBtn");
    hVideo.style.display = 'block';
}

function playVideo(video,nomVideo,langue) {
	if(!langue) langue=xLg;
	showFrame("/medias/player.aspx?file=/videos/"+video+"&langue="+langue, nomVideo, 610, 469);
	stopVideo_frame();
}

function showImage(imageUrl,imageTitre) {
    if(!imageTitre) imageTitre = top.document.title;
	tb_show(imageTitre,imageUrl+"?width");
}
