﻿// JavaScript Document

//弹出指定URL窗体
function Open_CenterWin(ow, oh, strURL) {

    try {
        var win = window.open(strURL, '', "left=" + ((parseInt(window.screen.width) - ow) / 2) + ",top=" + ((parseInt(window.screen.height) - oh) / 2) + ",width=" + ow + ",height=" + oh + ",resizable=yes,scrollbars=1");
        if (win && win.window && win.window.document) {
            win.focus();
        }
    }
    catch (e) { }
}


//展开或关闭指定图层
function DisplayAndCloseForDiv(ID)
{
    if(document.getElementById(ID).style.display=='none')
	{
	     document.getElementById(ID).style.display="";
	}
	else
	{
		document.getElementById(ID).style.display="none";
	}
	
}


function ListColorForMouseOver(object)
{	
	object.style.backgroundColor="#CCCCCC";
}

function ListColorForMouseOut(object)
{
   	object.style.backgroundColor="#FFFFFF";
	
}


//加入收藏夹
function AddFavorite(title) {   
  var url=parent.location.href;
                     if (window.sidebar) { 
                            window.sidebar.addPanel(title, url,""); 
                     } else if( document.all ) {
                     window.external.AddFavorite( url, title);
                     } else if( window.opera && window.print ) {
                     return true;
                     }

} 


//设为首页
function SetHome() {   

   if (document.all) { 
document.body.style.behavior = 'url(#default#homepage)'; 
document.body.setHomePage('http://www.hxzqjz.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','http://www.hxzqjz.com'); 
} 

} 



//Iframe高度自适应
function reinitIframe(obj){

var iframe = obj;

try{

var bHeight = iframe.contentWindow.document.body.scrollHeight;

var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;

var height = Math.max(bHeight, dHeight);

iframe.height =  height;

}catch (ex){}

}



//检测输入字符数
function CheckInputCount(ContentObj,DisplayObj,TextNum,KeyCode)
{
	 var input = $("#"+ContentObj); 
	 
	 if(input.val().length>TextNum && KeyCode.keyCode!=8 && KeyCode.keyCode!=116)
	 {
		 alert("只能输入"+TextNum+"个字！");
		 
		 input.val(input.val().substring(0,TextNum));
		 
		 $("#"+DisplayObj).html("0");
	 }
	 else
	 {
		 $("#"+DisplayObj).html(TextNum-parseInt(input.val().length));
	 }
}

