sys = new Object();
sys.Net = new Object();
sys.Net.data = '';

	sys.Net.SynchRequest = function(url, params, method){
		sys.Net.data = '';
		if (window.XMLHttpRequest){
			req = new XMLHttpRequest();
		}
		else if (window.ActiveXObject) 
			req = new ActiveXObject('Microsoft.XMLHTTP');
		
		switch(method){
			case 'GET' : req.open('GET', url+params, false);
						 req.send(null);
						 break;
			case 'POST' : req.open('POST', url, false);
						  req.setRequestHeader("Content-type","application/x-www-form-urlencoded");
						  req.setRequestHeader("Accept-Encoding", "gzip, deflate");
						  req.send(params);
						  break;
			default : alert('Private function');
		}		
		if ( req.status < 400 ) {
		  sys.Net.data = req.responseText;
		}
		else{
			alert('Error loading page '.url);
			sys.Net.data = '';
		}
    }    
    
	sys.Net.Request = function(url, params, method, displayfunc, retall){
		var req;
		if (window.XMLHttpRequest){
		//	user_pref("signed.applets.codebase_principal_support", true);
		//	netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserAccess');
		//	netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
			req = new XMLHttpRequest();
		//	netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserAccess');
		}
		else if (window.ActiveXObject) 
			req = new ActiveXObject('Microsoft.XMLHTTP');
		// callback function for asynch process
	  	req.onreadystatechange = function (aEvt) {
		    if (req.readyState == 4) {
				if(req.status < 400){
				    if(retall){
				    	displayfunc(sys.Net.GetXML(req));
				    }
				    else
		        		displayfunc(req.responseText);
		        }
				else
					alert('Error loading page '.url);
			}
		}
		switch(method){
			case 'GET' : req.open('GET', url+params, true);
						 req.send(null);
						 break;
			case 'POST' : req.open('POST', url, true);
						  req.setRequestHeader("Content-type","application/x-www-form-urlencoded");
						  req.send(params);
						  break;
			case 'BINPOST' : req.open('POST', url, true);
						  req.setRequestHeader("Content-type","multipart/form-data");
						  req.send(params);
						  break;
			default : alert('Private function');
		}
	}
	
	sys.Net.GetXML = function(req){
	    var curxml;
		if (window.ActiveXObject){
			var xmldoc=new ActiveXObject("Microsoft.XMLDOM");
			xmldoc.loadXML(req.responseText);
			curxml=xmldoc; 
	    }
	    else{
	      	
			curxml=new DOMParser().parseFromString(req.responseText,"text/xml");
	    }
	    var tmp = new Object();
	    tmp.status = req.status;
	    tmp.responseText = req.responseText;
	    tmp.responseXML = curxml;
		return tmp;
	}
	
	sys.Net.ReqGET = function(url, params, displayfunc){
	  	sys.Net.Request(url, params, 'GET', displayfunc);
	}
	
	sys.Net.ReqGETEmul = function(url, params, displayfunc){
	  	sys.Net.Request(url, params, 'GET', displayfunc,true);
	}

	sys.Net.ReqPOST = function(url, params, displayfunc){
	  	sys.Net.Request(url, params, 'POST', displayfunc);
	}
	
	sys.Net.ReqSynchGET = function(url, params){
	  	sys.Net.SynchRequest(url, params, 'GET');
	}

	sys.Net.ReqSynchPOST = function(url, params){
	  	sys.Net.SynchRequest(url, params, 'POST');
	}
	
	sys.Net.getBrowser = function(){
	  
	}

function vote_forum(id_forum, vote, type_comm, pass) {
  if ( !navigator.cookieEnabled ){
	alert("Votre navigateur doit accepter les cookies pour pouvoir voter");
	return;
  }
  var divtext = document.getElementById('article_texte_'+id_forum); 
  if(divtext.getAttribute("isvote") == "1" && pass!=1){
   alert("Vous avez déjà voté pour ce commentaire");
   	return;
  }
  divtext.setAttribute("isvote","1");
  var param = "id_forum="+ id_forum + "&vote=" + vote + "&type_comm=" + type_comm; 
  sys.Net.ReqPOST("forum_vote.php3?",param,handleHttpResponse);
}
function handleHttpResponse(html) {
   var test = html.substr(0,html.indexOf('#'));
   html = html.substr(html.indexOf('#')+1);
   var id_forum = html.substr(0,html.indexOf('#'));
   html = html.substr(html.indexOf('#')+1);
   var type_comm = html.substr(0,html.indexOf('#'));
   html = html.substr(html.indexOf('#')+1);
   type_comm = parseInt(type_comm);
   
   if(test == 'ok'){
		md = document.getElementById('votes' + id_forum);
		md.innerHTML = html;
		if (parseInt(html) == type_comm){
			var divlink = document.getElementById('linkhide_'+id_forum); 
			divlink.setAttribute("view",'1');
			showhidetext(id_forum);
		}
		if (parseInt(html) == (type_comm+1)){
			var divtext = document.getElementById('article_texte_'+id_forum); 
			var divlink = document.getElementById('linkhide_'+id_forum); 
			divlink.innerHTML = '';
		  	divtext.style.visibility = 'visible';
			divtext.style.display = 'block';
			divtext.style.height = '';
		}
	   
  	}
  	else{
  		alert(html);
  			
  	}
  
}

function showhidetext(id_forum){
 	var divlink = document.getElementById('linkhide_'+id_forum); 
 	var divtext = document.getElementById('article_texte_'+id_forum); 
 	var is_view = divlink.getAttribute("view");
 	
 	if(is_view != '1'){
		divlink.setAttribute("view",'1');
		divlink.innerHTML = '<b>[Cacher le texte]</b>';
	  	divtext.style.visibility = 'visible';
		divtext.style.display = 'block';
		divtext.style.height = '';
	}
	else{
	  	divlink.setAttribute("view",'0');
	  	divlink.innerHTML = '<b>[Montrer le texte]</b>';
	  	divtext.style.visibility = 'hidden';
		divtext.style.display = 'none';
		divtext.style.height = '1px';
	}
}
