var _DEBUG      = false;
var _SAT_WIDTH  = 500;
var _SAT_HEIGHT = 355;
var _SAT_NAME   = "cg36Satellite";

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function goToPage(idPage){
    window.location.href = getUrlGen("/cache/offonce","/pid/"+idPage);
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function goToPoleHome(){
    window.location.href = getUrlGen("/cache/offonce","");
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function goToPole(urlKeyPole){
    window.location.href = getUrlGen(_URLK_PORTAIL,urlKeyPole)+"/"+getModeUrlString();
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function goToPortailHome(){
    window.location.href = getUrlGen(_URLK_PORTAIL,_URLK_PORTAIL)+"/"+getModeUrlString();
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function getUrlGen(search,add){
     var theUrl = window.location.href;
     var pos = _PAGE_LOCATION.indexOf(search);
     if (pos != -1) {
        theUrl = _PAGE_LOCATION.substring( 0, pos ) + add;
     }
     if(_DEBUG)alert(theUrl+"\n"+_PAGE_LOCATION);
     return theUrl;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function getModeUrlString(){
    if(_PAGE_LOCATION.indexOf("op/edit")!=-1)return "op/edit";
    else if(_PAGE_LOCATION.indexOf("op/preview")!=-1)return "op/preview";
    else if(_PAGE_LOCATION.indexOf("op/compare")!=-1)return "op/compare";
    else return "";    
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function getWinWidth(){
	if(!document.all&&document.getElementById) return window.innerWidth;
	else return document.body.clientWidth;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function getWinHeight(){
	if(!document.all&&document.getElementById) return window.innerHeight;
	else return document.body.clientHeight;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function openWindow(url,nom,large,haut)
{	
	var MinWin, winOpts="width="+large+",height="+haut+",scrollbars=1,left="+Math.ceil((getWinWidth()-large)/2)+",top="+Math.ceil((getWinHeight()-haut)/2)+",menubar=0,toolbar=0";
	MinWin = window.open(url, nom, winOpts);
	if (navigator.appVersion.indexOf("(X11") != -1 || navigator.appVersion.indexOf("(Mac") != -1)
	   MinWin = window.open(url, nom, winOpts);
	if (navigator.appName == "Netscape" && (parseInt(navigator.appVersion) >=3 ))
	   MinWin.focus();
	return MinWin; 
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function openSatellite(url){
	var pop = openWindow(url,_SAT_NAME,_SAT_WIDTH,_SAT_HEIGHT);	
	pop.focus();
}