﻿function doZoom(size){ 
document.getElementById('zoom').style.fontSize=size+'px'
} 

function showcode(o){
 //重载验证码
  var timenow = new Date().getTime();
 o.src="/login/ValidateCode.aspx?d="+timenow;
}

function showcoded(o,tlength,tfontSize){
 //重载验证码
  var timenow = new Date().getTime();
 o.src="/login/VerifyCode.aspx?d="+timenow+"&tlength="+tlength+"&tfontSize="+tfontSize;
}
function showcodedr(o, tlength, tfontSize) {
    //重载验证码
    var timenow = new Date().getTime();
    o.src = "/login/ValidCode.aspx?d=" + timenow;
}

function CheckAll(form) 
{
   for (var i=0;i<form.elements.length;i++)
        {
	        var e = form.elements[i];
            if (e.type=="checkbox" && e.name !='deleteMode')
            {
               e.checked = form.chkall.checked;
            }
	}
            form.chkall.checked=!form.chkall.checked;
}

function CheckIsNull(obj,msg)
{
	if(obj.value=="")
	{
		alert(msg);
		obj.focus();
		return false;
	}
	return true;
}

function Chanagetop(obj)
{
    document.getElementById(obj).style.display="block";
}
function Chanagetopout(obj)
{
    document.getElementById(obj).style.display="none";
}

function changeTDPic1(id,count,oldclass,newclass)
{
    for (var i=1;i<count+1;i++)
    {
        document.getElementById("tbb" + i).className = oldclass;
        document.getElementById("tdd" + i).style.display = "none";
    }
    document.getElementById("tbb" + id).className = newclass;
    document.getElementById("tdd" + id).style.display = "block";
}
function changeTD(id, count, tbb,tdd,oldclass, newclass) {
    for (var i = 1; i < count + 1; i++) {
        document.getElementById(tbb + i).className = oldclass;
        document.getElementById(tdd + i).style.display = "none";
    }
    document.getElementById(tbb + id).className = newclass;
    document.getElementById(tdd + id).style.display = "block";
}
function changeTD1(id, count, tbb,tdd,oldclass, newclass) {
    for (var i = 1; i < count + 1; i++) {
        document.getElementById(tbb + i).src = "/images/img/t0"+i+".jpg";
        document.getElementById(tdd + i).style.display = "none";
    }
    document.getElementById(tbb + id).src = "/images/img/t"+id+".jpg";
    document.getElementById(tdd + id).style.display = "block";
}
function item_popup(url,width,height) { 
		var imgwin = window.open(url,'','scrollbars=no,status=no,toolbar=no,resizable=0,location=no,menu=no,width='+width+',height='+height+''); 
		imgwin.focus(); 
} 
function OpenWin(url,width,height){
	var rtn = showModalDialog(url,'',"dialogHeight:"+height+";dialogWidth:"+width+";scroll:yes;help:no;status:no;")
	if(typeof(rtn) != "undefined"){
		window.location = rtn;
	}
}
//图片按比例缩放
var flag = false;
function DrawImage(ImgD, iwidth, iheight) {
    //参数(图片,允许的宽度,允许的高度)
    var image = new Image();
    image.src = ImgD.src;
    if (image.width > 0 && image.height > 0) {
        flag = true;
        if (image.width / image.height >= iwidth / iheight) {
            if (image.width > iwidth) {
                ImgD.width = iwidth;
                ImgD.height = (image.height * iwidth) / image.width;
            } else {
                ImgD.width = image.width;
                ImgD.height = image.height;
            }
            ImgD.alt = image.width + "×" + image.height;
        }
        else {
            if (image.height > iheight) {
                ImgD.height = iheight;
                ImgD.width = (image.width * iheight) / image.height;
            } else {
                ImgD.width = image.width;
                ImgD.height = image.height;
            }
            ImgD.alt = image.width + "×" + image.height;
        }
    }
}
function checkformtu() {
    if (document.getElementById("login1_uname").value == "") {
        alert('请填写用户名!');
        document.getElementById("login1_uname").focus();
        return false;
    }
    if (document.getElementById("login1_psw").value == "") {
        alert('请填写密码!');
        document.getElementById("login1_psw").focus();
        return false;
    }
    else {
        var response = ascx_login.Get_Check(document.getElementById("login1_uname").value, document.getElementById("login1_psw").value, "")
        if (response.error != null) {
            window.alert('服务器忙请稍再后提交');
            return false;
        }
        if (response.value == 1) {
            alert('用户名或密码错误!');
            document.getElementById("login1_psw").focus();
            return false;
        }
        if (response.value == 2) {
            alert('帐户被停用!');
            document.getElementById("login1_uname").focus();
            return false;
        }
        if (response.value == 3) {
            alert('用户名或密码错误!');
            document.getElementById("login1_uname").focus();
            return false;
        }
    }
}
function addCookie(){ 
    try    
    {
        window.external.addFavorite('http://www.nowking.com', 'nowking.com');    
    }    
    catch (e)    
    {
        window.sidebar.addPanel('nowking.com', 'http://www.nowking.com', "");    
    }    
}   
   
function setHomepage(url){
    if (document.all){   
        document.body.style.behavior = 'url(#default#homepage)';   
        document.body.setHomePage(url);   
    }else if (window.sidebar){   
        if (window.netscape){   
            try {   
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");   
            }catch (e) {   
                alert("该操作被浏览器拒绝，如果想启用该功能，请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为true");   
            }   
        }   
        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);   
        prefs.setCharPref('browser.startup.homepage', url);   
    }   
}    
 
function setHomepage(){
    if (document.all){   
        document.body.style.behavior = 'url(#default#homepage)';   
        document.body.setHomePage('www.nowking.com');   
    }else if (window.sidebar){   
        if (window.netscape){   
            try {   
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");   
            }catch (e) {   
                alert("该操作被浏览器拒绝，如果想启用该功能，请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为true");   
            }   
        }   
        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);   
        prefs.setCharPref('browser.startup.homepage', 'www.nowking.com');   
    }   
}    

function checksearch()
{
    var nowDate = new Date();
    var type=document.getElementById("searchType");
    var keyword=document.getElementById("keywordtxt");
    if (keyword.value.replace(/(^\s*)|(\s*$)/g,"")=="")
    {
        alert("请填写关键字!");
        keyword.focus();
        return false;
    }
    keyword.value=keyword.value.replace(/(^\s*)|(\s*$)/g,"").replace(new RegExp(' ',"gm"),',').replace(new RegExp('　',"gm"),',');
    window.location="http://www.nowking.cn/search/"+(nowDate.getMonth()+1) +"/"+nowDate.getDate() +"/key"+type.value+"_"+escape(keyword.value).replace(/%/g,'$')+".html";
    return true;
}

function Search(kind)
{
    var nowDate = new Date();
    var keyword=document.getElementById("keywordtxt");
    if (keyword.value.replace(/(^\s*)|(\s*$)/g,"")=="")
    {
        window.location="/Search/index.html";
        return false;
    }
    keyword.value=keyword.value.replace(/(^\s*)|(\s*$)/g,"").replace(new RegExp(' ',"gm"),',').replace(new RegExp('　',"gm"),',');
    window.location="http://www.nowking.cn/search/"+(nowDate.getMonth()+1) +"/"+nowDate.getDate() +"/key"+kind+"_"+escape(keyword.value).replace(/%/g,'$')+".html";
    return true;
}

