// // ---------------------------------
// // ---------------------------------
// // ---------------------------------
// // ---------------------------------
/*       DONT modify   */
// // ---------------------------------
// // ---------------------------------
// // ---------------------------------
// // ---------------------------------

$.ajaxSetup({headers: {"X-Requested-With":"Ajax"}}); 

// Action ONLOAD ofor each page
// After loading the page, this is actions to do :
$(document).ready(function(){
//pass where to apply thickbox
tb_init('a.thickbox, area.thickbox, input.thickbox');
// preload image
imgLoader = new Image();
// Check display/hide the News Box
imgLoader.src = myurl+'../app/webroot/img/loadingAnimation.gif';
// Set the login box to hide
$('#loginbox').hide();
// Select how to display the news box
if (readCookie("news_box") == 1){toggle_news_box();}
});


// Load the new language and return to the previous page
function changelang(lng,return_link){
$.get(myurl+"menu/changelg/"+lng+'/',function(date){
	redir(return_link);
	});
}

// Display/hide the news box
function toggle_news_box(){

if (document.getElementById('rightcolumn'))
	{
	if (document.getElementById('rightcolumn').style.display == 'none')
		{
		document.getElementById('main').style.width = 460+'px';
		$('#rightcolumn_hide').hide();
		$('#rightcolumn').fadeIn();
		writecookie('news_box', 0);
		}
		else
		{
		document.getElementById('main').style.width = 560+'px';
		$('#rightcolumn').hide();
		$('#rightcolumn_hide').fadeIn();
		writecookie('news_box', 1);
		}
	}
}

// Write a cookie with name and value
function writecookie(nom, valeur)
{
var argv=writecookie.arguments;
var argc=writecookie.arguments.length;
var expires=(argc > 2) ? argv[2] : null;
var path=(argc > 3) ? argv[3] : null;
var domain=(argc > 4) ? argv[4] : null;
var secure=(argc > 5) ? argv[5] : false;
document.cookie=nom+"="+escape(valeur)+
((expires==null) ? "" : ("; expires="+expires.toGMTString()))+
((path==null) ? "" : ("; path="+path))+
((domain==null) ? "" : ("; domain="+domain))+
((secure==true) ? "; secure" : "");
}

// Write a cookie from name
function readCookie(name)
{
var cookieValue = "";
var search = name + "=";
if(document.cookie.length > 0)
	{ 
	offset = document.cookie.indexOf(search);
	if (offset != -1)
		{ 
		offset += search.length;
		end = document.cookie.indexOf(";", offset);
		if (end == -1) end = document.cookie.length;
		cookieValue = unescape(document.cookie.substring(offset, end))
		}
	}
return cookieValue;
}

// Do a redirection from the Url
function redir(url)
{
window.location.replace(url);
}

// Reload actual page
function reload()
{
window.location.reload();
}

// Display box
function Show(div)
{
document.getElementById(div).style.visibility = "visible";
document.getElementById(div).style.display = "block";
}

function Hide(div)
{
document.getElementById(div).style.visibility = "hidden";
document.getElementById(div).style.display = "none";
}

function HideAll(v_arr)
{
// Hide every divs
for (i=0;i<v_arr.length;i++)
	{
	Hide(v_arr[i]);
	}
}

function displayHide(id,v_arr)
{
// Hide every divs
HideAll(v_arr);

// active the right div
Show(id);
}