function restoreSystem(objID)
{
	strProgressMessage="System restore in progress...";
	doAjax("fatcmspro.restore.php","action=Restore_System",objID,"POST",strProgressMessage,0,"")
}

function doAjax(strURL,strPostData,strObj,method,strProgressMessage,nTime,fn) {
    var xmlHttpReq = false;
    var self = this;
	var msg="";
    // Mozilla/Safari
 
	www=(window.location.href.toLowerCase().indexOf("//www.")>0)?"http://www.":"http://";
	strURL=strURL.replace("http://",www);
	updateMessage(strObj,strProgressMessage);

    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open(method, strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
		
        if (self.xmlHttpReq.readyState == 4) 
		{
			
			msg=(strObj+"|"+self.xmlHttpReq.responseText).split("|");
			for (i=0;i<msg.length;i=i+2)
			{
				updateMessage(msg[i],msg[i+1]);
			}
			 
			switch(fn)
			{
				case "renderProductOptions":
					removeItemRow();
					updateMessage(strObj,"Inventory updated successfully!");
					renderProductOptions(self.xmlHttpReq.responseText);
					
					break;
				case null:
					break;
			}
			
			if (nTime>0) setTimeout("hide('"+strObj+"');",nTime);
        }
		else
		{
			//alert(self.xmlHttpReq.readyState);
		}
    }
    self.xmlHttpReq.send(strPostData);
}

  function xmlhttpPost(strURL, divName, txtObj) {
	 
    var xmlHttpReq = false;
    var self = this;      	
	// Mozilla/Safari	
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() 
	{
        if (self.xmlHttpReq.readyState == 4) 
		{
			var val = self.xmlHttpReq.responseText;		
			//alert(val);
			if(val != '')	{						
			 document.getElementById(divName).innerHTML=self.xmlHttpReq.responseText;
			 txtObj.value='';	
			 txtObj.focus();			 
			}
			else 
			document.getElementById(divName).innerHTML='';			
		}
    }
    self.xmlHttpReq.send('');
  }
   
   
   
   function defaulthttpPost(strURL,divName) {
   //alert(divName);
   //alert(strURL);
  if(divName=="news_msg")
  	{
	 document.getElementById(divName).innerHTML="<img src='images/loading_b.gif'>";  
	}
  else
  {
 	 document.getElementById(divName).innerHTML="<img src='images/loading_b.gif'>";
  }
   var xmlHttpReq = false;
    var self = this;      	
	// Mozilla/Safari	
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	  self.xmlHttpReq.onreadystatechange = function() 
	{
        if (self.xmlHttpReq.readyState == 4) 
		{
			var val = self.xmlHttpReq.responseText;	
			//alert("response : " +val);
			if(val != '')	{		
			 document.getElementById(divName).innerHTML=self.xmlHttpReq.responseText;
			 document.getElementById(divName).style.display = '';
			}
			else{ 
									
				document.getElementById(divName).innerHTML='';			
			}
			<!-- This code is working for addcontents.php keys: Starts here-->
			if(divName=="keydisplay")
			{
			document.getElementById("keyOption").value="";
			document.getElementById("keyField").value="";
			document.getElementById("keyValue").value="";
			}
			<!-- This code is working for addcontents.php keys Ends here -->
		}
    }
 
    self.xmlHttpReq.send('');
  }


function removeItemRow()
{
  var tbl = document.getElementById('tblGroups');
  var lastRow = tbl.rows.length;
  var iteration = lastRow;
  for (i=3;i<iteration;i++)
  {
  	tbl.deleteRow(tbl.rows.length-1);
	
  }

}


function updateMessage(obj,str)
{
	show(obj);	
	document.getElementById(obj).innerHTML=str;
}

function showHide(id)
{
	if (document.getElementById(id).style.display=='')
		document.getElementById(id).style.display='none';
	else
		document.getElementById(id).style.display='';
		
}
function show(id)
{
		document.getElementById(id).style.display='block';
		
}
function hide(id)
{
		document.getElementById(id).style.display='none';
}

function uplaodBackGround(field, id)		
{
	var mywindow=window.open("uploadPopUp.php?field="+field+"&id="+id,"mywindow","location=0,status=0,scrollbars=1,width=400,height=300");
	mywindow.moveTo(350,175);
}

function toPost(getString) 
{
	var parms = getString.split('?'); 
	var newF = document.createElement("form");
	newF.action = parms[0];
	newF.method = 'POST';
	var parms = parms[1].split('&');
	for (var i=0; i<parms.length; i++) 
	{
		var pos = parms[i].indexOf('=');
		if (pos > 0) {var key = parms[i].substring(0,pos);
		var val = parms[i].substring(pos+1);
		var newH = document.createElement("input"); newH.name = key;
		newH.type = 'hidden'; 
		newH.value = val; newF.appendChild(newH);
		}
	}
	document.getElementsByTagName('body')[0].appendChild(newF); newF.submit();
}

function newtext(val,valu)
{
	
setTimeout("moretext()",3000);

	if(val==1)
	{
	//	alert("val1-----------"+val);
	document.getElementById("color_"+valu).bgColor = "#FFFFFF";
	document.getElementById("statusValue_"+valu).value = 0;

	}
	else
	{
//	alert("val0------------"+val);
	document.getElementById("color_"+valu).bgColor = "#fafafa";
	document.getElementById("statusValue_"+valu).value =1;
	}

}
function moretext()
{
$("#status_div").fadeOut("slow");
//document.getElementById('status_div').innerHTML="";
}
/* End To change color of status record background*/

