/******************************************************************************
* xcndpFonctions.js
*******************************************************************************

*******************************************************************************
*                                                                             *
* Copyright 2008									                          *
*                                                                             *
******************************************************************************/
var textSearchAlert = 'Veuillez renseigner au minimum 2 caractères pour la recherche';
var textSearchDefault = 'Recherche:';
var textSearchNewColor = '#f40';
var textSearchNewAlign = 'center';
var textSearchDefaultAlign = 'left';

function caracterSearch(nameForm,inputDefaultWidth,textSearchDefaultColor){
	var fulltextAdvValue = document.forms[nameForm].fulltextAdv.value;
	if(fulltextAdvValue==textSearchDefault || fulltextAdvValue==textSearchAlert){
		document.forms[nameForm].fulltextAdv.value='';
		document.forms[nameForm].fulltextAdv.style.width=inputDefaultWidth+'px';
		document.forms[nameForm].fulltextAdv.style.color=textSearchDefaultColor;
		document.forms[nameForm].fulltextAdv.style.textAlign=textSearchDefaultAlign;

	}
};

function minCaracterSearch(nameForm,inputNewWidth){

	var nbMiniCaracterSearch = 2;
	var fulltextAdvValue = document.forms[nameForm].fulltextAdv.value;
	var disciplineValue = document.forms[nameForm].discipline.value;
	var levelValue = document.forms[nameForm].level.value;
	var supportValue = document.forms[nameForm].support.value;
	var editorValue = document.forms[nameForm].editor.value;
	var collectionValue = document.forms[nameForm].collection.value;
	
	
	if(nameForm == 'advSearch'){
		var labelRadioChecked = document.getElementById("labelRadio").checked;
		var authorsRadioChecked = document.getElementById("authorsRadio").checked;
		var noteRadioChecked = document.getElementById("noteRadio").checked;
		var isbnRadioChecked = document.getElementById("isbnRadio").checked;
		var issnRadioChecked = document.getElementById("issnRadio").checked;
		var publicCodeRadioChecked = document.getElementById("publicCodeRadio").checked;
				
		if(fulltextAdvValue != '' && fulltextAdvValue != textSearchAlert && !labelRadioChecked && !authorsRadioChecked && !noteRadioChecked && !isbnRadioChecked && !issnRadioChecked && !publicCodeRadioChecked){
			document.getElementById("labelRadio").checked = true;
			return true;
		}
		
		if((fulltextAdvValue == '' || fulltextAdvValue == textSearchAlert) && (disciplineValue != '' || levelValue != '' || supportValue != '' || editorValue != '' || collectionValue != '')){
			document.forms[nameForm].fulltextAdv.value = '';
			return true;
		}
	}
	
	if(fulltextAdvValue.length < nbMiniCaracterSearch || fulltextAdvValue == textSearchDefault || fulltextAdvValue == textSearchAlert){
		document.forms[nameForm].fulltextAdv.style.width=inputNewWidth+'px';
		document.forms[nameForm].fulltextAdv.style.color=textSearchNewColor;
		document.forms[nameForm].fulltextAdv.style.textAlign=textSearchNewAlign;
		document.forms[nameForm].fulltextAdv.value = textSearchAlert;
		document.forms[nameForm].blur();
		return false;
	}
	return true;
};

function displayArbo(num) {
	var ulId = 'ul' + num;
	var imgId = 'imgPuceMenu' + num;
	if (document.getElementById(ulId).style.display=='none'){
		document.getElementById(ulId).style.display='block';
		document.getElementById(imgId).src="iso_icons/puceMenu2Open.gif";
	}else{
		document.getElementById(ulId).style.display='none';
		document.getElementById(imgId).src="iso_icons/puceMenu2Close.gif";
	}
}

function openAdvSearch(){
	document.getElementById('visibleOption').style.display='block';
	document.getElementById('moreOption').style.display='none';
}