
var Urcam = {};


Urcam.detectIe = function(){
	return /MSIE (\d+\.\d+);/.test(navigator.userAgent);
}
Urcam.newsOver = function(n){
	//document.getElementsByName('news')[n].style.textDecoration='underline';
	n.getElementsByTagName('A')[0].style.textDecoration='underline';
}
Urcam.newsOut = function(n){
	//document.getElementsByName('news')[n].style.textDecoration='none';
	n.getElementsByTagName('A')[0].style.textDecoration='none';
}
Urcam.newsClick = function(n){
	//document.location.href=document.getElementsByName('news')[n].href;
	document.location.href = n.getElementsByTagName('A')[0].href
}
Urcam.lien = function(n){
	if (Urcam.detectIe()){
		document.location.href=document.getElementById('menuJS').childNodes[n].firstChild.firstChild.href;
	}
	else{
		document.location.href=document.getElementsByName('lienMenu')[n].href;
	}
}
// test sur recerche champ
Urcam.valueCheck = function(element){
	element.value='';
}
// test sur homePageR.html
Urcam.selectRegion= function(){
	var region=document.getElementById('rSelect').options[document.getElementById('rSelect').selectedIndex].value;
	var image='images/pictos/'+region+'.gif';
	document.getElementById('france').src=image;
}
// test sur pageOnglet
Urcam.changeOnglet = function(onglet){
	if(onglet=='r'){
		document.getElementById('ongletR').className='bouton gauche selection';
		document.getElementById('ongletD').className='bouton gauche';
		document.getElementById('ressources').className='';
		document.getElementById('docs_dl').className='invisible';
	}else if(onglet=='d'){
		document.getElementById('ongletD').className='bouton gauche selection';
		document.getElementById('ongletR').className='bouton gauche';
		document.getElementById('ressources').className='invisible';
		document.getElementById('docs_dl').className='';
	}
}



Urcam.formatType_fullWeigth = function() {
	//permet d'agrandir le portlet formatType en cas d'absence du menu à droite
	if(!document.getElementById('menuDroite')){
		if(document.getElementById('formatType')){
		document.getElementById('formatType').style.width='744px';
		document.getElementById('formatType').className='formatType fullWeigth gauche';
		}
	}
}
Event.observe(window, 'load', function(){
	//permet d'agrandir le portlet formatType en cas d'absence du menu à droite
	if(! $('menuDroite') && $('formatType')){
		document.getElementById('formatType').style.width = '744px';
		document.getElementById('formatType').className = 'formatType fullWeigth gauche';
	}
});




/**
 * toggle FAQ Items
 *
 * @param id 		the id of the FAQ item to hide or show
 * @param single	true to show only one item at a time, false the open as many as you want
 */
Urcam.toggleFaq = function (id, single, hash) {	
		
	if(single) {
		//show only one Q+A at a time
		
		Urcam.toggleAll(false, hash);		
		Urcam.showHideFaq(id, true, hash);
	}
	else {
		//open as many Q+A as you like		
		if(document.getElementById('irfaq_a_'+id+'_'+hash).style.display == 'none') {
			Urcam.toggleAll(false, hash);		
			Urcam.showHideFaq(id, true, hash);
		}
		else {
			Urcam.showHideFaq(id, false, hash);
		}	
	}	
}

/**
 * shows or hides a FAQ item at a time depending on the given status
 *
 * @param id 		the id of the FAQ item to hide or show
 * @param status	true to show the item, false to hide it
 */
Urcam.showHideFaq = function (id, status, hash) {	
	var faq_id = 'irfaq_a_'+id+'_'+hash; //answer
	var pm_id  = 'irfaq_pm_'+id+'_'+hash; // plus/minus icon
	if(status) {
		
		document.getElementById(faq_id).style.display = 'inline';
		document.getElementById(pm_id).src = tx_irfaq_pi1_iconMinus;
	}
	else {
		document.getElementById(faq_id).style.display = 'none';	
		document.getElementById(pm_id).src = tx_irfaq_pi1_iconPlus;
	}
}

/**
 * shows or hides all FAQ items with one click
 *
 * @param mode	true to show the items, false to hide them
 */
Urcam.toggleAll = function (mode, hash, count) {	
	//alert("count = " + count);
	//count = (count != "undefined") ? count : document.frm.test.value;
	count = document.modern_faq.cpt.value;
	//alert(document.frm.test.value + "###456]]]]" + count);
	
	/*for(i = 0; i < count; i++) {
		Urcam.showHideFaq(i+1, mode, hash);
	}	*/
}

var tx_irfaq_pi1_iconPlus = "images/pictos/faq_plus.gif";
var tx_irfaq_pi1_iconMinus = "images/pictos/faq_moins.gif";


Urcam.hide = 0;

Urcam.hideCritere = function () {
	if (!Urcam.hide) { // DOM3 = IE5, NS6
			document.getElementById('themeSearch').style.visibility = 'hidden';
			document.getElementById('themeSearch').style.overflow = 'hidden';
			document.getElementById('themeSearch').style.display="none"; 
			document.getElementById('hideCritere').innerHTML = "Afficher les critères";
			Urcam.hide = true;
	} else{
			document.getElementById('themeSearch').style.visibility = 'visible';
			document.getElementById('themeSearch').style.overflow = 'visible';
			document.getElementById('themeSearch').style.display="block"; 
			document.getElementById('hideCritere').innerHTML = "Masquer les critères";
			Urcam.hide = false;
	}
}


Urcam.hideCritere2 = function (link) {
	link = $(link);
	link.toggleClassName('themeAClicker');
	link.toggleClassName('themeClick');
	var div = link.next('div');
	if (div) div.toggle();
}


/**
 * Pour le block "Document à télécharger".
 */
Urcam.voirTousLesDocuments = function (elm) {
	elm = $(elm);
	var parentDiv = elm.up('div');
	if (! parentDiv) return;
	parentDiv = parentDiv.up('div');
	if (! parentDiv) return;

	//$$('.menuDroite .milieuListItem').each(function(elm){
	parentDiv.select('.milieuListItem').each(function(doc){
		doc.show();
	});
	elm.up().hide();
}

Urcam.tipAFriend = function(element)
{
  var currentHref = document.location.href;
  
  var hrefTipAFriend = element.href;
  
  var parametersUrl = "tipUrl="+encodeURIComponent(currentHref);
  if(hrefTipAFriend.indexOf("?") == -1)
  {
	parametersUrl = "?" + parametersUrl;
  }else
  {
	parametersUrl = "&" + parametersUrl;
  }
  var w = window.open( hrefTipAFriend+ parametersUrl, 'popup', 'height=500,width=600,status=0,menubar=0,scrollbars=1,resizable=1,location=0,directories=0,toolbar=0');
  w.focus();
}



Urcam.printPage = function(element)
{
  var currentHref = document.location.href;
  
  var hrefTipAFriend = element.href;
  
  var parametersUrl = "tipUrl="+encodeURIComponent(currentHref);
  if(hrefTipAFriend.indexOf("?") == -1)
  {
	parametersUrl = "?" + parametersUrl;
  }else
  {
	parametersUrl = "&" + parametersUrl;
  }
  var w = window.open( hrefTipAFriend+ parametersUrl, 'printPage', 'height=500,width=600,status=0,menubar=0,scrollbars=1,resizable=1,location=0,directories=0,toolbar=0');
  w.focus();
}






