function getVar (nomVariable)
{
 	var infos = location.href.substring(location.href.indexOf("?")+1, location.href.length)+"&"
	
 	if (infos.indexOf("#")!=-1)
 	infos = infos.substring(0,infos.indexOf("#"))+"&"
 	var variable=0
	{
 	nomVariable = nomVariable + "="
 	var taille = nomVariable.length
	
	if (infos.indexOf(nomVariable)!=-1)
	variable = infos.substring(infos.indexOf(nomVariable)+taille,infos.length).substring(0,infos.substring(infos.indexOf(nomVariable)+taille,infos.length).indexOf("&"))
	}
	
	return variable
} 

function SetCookie (name, value) {
	var argv=SetCookie.arguments;
	var argc=SetCookie.arguments.length;
	var expires=(argc > 2) ? argv[2] : null;
	/*var path=(argc > 3) ? argv[3] : null;*/
	var temp = argv[3].split('/');
	//if(temp[1] == "worldgsm_v3"){ var path="/worldgsm_v3/"; }else{ var path="/"; }
	var path="/";
	//var domain=(argc > 4) ? argv[4] : null;
	var domain = ".worldgsm.com";
	var secure=(argc > 5) ? argv[5] : false;
	document.cookie=name+"="+escape(value)+
		((expires==null) ? "" : ("; expires="+expires.toGMTString()))+
		((path==null) ? "" : ("; path="+path))+
		((domain==null) ? "" : ("; domain="+domain))+
		((secure==true) ? "; secure" : "");
}

function getCookieVal(offset) {
	var endstr=document.cookie.indexOf (";", offset);
	if (endstr==-1)
      		endstr=document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {
	var arg=name+"=";
	var alen=arg.length;
	var clen=document.cookie.length;
	var i=0;
	while (i<clen) {
		var j=i+alen;
		if (document.cookie.substring(i, j)==arg)
                        return getCookieVal (j);
                i=document.cookie.indexOf(" ",i)+1;
                        if (i==0) break;}
	return null;
}


//-----------------------------------------------

function set_visibility(element_id, state)
{
	var element = document.getElementById(element_id);
	if(state == 'true')
		element.style.display = "";
	else
		element.style.display = "none";
}
function checkbox_by_list(list, value) {
	//example : list = 'checkbox1;checkbox2;'
	var tableau=list.split(';');
	for (var i=0; i<tableau.length - 1; i++) {
		document.getElementById(tableau[i]).checked=value ; 
	}
}
//------------------------------DEBUT FONCTION GET_FORM_INPUTS--------------------------------
//fonction permettant de recuperer les differents champs d'un formulaire
//et de les renvoyer au format URL
function get_form_inputs(form_name)
{
	var return_string = '';	
	var form_size = document.forms[form_name].length;
	var element;
	
	for(var i = 0 ; i < form_size ; i++)
	{
		element = document.forms[form_name][i];
		if(element.type == 'text' || element.type == 'textarea')
		{
			return_string += element.name+'='+element.value + '&';
		}
		else if(element.type == 'radio' && element.checked )
		{
			return_string += element.name+'='+element.value + '&';
		}
		else if(element.type == 'checkbox')
		{
			return_string += element.name+'='+element.checked + '&';
		}
		else if(element.type == 'select-one')
		{
			return_string += element.name+'='+element.value + '&';
		}
		else if(element.type == 'hidden')
		{
			return_string += element.name+'='+element.value + '&';
		}
	}
	return return_string;
}
//------------------------------FIN FONCTION GET_FORM_INPUTS--------------------------------


//------------------------------DEBUT FONCTION ENABLE--------------------------------
function enable(thingId)
{
	var targetElement;
	targetElement = document.getElementById(thingId) ;
	//alert(targetElement);
	if (targetElement.disabled)
	{
		targetElement.disabled = false ;
	} 
	else 
	{
		targetElement.disabled = true ;
	}
}
//------------------------------FIN FONCTION ENABLE--------------------------------

//------------------------------DEBUT FONCTION VISIBLE--------------------------------
function visibilite(thingId)
{
	var targetElement;
	targetElement = document.getElementById(thingId) ;
	if (targetElement.style.display == "none")
	{
		targetElement.style.display = "" ;
	} else {
		targetElement.style.display = "none" ;
	}
}
//------------------------------FIN FONCTION VISIBLE--------------------------------
//------------------------------DEBUT FONCTION ROLLOVER--------------------------------
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//------------------------------FIN FONCTION ROLLOVER--------------------------------

//-------------------------DEBUT FONCTION POUR PASSER DES PARAMETRES DANS L'URL---------------------------------
function getUrl(url)
{	
	document.location = url;
}
//-------------------------FIN FONCTION POUR PASSER DES PARAMETRES DANS L'URL-----------------------------------

//-------------------------DEBUT FONCTION POP-UP INSERTION IMAGE PRODUIT----------------------------------------
function insertImage(product_id) 
{   
		window.open('popup_select_upload_product_image_web.php?product_id=' + product_id,'Popup',  'toolbar=0,location=0,directories=0,status=1,scrollbars=0,resizable=0,copyhistory=0,menuBar=0,width=550,height=400,top=100,left=100');  
}
//--------------------------FIN FONCTION POP-UP INSERTION IMAGE PRODUIT-----------------------------------------
//-------------------------DEBUT FONCTION POP-UP INSERTION IMAGE USER----------------------------------------
function insertUserImage(user_id) 
{   
		window.open('popup_select_upload_user_image_web.php?user_id=' + user_id,'Popup',  'toolbar=0,location=0,directories=0,status=1,scrollbars=0,resizable=0,copyhistory=0,menuBar=0,width=350,height=270,top=100,left=100');  
}
//--------------------------FIN FONCTION POP-UP INSERTION IMAGE USER-----------------------------------------
//-------------------------DEBUT FONCTION POP-UP COMPATIBILITES PRODUIT----------------------------------------
function popup_product_compatibility(product_id) 
{   
		window.open('popup_search_product_for_compatibility.php?product_id=' + product_id,'Popup',  'toolbar=0,location=0,directories=0,status=1,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width=700,height=600,top=50,left=100');  
}
//--------------------------FIN FONCTION POP-UP COMPATIBILITES PRODUIT-----------------------------------------
//-------------------------DEBUT FONCTION POP-UP RELATED PRODUIT----------------------------------------
function popup_product_related(product_id) 
{   
		window.open('popup_search_product_for_related.php?product_id=' + product_id,'Popup',  'toolbar=0,location=0,directories=0,status=1,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width=700,height=600,top=50,left=100');  
}
//--------------------------FIN FONCTION POP-UP RELATED PRODUIT-----------------------------------------
//-------------------------DEBUT FONCTION POP-UP HERITAGES PRODUIT----------------------------------------
function popup_product_heritages(product_id) 
{   
		window.open('popup_products_heritages.php?product_id=' + product_id,'Popup',  'toolbar=0,location=0,directories=0,status=1,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width=500,height=250,top=50,left=100');  
}
//--------------------------FIN FONCTION POP-UP HERITAGES PRODUIT-----------------------------------------
//-------------------------DEBUT FONCTION POP-UP VIDEOS PRODUIT----------------------------------------
function popup_product_videos(product_id, code) 
{   
		window.open('popup_products_videos.php?product_id=' + product_id + '&code=' + code,'video',  'toolbar=0,location=0,directories=0,status=1,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width=500,height=400,top=50,left=100');  
}
//--------------------------FIN FONCTION POP-UP VIDEOS PRODUIT-----------------------------------------
//-------------------------DEBUT FONCTION POP-UP STATS BANNIERES----------------------------------------
function popup_advertise_stats(advertise_id) 
{   
		window.open('popup_advertise_stats.php?advertise_id=' + advertise_id,'advertise',  'toolbar=0,location=0,directories=0,status=1,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width=620,height=320,top=50,left=100');  
}
//--------------------------FIN FONCTION POP-UP VIDEOS PRODUIT-----------------------------------------
//-------------------------DEBUT FONCTION POP-UP ----------------------------------------
function popup_plan_detail(pagename) 
{   
		window.open('includes/boxes/operators/'+ pagename, 'plan_detail',  'toolbar=0,location=0,directories=0,status=1,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width=620,height=500,top=50,left=100');  
}
//--------------------------FIN FONCTION POP-UP -----------------------------------------