// Langage change
// Šourtesy Antoine Schmitt 1999

if(!document.getElementById && document.all)
    document.getElementById = function(id) {
        return document.all[id];
    }

function Get_Cookie(name) {
    var start = document.cookie.indexOf(name+"=");
    var len = start+name.length+1;
   if ((!start) && (name != document.cookie.substring(0,name.length))) {
	return null;
    }
    if (start == -1) return null;
    var end = document.cookie.indexOf(";",len);
    if (end == -1) end = document.cookie.length;
    var valu = unescape(document.cookie.substring(len,end))
    return valu;
}

function Set_Cookie(name,value,expires,path,domain,secure) {
/*    if (! expires) {
	 expires = new Date(); 
         expires.setTime(expires.getTime() + 1800000);
    }
    if (!path) path = '/';
*/
    document.cookie = name + "=" +escape(value) +
        ( (expires) ? ";expires=" + expires.toGMTString() : "") +
        ( (path) ? ";path=" + path : "") + 
        ( (domain) ? ";domain=" + domain : "") +
        ( (secure) ? ";secure" : "");
}

function Delete_Cookie(name,path,domain) {
    if (Get_Cookie(name)) document.cookie = name + "=" +
        ( (path) ? ";path=" + path : "") +
        ( (domain) ? ";domain=" + domain : "") +
        ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function asRandom(mmin, mmax) {
	return mmin + Math.round(Math.random()*(mmax - mmin));
}

function layerNamed(aName) {
	calc = document.getElementById(aName);
	if (calc == null) { parent.status = 'unknown calc'+aName; return; }
	return calc;
}

function moveto(calque,x,y)
{
	calc = layerNamed(calque);
	if (calc == null) { return; }
	calc.style.left = x;
	calc.style.top = y;
}

function show(calque)
{
	calc = layerNamed(calque);
	if (calc == null) { return; }
	calc.style.visibility = 'visible';
}
function hide(calque)
{
	calc = layerNamed(calque);
	if (calc == null) { return; }
	calc.style.visibility = 'hidden';
}

// langage
var asLang;
function asSetFr() {
	Set_Cookie('asLang', 'fr');
	asCheckLang();
	}
function asSetEn() {
	Set_Cookie('asLang', 'en');
	asCheckLang();
}

// at start
function asCheckLang() {
	asLang = Get_Cookie('asLang');
	if (asLang == 'en') {
		hide('frCalque');
		show('enCalque');
	} else {
		show('frCalque');
		hide('enCalque');
	}
}

