var pid;
function tellfriend(id,type){
	pid	=	'p'+id;
	document.getElementById(pid).innerHTML="<img src=\""+ site_images +"/loading.gif\" >";
	var postVar	= '&id='+id+'&type='+type;
	ajax_do_call('GET',web_path+'/index.php?Action=pakistanvoices.tellfriendhtml',postVar,tellfriendHTML);
}
function tellfriendHTML(result){
		document.getElementById(pid).innerHTML=result;
}
function closeme(id){
	pid	=	'p'+id;
	document.getElementById(pid).style.display='none';

}
function email_tell_friend(pid,type){
	pid	=	pid;
	var email1	=	 'email1_'+pid;
	var email2	=	 'email2_'+pid;
	var email3	=	 'email3_'+pid;
	var email_message_pid	=	 'email_message_'+pid;
	
	var eid1	=	document.getElementById(email1).value;
	var eid2	=	document.getElementById(email2).value;
	var eid3	=	document.getElementById(email3).value;
	
	
	var postVar	= '&eid1='+eid1+'&eid2='+eid2+'&eid3='+eid3+'&pid='+pid+'&msg='+email_message_pid+'type='+type;
	ajax_do_call('GET',web_path+'/index.php?Action=pakistanvoices.send_tellfriend_email',postVar,emailtellfriend);
	
}
function emailtellfriend(result){
	//alert(result);
	var sentMessage	=	result.indexOf('sent');
	if(sentMessage > 0){
		document.getElementById(pid).innerHTML=result;
	}else{
		alert(result);	
	}
}

function get_comments(id,type){
	pid	=	'p'+id;
	document.getElementById(pid).innerHTML="<img src=\""+ site_images +"/loading.gif\" >";
	var postVar	= '&id='+id+'&type='+type;

	ajax_do_call('GET',web_path+'/index.php?Action=pakistanvoices.get_discuccs',postVar,getDiscuss);
}
function getDiscuss(result){
	//alert(result);
	//die();
	document.getElementById(pid).innerHTML=result;
}

function discussHTML(id,type){
	pid	=	'p'+id;
	document.getElementById(pid).innerHTML="<img src=\""+ site_images +"/loading.gif\" >";
	var postVar	= '&id='+id+'&type='+type;
	ajax_do_call('GET',web_path+'/index.php?Action=pakistanvoices.discuccs',postVar,discussPoliticiansHTML);
}
function discussPoliticiansHTML(result){
		document.getElementById(pid).innerHTML=result;
}
function discuss(pid,type){
	pid=pid;
	comment_body			=	'comment_body_'+pid;
	var comment_body_pid	=	 document.getElementById(comment_body).value;
	var postVar	= '&pid='+pid+'&comment_body='+comment_body_pid+'&type='+type;
	ajax_do_call('GET',web_path+'/index.php?Action=pakistanvoices.post_comments',postVar,post_comments);
}
function post_comments(result){
	var sentMessage	=	result.indexOf('successfully');
	if(sentMessage > 0){
		document.getElementById(pid).innerHTML=result;
	}else{
		alert(result);	
	}
}
function closeme(id){
	pid	=	'p'+id;
	document.getElementById(pid).style.display='none';
}
function post_vote(id,type,plusminus){
		if(sessId==''){
			alert('Please login to continue voting.');
			return false;
		}
		var postVar	= '&id='+id+'&type='+type+'&plusminus='+plusminus;
		ajax_do_call('GET',web_path+'/index.php?Action=pakistanvoices.post_vote',postVar,post_vote_result);
}
function post_vote_result(result){
	var ary	=	 result.split('__<>__');
	var message	=	ary[0];
	var type	=	ary[1];
	var id		=	ary[2];
	var plusminus		=	ary[3];
	var divId	=	 type+id;
	document.getElementById(divId).innerHTML="<img src=\""+ site_images +"/loading.gif\" >";
	var postVar	= '&id='+id+'&type='+type+'&divId='+divId+'&plusminus='+plusminus;
	ajax_do_call('GET',web_path+'/index.php?Action=pakistanvoices.get_vote',postVar,show_vote_result);
}
function show_vote_result(result){
	var ary			=	result.split('__<>__');	
	var string		=	ary[0];
	var divid		=	ary[1];
	var plusminus	=	ary[2];
	var burryId	=	'burry_'+divid;
	if(plusminus==0){
		document.getElementById(burryId).innerHTML='<font style="font-size:12px; font-family:Arial; color:#408FBD">Burry</font>';
	}
	document.getElementById(divid).innerHTML=string;
}

/* Refurandom*/
function postOpinion(){

	var vote	=	document.getElementById('vote').value;
	var fname	=	document.getElementById('fname').value;
	var email	=	document.getElementById('email').value;
	var opinion	=	document.getElementById('opinion').value;
	var region	=	document.getElementById('region').value;
	
	document.getElementById('divLoading').innerHTML="<img src=\""+ site_images +"/loading.gif\" >";
	var postVar	= '&vote='+vote+'&fname='+fname+'&email='+email+'&opinion='+opinion+'&region='+region;
	ajax_do_call('GET',web_path+'/index.php?Action=pakistanvoices.post_opinion',postVar,callBackOpinion);	
}
function callBackOpinion(result){
		document.getElementById('divLoading').innerHTML="";
		var strArray		=	result.split("__<>__");
		var msg				=	strArray[0];
		var idFavoreAgainst	=	strArray[1];
		var total			=	strArray[2];
		document.getElementById(idFavoreAgainst).innerHTML=total;
		document.getElementById('msgBar').innerHTML=msg;
	}

