function load_ajax(var1,divid,type,var2,var3,var4,var5)
{ 
		var url='load_constituency.php';
		var1=document.getElementById('state').value;
		var post_data='?var1='+var1+'&divid='+divid+'&type='+type+'&var2='+var2+'&var3='+var3+'&var4='+var4+'&var5='+var5+'';
		document.getElementById(divid).innerHTML = "<FONT SIZE='2' COLOR='red'><img src='images/ajax-loader.gif' border='0'></font>";
		if(window.XMLHttpRequest)
		{
			http_request=new XMLHttpRequest();
		if(http_request.overrideMimeType)
		{
			http_request.overrideMimeType('text/html');
			}
			
		}else if(window.ActiveXObject)
		{
			try{
				http_request = new ActiveXObject("Msxml2.XMLHTTP");
				}catch(e)
				{
				try{
					http_request = new ActiveXObject("Microsoft.XMLHTTP");
					}catch(e){}
				}
		
		}
	
	http_request.onreadystatechange=function(){sendrequest(http_request,divid);};
	http_request.open('GET',url+post_data,true);
	http_request.send(null);
	
	
	}
	
	function sendrequest(http_request,divid)
	{
		if(http_request.readyState ==4)
		   { 
			   if(http_request.status ==200)
			   {
				resText=http_request.responseText;
				document.getElementById(divid).innerHTML=resText;
			   }
			    else {
			document.getElementById(divid).innerHTML = "<FONT SIZE='4' COLOR='red'>Query not submitted!</FONT>";
					}
		   }
	}
	function loadBillCategoryChange1(self,id,name)
	{
		
		var category=document.getElementById('category').value;
		var parent_category=self;//=document.getElementById('parent_category').value;
	window.location.href='index.php?name='+name+'&id='+id+'&parent_category='+parent_category+'&category='+category;
	
	
	}
	function loadBillCategoryChange2(self,id,name)
	{
		
		var category=self;//document.getElementById('category').value;
		var parent_category=document.getElementById('parent_category').value;
	window.location.href='index.php?name='+name+'&id='+id+'&parent_category='+parent_category+'&category='+category;
	
	
	}
	function loadBillCategoryChange3(self,id,name)
	{
		
		var bill_id=self;//document.getElementById('category').value;
		var category=document.getElementById('category').value;
		var parent_category='';
		window.location.href='index.php?name='+name+'&id='+id+'&parent_category='+parent_category+'&category='+category+'&action=bill_details&bill_id='+bill_id;
	
	
	}
	function loadBillCategoryChange4(self,id,name)
	{
		
		var bill_id=self;//document.getElementById('category').value;
		var category=document.getElementById('category').value;
		var parent_category='';
		window.location.href='index.php?name=mptrack';
	
	
	}
	
	function highlight(objcell,flag)
		{
			if(flag){
				objcell.style.backgroundColor="#E3E3E3";
			}else{
				objcell.style.backgroundColor="";
			}
		}
		function highlightleft(objcell,flag)
		{
			if(flag){
				objcell.style.backgroundColor="#9bbcdd";
			}else{
				objcell.style.backgroundColor="";
			}
		}
		function highlight1(objcell,flag)
		{
			if(flag){
				objcell.style.backgroundColor="#FFFFFF";
			}else{
				objcell.style.backgroundColor="";
			}
		}
		function redirectbill(url)
		{
			window.document.location.href=url;
			//window.open(url, '_blank');
		}
		
		function redirectnews(url)
			{
			window.document.location.href=url;
			}
			
			
		function viewAllBillTypes()
			{	
				if(document.getElementById('billtype').style.display=='none')
					{
				document.getElementById('plusm').innerHTML='[-] View All Bill Types';
				document.getElementById('billtype').style.display='';
					}else
					{
						document.getElementById('parent_category').value='';
				document.getElementById('plusm').innerHTML='[+] View All Bill Types';
				document.getElementById('billtype').style.display='none';
					}
			}
				
		function viewAllBillTypes2()
			{	
				if(document.getElementById('billtype2').style.display=='none')
					{
				
				document.getElementById('plusm2').innerHTML='[-] View All Categories';
				document.getElementById('billtype2').style.display='';
					}else
					{
				document.getElementById('category').value='';
				document.getElementById('plusm2').innerHTML='[+] View All Categories';
				document.getElementById('billtype2').style.display='none';
					}
			}
			
			function goToPage(pageno,name,id)
			{
				window.location.href="index.php?name="+name+"&pageno="+pageno+"&id="+id;
			}
			//var poupvar;
			function loadPopup(filename)
			{
			poupvar=window.open(filename,"mywindow","height=350, width=350, scrollbars=1, resizable=1");
			}

			function loadPopupwide(filename)
			{
				var query = "";

				if(filename.indexOf('?') > 1);
				{
									
					var brokenstring=filename.split("?");
					filename = brokenstring['0'];
					query ="?"+brokenstring['1'];
					
				}
				
				
				if(filename=="quiz.php")
				{
					poupvar=window.open(filename+query,"mywindow","height=355, width=670, scrollbars=1, resizable=1");
				}
				if(filename=="poll.php")
				{
					if(query =="?undefined")
					{
						poupvar=window.open(filename+query,"mywindow","height=555, width=670, scrollbars=1, resizable=1");
					}
					else
					{
						poupvar=window.open(filename+query,"mywindow","height=300, width=670, scrollbars=1, resizable=1");
					}
				}
			
			}
function ajaxAddComment(char_id,textareaid,loaderid,parent, edited_id)
{		var divid='commentDiv';//loaderid;
	if(edited_id==undefined || edited_id=='')
	edited_id=0;
 		var data=document.getElementById(textareaid).value;
		data=data.replace('"',"'");
 		var url= 'ajax.php?op=addCharComment&p_id='+char_id+'&txt='+data+'&parent='+parent+'&edited_id='+edited_id;
		 //alert(url);
  		var post_data=url;
 		document.getElementById(divid).innerHTML = "<FONT SIZE='2' COLOR='red'><img src='images/ajax-loader.gif' border='0'></font>";
		if(window.XMLHttpRequest)
		{
			http_request=new XMLHttpRequest();
		if(http_request.overrideMimeType)
		{
			http_request.overrideMimeType('text/html');
			}
			
		}else if(window.ActiveXObject)
		{
			try{
				http_request = new ActiveXObject("Msxml2.XMLHTTP");
				}catch(e)
				{
				try{
					http_request = new ActiveXObject("Microsoft.XMLHTTP");
					}catch(e){}
				}
		
		}
	
	http_request.onreadystatechange=function(){sendrequest(http_request,divid);};
	http_request.open('GET',url,true);
	http_request.send(null);
	

	
	}
	function ajaxAddCommentAudeo(char_id,textareaid,loaderid,parent, edited_id)
{		var divid='commentDiv';//loaderid;
	if(edited_id==undefined || edited_id=='')
	edited_id=0;
 		var data=document.getElementById(textareaid).value;
		data=data.replace('"',"'");
 		var url= 'ajax.php?op=addAudeoComment&p_id='+char_id+'&txt='+data+'&parent='+parent+'&edited_id='+edited_id;
		 //alert(url);
  		var post_data=url;
 		document.getElementById(divid).innerHTML = "<FONT SIZE='2' COLOR='red'><img src='images/ajax-loader.gif' border='0'></font>";
		if(window.XMLHttpRequest)
		{
			http_request=new XMLHttpRequest();
		if(http_request.overrideMimeType)
		{
			http_request.overrideMimeType('text/html');
			}
			
		}else if(window.ActiveXObject)
		{
			try{
				http_request = new ActiveXObject("Msxml2.XMLHTTP");
				}catch(e)
				{
				try{
					http_request = new ActiveXObject("Microsoft.XMLHTTP");
					}catch(e){}
				}
		
		}
	
	http_request.onreadystatechange=function(){sendrequest(http_request,divid);};
	http_request.open('GET',url,true);
	http_request.send(null);
	

	
	}
	function resetCommentbox(id)
{
document.getElementById(id).value='';
}
function showHideDiv(divid)
{
	
	if(document.getElementById(divid).style.display=='none')
	{
	document.getElementById(divid).style.display='';
	}
	else
	{
 	document.getElementById(divid).style.display='none'
	}
}
function expandTextArea(id,width,height,expandid,exTxt, redTxt)
{
	 
	curWidth=parseInt(document.getElementById(id).style.width);
	curHeight=parseInt(document.getElementById(id).style.height);
	 
	if(curWidth <  width)
	{
	document.getElementById(id).style.width=(curWidth+200)+'px';
	document.getElementById(id).style.height=(curHeight+200)+'px';
	document.getElementById(expandid).innerHTML=redTxt;

	 }else
 	{
	 document.getElementById(id).style.width=(curWidth-200)+'px';
	document.getElementById(id).style.height=(curHeight-200)+'px';
	document.getElementById(expandid).innerHTML=exTxt;


	}

}
	function refreshWindow()
	{setTimeout("refreshWindow2()",1250);
		 
	}
	function refreshWindow2(id,url)
	{   
		 
	window.location.href='';
	}
	function pollingFrm(numQ)
	{
		var j=1;
		for(var i=1;i<=numQ;i++)
		{
			var qname=document.getElementById('question'+i).value;
			var ansnum=document.getElementById('answerH'+qname).value;
			var min=document.getElementById('min'+i).value;
			var max=document.getElementById('max'+i).value;
			//alert(max);
			var k=1;
			var sel=0; 
			for(j=1;j<=ansnum;j++)
			{
				if(document.getElementById('answer'+qname+'_'+j).checked==true)
				{
				//break;
				sel++;
				}else{
					k++;
				}
			}
			 
			if(k>ansnum || sel < min)
			{
			alert("Please select minimum "+min+" options(s) for question no. "+i);
			return false;
			} else
			{
				if(sel > max)
				{
				alert("Please select maximum "+max+" options(s) for question no. "+i);
				return false;
				}
			}
		
		}
		 
	 document.forms[0].submit();
	}


	function isChecked(qname,i)
	{
	var	chk='answer'+qname+'_'+i;
	name=document.getElementById(chk);
	if(name.checked==true)
	return true;
	}
function checkFormMessage2(id)
{ 
	
	if(document.getElementById('username_'+id).value=='')
	{
		alert("Please enter your name.");
		document.getElementById('username_'+id).focus();
		return false;
	}
	 
	if(document.getElementById('comment_'+id).value=='')
	{
	alert("Please enter your message.");
	document.getElementById('comment_'+id).focus();
	return false;
	}

}
function checkFormMessage()
{
	if(document.getElementById('username').value=='')
	{
		alert("Please enter your name.");
		document.getElementById('username').focus();
		return false;
	}

	if(document.getElementById('gender').value=='')
	{
		alert("Please enter gender.");
		document.getElementById('gender').focus();
		return false;
	}
	if(document.getElementById('location').value=='')
	{
		alert("Please enter Location.");
		document.getElementById('location').focus();
		return false;
	}
	/*if(document.getElementById('email').value=='')
	{
	alert("Please enter your email.");
	document.getElementById('email').focus();
	return false;
	}
	if(document.getElementById('email').value.indexOf('@')==-1 || document.getElementById('email').value.indexOf('.')==-1)
	{
	alert("Please enter correct email format.");
	document.getElementById('email').focus();
	return false;
	}*/
	
	if(document.getElementById('message').value=='')
	{
	alert("Please enter your message.");
	document.getElementById('message').focus();
	return false;
	}

}


function downloadPodcast()
{
id=document.getElementById('firstEpisode').value;

location.href='download.php?id='+id+'&op=audios';
}
function playPodcast()
{
	
var id=document.getElementById('firstEpisode').value;
var index=getIndex(id);
document.getElementById('index').value=index;
//alert(index);
loadPopup('video_viewer.php?id='+id);


}
function getIndex(id)
{
allIndex=document.getElementById('episodes').value;
arrIndex=allIndex.split("~");
	for(j=0;j<3;j++)
	{
		if(arrIndex[j]==id)
		{
		var index=j;
		break;
		}
	}
	return index;
}
function getIndexValue(id)
{
var allIndex=document.getElementById('episodes').value;
arrIndex=allIndex.split("~");
	for(j=0;j<3;j++)
	{
		if(j==id)
		{
		var val=arrIndex[j];
		break;
		}
	}
	return val;
}
function getEpisodesNum()
{
allIndex=document.getElementById('episodes').value;
arrIndex=allIndex.split("~");
len=arrIndex.length;
 
return len;
}
function forward(id)
{
	var len=(getEpisodesNum()-1);
if(id==undefined)
	{
var index=document.getElementById('index').value;
index++;
	}else
		index=id;
	
if(index>len)
	index=0;

document.getElementById('index').value=index;
val=getIndexValue(index);
document.getElementById('firstEpisode').value=val;
changeClass(index);
}
function backword()
{
	var len=(getEpisodesNum()-1);
	
var index=document.getElementById('index').value;
 index--;
if(index<0)
	index=len;

document.getElementById('index').value=index;
val=getIndexValue(index);
document.getElementById('firstEpisode').value=val;
changeClass(index);
}
function changeClass(index)
{var len=(getEpisodesNum()-1);
	for(i=0;i<=len;i++)
	{
	document.getElementById('ep'+i).className='episode-non';
	document.getElementById('ep2'+i).className='episode-non';
	}
	document.getElementById('ep'+index).className='episode-active';
	document.getElementById('ep2'+index).className='episode-active';
}
