var returnlocation = "/intranet/workspace.php"
var st = 0;


function getDim(el){
	for (var lx=0,ly=0;el!=null;
		lx+=el.offsetLeft,ly+=el.offsetTop,el=el.offsetParent);
	return {x:lx,y:ly}
}

function showMapItem(s,dx,dy,pos) {
	
	
	
	//Turn off panes
	//var divc = document.getElementById('balloon');
	//divc.className="off";

	var divc = document.getElementById('balloon');
	var imgp = document.getElementById("bmap");
	var ppal = getDim(imgp);

	var uA = navigator.userAgent;
	var winloc = window.location.href;
	//alert('X:'+cursor_x+' => Y'+cursor_y+' => P X:'+ppal.x+' => P Y:'+ppal.y);

	var curs_x = cursor_x;
	var curs_y = cursor_y;
	if(curs_y < ppal.y+100) {
		curs_y = ppal.y+250;	
	}

	if(pos == 'b_l') {
		divc.style.top = curs_y-225;
		divc.style.left = curs_x-400;
	} else if(pos == 'b_r') {
		divc.style.top = curs_y-200;
		divc.style.left = curs_x;		
	} else if(pos == 't_l') {
		divc.style.top = curs_y-200;
		divc.style.left = curs_x;	
	} else if(pos == 't_r') {
		divc.style.top = curs_y-200;
		divc.style.left = curs_x-400;
	}


	//alert('X:'+cursor_x+' => '+divc.style.top+'\nY:'+cursor_y+' => '+divc.style.left);
	
	//divc.style.top = ppal.x + parseInt(dx)-40;
	//divc.style.left = ppal.y + parseInt(dy);
	
	var spc = document.getElementById('sp_'+s);
	var gsp = document.getElementById('sp_balloon');
	gsp.innerHTML = spc.innerHTML;
	divc.className = 'on_'+pos;
}



function closeCommunityPane() {
	
	var div1 = document.getElementById('cty_pane_left');
	div1.className="off";
	var div2 = document.getElementById('cty_pane_right');
	div2.className="off";
	var div3 = document.getElementById('cty_pane_ext_left');
	div3.className="off";
	var div4 = document.getElementById('cty_pane_ext_right');
	div4.className="off";	
	var div5 = document.getElementById('cty_pane_middle_left');
	div5.className="off";
	var div6 = document.getElementById('cty_pane_middle_right');
	div6.className="off";		
	
}

function mH(id) {
	
	var m1 = document.getElementById('hm_'+id);
	var m2 = document.getElementById('hml_'+id);
	var cls = m1.className;
	var cls = cls.slice(cls.lastIndexOf('_')+1,cls.length);
	if(cls) {
		if(cls != "on") {
			if(cls == "off") 
				{
				m1.className ="h_menu_on";
				m2.className ="h_menu_on";
				}
				else {
				m1.className="h_menu_off";				
				m2.className="h_menu_off";				
				}
		}//if class != on
	}//if tsect
}

function send_to_a_friend(page)
{
var u = '/en/send.php?url='+page;
var w = window.open(u,"","width=400,height=600, toolbar=0, addressbar=0, directories=0, location=0, menubar=0, resizable=1,scrollbars=1,status=0,left=1,top=1");
w.window.focus();
}

function envoyer_a_un_ami(page)
{
var u = '/fr/envoyer.php?url='+page;
var w = window.open(u,"","width=400,height=600, toolbar=0, addressbar=0, directories=0, location=0, menubar=0, resizable=1,scrollbars=1,status=0,left=1,top=1");
w.window.focus();
}

function getLeft(MyObject)
    {
    if (MyObject.offsetParent)
        return (MyObject.offsetLeft + getLeft(MyObject.offsetParent));
    else
        return (MyObject.offsetLeft);
    }

function getTop(MyObject)
    {
    if (MyObject.offsetParent)
        return (MyObject.offsetTop + getTop(MyObject.offsetParent));
    else
        return (MyObject.offsetTop);
    }


function hmSubmenu(id,state) {
	
	mH(id);
	var hs = document.getElementById("hm_sub_"+id);
	//var h2 = document.getElementById("h2_sub_"+id);
	var inti = document.getElementById('hm_i_'+id);
	t2 = getLeft(hs);
	tleft = getLeft(inti);
	ttop = getTop(inti)+30;
	//var cls = hs.className;
	//var state = cls.slice(cls.lastIndexOf('_')+1,cls.length);
	if(state == "on") {
		hs.className="h_sub_on";
		hs.style.posLeft=tleft;
		hs.style.posTop=ttop;
		hs.style.left=tleft;
		hs.style.top=ttop;
	} else if(state== "off") {
		hs.style.posLeft=-500;
		hs.style.posTop=-500;
		hs.style.left=-500;
		hs.style.top=-500;
		hs.className="h_sub_off";
	}
}


function searchSite() {

	var req = document.getElementById('search').value;
	if(req) {
		if(req == "Recherche" || req == "Search") {
	
			return null;	
			} else {
			document.forms[0].submit;
		} //
	} //
} //


function goSelectedPage(url) {
	if(url) {
	 window.location.href = url;
	}
}

function onSubMenuPictureOver(divid) {
	
	if(st == 0) {	
		var sp1 = document.getElementById("smp_s_"+divid);
		var sp2 = document.getElementById("smp_t_"+divid);
		var sp1_s = sp1.innerHTML;
		var sp2_s = sp2.innerHTML;
		sp1.innerHTML = sp2_s;
		sp2.innerHTML = sp1_s;
		st = 1;
	}
}
function onSubMenuPictureOut(divid) {
	
	if(st == 1) {	
		var sp1 = document.getElementById("smp_s_"+divid);
		var sp2 = document.getElementById("smp_t_"+divid);
		var sp1_s = sp1.innerHTML;
		var sp2_s = sp2.innerHTML;
		sp1.innerHTML = sp2_s;
		sp2.innerHTML = sp1_s;
		st = 0;
	}
}



function expandStory(divid) {
	
	var d = document.getElementById(divid);
	if(d) {
		d.className = 'story_frame_sans';
	}
	var d1 = document.getElementById('expandStory');
	d1.className = 'off';
}


function post_comment(blogid,postid) {
	var fblogid = document.getElementById('top_node_id');
	fblogid.value = blogid;
	var fpostid = document.getElementById('reference_id');
	fpostid.value = postid;

	var	czone = document.getElementById('comment_zone');
	czone.style.visibility = 'visible';
	window.location.href = '#comment';
	document.forms["comment_frm"].elements["title"].focus();
} // 


function Popup(doc)
{
var u = doc;
var w = window.open(u,"","width=800,height=600, toolbar=1, addressbar=1, directories=1, location=1, menubar=1, resizable=1,scrollbars=1,status=1,left=1,top=1");
w.window.focus();
}

function printDocument(page)
{
var u = page;
var w = window.open(u,"","width=750,height=600, toolbar=0, addressbar=0, directories=0, location=0, menubar=0, resizable=1,scrollbars=1,status=0,left=1,top=1");
w.window.focus();
}

function getPrintableArea() {
//Opener window print area
var opa = window.opener.document.getElementById('printable_area');
var pa = document.getElementById("printable_area");
pa.innerHTML = opa.innerHTML;
var print_zone = document.getElementById("print");
print_zone.innerHTML = "";
}


function PopFile(doc)
{
var u = doc;
var w = window.open(u,"","width=600,height=450, toolbar=0, addressbar=0, directories=0, location=0, menubar=0, resizable=0,scrollbars=0,status=0,left=200,top=200");
w.window.focus();
}

function PopAudio(doc)
{
var u = doc;
var w = window.open(u,"","width=300,height=200, toolbar=0, addressbar=1, directories=1, location=1, menubar=1, resizable=1,scrollbars=1,status=0,left=1,top=1");
w.window.focus();
}

function close_window(v1,v2)
{
window.close();
}

function showSection(id) {
	
	var tsect = document.getElementById(id);
	if(tsect) {
		if(tsect.className == "on") 
			{
			tsect.className ="off";
			}
			else {
			tsect.className="on";				
			}
	}//if tsect
}

function goSearch() {
	var query = document.getElementById('searchIndex').value;
	var wurl = window.location.href;
	var pquery = '?';
	if(window.location.search) {
		pquery = '';	
	}
	if(query) {
	var nurl = wurl+pquery+'&search='+query;
	window.location.href = nurl;
	}
}

function get_error_message(message) {
	
	var lang;
	if(document.getElementById('wksp_language')) {
	lang = document.getElementById('wksp_language').value;
	} else {
	lang = document.getElementById('s_user_language').value;
	}
	message = message+'_'+lang;
	switch(message)
    {
	case "logged_in_to_access_en" :
        alert('You must be logged in to have access to this section.');
        break;			
	case "logged_in_to_access_fr" :
        alert('Vous devez ouvrir une session pour accéder à cette section.');
        break;		
		
	case "logged_in_to_comment_en" :
        alert('You must be logged in to post a comment.');
        break;			
	case "logged_in_to_comment_fr" :
        alert('Vous devez avoir ouvert une session pour ajouter un commentaire.');
        break;				
	case "user_has_already_clicked_en" :
        alert('Operation already in progress and should resume in a few seconds.');
        break;			
	case "user_has_already_clicked_fr" :
        alert('Opération en cours. Veuillez patienter quelques instants.');
        break;		
	case "file_not_saved_yet_fr" :
        alert('Vous devez enregistrer ce document avant de visualiser le fichier.');
        break;	
	case "file_not_saved_yet_en" :
        alert('You must save your document before viewing this file.');
        break;	
    case "too_many_docs_selected_fr" :
        alert('Vous ne pouvez sélectionner qu\'un document pour cette opération.');
        break;
    case "too_many_docs_selected_en" :
        alert('This operation requires you to select only 1 document.');
        break;
	case "no_docs_selected_fr" :
        alert('Vous devez sélectionner au moins un document pour cette opération.');
        break;
    case "no_docs_selected_en" :
        alert('This operation requires you to select at least 1 document.');
        break;
	case "user_not_authorized_en" :
        alert('You are not authorized to access the page you requested.');
        break;		
	case "user_not_authorized_fr" :
        alert('Vous n\'êtes pas autorisé à accéder à la page demandée.');
        break;
	case "not_available_en" :
        alert('Not available at this time.\n Thanks for your patience.');
        break;		
	
	case "not_available_fr" :
        alert('En développement.\n Merci de votre patience.');
        break;		
		
    } //switch
} //function


//Accents
function replaceAccents(c) {

while(c.indexOf(" ") != -1) c = c.replace(" ","+");

while(c.indexOf("à") != -1) c = c.replace("à","a");
while(c.indexOf("â") != -1) c = c.replace("â","a");
while(c.indexOf("ä") != -1) c = c.replace("ä","a");
while(c.indexOf("À") != -1) c = c.replace("À","A");
while(c.indexOf("Â") != -1) c = c.replace("Â","A");
while(c.indexOf("Ä") != -1) c = c.replace("Ä","A");

while(c.indexOf("ç") != -1) c = c.replace("ç","c");
while(c.indexOf("Ç") != -1) c = c.replace("Ç","c");

while(c.indexOf("é") != -1) c = c.replace("é","e");
while(c.indexOf("è") != -1) c = c.replace("è","e");
while(c.indexOf("ê") != -1) c = c.replace("ê","e");
while(c.indexOf("ë") != -1) c = c.replace("ë","e");
while(c.indexOf("É") != -1) c = c.replace("É","E");
while(c.indexOf("Ê") != -1) c = c.replace("Ê","E");


while(c.indexOf("Ë") != -1) c = c.replace("Ë","E");
while(c.indexOf("È") != -1) c = c.replace("È","E");

while(c.indexOf("î") != -1) c = c.replace("î","i");
while(c.indexOf("ï") != -1) c = c.replace("ï","i");
while(c.indexOf("Î") != -1) c = c.replace("Î","i");
while(c.indexOf("Ï") != -1) c = c.replace("Ï","i");

while(c.indexOf("ô") != -1) c = c.replace("ô","o");
while(c.indexOf("ö") != -1) c = c.replace("ö","o");
while(c.indexOf("Ô") != -1) c = c.replace("Ô","O");
while(c.indexOf("Ö") != -1) c = c.replace("Ö","O");

while(c.indexOf("ù") != -1) c = c.replace("ù","u");
while(c.indexOf("ü") != -1) c = c.replace("ü","u");
while(c.indexOf("û") != -1) c = c.replace("û","u");
while(c.indexOf("Ù") != -1) c = c.replace("Ù","U");
while(c.indexOf("Ü") != -1) c = c.replace("Ü","U");
while(c.indexOf("Û") != -1) c = c.replace("Û","U");

return c;
}
