﻿
//function escape2(str){
//	return escape(str).replace(/\+/g,"%2b");
//}

//function addVote(id,mtype,btn)
//{
//    btn.value="请在提交,请稍等!";
//    btn.disabled=true;
//    var voteNum;
//    var rbVote=document.forms[0].elements["vote"];
//    for(var i=0;i<rbVote.length;i++)
//    {
//        if(rbVote[i].checked){
//            if(!voteNum)
//                voteNum=rbVote[i].value;
//            else
//                voteNum += "," + rbVote[i].value;
//        }
//    }
//    if(!voteNum){
//        alert("请先选择项目!");
//        btn.disabled=false;
//        btn.value="投票";
//        return;
//    }
//    var option={
//		parameters:"oper=addVote&id="+id+"&mtype="+mtype+"&vote="+voteNum+"&time="+Date(),
//		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(InstallDir+"ajax.aspx",option);
//	return;
//}

//function getVote(id,sobj)
//{
//    if($("voteDisplay") && $("voteDisplay").style.display!="none")
//    {
//        $("voteDisplay").style.display="none";
//        return;
//    }
//    var h,tooltip,s,w;
//    if(!$("voteDisplay"))
//    {
//        h=document.createElement("div");
//        h.setAttribute("id","voteDisplay");
//        h.className="siteInfo";
//        h.style.position="absolute";
//        document.getElementsByTagName("body")[0].appendChild(h);
//        w=CreateEl("ul","voteClose");
//        w.innerHTML="<input type=button onclick=\"getVote(0,0)\" value=关闭>";
//        $("voteDisplay").appendChild(w);
//        tooltip=CreateEl("ul","tooltip");
//        
//        tooltip.innerHTML="正在加载数据...";
//        $("voteDisplay").appendChild(tooltip);
//    }
//    $("voteDisplay").style.display="block";
//    
//    var ttop=sobj.offsetTop;
//    if(sobj.clientHeight!="undefined")ttop+=sobj.clientHeight+5;
//    var ttleft=sobj.offsetLeft;
//    while(sobj=sobj.offsetParent){ttop+=sobj.offsetTop;ttleft+=sobj.offsetLeft;}
//    if((ttleft+300)>screen.width)ttleft=screen.width-300;
//    $("voteDisplay").style.top=ttop-30;
//    $("voteDisplay").style.left=ttleft+40;

//    var option={
//		parameters:"oper=getVote&id="+id+"&time="+Date(),
//		method:"get",
//		onSuccess:function(transport){
//			var rp=transport.responseText;
//			document.getElementsByClassName("tooltip",$("voteDisplay"))[0].innerHTML=rp;
//		},
//		onFailure:function(transport){
//			alert("数据提交失败，请检查网络或重试。");
//		}
//	}
//	var request=new Ajax.Request(InstallDir+"ajax.aspx",option);
//	return;
//}
//function CreateEl(t,c){
//    var x=document.createElement(t);
//    x.className=c;
//    x.style.display="block";
//    return(x);
//}
function getViewNum(cTypes,ids)
{
    $.post(InstallDir+"ajax.aspx",{
        oper:"getViewNum",
        id:ids,
        cType:cTypes,
        time:Date()
      },function(msg){
        $("getViewNum"+id).text(msg);
      });
}
function viewCount(cTypes,ids)
{
    $.post(InstallDir+"ajax.aspx",{
        oper:"viewCount",
        id:ids,
        cType:cTypes,
        time:Date()
      });
}
//function getReviewNum(cType,id)
//{
//    var option={
//		parameters:"oper=getReviewNum&id="+id+"&cType="+cType+"&time="+Date(),
//		method:"get",
//		onSuccess:function(transport){
//		    var rp=transport.responseText;
//			$("getReviewNum"+id).innerHTML=rp;
//		},
//		onFailure:function(transport){
//			$("getReviewNum"+id).innerHTML=0;
//		}
//	}
//	var request=new Ajax.Request(InstallDir+"ajax.aspx",option);
//}
//function addFav(id)
//{
////参数说明 x=0,1表示动态和静态页
//    var option={
//		parameters:"oper=addFav&id="+id+"&time="+Date(),
//		method:"get",
//		onSuccess:function(transport){
//		    var rp=transport.responseText;
//			if(rp=="ok")
//			    alert("操作成功!");
//			else
//			    alert(rp);
//		},
//		onFailure:function(transport){
//			alert("数据提交失败，请检查网络或重试。");
//		}
//	}
//	
//	var request=new Ajax.Request(InstallDir+"ajax.aspx",option);
//	return;
//}
//function getLoginBar(w)
//{
////参数说明:w=-1,0,1分别指"退出","初始化"和"登陆"
////x=0,1,2分别表示首页或动态,列表页和内容页
//    var uName="";
//    var uPass="";
//    if(w==1)
//    {
//        uName=$("loginBarName").value;
//        uPass=$("loginBarPass").value;
//        if(!uName || !uPass)return;
//        $("btnLoginBarBtn").disabled=true;
//    }
//    
//    var option={
//		parameters:"name="+escape2(uName)+"&pass="+escape2(uPass)+"&state="+w+"&time="+Date(),
//		method:"post",
//		onSuccess:function(transport){
//		    var rp=transport.responseText;
//		    if(rp!="")
//		    {
//			    if(rp=="ok")
//			        location.reload();
//			    else if(rp=="nopass")
//			        alert("密码错误!");
//			    else if(rp=="noname")
//			        alert("用户不存在");
//			    else if(rp=="nologin")
//			        alert("不允许登陆");
//			    else
//			    {
//			        $("loginBarPass").value="";
//			        $("loginBarContent").innerHTML=rp;
//			    }
//			}
//			$("btnLoginBarBtn").disabled=false;
//		},
//		onFailure:function(transport){
//			//alert("数据提交失败，请检查网络或重试。");
//		}
//	}
//	var request=new Ajax.Request(InstallDir+"ajax.aspx?oper=login",option);
//	return;
//}
//function addReview(id)
//{
////参数说明 x=0,1表示动态和静态页
//    var uName=$("reviewName").value;
//    var content=$("reviewContent").value;
//    if(!uName || !content || content.length<10) {
//        alert("评论字符太少!");
//        return;
//    }
//    if(content.length>250){
//        alert("评论字符太多");
//        return;
//    }
//    $("btnAddReview").disabled=true;
//    
//    var option={
//		parameters:"id="+id+"&name="+escape2(uName)+"&content="+escape2(content)+"&stype="+escape2(ChannelType),
//		method:"post",
//		onSuccess:function(transport){
//		    var rp=transport.responseText;
//			if(rp=="ok")
//			{
//			    $("reviewName").value="";
//			    $("reviewContent").value="";
//			    alert("发表成功!");
//			}
//			else
//			{
//			    alert(rp);
//			    $("btnAddReview").disabled=false;
//			}
//		},
//		onFailure:function(transport){
//			alert("数据提交失败，请检查网络或重试。");
//			$("btnAddReview").disabled=false;
//		}
//	}
//	
//	var request=new Ajax.Request(InstallDir+"ajax.aspx?oper=addReview&time="+Date(),option);
//	return;
//}
//自动限制图片大小
function check(dd,mystr1,mystr2)
{
var imgwidth;
var imgheight;
imgwidth=mystr1;
imgheight=mystr2;
if (dd.width>imgwidth && dd.height>imgheight){
    if (dd.width/dd.height>imgwidth/imgheight){
	    dd.width=imgwidth;
    }
    else
    {
	    dd.height=imgheight
    }
}
else if(dd.width>imgwidth){
	    dd.width=imgwidth
    }
    else if(dd.height>imgheight){
	    dd.height=imgheight
    }
}

function openwin(url,width,height)
{
	var aWin = window.open(url,"aWin","width=" + width + ",height=" + height + ",top=50,left=200,status=0,toolbars=0");
	if (aWin) {
		aWin.focus();
	} else {
		alert("检测到弹出窗口阻止程序。您的 Web 浏览器必须允许该站点弹出窗口。");
		return;
	}
}