// XMLHttpRequest object created after checking wheather the browser are compatible with ajax.
//============================================================================================
function GetXmlHttpObject()
{
	
  var xmlHttp=null;
  try
    {
    // Firefox, Opera 8.0+, Safari
    	xmlHttp=new XMLHttpRequest();
    	
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      	xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      	xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    }
  return xmlHttp;
}

//Getting XMLHttpRequest object for starting Ajax functionalities.
//===================================================================
function callazax(id)
{
	msg = "Are you sure to recommend the Contributor?";
	
	confirmation(msg);

	xmlHttp=GetXmlHttpObject()
	
	if (xmlHttp==null)
	{
  		alert ("Your browser does not support AJAX!");
  		return;
	}
	else
	{
		//alert(id);
		if(id){
			
			xmlHttp.onreadystatechange=stateChanged;
								
			url="ajax/recommend.php?user="+id+"&u="+Math.random();
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);
		}
		
	}   
}


//After getting response from server,response text is being manupulated here.
//===========================================================================
function stateChanged()
{
	if (xmlHttp.readyState==4)
	{
		//alert(state);
		var str=xmlHttp.responseText;
		
		arr=str.split("~");	
		
		var type = arr[0];
		var text = arr[1];
			
		
		if(type == 'fail')
		{
			alert(text);		
			
		}
		else
		{
			document.location.reload();
			alert(text);
			return false;
			
			
			
			
		}
		
						
	}
}

//Confirmation ======================
//===================================

function confirmation(msg)
{
	var answer = confirm(msg)
	if (answer)
	{
		//alert("DELETED")
		return;
	}
	else
	{
		//alert("NOT DELETED")
		return false();
		exit;

	}
}

//Popup ====
//==========

function myPopup(user_id)
{
	path = "edit_user.php?user_id="+user_id;
	window.open(path , "Edit", 
"status = 1, left=360, top=250, height = 420, width = 450, resizable = 0");
}

//Refresh Parent
//==============

function refresh_parent()
{
	window.opener.location.reload(true);
   	self.close();
}