	var request;
	var req;


	function checkUserLoggedIn(){
		
		var jSessionId = getCookie("JSESSIONID");
		var pSessionId = getCookie("PSESSIONID");

		if (jSessionId == null
				|| jSessionId == "null" 
				|| jSessionId.length == 0
				|| pSessionId == null
				|| pSessionId == "null" 
				|| pSessionId.length == 0
				|| jSessionId !=  pSessionId){
			expiredSession = "Votre session a expiré, merci de vous <a href='acheter-produit-de-gestion-e-reputation-en-ligne-web-reputation-outil-de-monitoring-buzz-et-analyse-d-opinion.html'>reconnecter</a>.";
			window.location = "./index.html?message=" + expiredSession;
		}		
		
	}
	
	function isUserLoggedIn(){
		
		var jSessionId = getCookie("JSESSIONID");
		var pSessionId = getCookie("PSESSIONID");

		if (jSessionId == null
				|| jSessionId == "null" 
				|| jSessionId.length == 0
				|| pSessionId == null
				|| pSessionId == "null" 
				|| pSessionId.length == 0
				|| jSessionId !=  pSessionId){
			return false;
		}		
		else return true;
		
	}
	
	function pcs(){
		window.setTimeout("checkRights()", 50);
	}
	
	function checkRights(){
		
		var valuePma = getCookie("pcsasafef");
		
		//alert(valuePma);
		
		if (valuePma != "lkjrnqezfgrnqekl"){
			window.location = "./subscriptionsetup.html";
		}
	}
	
	
	function checkUserLoggedInToBuy(){
		
		var value = getCookie("JSESSIONID");
		if (value == null || value == undefined || value == ""){
			expiredSession = "Votre session a expiré, merci de vous authentifier de nouveau";
			window.location = "./acheter-produit-de-gestion-e-reputation-en-ligne-web-reputation-outil-de-monitoring-buzz-et-analyse-d-opinion.html?customertype=entreprise=GOLD";
		}	
		else{
			/*var newProduct = document.getElementById("productName").value;
			alert(newProduct);
			window.location = "./basket.html";*/
		}
		
	}
	
	
	function callback() {
	    if (request.readyState == 4) {
	        if (request.status == 200) {
	        	document.write(request.responseText);
	        }
	    }
	}

	function addrequest(req) {
		
		if (typeof XMLHttpRequest != "undefined") {
		       request = new XMLHttpRequest();
		}
		else if (window.ActiveXObject) {
		       request = new ActiveXObject("Microsoft.XMLHTTP");
		}
		
	    request.open("GET", req, false);       	    
	    request.send(null);                    
	    
	    mResponse = request.responseText; 	    
	    
	    if (mResponse.substring(0,4) == "null"){
	    	document.write("Please login");
	    }
	    /*else {
	    	document.getElementById("userName").innerHTML = mResponse;
	    }*/

	}

	
	
	function getCookie(c_name) {
	 	
		if (document.cookie.length>0)
	  	{
	  	c_start=document.cookie.indexOf(c_name + "=");
	  	if (c_start!=-1)
		    { 
	    	c_start=c_start + c_name.length+1; 
	    	c_end=document.cookie.indexOf(";",c_start);
	    	if (c_end==-1) c_end=document.cookie.length;
	    	return unescape(document.cookie.substring(c_start,c_end));
	    	} 
	  	}
		return "";
		 
	}
