/**
* NetStarter-LinuX Javascript Code
* Author : Benoît Hervochon (for most of the functions!)
* Created : 07-02-2004
**/
function simplePopup(url, w, h, sc) {
if (window.photoWindow) {
		photoWindow.close();
}
window.open(url, 'photoWindow', 'resizable=no,scrollbars=' + sc + ',menubar=no,left=0,top=0,screenX=0,screenY=0,width=' + w + ',height=' + h);
}


function msgWebValidator ()
{
	var test = document.forms['msgWeb'].elements['msgmail'].value;
	var testLength = test.length;
	if (testLength <= 0) {
		alert("Merci de saisir votre message !");
		return false;
	} else {
		if(confirm("Merci de confirmer votre message !")) {
			document.forms['msgWeb'].submit();
		} else {
			return false;
		}
	}
}


function hasParameter(uri, name)
{
	re = new RegExp("[\?\&]" + name + "=");
	return (uri.search(re) != -1);
}


function addParameter(uri, name, value)
{
	re = new RegExp("[\?]");	
	if (uri.search(re) != -1) {uri2 = uri + "&";}
	else {uri2 = uri + "?";}	
	uri2 = uri2 + name + "=" + value;
	return uri2;
}


function replaceParameter(uri, name, value)
{
	if (hasParameter(uri, name)) {	
		re = new RegExp("([\?\&])" + name + "=([^\&]*)(.*)$","");
		uri2 = uri.replace(re, "$1" + name + "=" + value + "$3");
	} else {
		uri2 = addParameter(uri, name, value);
	}
	return uri2;
}


function deleteParameter(uri, name)
{
	re = new RegExp("([\&])" + name + "=([^\&]*)");
	uri = uri.replace(re, "");
	re = new RegExp("([\?])" + name + "=([^\&]*)");
	uri = uri.replace(re, "$1");
	re = new RegExp("[\?][\&]");
	uri = uri.replace(re, "?");	
	re = new RegExp("[\?]$");
	uri = uri.replace(re, "");	
	return uri;
}


function getURL(page, content, params)
{
	uri = URI;
	
	if (page > "") {
		uri = replaceParameter(uri, "page", page);
		if (content > "") {
			uri = replaceParameter(uri, "portlet", content);
		} else {
			uri = deleteParameter(uri, "portlet");
		}
	} else {
		if (content > "") {
			if (hasParameter(uri, "page")) {
				uri = replaceParameter(uri, "portlet", content);
			} else {
				uri = replaceParameter(uri, "page", content);
			}
		}
	}
	
	return (uri + params);
}


function goToPage(page, content, params)
{
	window.location = getURL(page, content, params);
}


function goToPopup(name, page, content, params, width, height, left, top, options)
{

	if (options == '') 
	{
		options = "toolbar=no,location=no,directories=no,status=no,";
		options += "menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,";
	}
	if (left > '') options += "left=" + left + ",";
	if (top > '') options += "top=" + top + ",";
	options += "width=" + width + ",height=" + height;
	if (name == '') name = "atlantal";
	
	window.open(getURL(page, content, params), name, options);
}


function popup(link)
{
	var options = "toolbar=no,location=no,directories=no,status=no,";
	options += "menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,";
	options += "width=600,height=450";
	window.open(link, "test", options);
}


function showit(what) {
         var __obj;
         if (document.getElementById)
                 __obj=document.getElementById(what).style;
         else if (document.layers)
                 __obj=document.layers[what];
         else if (document.all)
                 __obj=document.all[what].style;
         if (__obj)
                 __obj.visibility="visible";
}


function hideit(what) {
         var __obj;
         if (document.getElementById)
                 __obj=document.getElementById(what).style;
         else if (document.layers)
                 __obj=document.layers[what];
         else if (document.all)
                 __obj=document.all[what].style;
         if (__obj)
                 __obj.visibility="hidden";
}


function daKillerPopUp(url, w, h, sc, decalH, decalG, name)
{
	var largEcran = screen.availWidth;
	
	if(name == '')
	{
		var name = 'popup';
		posX = ((largEcran/2)-(w/2))+decalG;
		posY = (80)+decalH;
	}
	else
	{
		posX = ((largEcran/2)-(w/2))+decalG;
		posY = (80)+decalH;
	}
	var sc = sc.toLowerCase();
	if (sc == 'yes scrolling')
	{
		var sc = 'yes';
	}
	else if(sc == 'no scrolling')
	{
		var sc = 'no';
	}
	window.open(url, name, 'resizable=no,scrollbars=' + sc + ',width=' + w + ' ,location=no,status=no,menubar=no,toolbar=no,screenX=' + posX + ',screenY=' + posY +',height=' + h + ',top=' + posY + ',left=' + posX+',screenLeft='+posX+',screenTop='+posY).focus();
}


function setCookie(name,value,expires,path,domain,secure)
{
	document.cookie = name + "=" + escape(value) + 
	((expires) ? ";expires=" + expires.toGMTString() : " ") +
	((path) ? ";path=" + path : " ") +
	((domain) ? ";domain=" + domain : " ") +
	((secure) ? ";secure=" + secure : " ");
}