var activecand = "";
var activecadaa = "";
var activepane= "";
function ShowSubCand(div_id){
	var d = MM_findObj(div_id);
	if(activecand != ""){
		ad = MM_findObj(activecand);
		if(ad.style.display == "block"){ ad.style.display = "none" }
	}
	if(d != null){
		if(d.style.display == "block"){
			d.style.display = "none";
		} else {
			d.style.display = "block";
			activecand = div_id;
		}
	}
	$(d).addClass("flexcroll").css({ width: "152px", height:"100px" });
	fleXenv.globalInit();
	fleXenv.globalInit();	// repeated to fix IE8 bug
	
	var items = $(d).find(".CandName").length;
	if(items < 6) {
		$(d).css({ height: "auto" });
		//$(d).find(".mcontentwrapper").css({ height: "auto" });
		$(d).find(".mcontentwrapper").css({ height: "auto", float: "right" });
	}
	
}

function ShowSubKadaa(div_id) {
	var d = MM_findObj(div_id);
	if(activecadaa != ""){
		ad = MM_findObj(activecadaa);
		if(ad.style.display == "block"){ ad.style.display = "none" }
	}
	if(d != null){
		if(d.style.display == "block"){
			d.style.display = "none";
		} else {
			d.style.display = "block";
			activecadaa = div_id;
		}
	}
}

function ShowSubPane(div_id) {
	var d = MM_findObj(div_id);
	if(activepane != ""){
		ad = MM_findObj(activepane);
		if(ad.style.display == "block"){ ad.style.display = "none" }
	}
	if(d != null){
		if(d.style.display == "block"){
			d.style.display = "none";
		} else {
			d.style.display = "block";
			activepane = div_id;
		}
	}
	$(d).addClass("flexcroll").css({ width: "152px", height:"100px" });
	fleXenv.globalInit();
	fleXenv.globalInit();	// repeated to fix IE8 bug
	
	var items = $(d).find(".BgGray").length;
	if(items < 3) {
		$(d).css({ height: "auto" });
		$(d).find(".mcontentwrapper").css({ height: "auto", float: "right", left: "0px" });
	}
	
}

/*

function ShowSubCand(x,alltabs) {
	var p = document.getElementById("Key"+x);
	if (p.style.display=='none'){
		for(var i=1;i<=alltabs;i++){
			document.getElementById("Key"+i).style.display="none";
	}
	p.style.display='';
	$(function(){$('#pane'+x).jScrollPane({showArrows:true});});
	//alert('#pane'+x);
	}
	else{
		p.style.display='none';
		}
}

function ShowSubKadaa(x,alltabs) {
	var p = document.getElementById("Keyy"+x);
	if (p.style.display=='none'){
		for(var i=1;i<=alltabs;i++){
			document.getElementById("Keyy"+i).style.display="none";
	}
	p.style.display='';
	//alert('#pane'+x);
	}
	else{
		p.style.display='none';
		}
}

function ShowSubPane(x,alltabs) {
	var p = document.getElementById("Keyyy"+x);
	if (p.style.display=='none'){
		for(var i=1;i<=alltabs;i++){
			document.getElementById("Keyyy"+i).style.display="none";
	}
	p.style.display='';
	$(function(){$('#panee'+x).jScrollPane({showArrows:true});});
	}
	else{
		p.style.display='none';
		}
}
*/
function CheckIfEmailVoted(Email){
   // $("#"+DivID).show("normal");
	//$("#"+DivID).html("<span>Loading...</span>");
	//$.get("ELCheckEmail.aspx?Email="+Email, '', function(data){$("#divCode").css("display",data);});
	$.get("ELCheckEmail.aspx?Email="+Email, '', function(data){
		if(datat=="true"){
			$("#divCode").show();
			return false;
			}
		else
			return true;

	});
	}


function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}
	
function showAlert(cazaid, divvote){
	var mps_ids;
	mps_ids=$("#"+divvote+" :checkbox").getValue();
	if (mps_ids==""){
		alert("please select your candidates");
		}
	else{
		var scroll_top = getScrollXY()[1];
		var t = scroll_top + ($(window).height()/2 - $("#alert_window").height()/2);
		$("#alert_window").parent().css({position: "absolute", top: "0"})
		$("#alert_window").css("top", t)
		$("#alert_window").show();
		$("#alert_window .closebtn").click(function(){hideAlert();});
		//$("#alert_window .closebtn").click(function(){hideAlert();});
		//$("#alert_window #aclose").click(function(){CollapseVote(divvote)})
		//$("#alert_window iframe #aclose").click(alert(""));
		$("#alert_window iframe").attr("src", 'ELSubmitVote.aspx?cazaID='+cazaid+'&MPsIDs='+mps_ids+'&div='+divvote);
		//$("#alert_window iframe #aclose").click(function(){$(this).parent().CollapseVote(divid)});

		}
	return false;
	}

function hideAlert() 
{
	$("#alert_window").slideUp(200);
}



function validateVote(){
	var msg="";
	if (document.getElementById("txtEmail").value==""){
		alert("Please enter your email");
		return false;
	}
	else{
		var strvalmail=IsValidEmail(document.getElementById("txtEmail"));
	    if (strvalmail.length>0){
			alert(strvalmail)
			return false;
		}
		else
			return true;
	}
}


current="";
function ExpandVote(divid){	
	if(current!=""){current.style.display='none';}
	
	thediv = document.getElementById(divid);
	$(thediv).show("slow");
	thediv.style.display='block';
	current=thediv;
}

current="";
function CollapseVote(divid){	
	if(current!=""){current.style.display='block';}
	
	thediv = document.getElementById(divid);
	thediv.style.display='none';
	current=thediv;
}

function hidealertdiv(div_id){
	
	window.parent.hideAlert();
	window.parent.CollapseVote(div_id)
	}