function getHTTPObject() {
  var xmlhttp;
 
  if(window.XMLHttpRequest){
    xmlhttp = new XMLHttpRequest();
  }
  else if (window.ActiveXObject){
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    if (!xmlhttp){
        xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
    } 
}
  return xmlhttp;
}
var http = getHTTPObject(); // We created the HTTP Object
function requestInfo(url,id,redirectPage) {      
		var temp=new Array();
		var url=url+"&sid="+Math.random()
			http.open("GET", url, true);
			http.onreadystatechange = function() {
				if (http.readyState == 4) { 
				  if(http.status==200) {
			  		var results=http.responseText;
					//alert(results);
					if(redirectPage=="") {
						
						var temp=id.split("~"); // To display on multiple div 
						//alert(temp.length);
						var r=results.split("~"); // To display multiple data into the div 
						//alert(temp.length);
						if(temp.length>1) {
							for(i=0;i<temp.length;i++) {	
								//alert(temp[i]);
								document.getElementById(temp[i]).innerHTML='';
								document.getElementById(temp[i]).innerHTML=r[i];
							}
						} else {
							//document.getElementById(id).innerHTML = '';							
							document.getElementById(id).innerHTML = results;
						}	
					} else {
							
							//window.location.href=redirectPage;
							document.getElementById(id).innerHTML = results;
							}
				  } 
  				}
			};
			http.send(null);
       }

/*
	Function Name= emptyValidation
	Desc = This function is used to validation for the empty field 
	Param fieldList = This arguments set as a string varialble. you just need to supply the textbox name
	if the textbox is multiple then supply with ~ separator for eg. username~password
*/
function emptyValidation(fieldList) {
		
		var field=new Array();
		field=fieldList.split("~");
		var counter=0;
		for(i=0;i<field.length;i++) {
			if(document.getElementById(field[i]).value=="") {
				document.getElementById(field[i]).style.backgroundColor="#d1d1d1";
				counter++;
			} else {
				document.getElementById(field[i]).style.backgroundColor="#FFFFFF";	
			}
		}
		if(counter>0) {
				alert("The Field mark as colour could not left empty");
				return false;
				
		}  else {
			return true;
		}
		
}
function searchvalid(id)
{
	if(document.getElementById(id).value=="")
	{
		alert("Recherche non valide");
		return false;	
	}
	else
	{
		return true;	
	}
}
function art_listSort(MODE,START,BY)
{
		if(START == 'NULL')
		{
			START = 0;
		}
		document.getElementById("article").innerHTML='<img src="../images/loading.gif" width="100px" height="25px" />';
		requestInfo('includes/article_PublicAjax.php?mode='+MODE+'&start='+START+'&by='+BY,'article','');
	
}
// Functions for Admin Article page

function art_list(MODE,START)
{
		if(START == 'NULL')
		{
			START = 0;
		}
		document.getElementById("article").innerHTML='<img src="images/loading.gif" width="100px" height="25px" />';
		requestInfo('includes/article_PublicAjax.php?mode='+MODE+'&start='+START,'article','');
		
}
//Function for Geting Article view
function showArticle(id,MODE,eid)
{
	
	var total = document.getElementById('total').value;
	for(i=1;i<total;i++)
	{	
		document.getElementById('sprint'+i).innerHTML='';
	}
	document.getElementById(eid).innerHTML='<img src="images/loading.gif" width="100px" height="25px" />';
	requestInfo('includes/article_PublicAjax.php?mode='+MODE+'&ID='+id+'&EID='+eid,eid,'');	
}
//Function for closing the article view
function closArticle(eid)
{
	document.getElementById(eid).innerHTML='';
}