/*
 * Devolia front-end Javascript API
 * Date 2008.07.07
 * @Version 2008.07.07
 * @copyright 2006-2009 Devolia
 * 
 * Mediathèque PSA Peugeot Citroën
*/

// Variables Globales

//Foncions globales

	function getWindowSize(){
		windowWidth =  window.innerWidth;
		windowWidth = (windowWidth)? windowWidth : document.documentElement.clientWidth;
		windowWidth = (windowWidth)? windowWidth : document.body.clientWidth;
		windowHeight =  window.innerHeight;
		windowHeight = (windowHeight)? windowHeight: document.documentElement.clientHeight;
		windowHeight = (windowHeight)? windowHeight: document.body.clientHeight;  
		return {'width': windowWidth, 'height': windowHeight};
	}
		
	function getPageSize(){
		var windowSize = getWindowSize()
		var xScroll = document.body.scrollWidth;
		var yScroll = (window.innerHeight && window.scrollMaxY)? window.innerHeight + window.scrollMaxY : document.body.scrollHeight;
		var pageWidth = (xScroll < windowSize.width)? windowSize.width : xScroll;  
		var pageHeight = (yScroll < windowSize.height)? windowSize.height : yScroll;
		return {'width': pageWidth, 'height': pageHeight};
	}


//Fonctions d'initialisation

	 /**
	 *	Loads everything
	 *	@version 2008.02.19
	 */
	function init_ds(){
		
		var screendim=getPageSize();
		document.getElementById('opacity_back').style.height = Math.round(screendim.height)+'px';
		document.getElementById('opacity_back').style.width = Math.round(screendim.width)+'px';
		
		document.getElementById('forms_background').style.top = Math.round((screendim.height/2 - 340))+'px';
		document.getElementById('forms_background').style.left = Math.round((screendim.width/2 - 305))+'px';
	}

/**
 *	Screen has been resized
 *	@version 2008.02.20
 */
function resize_event(){
	
	var screendim=getPageSize();
	
	document.getElementById('opacity_back').style.height = Math.round(screendim.height)+'px';
	document.getElementById('opacity_back').style.width = Math.round(screendim.width)+'px';
	
	document.getElementById('forms_background').style.top = Math.round(screendim.height/2 - 340)+'px';
	document.getElementById('forms_background').style.left = Math.round(screendim.width/2 - 305)+'px';
}

/**
 *	Highlights the navigate div on Hover
 *	@version 2008.07.06
 */
function menu_on(number){
	
	switch(number){
		
		case '1':
			document.getElementById('mediatheque_img').src = "images/navigate_mediatheque_on.png";
			document.getElementById('mediatheque_text').style.color="#FFFFFF";
		break;
		
		case '2':
			document.getElementById('thematique_img').src = "images/navigate_thematique_on.png";
			document.getElementById('thematique_text').style.color="#FFFFFF";
		break;
		
		case '3':
			document.getElementById('actus_img').src = "images/navigate_actu_on.png";
			document.getElementById('actus_text').style.color="#FFFFFF";
		break;
		
		default:
		break;
	}
}

/**
 *	NOT Highlights the navigate div on Hover
 *	@version 2008.07.06
 */
function menu_off(number){
	
	switch(number){
		
		case '1':
			document.getElementById('mediatheque_img').src = "images/navigate_mediatheque_off.png";
			document.getElementById('mediatheque_text').style.color="#666666";
		break;
		
		case '2':
			document.getElementById('thematique_img').src = "images/navigate_thematique_off.png";
			document.getElementById('thematique_text').style.color="#666666";
		break;
		
		case '3':
			document.getElementById('actus_img').src = "images/navigate_actu_off.png";
			document.getElementById('actus_text').style.color="#666666";
		break;
		
		default:
		break;
	}
}

/**
 *	Opens the left div on Hover
 *	@version 2008.07.06
 */
function menu_open(number){
	
	switch(number){
		
		case '1':
			document.getElementById('left_dossiers_div').style.display = "block";
			document.getElementById('left_panier_div').style.display = "none";
			document.getElementById('left_recherche_div').style.display = "none";
		break;
		
		case '2':
			document.getElementById('left_dossiers_div').style.display = "none";
			document.getElementById('left_panier_div').style.display = "block";
			document.getElementById('left_recherche_div').style.display = "none";
		break;
		
		case '3':
			document.getElementById('left_dossiers_div').style.display = "none";
			document.getElementById('left_panier_div').style.display = "none";
			document.getElementById('left_recherche_div').style.display = "block";
		break;
		
		default:
		break;
	}
}

/**
 *	Shows the identified form
 *	@version 2008.07.06
 */
function show_forms(){
	
	document.getElementById('opacity_back').style.display = "block";
	document.getElementById('forms_background').style.display = "block";
	
}

/**
 *	Hides the identified form
 *	@version 2008.07.06
 */
function hide_forms(){
	
	document.getElementById('opacity_back').style.display = "none";
	document.getElementById('forms_background').style.display = "none";
	
}

/**
 *	Shows the identified list
 *	@version 2008.07.06
 */
function show_liste(number){
	
	switch(number){
		
		case '1':
			document.getElementById('liste_bloc1_div').style.display = "block";
			if(document.getElementById('liste_bloc2_div')){
				document.getElementById('liste_bloc2_div').style.display = "none";
			}
		break;
		
		case '2':
			document.getElementById('liste_bloc2_div').style.display = "block";
			if(document.getElementById('liste_bloc1_div')){
				document.getElementById('liste_bloc1_div').style.display = "none";
			}
		break;
		
		default:
		break;
	}
	
}

/**
 *	Hides the identified list
 *	@version 2008.07.06
 */
function hide_liste(number){
	
	switch(number){
		
		case '1':
			document.getElementById('liste_bloc1_div').style.display = "none";
		break;
		
		case '2':
			document.getElementById('liste_bloc2_div').style.display = "none";
		break;
		
		default:
		break;
	}
	
}