var returnlocation = "/intranet/workspace.php"

function showToolsMenu(id) {
	
	var hs = document.getElementById(id);
	var inti = document.getElementById(id+'-pimg');
	t2 = getLeft(hs);
	tleft = getLeft(inti)-140;
	ttop = getTop(inti)+21;
	var state = hs.className;
	alert(state);
	if(state == "off") {
		inti.src = '/ressources/modules/on.png';
		hs.className="on";
		hs.style.posLeft=tleft;
		hs.style.posTop=ttop;
		hs.style.left=tleft;
		hs.style.top=ttop;
	} else if(state== "on") {
		inti.src = '/ressources/modules/off.png';
		hs.style.posLeft=-500;
		hs.style.posTop=-500;
		hs.style.left=-500;
		hs.style.top=-500;
		hs.className="off";
	}
}

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

function show_author_cv() {
	var cv = document.getElementById('author_cv_1');
	if(cv) {
	 cv.className='on';
	}
}

function hide_author_cv() {
	var cv = document.getElementById('author_cv_1');
	if(cv) {
	 cv.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_hover";
				m2.className ="h_menu_hover";
				}
				else {
				m1.className="h_menu_off";				
				m2.className="h_menu_off";				
				}
		}//if class != on
	}//if tsect
}

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)+5;
	ttop = getTop(inti)+22;
	alert(state);
	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_submenu_off";
	}
}

//////////////////////////////////////////////////////////////////
/*VERTICAL MENU */


function vmSubmenu(id,state) {
	
	vH(id);
	var vs = document.getElementById("vm_sub_"+id);
	if(state == "on") {
		vs.className="v_submenu_on";
	} else if(state== "off") {
		vs.className="v_submenu_off";
	}
}

function vH(id) {
	
	var m1 = document.getElementById('vm_'+id);
	var m2 = document.getElementById('vml_'+id);
	var cls = m1.className;
	var cls = cls.slice(cls.lastIndexOf('_')+1,cls.length);
	if(cls) {
		if(cls != "on") {
			if(cls == "off") 
				{
				m1.className ="v_menu_hover";
				m2.className ="v_menu_hover";
				}
				else {
				m1.className="v_menu_off";				
				m2.className="v_menu_off";				
				}
		}//if class != on
	}//if tsect
}

function mvOnClick(id) {
	
	var vmd = document.getElementById('vm_div_'+id);
	var vm = document.getElementById('vm_'+id);
	var cls = vmd.className;
		if(cls == "off") {
				vmd.className ="on";
				vm.className  = "vm_n1_0_on";
		}
				else {
				vmd.className ="off";
				vm.className  = "vm_n1_0_off";
		}//if class != on
}

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

	var	czone = document.getElementById('comment_zone');
	czone.style.visibility = 'visible';
	window.location.href = '#comment';
	document.forms["post_comment"].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 doSearch() {
	var query = document.getElementById('search').value;
	var nurl = '/search/'+query;
	window.location.href = nurl;
}

function recherche() {
	alert('x');
	var query = document.getElementById('search').value;
	var nurl = '/recherche/'+query;
	window.location.href = nurl;
}

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;
}
