// JavaScript Document
var myMenu;
window.onload = function() 
{
expandcontent('sc<?=$subcat_id?>');
myMenu = new SDMenu("my_menu");
myMenu.init();
};

subject_id = '';
function handleHttpResponse() 
{
	if (http.readyState == 4) 
	{
		if (subject_id != '') 
		{
			document.getElementById(subject_id).innerHTML = http.responseText;
		}
	}
}

var http = GetXmlHttpObject();

function getScriptPage(div_id,inputString)
{
	subject_id = div_id;
	content = document.getElementById(inputString).value;
	http.open("GET", "recipe_autosearch_ajax_new.php?content="+escape(content), true);
	http.onreadystatechange = handleHttpResponse;
	http.send(null);
	if(content.length>0)
		box('1');
	else
		box('0');
}

function getScriptPageNew(div_id,inputString,url)
{
	subject_id = div_id;
	content = document.getElementById(inputString).value;
	http.open("GET", url+"?content="+escape(content), true);
	http.onreadystatechange = handleHttpResponse;
	http.send(null);
	if(content.length>0)
		box('1');
	else
		box('0');
}	


function highlight(action,id)
{
  if(action)	
	document.getElementById('word'+id).bgColor = "#dcd9d7";
  else
	document.getElementById('word'+id).bgColor = "#FFFFFF";
}
function display(word)
{  
	document.getElementById('inputString').value = word;
	document.getElementById('suggestions').style.display = 'none';
	document.getElementById('autosearch_frm').submit();
}
function box(act)
{
  if(act=='0')	
  {
	document.getElementById('suggestions').style.display = 'none';

  }
  else
	document.getElementById('suggestions').style.display = 'block';
}

function recipe_comment()
{
agewindow=dhtmlmodal.open('agebox', 'div', 'modalalertdivcomment', '', 'width=420px,height=320px,left=400px,top=220px,resize=0,scrolling=0')
}
function process_age(whichbutton){
	if (whichbutton=="no")
	agewindow.hide()
}
function ageprompt()
{	agewindow=dhtmlmodal.open('agebox', 'div', 'modalalertdiv', '', 'width=520px,height=800px,left=340px,top=80px,resize=0,scrolling=0, ')
}

function rec_img_upload()
{
	agewindow=dhtmlmodal.open('agebox', 'div', 'modalalertdivimg', '', 'width=520px,height=500px,left=340px,top=80px,resize=0,scrolling=0, ')
}

function show_more_comment(id)
{	
	var xmlHttp_comment = GetXmlHttpObject();
	var url_comment="more_comment.php?id="+id;
	xmlHttp_comment.onreadystatechange=function()
	{
		if(xmlHttp_comment.readyState==4)
		{
			comment_content = xmlHttp_comment.responseText
			document.getElementById("comment_div").innerHTML='<p align="right"><img src="http://www.desidieter.com/windowfiles/close.gif" onclick="hidediv()"/></p>' + xmlHttp_comment.responseText;
			document.getElementById("comment_div").style.display = 'block';
		}
	 }
  	 xmlHttp_comment.open("GET",url_comment,true);
 	 xmlHttp_comment.send(null);
}

function show_more_comment_new(url,id)
{	
	agewindow=dhtmlmodal.open('agebox', 'div', 'modalalert_morecomments', '', 'width=520px,height=160px,left=400px,top=300px,resize=0,scrolling=0')

	var xmlHttp_comment = GetXmlHttpObject();
	var url_comment=url+"?id="+id;
	xmlHttp_comment.onreadystatechange=function()
	{
		if(xmlHttp_comment.readyState==4)
		{
			comment_content = xmlHttp_comment.responseText
			document.getElementById("more_comment_div").innerHTML= xmlHttp_comment.responseText;
			document.getElementById("more_comment_div").style.display = 'block';
		}
	 }
  	 xmlHttp_comment.open("GET",url_comment,true);
 	 xmlHttp_comment.send(null);
	
}

function hidediv()
{
document.getElementById("comment_div").style.display = 'none';
}

function rate_recipe(url, j,q,t,c)
{  
	alert(url+ "jhb")
	xmlHttp_rate=GetXmlHttpObject()  
	if (xmlHttp_rate==null)   
	{ 
	alert ("Browser does not support HTTP Request");      
	return;  
	} 
	url=url+"?"+j+"&"+q+"&"+t+"&"+c;
	url=url+"&sid="+Math.random(); 
	xmlHttp_rate.open("GET",url,true) ;   
	xmlHttp_rate.onreadystatechange=stateChanged_rate;
	xmlHttp_rate.send(null);
	
}

function stateChanged_rate()
{ 
	if (xmlHttp_rate.readyState==4 || xmlHttp_rate.readyState=="complete")   
	{
		//alert(xmlHttp_rate.responseText);
		document.getElementById("container").innerHTML=xmlHttp_rate.responseText;
				 
	} 
}

function dd_web_new(url)
{
	//Created by Mohan dtd 300909
	//Purpose: on submit search the web
	srchVal=document.getElementById("inputString").value;
	if(srchVal.length<3)
	{
		alert("Please enter the recipe name.");
	}
	else
	{
		window.location.href=url+"rcp=" + srchVal;
	}
}

function dd_web()
{
	//Created by Mohan dtd 300909
	//Purpose: on submit search the web
	srchVal=document.getElementById("inputString").value;
	if(srchVal.length<3)
	{
		alert("Please enter the recipe name.");
	}
	else
	{
		window.location.href="recipe_from_web.php?rcp=" + srchVal;
	}
}