// JavaScript Document
var xmlhttp;
function favorite_text(quoteid,userid,currenturl)
{	
	//alert(currenturl);
	//alert(userid);
	if(userid=="guest")
	{		
		var answer = confirm("You need to Login for Favorite this quote. Are you sure want to login?");
		if (answer)
		{
			window.location="http://thegreatquotes.com/wp-login.php?redirect_to="+currenturl+"?quoteid="+quoteid;
			//javascript:(alert('hi'))
		}
		else
		{
			//window.location=currenturl;
		}		
	}
	else
	{
		favtext_ajax(quoteid,userid);
	}
	
}

function fav_single_text (userid,redirecturl,quoteid)

{
	if(userid=="guest")
	{		
		var answer = confirm("You need to Login for Favorite this quote. Are you sure want to login?");
		if (answer)
		{
			window.location=redirecturl;
			//javascript:(alert('hi'))
		}
		else
		{
			//window.location=currenturl;
		}		
	}
	else
	{
		favtext_ajax(quoteid,userid);
	}
}

function fav_single_image (userid,redirecturl,quoteid)

{
	if(userid=="guest")
	{		
		var answer = confirm("You need to Login for Favorite this quote. Are you sure want to login?");
		if (answer)
		{
			window.location=redirecturl;
			//javascript:(alert('hi'))
		}
		else
		{
			//window.location=currenturl;
		}		
	}
	else
	{
		favimage_ajax(quoteid,userid);
	}
}

function favtext_ajax(quoteid,userid)
{
	querystring="quoteid="+quoteid+"&userid="+userid;
	//alert(querystring);
	xmlhttp=GetXmlHttpObject();
	  if (xmlhttp==null)
	  {
		  alert ("Browser does not support HTTP Request");
		  return;
	  }
	//var url="http://thegreatquotes.com/ajax_emailshare.php";
	var url="http://thegreatquotes.com/favtext_option.php";
	
	xmlhttp.onreadystatechange=stateChanged_favtext;

	xmlhttp.open('POST', url, true);
	  xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	  xmlhttp.setRequestHeader("Content-length", querystring.length);
	  xmlhttp.setRequestHeader("Connection", "close");
	  xmlhttp.send(querystring);
}
function stateChanged_favtext()
{
	if (xmlhttp.readyState==4)
	{		
		var quotes_path="http://thegreatquotes.com/wp-content/themes/updated_simplista1/img/select_fav.png";
		
		var elementid="favorite"+xmlhttp.responseText;
		//alert(elementid);		
		document.getElementById(elementid).setAttribute('src', quotes_path);
		//document.getElementById('favorite').src="http://192.168.1.7/thegreatquotes/wp-content/themes/updated_simplista1/img/select_fav.png";		
		//alert(xmlhttp.responseText);	
	}
}
/* ------------image quote favorite optoin ---------*/
function favorite_image(quoteid,userid,currenturl)
{	
	//alert(quoteid);
	//alert(userid);
	if(userid=="guest")
	{
		var answer = confirm("You need to Login for Favorite this quote. Are you sure want to login?");
		if (answer)
		{
			window.location="http://thegreatquotes.com/wp-login.php?redirect_to="+currenturl+"?imgquoteid="+quoteid;
		}
		else
		{
			//window.location=currenturl;
		}	
	}
	else
	{
		favimage_ajax(quoteid,userid);
	}
	
}
function favimage_ajax(quoteid,userid)
{
	querystring="quoteid="+quoteid+"&userid="+userid;
	//alert(querystring);
	xmlhttp=GetXmlHttpObject();
	  if (xmlhttp==null)
	  {
		  alert ("Browser does not support HTTP Request");
		  return;
	  }
	//var url="http://thegreatquotes.com/ajax_emailshare.php";
	var url="http://thegreatquotes.com/favimage_option.php";
	
	xmlhttp.onreadystatechange=stateChanged_favimage;

	xmlhttp.open('POST', url, true);
	  xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	  xmlhttp.setRequestHeader("Content-length", querystring.length);
	  xmlhttp.setRequestHeader("Connection", "close");
	  xmlhttp.send(querystring);
}
function stateChanged_favimage()
{
	if (xmlhttp.readyState==4)
	{		
		var quotes_path="http://thegreatquotes.com/wp-content/themes/updated_simplista1/img/select_fav.png";
		
		imageelementid="favimage"+xmlhttp.responseText;
		//alert(imageelementid);		
		document.getElementById(imageelementid).setAttribute('src', quotes_path);
		//document.getElementById('favorite').src="http://192.168.1.7/thegreatquotes/wp-content/themes/updated_simplista1/img/select_fav.png";		
		//alert(xmlhttp.responseText);	
	}
}
