/*  参数设定  */
				var x0=0,y0=0,x1=0,y1=0;
                var offx=6,offy=6;
                var moveable=false;
                var hover='orange',normal='#336699';//color;
                var index=10000;//z-index;
				/*  参数设定完毕  */
				var isIE=document.all? true:false;
				var parentId = "xMsg1";
//if(isIE==false)
//{
//document.addEventListener("mousemove",startDrag,true);
//document.removeEventListener("mousemove",stopDrag,true);
//}
/**
 * 投票函数
 * @param parentId 投票项目ID
 */
function vote(parentId,voteType)
{
     var sName = 'voteProject'+parentId;
     var aVoteProject = document.getElementsByName(sName);
     var aSelect = new Array(); 
     
     for(var i=0;i<aVoteProject.length;i++)
     {
    	if(aVoteProject[i].checked==true)
    	{
    	   aSelect.push(aVoteProject[i].value);
    	}
     }
     if(aSelect.length>0)
     {
     activePage.toVote(aSelect,voteCallBack=function(data){if(data==1)
	{
	alert(sitesInfo_active_msg001);
	}else if(data==2)
	{
	alert(sitesInfo_active_msg002);
	}else if(data==3){
		alert("投票还未开始！");
	}else if(data==4){
		alert("投票已经结束！")
	}else if(data==5){
		alert("对不起，此次投票只针对相关人员，您无法参与！");
	}else{
		alert(sitesInfo_active_msg003);
	}});
     }else{
    	 alert(sitesInfo_active_msg004);
     }
}

/**
 * 查看投票结果
 */

function lookVoteResult(itemId,topValue)
{
	activePage.toLookVote(itemId,lookVoteCallBack=function(data)
			{
			    var left = (window.screen.width - 500)/2;
		        var top =  (window.screen.height +200)/2;
				var width = 200;
				//alert(window.screen.width);
				//alert(left);
				//alert(window.screen.height);
				//alert(top);
			    //alert(topValue);
				
				var oItem = data[0];
				var aItemProject = data[1];
				var totalCount = oItem.voterCount;//总票数
				var str='';
				//parentId = "voteTempDiv"+oItem.id;
				
				/** 大块的设定 **/
				var divStr = ""
						+ "<div id=xMsg1 "
						+ "style='"
						+ "z-index:" + (index+2) + ";"
						//+ "z-index:" + index + ";"
						+ "width:500px;"
						+ "height:300px;"
						+ "left:" + left + "px;"
						+ "top:"  + topValue + "px;"
						+ "background-color:" + normal + ";"
						+ "color:" + normal + ";"
						+ "font-size:10pt;"
						+ "font-family:Tahoma;"
						+ "position:absolute;"
						+ "cursor:default;"
						+ "border:2px solid " + normal + ";"
						//+"border:2px solid red;"
						+ "' "
						+ "onmousedown='getFocus(this)'>";
				/** 标题栏设定**/
			    var titleStr="<div "
							+ "style='"
							+ "background-color:" + normal + ";"
							+ "width:" + (this.width-2*2) + ";"
							+ "height:20px;"
							+ "color:white;"
							+ "' " //\"voteTempDiv"+oItem.id+"\",
							+ "onmousedown='startDrag(this,event)' "
							+ "onmouseup='stopDrag(this,event)' "
							+ "onmousemove='drag(this,event)' "
							//+ "ondblclick='min(this.childNodes[1])'"
							+ ">"
							+ "<span style='width:" + (this.width-2*12-4) + ";padding-left:3px;'>"+sitesInfo_active_msg005+"</span>"
							//+ "<span style='width:12;border-width:0px;color:white;font-family:webdings;' onclick='min(this)'>0</span>"
							//+ "<span style='width:12;border-width:0px;color:white;font-family:webdings;' onclick='ShowHide(\""+this.id+"\",null)'>x</span>"
							+ "</div>";
				str+=divStr;
				str+=titleStr;
				str+='<div style="width:98%;height:275px;background-color:white;line-height:14px;padding:3px 3px 3px 3px;text-align:center;overflow:auto;">';
				str+='<br>';
				str+='<h4>《'+oItem.itemName+'》'+sitesInfo_active_msg006+'</h4>';
				str+='<br>';
				str+='<p  style="width:98%;text-align:left;padding-left:4px;margin:0 0 6px;line-height:14px;font-weight:normal;font-size:12px;">'+sitesInfo_active_msg007+'<span style="color:red;font-weight:bold">'+totalCount+'</span>'+sitesInfo_active_msg008+'</p>';
				str+='<table border="0" cellpadding="0" cellspacing="0" align="center" width="98%">';
				str+='<thead><tr>';
				str+='<th style="border:solid 1px #d5d9d8;background-color:#f6f6f6;color:#666;line-height:24px;font-weight:normal;">'+sitesInfo_active_msg009+'</th>';
				str+='<th style="border:solid 1px #d5d9d8;background-color:#f6f6f6;color:#666;line-height:24px;font-weight:normal;">'+sitesInfo_active_msg010+'</th>';
				//判断是否有百分比
				if(oItem.isRate==1)
				{
					str+='<th style="border:solid 1px #d5d9d8;background-color:#f6f6f6;color:#666;line-height:24px;font-weight:normal;">'+"百分比"+'</th>';
				}
				if(oItem.picShowType!=0)
				{
					str+='<th style="border:solid 1px #d5d9d8;background-color:#f6f6f6;color:#666;line-height:24px;font-weight:normal;">'+"图形百分比"+'</th>';
				}
				
				str+='<th style="border:solid 1px #d5d9d8;background-color:#f6f6f6;color:#666;line-height:24px;font-weight:normal;">'+sitesInfo_active_msg011+'</th>';
				str+='</tr></thead>';
				str+='<tbody>';
				for(var i=0;i<aItemProject.length;i++)
				{
                var tCount = aItemProject[i].tickets;		
                var rate = (100*(tCount/totalCount)).toFixed(2);
                if(isNaN(rate))
                	rate = 0;
				str+='<tr>'
				str+='<td style="border:solid 1px #d5d9d8;background-color:#fff;color:#363636;line-height:33px">'+(i+1)+'</td>';
				str+='<td style="border:solid 1px #d5d9d8;background-color:#fff;color:#363636;line-height:33px"> '+aItemProject[i].itemName+'&nbsp;&nbsp;</td>';
				//百分比和图形百分比
				if(oItem.isRate==1)
				{
					str+='<td style="border:solid 1px #d5d9d8;background-color:#fff;color:#363636;line-height:33px"> '+rate+"%"+'&nbsp;&nbsp;</td>';
				}
				if(oItem.picShowType==1)
				{
					
					str+='<td style="border:solid 1px #d5d9d8;background-color:#fff;color:#363636;line-height:33px"> ';
					var sDivStr = '<div style="width:100%;height:30px;text-align:left;"><div style="width:30%;float:left;text-align:right;height:20px;margin-top:6px;line-height:20px;">'+rate+'%</div><div style="float:right;width:50%;background-color:#d9e4f8;height:8px;margin:8px 10px 0 0;">';
					var sSpanStr = '<span style="display:block;background-color:red;width:'+rate+'%;height:8px;"></span>';
					sDivStr+= sSpanStr;
					sDivStr+='</div></div>';
					str+=sDivStr;
					str+='</td>';
				}
				str+='<td style="border:solid 1px #d5d9d8;background-color:#fff;color:#363636;line-height:33px"><span style="color:red;">'+tCount+sitesInfo_active_msg012+'</span><td>';
				str+='</tr>';
				}
				str+='<tbody>';
				str+='</table>';
				str+='<br><input type="button" value="'+sitesInfo_active_msg013+'" sytle="border-right: #7b9ebd 1px solid; padding-right: 2px; border-top: #7b9ebd 1px solid; padding-left: 2px; font-size: 12px; filter: progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#ffffff, EndColorStr=#cecfde); border-left: #7b9ebd 1px solid; cursor: pointer; color: black; padding-top: 2px; border-bottom: #7b9ebd 1px solid;"    onclick=closeVoteDiv("voteTempDiv'+oItem.id+'") />';
				str+='</div>';
				str+='</div>';
				var endStr = "<div id=xMsg1bg style='"
								+ "width:300px;"
								+ "height:300px;"
								+ "top:" + topValue + "px;"
								+ "left:" + left + "px;"
								//+ "z-index:" + (index-1) + ";"
								+ "z-index:" + (index-1) + ";"
								+ "position:absolute;"
								+ "background-color:black;"
								+ "filter:alpha(opacity=40);"
								+ "'></div>";
				str+=endStr;
				var oDiv = window.document.createElement("DIV");
				oDiv.id="voteTempDiv"+oItem.id;
				//oDiv.style.position = "relative";
				//oDiv.style.position = "absolute";
				//oDiv.style.width="310px";
				//oDiv.style.height="300px";
				//oDiv.style.left = left+"px";
				//oDiv.style.top = topValue+"px";
				//oDiv.style.border = "2px solid " + normal;
				//oDiv.style.border="2px solid green";
				//oDiv.style.textAlign = "center";

				//oDiv.style.background = normal;
				//oDiv.style.cursor="default";
				//oDiv.style.display = "block";
				//oDiv.style.zIndex = index;
				oDiv.innerHTML = str;

				document.body.appendChild(oDiv);
				//oDiv.onmousedown = getFocus(oDiv,index);
				//oDiv.focus();
			}
			);
}

//获得焦点;
function getFocus(obj,index)
{
if(obj.style.zIndex!=index)
{
index = index + 2;
var idx = index;
obj.style.zIndex=idx;
obj.nextSibling.style.zIndex=idx-1;
}
}

function startDrag(obj,evt)
{
 //debugger;
evt=evt?evt:(window.event?window.event:null);

//if(evt.button==1)
//{
if(isIE==true)
{
obj.setCapture();
}else{
document.addEventListener("mousemove",startDrag,true);
}


var win = obj.parentNode;
var sha = win.nextSibling;
//var win = document.getElementById(parentId);
//var sha = win.nextSibling;

x0 = evt.clientX;
y0 = evt.clientY;
x1 = parseInt(win.style.left);
y1 = parseInt(win.style.top);

normal = obj.style.backgroundColor;

obj.style.backgroundColor = hover;
win.style.borderColor = hover;
obj.nextSibling.style.color = hover;
sha.style.left = x1 + offx;
sha.style.top = y1 + offy;
moveable = true;
//}
}

function drag(obj,evt)
{
evt=evt?evt:(window.event?window.event:null);
if(moveable)
{
var win = obj.parentNode;
var sha = win.nextSibling;
//var win = document.getElementById(parentId);
//var sha = win.nextSibling;
win.style.left = x1 + evt.clientX - x0;
win.style.top = y1 + evt.clientY - y0;
sha.style.left = parseInt(win.style.left) + offx;
sha.style.top = parseInt(win.style.top) + offy;
}
}

function stopDrag(obj)
{
if(moveable)
{
var win = obj.parentNode;
var sha = win.nextSibling;
//var win = document.getElementById(parentId);
//var sha = win.nextSibling;
var msg = obj.nextSibling;
win.style.borderColor     = normal;
obj.style.backgroundColor = normal;
msg.style.color           = normal;
sha.style.left = obj.parentNode.style.left;
sha.style.top = obj.parentNode.style.top;
if(isIE==true)
{
obj.releaseCapture();
}else{
document.addEventListener("mousemove",startDrag,true);
}

moveable = false;
}
}

function getFocus(obj)
{
if(obj.style.zIndex!=index)
{
index = index + 2;
var idx = index;
obj.style.zIndex=idx;
obj.nextSibling.style.zIndex=idx-1;
}
}

/*
function min(obj)
{
var win = obj.parentNode.parentNode;
var sha = win.nextSibling;
var tit = obj.parentNode;
var msg = tit.nextSibling;
var flg = msg.style.display=="none";
if(flg)
{
win.style.height = parseInt(msg.style.height) + parseInt(tit.style.height) + 2*2;
sha.style.height = win.style.height;
msg.style.display = "block";
obj.innerHTML = "0";
}
else
{
win.style.height = parseInt(tit.style.height) + 2*2;
sha.style.height = win.style.height;
obj.innerHTML = "2";
msg.style.display = "none";
}
}
*/

/**
*关闭DIV块
*/
function closeVoteDiv(oDivId)
{
   var oDiv = document.getElementById(oDivId);
   if(oDiv!=null)
   {
		document.body.removeChild(oDiv);
   }
   
}