﻿
//获得当前页的文件名
function currentPageFilename() 
{ 
    var currentUrl = window.location.href; 
    var pageFilename = turl.substring(turl.lastIndexOf('/')+1); 
    return pageFilename;
}

//关闭窗口
function closeWindow() 
{
    window.opener=null;
    window.open('','_top');
    window.top.close();
}

//-----Prototype function------------------------------------------

//信息内容页面区域
function GetNewsContentBody()
{
    var imgs=$("NewsContentBody").getElementsByTagName("img");
    for(var i=0; i<imgs.length;i++){
        imgs[i].onclick = function(){window.open(this.src); };
        imgs[i].style.cursor = "pointer";
        imgs[i].onmousewheel = function(){
            var zoom=parseInt(this.style.zoom, 10)||100;
            zoom+=event.wheelDelta/12;
            if (zoom>0) this.style.zoom=zoom+'%';
			return false;
        }
    }
}

//-----Ajax-------------------------------------------------

// 用户投票动作 addPoll
function addPoll(id,mtype,btn,actionpage)
{
    btn.value="请在提交...";
    btn.disabled=true;
    var PollNum;
    var rbPoll=eval("document.pollform"+id).elements["iptPoll"];
    for(var i=0;i<rbPoll.length;i++)
    {
        if(rbPoll[i].checked){
            if(!PollNum)
                PollNum=rbPoll[i].value;
            else
                PollNum += "," + rbPoll[i].value;
        }
    }
    if(!PollNum){
        alert("请先选择项目!");
        btn.disabled=false;
        btn.value="投票";
        return;
    }
    var option={
		parameters:"action=addPoll&Id="+id+"&Num="+PollNum+"",
		method:"get",
		onSuccess:function(transport){
			var rp=transport.responseText;
			if(rp=="ok"){ 
			    alert("成功,谢谢你的投票!");
                btn.value="已投票";
			} else {
			    alert(rp);
			    btn.disabled=false;
                btn.value="投票";
			}
		},
		onFailure:function(transport){
			alert("数据提交失败!请检查网络或重试。");
		}
	}
	var request=new Ajax.Request(actionpage,option);
	//var request=new Ajax.Request("../AjaxPoll.aspx",option);

	return;
}