/*
	Fonction FormAction_DoThis
	Soummettre un formulaire
*/
if (document.all)    {n=0;ie=1;ns6=0;fShow="visible";fHide="hidden";}
if (document.getElementById&&!document.all)    {n=0;ie=0;ns6=1;fShow="visible";fHide="hidden";}
if (document.layers) {n=1;ie=0;ns6=0;fShow="show";fHide="hide";}
opr6=ie&&navigator.userAgent.indexOf("Opera")!=-1
window.onerror=new Function("return true")
/*
var Ver4 = parseInt(navigator.appVersion) >= 4
var Nav4 = ((navigator.appName == "Netscape") && Ver4)
var IE4 = ((navigator.userAgent.indexOf("MSIE") != -1) && Ver4)*/

var timeOn = null;
numMenus = 2;
document.onClick = hideAllMenus;
window.onError = null;

// Navigation menu
function NavOver() {
	clearTimeout(timeOn);
	menuActive = 1;
}
function NavOut() {
 	menuActive = 0;
 	timeOn = setTimeout("hideAllMenus()", 400)
}

function hideAllMenus() {
    for(counter = 1; counter <= numMenus; counter++) {
	changeObjectVisibility('menu' + counter, 'hidden');
    }
}

function NavShowMenu(navname) {
    document.getElementById(navname).style.visibility='visible';
	//clearTimeout(timeOn);
	//NavPushConcent(navname);
}
function NavHideMenu(navname) {
    document.getElementById(navname).style.visibility='hidden';
	//timeOn = setTimeout( 'NavHideDelayed("'+navname+'")', 1000);
}
function NavHideDelayed(navname) {
    document.getElementById(navname).style.visibility='hidden';
	//setTimeout(myfun, 50);
}
/*
function NavPushConcent(navname) {
	//document.frames[0].document.write('Hello world');
	
	doc = document.frames[0];//getElementById(navname);
	//doc.open( );
	doc.document.write("x");
	doc.close( );
	//document.getElementById(navname).write('Hello world');
	
	//document.getElementById(navname).block.innerHTML="Good Afternoon";
}*/
function openWin(url, name) { 
	var n=navigator.appName;
	var browserVersion = navigator.appVersion;
	var ns=(n=="Netscape");
	var ie=(n=="Microsoft Internet Explorer");

	if (isCookieEnabled()) {
	
		if (ns) { //&& browserVersion == '6'
			popupWin = window.open(url, name, "status=yes,toolbar=no,menubar=no,resizable=no,scrollbars,left=100,top=50,width=600,height=500"); 
			windowIsOpen = "true"; 
			popupWin.focus(); 
		}
		else if (ie) { //&& browserVersion == '5'
			popupWin = window.open(url, name, "toolbar=no,menubar=no,resizable=no,scrollbars,left=100,top=50,width=600,height=500"); 
			windowIsOpen = "true"; 
			popupWin.focus(); 
		}
		else {
			popupWin = window.open("browser_error.html", "browser_error", "toolbar=no,menubar=no,resizable=no,scrollbars,left=100,top=50,width=530,height=500"); 
			windowIsOpen = "true"; 
			popupWin.focus(); 
		}
	}
} 

function Form_KeyPress(myfield, e) {
	var keycode;
	if (window.event)
		keycode = window.event.keyCode;
	else if (e)
		keycode = e.which;
	else
		return true;
	if (keycode == 13) {
		if (myfield == 'query') {
			Form_Search();
		} else {
			Form_DoThis('');
			return false;
		}
	} else
		return true;
}

function Form_KEnter(myfield, e, action) {
	var keycode;
	if (window.event)
		keycode = window.event.keyCode;
	else if (e)
		keycode = e.which;
	else
		return true;
	if (keycode == 13) {
		Form_DoThis(action);
	} else
		return true;
}


function Form_KSearch(myfield,e) {
	var keycode;
	if (window.event)
		keycode = window.event.keyCode;
	else if (e)
		keycode = e.which;
	/*else
		return true;*/
		
	if (keycode == 13 || myfield == 'searchbtn' ) {
		var m1 = document.Search;
		m1.submit();
	} else
		return true;
}

function form_autopost(vdelay) {
	if(vdelay>0) {
		vdelay = vdelay*1000;
	} else {
		vdelay = 1000;
	}
	setTimeout('document.FormPrincipal.submit()', vdelay);
}

/*disparait avec la nouvelle version*/
function Form_Search() {
	
	var m1 = document.FormPrincipal;
	m1.action = "/catalog.php";
	m1.iaction.value = "search";
	m1.submit();
}

function Form_DoiAction(_iaction) { 
	var ml = document.FormPrincipal;
	ml.iaction.value = _iaction;
	ml.submit();
}
	
function Form_DoThis(vaction) {
	
	var ml = document.FormPrincipal;
	ml.iaction.value = vaction;
	ml.submit();
}

function Form_DoThisFunction(vfonction) {
	
	var ml = document.FormPrincipal;
	ml.fonction.value = vfonction;
	ml.submit();
}
//Fonction pour effacer une inscrisption
function Form_ConfirmThis(vfonction, message) {
	var ml=document.FormPrincipal;
	var agree = false;
	agree = confirm(message);
	if (agree) {
		ml.fonction.value = vfonction;
		ml.submit();
	} else {
		return false;
	}
}

/*
	SELECT ALL
*/
function Toggle(e) {
	if (e.checked) {
		//Highlight(e);
		document.cours.toggleAll.checked = AllChecked();
	} else {
		//Unhighlight(e);
		document.cours.toggleAll.checked = false;
	}
}

function ToggleAll(e) {
	if (e.checked) {
		CheckAll();
	} else {
		ClearAll();
	}
}

function Check(e) {
	e.checked = true;
	//Highlight(e);
}

function Clear(e) {
	e.checked = false;
	//Unhighlight(e);
}

function CheckAll() {
	var ml = document.FormPrincipal;
	var len = ml.elements.length;
	for (var i = 0; i < len; i++) {
		var e = ml.elements[i];
		if (e.name == "selecteditems[]") {
			Check(e);
		}
	}
	ml.toggleAll.checked = true;
}

function ClearAll() {
	var ml = document.FormPrincipal;
	var len = ml.elements.length;
	for (var i = 0; i < len; i++) {
		var e = ml.elements[i];
		if (e.name == "selecteditems[]") {
			Clear(e);
		}
	}
	ml.toggleAll.checked = false;
}

function SetAction(_this, _iaction) {
	//alert(_iaction);
	_this.form.iaction.value = _iaction;
	return(true);
}

function ProcessOnce(e) {
	e.value = "In Process...";
	e.disabled = true;
	e.form.submit();
	return(true);
}
