




var serverPath = "http://prac-vm225.univ-lyon1.fr/";
var defaultSiteId = "lyon1";
var clarolineURL = "https://clarolineconnect.univ-lyon1.fr/";
var clarolineName = "Claroline Connect";

/***************************************************
 * CRYPTAGE DES CONNEXIONS :
 * si pas de SSL , on utilise l'url non sécurisée.
 *  AVEC SSL
 * 	var secureServerPath =  "https://prac-vm225.univ-lyon1.fr";
 *  SANS SSL 
 * 	var secureServerPath =  "http://prac-vm225.univ-lyon1.fr";
 * *************************************************/
var secureServerPath =  "http://prac-vm225.univ-lyon1.fr/";
var cookieDomain = ".univ-lyon1.fr";
//var cookieDomain = ".univ-lyon1.fr";

var session_ws_dest = serverPath+"/spiral-ws/sessionUtils/";

global_currentModuleId = -1;

// permet de récupérer les variables passées en url.
function getUrlVars(url)
{
	var vars = [], hash;
	var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
	if(typeof url!="undefined"&&url!=null&&url!="") hashes = url.slice(url.indexOf('?') + 1).split('&');
	for(var i = 0; i < hashes.length; i++)
	{
		hash = hashes[i].split('=');
		vars.push(hash[0]);
		if(hash[1] != null && hash[1] != undefined)
		{
			var hash2 = hash[1].split('#');
			vars[hash[0]] = hash2[0];
		}
	}
	return vars;
}

// permet de récupérer les variables passées en url.
function getPortalVars(url)
{
	var vars = [], hash;
	var hashes = window.location.href.slice(window.location.href.indexOf('#') + 1).split('&');
	if(typeof url!="undefined"&&url!=null&&url!="") hashes = url.slice(url.indexOf('?') + 1).split('&');
	for(var i = 0; i < hashes.length; i++)
	{
		hash = hashes[i].split('=');
		vars.push(hash[0]);
		if(hash[1] != null && hash[1] != undefined)
		{
			var hash2 = hash[1].split('#');
			vars[hash[0]] = hash2[0];
		}
	}
	return vars;
}

/**
* Lance un appel AJAX pour interroger le serveur
*/
function makeRequest(dest, format, method, dataPush,  successHandler, errorHandler, _processData, sendJson){
	
	//Récupération du param url sequenceId
//	var params = getUrlVars();
//	var idSequence = params["idSequence"];
//	if(idSequence != undefined && idSequence != null) {
//		if(dataPush != null && dataPush != undefined) {
//			dataPush.idSequence = idSequence;
//		}else {
//			dest += "/"+idSequence;
//		}
//	}
	
	var contentType = "application/x-www-form-urlencoded";
	 if(sendJson) {
		 contentType = "application/json";
	 }
	 
	if (dest) {
		$.ajax({url:dest, processData: _processData, contentType:contentType, data:dataPush, cache:false, type:method, dataType:format, success: successHandler, error:errorHandler});
   } else {
       alert("L'url est vide !");
   }
}

/**
* Récupère l'idSequence si existant
*/
function getSequenceId(){
	
	//Récupération du param url sequenceId
	var params = getUrlVars();
	var idSequence = params["sequenceId"];
	if(idSequence != undefined)
	{
		return idSequence.toString().split('#',1).toString();
	}else
	{
		return "";
	}
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path="+cookieDomain+"";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function isLogViaCAS() {
	var logViaCAS = readCookie("IS_LOG_CAS");
	return logViaCAS == "true";
}