
var xmlHttp;

function fn_constituency(str) { 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request");
 return;
 }
var url="representative_constituency.php";
url=url+"?q="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
	document.getElementById("constituency").innerHTML=xmlHttp.responseText;
	document.getElementById("loader").style.display = "none";
} 
else {
	document.getElementById("loader").style.display = "";
}
}

////////////////////////////
function fn_filter(str,stateid)
{ 
//alert(str);
//alert(stateid);
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request");
 return;
 }
var url="filter.php";
url=url+"?q="+str;
url=url+"&stateid="+stateid;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChangedfilter;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChangedfilter() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById("filter").innerHTML=xmlHttp.responseText;
 } 
}
///////////////////////////////////

//////////////////////////// FILTER ASS
function fn_filter_ass(str,type)
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request");
 return;
 }
var url="filter_select.php";
url=url+"?v="+str;
url=url+"&type="+type;
xmlHttp.onreadystatechange=stateChangedfilterass;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChangedfilterass() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById("constituency").innerHTML=xmlHttp.responseText;
 } 
}
///////////////////////////////////

function fn_details(con,state) {
if(con == '') { 
	alert('Please Select the Constituency'); return false;
}
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) {
 alert ("Browser does not support HTTP Request");
 return;
}
var url="representative_details.php";
url=url+"?q="+con;
url=url+"&sid="+state;
//document.getElementById("con").innerHTML='<iframe id=newcategory frameborder=0 height=1000 src='+url+' width=800 style="overflow:hidden;"></iframe>';
xmlHttp.onreadystatechange=stateChanged0;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChanged0() {
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
	document.getElementById("con").innerHTML=xmlHttp.responseText;
	document.getElementById("loader").style.display = "none";
} 
else {
	document.getElementById("loader").style.display = "";
}
}

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;
}


function toggle_visibility(id) {
       var e = document.getElementById(id);
       if(e.style.display == 'block')
          e.style.display = 'none';
       else
          e.style.display = 'block';
	
       if (id == 'sms')
       { 
			if(document.getElementById('locksms').value == "") {
			document.getElementById('sms').style.display = 'none';
			alert('Please Register or Login to send sms');
			return false;
			}
			else {
			document.getElementById('email').style.display = 'none';
			document.getElementById('url').style.display = 'none'; 
			document.getElementById('plugin').style.display = 'none';  
			document.getElementById('emailinfo').style.display = 'none'; 
			document.getElementById('captcha').src = '/modules/captcha/securimage_show.php?' + Math.random();
			}
       }
       else if (id == 'email')
       { 
		document.getElementById('sms').style.display = 'none'; 
		document.getElementById('emailinfo').style.display = 'none'; 
		document.getElementById('url').style.display = 'none'; 
		document.getElementById('plugin').style.display = 'none';  
		document.getElementById('captcha1').src = '/modules/captcha/securimage_show.php?' + Math.random();
       }

       else if (id == 'url')
       { 
		document.getElementById('sms').style.display = 'none'; 
		document.getElementById('emailinfo').style.display = 'none'; 
		document.getElementById('email').style.display = 'none'; 
		document.getElementById('plugin').style.display = 'none';  
		document.getElementById('captcha2').src = '/modules/captcha/securimage_show.php?' + Math.random();
       }	
       else 
       { 
		document.getElementById('sms').style.display = 'none'; 
		document.getElementById('emailinfo').style.display = 'none'; 
		document.getElementById('url').style.display = 'none'; 
		document.getElementById('email').style.display = 'none';  
		document.getElementById('captcha3').src = '/modules/captcha/securimage_show.php?' + Math.random();
       }	

}

function fn_smsnumber(e)
{
var keycode;
if(window.event)
{
keycode = window.event.keyCode;
}
else if(e)
{ 
keycode = e.which;
}

if ((keycode==0)||(keycode==8)||(keycode==44)||(keycode >= 48 && keycode <= 57)||(keycode==127)) 
{
}
else 
{
alert("Numbers Only");
return false;
}
}


function fn_usernamekey(e)
{
var keycode;
if(window.event)
{
keycode = window.event.keyCode;
}
else if(e)
{ 
keycode = e.which;
}

if ((keycode==0) || (keycode==8) || (keycode==44) || (keycode >= 65 && keycode <= 90) || (keycode >= 97 && keycode <= 122) || (keycode==127)) 
{
}
else 
{
alert("Alphabets Only");
return false;
}
}



document.write("<script type='text/javascript' src='/scripts/jquery/jquery/jquery.js'></script>");
var comtype = "mhass";
function post_comment(pid)
{
  if(document.vote.comment_text.value == '')
  {
  alert('Please enter your comment');
  document.vote.comment_text.focus();
  return false;
  }
  if(document.vote.comment_text.value.substring(0,1) == " ")
  {
  alert("The First character should not be a space in comments");
  document.vote.comment_text.focus();
  return false;
  }
  if(document.vote.name.value == '')
  {
  alert('Please enter your name');
  document.vote.name.focus();
  return false;
  }
  if(document.vote.name.value.substring(0,1) == " ")
  {
  alert("The First character should not be a space in your name");
  document.vote.name.focus();
  return false;
  }
  if(document.vote.email.value == '') 
  {
  alert('Please enter your email');
  document.vote.email.focus();
  return false;
  }
  if(document.vote.email.value.substring(0,1) == " ")
  {
  alert("The First character should not be a space in email");
  document.vote.email.focus();
  return false;
  }
  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.vote.email.value)) { 
  }
  else
  {
  alert("Invalid E-mail Address! Please re-enter.");
  return false;
  }
  if(document.vote.security_code.value == '')
  {
  alert('Please enter security code as shown');
  document.vote.security_code.focus();
  return false;
  }
  if(document.vote.security_code.value.substring(0,1) == " ")
  {
  alert("The First character should not be a space in security code");
  document.vote.security_code.focus();
  return false;
  }	
  var comm = document.vote.comment_text.value;
  var myname = document.vote.name.value;
  var mail = document.vote.email.value;
  var pqid = pid;
  var secode = document.vote.security_code.value;
       
 $.get("/modules/comments/add_comments.php",{comment:comm,name:myname,email:mail,pid:pqid,security_code:secode,type:comtype},
 function (resp)
 {
  //alert(resp);
  if(resp == 404)
  {
  alert('Invalid Code. Please Try Again!');
  document.getElementById('errmsg').style.display="";
  document.getElementById('errmsg').innerHTML = "<center><font color=red>Invalid Code. Please Try Again!</font></center>";
  document.vote.security_code.value="";
  }
       if(resp == 1)   
       {
          $.get("/modules/comments/view_comments.php",{pqid:pid,type:comtype},
          function (resp)
          {
		   document.getElementById('dispcomm').innerHTML = resp;
           $('#showform').hide();//hides body content
           $('#dispcomm').show();//shows spinner
		   document.vote.comment_text.value='';
		   //document.vote.name.value='';
		   //document.vote.email.value='';
		   document.vote.security_code.value='';
		   document.getElementById('errmsg').style.display = "none";
		  })
       }
         
 }
 )
}


function disp(pid) {
   document.getElementById('dispcomm').style.display = '';
   $.get("/modules/comments/view_comments.php",{pqid:pid,type:comtype},
   function(resp)
   {
    //document.getElementById('dispcomm').style.display = '';
    document.getElementById('showform').style.display = 'none';
	//document.getElementById('errmsg').style.display = 'none';
    //document.getElementById('loginspan').style.display = '';
    document.getElementById('dispcomm').innerHTML = resp;
   }
  );
} 

function disp1(){
 document.getElementById('captcha4').src = '/modules/captcha/securimage_show.php?' + Math.random();
 document.getElementById('dispcomm').style.display = 'none';
 document.getElementById('showform').style.display = '';
 document.getElementById('loginspan').style.display='';
 document.getElementById('entercomm').style.display = '';
}


function load_page(pno,pid)///////////for ajax pagination
{
 $.get("/modules/comments/view_comments.php",{pqid : pid,page : pno,type:comtype},
  function(resp)
  {
   document.getElementById('dispcomm').innerHTML = resp;
	docuemnt.getElementById('loginspan').style.display='';
	document.getElementById('entercomm').style.display = '';
  }
 );
}

//SEND EMAIL
function sendemail()
{
if(document.email_form.sname.value == '')
	{
	alert('Please Enter Your name before sending the email');
	document.email_form.sname.focus();
	return false;
	}
if(document.email_form.senderemail.value == '')
	{
	alert('Please Enter your email id');
	document.email_form.senderemail.focus();
	return false;
	}
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.email_form.senderemail.value)) { 
}
 else
 {
 alert("Invalid E-mail Address! Please re-enter.");
 return false;
 }
if(document.email_form.emailid.value == '')
	{
	alert('Please enter to email address');
	document.email_form.emailid.focus();
	return false;
	}
if(document.email_form.emailid.value != '')
{
	var emailo=document.email_form.emailid.value;
	var emailsplit=emailo.split(",");
	//alert(emailsplit.length);
		for(p=0;p<emailsplit.length;p++)
		{
			if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(emailsplit[p])) { 
			}
			else {
			alert('Please check the To email');
			return false;
			}
		}
	}
if(document.email_form.security_code.value == '')
	{
	alert('Please Enter the Security Code');
	document.email_form.security_code.focus();
	return false;
	}

  var scode = document.email_form.security_code.value;
  var state = document.email_form.statevalue.value;
  var mail = document.email_form.emailid.value;
  var hidden = document.email_form.hiddenid.value;
       
 $.get("rep_email.php",{security_code:scode,stateid:state,hiddenid:hidden,emailid:mail},
 function (resp)
 {
  //alert(resp);
        if(resp == 1)
           {
			$('#url').hide();//hides body content
   		    $('#emailinfo').show();//shows spinner
            document.getElementById('emailinfo').innerHTML = "<center><font color=green>Mail Sent Successfully</font></center>";
			document.email_form.security_code.value='';
			//document.email_form.sname.value='';
			//document.email_form.senderemail.value='';
			document.email_form.emailid.value='';
			document.getElementById('email').style.display="none";
           }
		else if(resp == 2)
		 {
		  $('#url').hide();//hides body content
   		  $('#emailinfo').show();//shows spinner
          document.getElementById('emailinfo').innerHTML = "<center><font color=red>Invalid Code. Please try again!</font></center>";
			document.email_form.security_code.value='';
			//document.email_form.sname.value='';
			//document.email_form.senderemail.value='';
			//document.email_form.emailid.value='';
		}
 }
 )
}

//URL Validation
function sendurl()
{
	if(document.url_form.sname.value == '')
	{
	alert('Please Enter Your name before sending the email');
	document.url_form.sname.focus();
	return false;
	}
	if(document.url_form.senderemail.value == '')
	{
	alert('Please Enter your email id');
	document.url_form.senderemail.focus();
	return false;
	}
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.url_form.senderemail.value)) { 
	}
	 else
	 {
	 alert("Invalid E-mail Address! Please re-enter.");
	 return false;
	 }
if(document.url_form.emailid.value == '')
	{
	alert('Please enter to email address');
	document.url_form.emailid.focus();
	return false;
	}
if(document.url_form.emailid.value != '')
{
	var emailo=document.url_form.emailid.value;
	var emailsplit=emailo.split(",");
	//alert(emailsplit.length);
		for(p=0;p<emailsplit.length;p++)
		{
			if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(emailsplit[p])) { 
			}
			else {
			alert('Please check the To email');
			return false;
			}
		}
	}
if(document.url_form.security_code.value == '') {
	alert('Please Enter the Security Code');
	document.url_form.security_code.focus();
	return false;
	}

  var uscode = document.url_form.security_code.value;
  var ustate = document.url_form.statevalue.value;
  var umail = document.url_form.emailid.value;
  var uhidden = document.url_form.hiddenid.value;
  var url = document.url_form.url.value;
  var username = document.url_form.sname.value; 		 	
       
$.get("rep_email.php",{usecurity_code:uscode,ustateid:ustate,uhiddenid:uhidden,uemailid:umail,urlid:url,uname:username},
 function (resp)
 {
  //alert(resp);
        if(resp == 1)
           {
			$('#email').hide();//hides body content
   		    $('#emailinfo').show();//shows spinner
            document.getElementById('emailinfo').innerHTML = "<center><font color=green>Mail Sent Successfully</font></center>";
			document.url_form.security_code.value='';
			document.url_form.emailid.value='';
			document.getElementById('url').style.display="none";			
           }
		else if(resp == 2)
		 {
			$('#email').hide();//hides body content
            $('#emailinfo').show();//shows spinner
            document.getElementById('emailinfo').innerHTML = "<center><font color=red>Invalid Code. Please Try Again!</font></center>";
			document.url_form.security_code.value='';
			//document.url_form.sname.value='';
			//document.url_form.senderemail.value='';
			//document.url_form.emailid.value='';
			
		}
      
 }
 )
}
// End URL Validation


//SEND PLUGIN
function sendplugin()
{
	if(document.plugin_form.pname.value == '')
	{
	alert('Please Enter Your name before sending the email');
	document.plugin_form.pname.focus();
	return false;
	}
	if(document.plugin_form.pemail.value == '')
	{
	alert('Please Enter your email id');
	document.plugin_form.pemail.focus();
	return false;
	}
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.plugin_form.pemail.value)) { 
	}
	 else
	 {
	 alert("Invalid E-mail Address! Please re-enter.");
	 return false;
	 }
	if(document.plugin_form.pemailid.value == '')
	{
	alert('Please enter to email address');
	document.plugin_form.pemailid.focus();
	return false;
	}
	if(document.plugin_form.pemailid.value != '')
	{
	var emailo=document.plugin_form.pemailid.value;
	var emailsplit=emailo.split(",");
	//alert(emailsplit.length);
		for(p=0;p<emailsplit.length;p++)
		{
			if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(emailsplit[p])) { 
			}
			else {
			alert('Please check the To email');
			return false;
			}
		}
	}
	if(document.plugin_form.pusecurity_code.value == '') {
	alert('Please Enter the Security Code');
	document.url_form.pusecurity_code.focus();
	return false;
	}

  var seccode = document.plugin_form.pusecurity_code.value;
  var sendermail = document.plugin_form.pemailid.value;
  var consid = document.plugin_form.phiddenid.value;
  var plugincode = document.plugin_form.pluginid.value;
  var sname = document.plugin_form.pname.value;
	       
$.get("rep_email.php",{pusecurity_code:seccode,phiddenid:consid,pemailid:sendermail,pluginid:plugincode,pname:sname},
 function (resp)
 {
  //alert(resp);
        if(resp == 1)
           {
			$('#email').hide();//hides body content
   		    $('#emailinfo').show();//shows spinner
            document.getElementById('emailinfo').innerHTML = "<center><font color=green>Mail Sent Successfully</font></center>";
			document.plugin_form.pusecurity_code.value='';
			document.plugin_form.pemailid.value='';
			document.getElementById('plugin').style.display="none";
           }
		else if(resp == 2)
		 {
			$('#email').hide();//hides body content
            $('#emailinfo').show();//shows spinner
            document.getElementById('emailinfo').innerHTML = "<center><font color=red>Invalid Code. Please Try Again!</font></center>";
			document.url_form.pusecurity_code.value='';
			//document.url_form.sname.value='';
			//document.url_form.senderemail.value='';
			document.url_form.pemailid.value='';
		}
      
 }
 )
}


//SEND SMS
function sendsms()
{
if(document.sms_form.yourname.value == '')
	{ 
	alert('Please enter your name before sending the sms');
	document.sms_form.yourname.focus();
	return false;
	}
if(document.sms_form.yournumber.value == '')
	{ 
	alert('Please enter your mobile number before sending the sms');
	document.sms_form.yournumber.focus();
	return false;
	}
if(document.sms_form.yournumber.value.length < 10)
	{
	alert('Your Mobile Number is Invalid');
	document.sms_form.yournumber.focus();
	return false;	
	}
if(document.sms_form.smsnumber.value == '')
	{
	alert('Please enter the mobile number you like to sent');
	document.sms_form.yournumber.focus();
	return false;
	}
if(document.sms_form.smsnumber.value != '')
	{
	var smso=document.sms_form.smsnumber.value;
	var smssplit=smso.split(",");
		for(k=0;k<smssplit.length;k++)
		{
			if(smssplit[k].length!=10)
			{
			alert('Please check the mobile numbers');
			return false;
			}
		}
	}
if(document.sms_form.security_code.value == '')
	{
	alert('Please Enter the Security Code');
	document.sms_form.yournumber.focus();
	return false;
	}

  var scode = document.sms_form.security_code.value;
  var smsno = document.sms_form.smsnumber.value;
  var hidden = document.sms_form.hiddenid.value;
       
 $.get("rep_sms.php",{security_code:scode,smsnumber:smsno,hiddenid:hidden},
 function (resp)
 {
  //alert(resp);
        if(resp == 1)
           {
			$('#sms').hide();//hides body content
            $('#emailinfo').show();//shows spinner
            document.getElementById('emailinfo').innerHTML = "<center><font color=green>SMS Sent Successfully</font></center>";
			document.sms_form.security_code.value='';
			//document.sms_form.yourname.value='';
			//document.sms_form.yournumber.value='';
			document.sms_form.smsnumber.value='';
	        }
		else if(resp == 2)
		 {
			$('#sms').show();//hides body content
            $('#emailinfo').show();//shows spinner
            document.getElementById('emailinfo').innerHTML = "<center><font color=red>Invalid Code or Insufficent SMS Balance. Please try again!</font></center>";
			document.sms_form.security_code.value='';
			//document.sms_form.yourname.value='';
			//document.sms_form.yournumber.value='';
			//document.sms_form.smsnumber.value='';
		}
	   	else 
	 	{
			$('#sms').show();//hides body content
            $('#emailinfo').show();//shows spinner
            document.getElementById('emailinfo').innerHTML = "<center><font color=red>SMS not sent. Please try later!</font></center>";
			document.sms_form.security_code.value='';
			//document.sms_form.yourname.value='';
			//document.sms_form.yournumber.value='';
			//document.sms_form.smsnumber.value='';
		}
  }
 )
}

/******************************************
* Popup Box- By Jim Silver @ jimsilver47@yahoo.com
* Visit http://www.dynamicdrive.com/ for full source code
* This notice must stay intact for use
******************************************/

var ns4=document.layers
var ie4=document.all
var ns6=document.getElementById&&!document.all

//drag drop function for NS 4////
/////////////////////////////////
var dragswitch=0
var nsx
var nsy
var nstemp

function drag_dropns(name){
if (!ns4)
return
temp=eval(name)
temp.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP)
temp.onmousedown=gons
temp.onmousemove=dragns
temp.onmouseup=stopns
}

function gons(e){
temp.captureEvents(Event.MOUSEMOVE)
nsx=e.x
nsy=e.y
}
function dragns(e){
if (dragswitch==1){
temp.moveBy(e.x-nsx,e.y-nsy)
return false
}
}

function stopns(){
temp.releaseEvents(Event.MOUSEMOVE)
}
//drag drop function for ie4+ and NS6////
/////////////////////////////////

function drag_drop(e){
if (ie4&&dragapproved){
crossobj.style.left=tempx+event.clientX-offsetx
crossobj.style.top=tempy+event.clientY-offsety
return false
}
else if (ns6&&dragapproved){
crossobj.style.left=tempx+e.clientX-offsetx+"px"
crossobj.style.top=tempy+e.clientY-offsety+"px"
return false
}
}

function initializedrag(e){
crossobj=ns6? document.getElementById("showimage") : document.all.showimage
var firedobj=ns6? e.target : event.srcElement
var topelement=ns6? "html" : document.compatMode && document.compatMode!="BackCompat"? "documentElement" : "body"
while (firedobj.tagName!=topelement.toUpperCase() && firedobj.id!="dragbar"){
firedobj=ns6? firedobj.parentNode : firedobj.parentElement
}

if (firedobj.id=="dragbar"){
offsetx=ie4? event.clientX : e.clientX
offsety=ie4? event.clientY : e.clientY

tempx=parseInt(crossobj.style.left)
tempy=parseInt(crossobj.style.top)

dragapproved=true
document.onmousemove=drag_drop
}
}
document.onmouseup=new Function("dragapproved=false")
////drag drop functions end here//////

function hidebox(){
crossobj=ns6? document.getElementById("showimage") : document.all.showimage
if (ie4||ns6)
crossobj.style.visibility="hidden"
else if (ns4)
document.showimage.visibility="hide"
}


//Javascript FOR FILTER
function plus() {
if(document.getElementById("state").value=="") {
alert('Please Select State');
return false;
}
document.getElementById("plus").style.display = "none";
document.getElementById("minus").style.display = "block";
document.getElementById("options").style.display = "block";
document.getElementById("filter").style.display = "block";
}

function minus() {
document.getElementById("plus").style.display = "block";
document.getElementById("minus").style.display = "none";
document.getElementById("options").style.display = "none";
document.getElementById("filter").style.display = "none";
}

function fn_tabs(str) {
	if(str == "representative") {
	document.getElementById("party").style.backgroundImage = "url(/themes/images/subhead.jpg)";
	document.getElementById("alliance").style.backgroundImage = "url(/themes/images/subhead.jpg)";
	document.getElementById(str).style.backgroundImage = "";
	}
	else if(str == "party") {
	document.getElementById("partytracker").style.display = "";
	document.getElementById("representative").style.backgroundImage = "url(/themes/images/subhead.jpg)";
	document.getElementById("alliance").style.backgroundImage = "url(/themes/images/subhead.jpg)";
	document.getElementById(str).style.backgroundImage = "";
	}
	else {
	document.getElementById("representative").style.backgroundImage = "url(/themes/images/subhead.jpg)";
	document.getElementById("party").style.backgroundImage = "url(/themes/images/subhead.jpg)";
	document.getElementById(str).style.backgroundImage = "";
	}
}

function flash() {
	if(document.getElementById("flashchart").style.display == "none")
		document.getElementById("flashchart").style.display = "";
	else
		document.getElementById("flashchart").style.display = "none";
}

function flash1() {
	alert("welcome");
	document.getElementById("flashchart").style.display = "";
}

function lastresult() {
	if(document.getElementById("lastresult").style.display == "none")
		document.getElementById("lastresult").style.display = "";
	else
		document.getElementById("lastresult").style.display = "none";
}

