function getResponse(ele,url,qrystr)
{ 
    divele="";
    divele=ele;
//alert ("URL: " + url);
    makePOSTRequest(url, qrystr);
}
function makePOSTRequest(url, parameters) {
	http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
			http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
	            http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      http_request.onreadystatechange = alertContents;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
 }
function alertContents() {
//alert (http_request.status);
    if (http_request.readyState < 4) {
		if (document.getElementById(divele))
		{
			document.getElementById(divele).innerHTML = "<br> <img src='http://sifyimg.edgesuite.net/indianidol.sify.com/images2008/loader.gif' border='0'> <br>Loading...";    
		}
	}
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
	         result = http_request.responseText;
			 if (document.getElementById(divele))
			 {
					document.getElementById(divele).innerHTML= result;
			 }
         } else {
            alert('There was a problem with the request.');
         }
      }
   }
var currDiv,prevDiv;
function call_div(obj_id, querystr)
{
	var divArray = document.getElementsByTagName("div");
	var foundDiv,foundcurrDiv=0;
	for(i=0;i<divArray.length;i++)
	{
		if(divArray[i].id.indexOf("buse")>0 || divArray[i].id.indexOf("eply")>0 || divArray[i].id.indexOf("omments")>0 || divArray[i].id.indexOf("orward")>0)
		{
			document.getElementById(divArray[i].id).style.height='310px';
			document.getElementById(divArray[i].id).style.width='475px';
			var collapse1=new animatedcollapse(divArray[i].id, 1000, false)
			if(obj_id==divArray[i].id)
			{
				collapse1.slidedown();
				document.getElementById(divArray[i].id).style.visibility='visible';
				document.getElementById(divArray[i].id).style.display='block';
				if(currDiv)
				prevDiv = currDiv
				currDiv = divArray[i].id;
				foundcurrDiv =1;
			}
			else
			{
				if(foundcurrDiv==1 && divArray[i].id==prevDiv)
				{
					document.getElementById(divArray[i].id).style.height='310px';
					document.getElementById(divArray[i].id).style.width='475px';
				}
				else if(foundcurrDiv==0 && divArray[i].id==currDiv)
				{
					document.getElementById(divArray[i].id).style.height='310px';
					document.getElementById(divArray[i].id).style.width='475px';
				}
				collapse1.slideup();
				document.getElementById(divArray[i].id).style.height="0";
				document.getElementById(divArray[i].id).innerHTML ='';
			}
		}
	}
	if (obj_id=="comments")
	{
		document.getElementById(obj_id).style.display="block";
		getResponse(obj_id, 'http://indianidol.sify.com/comments/comments_form.php', querystr);
	}
	else if (obj_id.indexOf("buse")>0)
	{
		document.getElementById(obj_id).style.display="block";
		getResponse(obj_id, 'http://indianidol.sify.com/comments/abuse_submit.php', querystr);
	}
	else if (obj_id.indexOf("eply")>0)
	{
		document.getElementById(obj_id).style.display="block";
		getResponse(obj_id, 'http://indianidol.sify.com/comments/reply_form.php', querystr);
	}
	else if (obj_id.indexOf("orward")>0)
	{
		document.getElementById(obj_id).style.display="block";
		getResponse(obj_id, 'http://indianidol.sify.com/comments/mail_form.php', querystr);
	}
	for(i=0;i<divArray.length;i++)
	{
		if(divArray[i].id.indexOf("buse")>0 || divArray[i].id.indexOf("eply")>0 || divArray[i].id.indexOf("omments")>0|| divArray[i].id.indexOf("orward")>0)
		{
			if ((divArray[i].id != obj_id) && (document.getElementById(divArray[i].id).style.height=="0"))
				document.getElementById(divArray[i].id).style.display='none';
		}
	}
	if (parent.document.getElementById("latest_comments"))
	{
	   parent.document.getElementById("latest_comments").style.height= parseInt(document.getElementById("tbl_lc").scrollHeight)+250;
	}

}

function call_div_ques(obj_id, querystr, url)
{
	var divArray = document.getElementsByTagName("div");
	var foundDiv,foundcurrDiv=0;
	for(i=0;i<divArray.length;i++)
	{
		if((divArray[i].id.indexOf("d_")>0) ||(divArray[i].id.indexOf("oader")>0))
		{
			document.getElementById(divArray[i].id).style.height='255px';
			var collapse1=new animatedcollapse(divArray[i].id, 1000, false)
			if(obj_id==divArray[i].id)
			{
				collapse1.slidedown();
				document.getElementById(divArray[i].id).style.visibility='visible';
				document.getElementById(divArray[i].id).style.display='block';
				if(currDiv)
				prevDiv = currDiv
				currDiv = divArray[i].id;
				foundcurrDiv =1;
			}
			else
			{
				if(foundcurrDiv==1 && divArray[i].id==prevDiv)
					document.getElementById(divArray[i].id).style.height='255px';
				else if(foundcurrDiv==0 && divArray[i].id==currDiv)
					document.getElementById(divArray[i].id).style.height='255px';
				collapse1.slideup();
				document.getElementById(divArray[i].id).style.height="0";
				document.getElementById(divArray[i].id).innerHTML ='';
			}
		}
	}
	document.getElementById(obj_id).style.display="block";
	getResponse(obj_id, url, querystr);
	for(i=0;i<divArray.length;i++)
	{
		if((divArray[i].id.indexOf("d_")>0) || (divArray[i].id.indexOf("oader")>0))
		{
			if ((divArray[i].id != obj_id) && (document.getElementById(divArray[i].id).style.height=="0"))
				document.getElementById(divArray[i].id).style.display='none';
		}
	}
	if (parent.document.getElementById("latest_comments"))
   parent.document.getElementById("latest_comments").style.height= parseInt(document.getElementById("tbl_c").scrollHeight)+180;

}

function hiddiv(obj_id)
{ 
   document.getElementById(obj_id).style.height="0px";
   document.getElementById(obj_id).style.display="none";
   document.getElementById(obj_id).innerHTML="";
   if (parent.document.getElementById("latest_comments"))
     parent.document.getElementById("latest_comments").style.height= parseInt(document.getElementById("tbl_lc").scrollHeight);
}
