/*
Author:Andyfoo
Email:andyfoo@163.com
Company:huacai.cn
*/

var lotteryurl = 'http://www.huacai.cn';
var cmsurl = 'http://www.huacai.com';

var bbsurl = 'http://bbs.huacai.com';
var blogurl = 'http://blog.huacai.com';
var tubiaourl = 'http://tubiao.huacai.com';
var tubiao2url = 'http://tbklc.huacai.com';

lotteryurl = '';


//菜单
var top_menu_init = false;
var top_menu_is_show = false;
var top_menu_btn_id = null;
var top_menu_div_id = null;
function top_menu_show(obj){ 
	if(!top_menu_init){
		top_menu_btn_id = obj;
		top_menu_div_id = getID("top_lot_menu");
		addEvent(document, "onmousemove",top_menu_move);
	}
	if(!top_menu_div_id)return;
	if(obj && top_menu_div_id.style.display == "none"){
		top_menu_div_id.style.display = "";
		top_menu_div_id.style.left = (get_left(obj) - get_width(top_menu_div_id) + get_width(obj)) + "px";
		top_menu_div_id.style.top = (get_top(obj) + get_height(obj)) + "px";
	}
	x_fade(obj, true, 90);
	top_menu_init = true;
}
function top_menu_show2(){ 
	top_menu_set_show(true);
	if(!top_menu_div_id)return;
	if(top_menu_div_id.style.display == "none"){
		top_menu_div_id.style.display = "";
	}
}
function top_menu_set_show(v){
	top_menu_is_show = v;
}
function top_menu_move(e){
	if(!top_menu_div_id)return;
	var evt = window.event || e;
	if(!evt)return;
	var ex = evt.clientX + get_scroll_left();
	var ey = evt.clientY + get_scroll_top();
	var ox = get_left(top_menu_btn_id);
	var oy = get_top(top_menu_btn_id);
	var ow = get_width(top_menu_btn_id);
	var oh = get_height(top_menu_btn_id);
	if((ex < ox || ey < oy || (ex > ox + ow) || (ey > oy + oh + 10)) && !top_menu_is_show){
		x_fade(top_menu_btn_id, false);
		top_menu_hide();
	}
}
function top_menu_out(){
	top_menu_set_show(false);
	top_menu_hide();
}
function top_menu_hide(){
	if(!top_menu_div_id)return;
	if(top_menu_div_id.style.display == "" && !top_menu_is_show){
		top_menu_div_id.style.display = "none";
		top_menu_is_show = false;
	}
}



var x_confirm_msg = "";
var x_confirm_url = "";
var x_confirm_target = "";
function x_confirm(title, msg, url, w, h, target){
	if(!w)var w=360;
	if(!h)var h=240;
	x_open(title, "confirm_small.html", w, h, "center","middle");
	x_confirm_msg = msg;
	x_confirm_url = url;
	x_confirm_target = target;
}
var x_alert_msg = "";
var x_alert_url = "";
var x_alert_target = "";
function x_alert(title, msg, url, w, h, target){
	if(!w)var w=360;
	if(!h)var h=200;
	x_open(title, "alert_small.html", w, h, "center","middle");
	x_alert_msg = msg;
	x_alert_url = url;
	x_alert_target = target;
}


function reload_main_frame(url) {
	try {
		if(url){
			window.main_frame.location.href=url;
		}else{
			window.main_frame.location.href=window.main_frame.location.href;
		}
	} catch(e) {
	 
	}
	try {
		x_open_close();
	} catch(e) {
	}

}
function reload_window(url) {
	try {
		if(url){
			window.location.href=url;
		}else{
			window.location.href=window.location.href.indexOf("#") > -1 ? window.location.href.split("#")[0] : window.location.href;
		}
	} catch(e) {
	 
	}
}

var Browser = {
	IE:     !!(window.attachEvent && !window.opera),
	Opera:  !!window.opera,
	WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
	Gecko:  navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1
}
function killErrors() {
	return true;
}
//window.onerror = killErrors;

//解决IE6下默认不缓存背景图片
try {

if(Browser.IE)
          document.execCommand('BackgroundImageCache', false, true);

} catch(e) {}
//取get变量的值 var info = getParameter("info");
function getParameter( sProp ) {
	try {
		var str = document.location.search;
		str = unescape(str);
		var re = new RegExp( sProp + "=([^\&]*)", "i" );
		var a = re.exec( str );
		if ( a == null )
			return "";
		return a[1];
	} catch(e) {
		return "";
	}
};
var _run_time_begin_val = 0;
var _run_time_end_val = 0;
function _run_time_begin(){
	_run_time_begin_val = (new Date()).getTime();
}
function _run_time_end(){
	_run_time_end_val = (new Date()).getTime();
	return (_run_time_end_val-_run_time_begin_val);
}

//日历
var calendar_open = false;
function showCalendar(id, f){
	if(window.self.cPop)cPop.XCalendar(getID(id));
	return true;
}
function calendar(calendar_path){
	if(!calendar_open){
		if(!calendar_path)var calendar_path = "calendar/";
		document.write("<iframe width=172 height=168 name='gToday:normal' id='gToday:normal' ");
		document.write(" src='" + calendar_path + "calendar.htm' scrolling='no' frameborder='0' ");
		document.write(" style='visibility:visible; z-index:999; position:absolute; top:-500px; left:-500px;'>");
		document.write("</iframe>");
	}
	calendar_open=true;
}


function copyText(obj) {
	ie = (document.all)? true:false;
	try{
		if(typeof(obj) == "string")var obj = getID(obj);
	}catch(e){}
	if (ie){
		var rng = document.body.createTextRange();
		rng.moveToElementText(obj);
		rng.scrollIntoView();
		rng.select();
		rng.execCommand("Copy");
		rng.execCommand("Unselect");
		rng.collapse(false);
		return true;
	}else{
		try{prompt("请复制以下内容:",obj.innerHTML); }catch(e){}
	}
	return false;
}
function disabled_menu(){
	var e = window.event;
	try{
		if(e.srcElement.type == 'text' || e.srcElement.type == 'textarea' || e.srcElement.type == 'password')
			window.event.returnValue=true;
		else 
			window.event.returnValue=false;
	}catch(e){}
}
function disabled_select(){ 
	var e = window.event;
	try{
		if(e.srcElement.type == 'text' || e.srcElement.type == 'textarea' || e.srcElement.type == 'password')
			window.event.returnValue=true;
		else 
			window.event.returnValue=false;
	}catch(e){}
} 


var document_domain = "";
try{
	document_domain = document.domain;
}catch(e){}
if(document_domain != "localhost"){
	//window.onerror = killErrors;
	//document.oncontextmenu = disabled_menu;
	//document.onselectstart = disabled_select;
}

//显示与隐藏帐户信息
function show_money(obj, t){
	var check = '';
	if(t == 'txt'){
		check = showhide_obj('div_account');
		check = check == 'hide' ? 'show' : 'hide';
		showhide_obj('div_cash');
		showhide_obj('div_handsel');
		showhide_obj('div_integral');		

		showhide_obj('div_account_hide');
		showhide_obj('div_cash_hide');
		showhide_obj('div_handsel_hide');
		showhide_obj('div_integral_hide');	

		
		if(check == 'hide'){
			obj.innerHTML = "隐藏";
		}else{
			obj.innerHTML = "显示";
		}

	}

}
function set_money(v){
	getID("div_account").innerHTML = v;
}
function show_money2(obj){
	var check = '';

	check = showhide_obj('div_account');
	check = check == 'hide' ? 'show' : 'hide';
	

	
	if(check == 'hide'){
		hide_obj('div_account_hide');
		obj.src = "images/checkbox_s.gif";
	}else{
		show_obj('div_account_hide');
		obj.src = "images/checkbox.gif";
	}


}

function input_onfocus(obj, c) {
	if(!c)var c = 'input_focus';
	obj.className = c;
}
function input_onblur(obj, c) {
	if(!c)var c = 'input';
	obj.className = c;
}
function textarea_onfocus(obj, c) {
	if(!c)var c = 'textarea_focus';
	obj.className = c;
}
function textarea_onblur(obj, c) {
	if(!c)var c = 'textarea_onblur';
	obj.className = c;
}

//保持会员登录状态
var keepLoginStatusTime = 300 * 1000;
function keepLoginStatus(){
	var url = "/keepLoginStatus.do?_t=" + new Date().getTime();
	load_script(url);
	window.setTimeout('keepLoginStatus()', keepLoginStatusTime);
}

function closeBrowser(){
	/*
	try{
		window.opener=null;
		window.close();
	}catch(e){
		window.opener=null;
		top.window.close();
	}
	*/
}

//改变列表颜色
function init_list_event(e){
	try{
		try{
			e = xalt_fixE(e);
			obj = e.srcElement.parentElement;

			obj.onmouseout = function (){
				this.className='list_item_out';
			}
			obj.onmouseover = function (){
				this.className='list_item_over';
				return;
			}
			this.className='list_item_over';
		}catch(e){}
	}catch(e){}
}
function get_width(obj){
	var n = parseInt(obj.offsetWidth, 10);
	if(isNaN(n) || !n){
		n = parseInt(obj.style.width, 10);
	}else{
		
	}
	if(isNaN(n) || !n){
		n = 0	
	}
	return n;
}
function get_height(obj){
	var n = parseInt(obj.offsetHeight, 10);
	if(isNaN(n) || !n){
		n = parseInt(obj.style.height, 10);
	}else{
		
	}
	if(isNaN(n) || !n){
		n = 0	
	}
	return n;
}
function get_page_width(){
	return document.body.clientWidth ? document.body.clientWidth  : x_openFloat.get_scroll_left() + x_openFloat.get_body_width(); 
}
function get_page_height(){
	return document.body.clientHeight ? document.body.clientHeight : x_openFloat.get_scroll_top() + x_openFloat.get_body_height();
}
function get_scroll_top(){
	var s; 
	if (typeof(window.pageYOffset) != 'undefined') { 
		s = window.pageYOffset; 
	} 
	else if (typeof(document.compatMode) != 'undefined' &&document.documentElement.scrollTop > 0) { 
		s = document.documentElement.scrollTop; 
	}  
	else if (typeof(document.body) != 'undefined') { 
		s = document.body.scrollTop; 
	} 
	
	return parseInt(s, 10);
}
function get_scroll_left(){
	var s; 
	if (typeof(window.pageXOffset) != 'undefined') { 
		s = window.pageXOffset; 
	} 
	else if (typeof(document.compatMode) != 'undefined' &&document.documentElement.scrollLeft > 0) { 
		s = document.documentElement.scrollTop; 
	}
	else if (typeof(document.body) != 'undefined') { 
		s = document.body.scrollLeft; 
	} 
	return parseInt(s, 10);
}
function get_body_width(){ 
	var w = 0;
	if (!document.all) {
		w = document.body.clientWidth > document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.clientWidth;
	}
	else{
		w = document.documentElement.clientWidth == 0 ? document.body.clientWidth : document.documentElement.clientWidth;
	}
	return parseInt(w, 10);
}
function get_body_height(){
	var h = 0;
	if (!document.all) {
		h = document.body.clientHeight > document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
	}
	else{
		h = document.documentElement.clientHeight == 0 ? document.body.clientHeight : document.documentElement.clientHeight;
	}
	return parseInt(h, 10);
	return parseInt((document.all) ? document.body.clientHeight : window.innerHeight, 10);
}


//=====解决js浮点运算bug<<<

//除法函数，用来得到精确的除法结果
//调用：accDiv(arg1,arg2)
//返回值：arg1除以arg2的精确结果
function accDiv(arg1,arg2){
    var t1=0,t2=0,r1,r2;
    try{t1=arg1.toString().split(".")[1].length}catch(e){}
    try{t2=arg2.toString().split(".")[1].length}catch(e){}
    with(Math){
        r1=Number(arg1.toString().replace(".",""))
        r2=Number(arg2.toString().replace(".",""))
        return (r1/r2)*pow(10,t2-t1);
    }
}

//给Number类型增加一个div方法，调用起来更加方便。
Number.prototype.div = function (arg){
    return accDiv(this, arg);
}

//乘法函数，用来得到精确的乘法结果
//调用：accMul(arg1,arg2)
//返回值：arg1乘以arg2的精确结果
function accMul(arg1,arg2)
{
    var m=0,s1=arg1.toString(),s2=arg2.toString();
    try{m+=s1.split(".")[1].length}catch(e){}
    try{m+=s2.split(".")[1].length}catch(e){}
    return Number(s1.replace(".",""))*Number(s2.replace(".",""))/Math.pow(10,m)
}

//给Number类型增加一个mul方法，调用起来更加方便。
Number.prototype.mul = function (arg){
    return accMul(arg, this);
}

//加法函数，用来得到精确的加法结果
//调用：accAdd(arg1,arg2)
//返回值：arg1加上arg2的精确结果
function accAdd(arg1,arg2){
    var r1,r2,m;
    try{r1=arg1.toString().split(".")[1].length}catch(e){r1=0}
    try{r2=arg2.toString().split(".")[1].length}catch(e){r2=0}
    m=Math.pow(10,Math.max(r1,r2))
    return (arg1*m+arg2*m)/m
}

//给Number类型增加一个add方法，调用起来更加方便。
Number.prototype.add = function (arg){
    return accAdd(arg,this);
}

//减法函数，用来得到精确的减法结果
//调用：accSub(arg1,arg2)
//返回值：arg1减去arg2的精确结果
function accSub(arg1,arg2){
     var r1,r2,m,n;
     try{r1=arg1.toString().split(".")[1].length}catch(e){r1=0}
     try{r2=arg2.toString().split(".")[1].length}catch(e){r2=0}
     m=Math.pow(10,Math.max(r1,r2));
     //last modify by deeka
     //动态控制精度长度
     n=(r1>=r2)?r1:r2;
     return ((arg1*m-arg2*m)/m).toFixed(n);
}

//给Number类型增加一个add方法，调用起来更加方便。
Number.prototype.sub = function (arg){
    return accSub(arg,this);
}
//=====解决js浮点运算bug>>>
 


//转换为整数
function toInt(str){
	var result = parseInt(str, 10);
	return isNaN(result) ? 0 : result;
}

//取unix时间戳
function get_timestamp(){
	var d = new Date();
	return Math.round(d.getTime()/1000);
}
//格式化时间, t=时间戳
function get_date(type, t){
	if(t){ 
		var o = new Date(parseInt(t) * 1000); 
	}else{
		var o = new Date();
	}
	var dd = new Array();
	dd['y'] = o.getYear();
	dd['Y'] = o.getFullYear();
	dd['n'] = (parseInt(o.getMonth())+1);
	dd['m'] = strPad(dd['n'], 2);
	dd['j'] = o.getDate();
	dd['d'] = strPad(dd['j'], 2);
	
	dd['g'] = o.getHours();//小时，12 小时格式，没有前导零 1 到 12 
	if(dd['g']>12)dd['g'] = dd['g'] - 12;
	dd['G'] = o.getHours() ;//小时，24 小时格式，没有前导零 0 到 23 
	dd['h'] = strPad(dd['g'], 2);//小时，12 小时格式，有前导零 01 到 12 
	dd['H'] = strPad(dd['G'], 2);//小时，24 小时格式，有前导零 00 到 23 

	dd['i'] = strPad(o.getMinutes(), 2);
	dd['s'] = strPad(o.getSeconds(), 2);
	
	
	var date = dd['Y'] + '-' + dd['m'] + '-' + dd['d'];
	var time = dd['H'] + ':' + dd['i'] + ':' + dd['s'];
	switch(type){
		case 'date':
			return date;
		break;
		case 'time':
			return time;
		break;
		case '':
		case 'datetime':
			return date + ' ' + time;
		break;
		default:
			var str = "Y-m-d H:i:s";
			if(typeof(type) == "string")str = type;
			for(var i in dd){
				str = str_replace (str, i, dd[i]);
			}
			return str;
		break;
	}
}

//替换字符串中的字符
function str_replace (str,replace_what,replace_with)   
{   
	var   ndx=str.indexOf(replace_what);   
	var   delta=replace_with.length - replace_what.length;   
	while(ndx >= 0)   
	{   
		str=str.substring(0,ndx)+replace_with+str.substring(ndx+replace_what.length);   
		ndx=str.indexOf(replace_what,ndx+delta+1);   
	}   
	return str;   
}
//字符串填充
function strPad(v, l){
	if(typeof(l) == 'undefined')var l = 2;
	var s = v + '';
	if(s.length < l){
		for(var i = s.length; i < l;i++){
			s = '0' + s;
		}
	}
	return s;
}

//判断是字符串是否在数组中存在
function inArray(v, arr){
	try{
		for(var i = 0; i < arr.length;i++){
			if(v == arr[i])return true;
		}
	}catch(e){}
	return false;
}
//判断是字符串是否在数组中存在
function searchArray(v, arr){
	try{
		for(var i = 0; i < arr.length;i++){
			var str = arr[i] + "";
			if(str.indexOf(v) != -1)return new Array(i, arr[i]);
		}
	}catch(e){}
	return false;
}

//删除数组中的一个元素
function arrayDeleteItem(v, arr){
	var new_arr = new Array();
	try{
		for(var i = 0; i < arr.length;i++){
			if(v != arr[i]){new_arr[new_arr.length] = arr[i]}
		}
	}catch(e){}
	return new_arr;
}
//取数组最大数
function arrayMaxNum(a){
	var arr = new Array();
	arr = arr.concat(a);
	arr = arr.sort(function(a, b){
		a = parseInt(a, 10);b = parseInt(b, 10);
		if(a<b)return -1;
		if(a==b)return 0;
		if(a>b)return 1;
	});
	arr = arr.reverse();
	return arr[0];
}

//是否为数字
function isNum(num){
	var rule = /^\d+$/; 
	if(rule.test(num))return true;
	return false;
}
//数组随机排序
function arrayRand(Arr){
	Arr.sort(function(){return Math.random()>0.5?-1:1;});
	return Arr;
}
//取min-max区间的随机数
function rand(min, max){
	var r = 0;
	switch(arguments.length){ 
		case 1: r = parseInt(Math.random()*min+1,10); 
		case 2: r = parseInt(Math.random()*(max-min+1) + min,10);  
	}
	return r > min && r < max ? r : 0;
}

//去除字符串两边的空格
function trim(value) {
   var temp = value;
   var obj = /^(\s*)([\W\w]*)(\b\s*$)/;
   if (obj.test(temp)) { 
     temp = temp.replace(obj, '$2'); 
   }
   return temp;
}


//格式化数字
function format_number(num, dot, dec_point){
	try{
		num = parseFloat(num);
		if(typeof(dot) == 'undefined')var dot=2;
		if(typeof(dec_point) == 'undefined')var dec_point='';
		num = num.toFixed(dot);
		if(dec_point.length>0){
			var   re=/(\d+)(\d{3})/,s=num.toString();  
			while(re.test(s))s=s.replace(re,"$1" + dec_point + "$2");  
			return s;  
		}
	}catch(e){
		
	}
	if(isNaN(num))num = "";
	return num;  
}
//图片按钮变色
function x_fade(obj, t, v) {
	if(!v)var v = '75';
	if(document.all){
		try{
			if (t == true) {
				if(obj.filters.alpha.opacity > 30) obj.filters.alpha.opacity = v;
			} else {
				if(obj.filters.alpha.opacity <  100) obj.filters.alpha.opacity = 100;
			}	
		}catch(e){
			try{
				if (t == true) {
					obj.style.filter = "Alpha(Opacity=" + v + ")";
				} else {
					obj.style.filter = "Alpha(Opacity=100)";
				}
			}catch(e){
				alert(e.description);
			}
		}
	}
	else if(document.getElementById)
	{ 
		v = v/100;
		obj.style.MozOpacity = 1;
		if (t == true) {
			if(obj.style.MozOpacity > 0.1) obj.style.MozOpacity = v;
		} else {
			if(obj.style.MozOpacity < 1) obj.style.MozOpacity = 1;
		}
	}
}
//禁用、恢复图片按钮 btn=按钮ID, d=true OR false(禁用、恢复)
function disable_button(btn, d, opacity ){
	try{
		var btn = getID(btn);
	}catch(e){}
	if(btn){
		if(d){
				if(!opacity)var opacity = 30;
				btn.disabled = true;
				x_fade(btn, true, opacity); 
		}else{
				btn.disabled = false;
				x_fade(btn, false, 100); 
		}
	}
}


//限制只能输入金额
function onlyAmount(evt)
{
	var c = evt.charCode ? evt.charCode : evt.keyCode;

	if(evt.ctrlKey && c==88 || evt.ctrlKey && c==86)return true;
	if(c==8 || c==46 || c==190)return true;
	if(!((c>=48&&c<=57)||(c>=96&&c<=105)))return false;
	return true;
}
//限制只能输入数字
function onlyNum(evt)
{
	var c = evt.charCode ? evt.charCode : evt.keyCode;
	if(c==8 || c==46)return true;
	if(!((c>=48&&c<=57)||(c>=96&&c<=105)))return false;
	return true;
}

//限制只能输入英文
function onlyEng(evt)
{
	var c = evt.charCode ? evt.charCode : evt.keyCode;
	if(c==8 || c==46)return true;
	if(!(c>=65&&c<=90))return false;
	return true;
}

//限制只能输入金额
function replaceAmount(obj,dot)
{
	if(!dot)var dot = 2;
	var str = obj.value;
	var res = '';
	for(var i = 0; i < str.length ;i+=1){
		var s = str.substr(i,1);
		s = replace_number(s, true);
		s1 = parseInt(s, 10);
		if((s1>=0 && s1<=9) || s == "."){
			res+=(s+"");
		}else{
			break;
		}
	}
	
	obj.value=format_number(res, dot);
}
//限制只能输入数字
function replaceNum(obj, def)
{
	var str = obj.value;
	var res = '';
	for(var i = 0; i < str.length ;i+=1){
		var s = str.substr(i,1);
		s = parseInt(replace_number(s), 10);
		if(s>=0 && s<=9){
			res+=(s+"");
		}else{
			break;
		}
		
	}
	if(isNaN(res))res="";
	if(res == "" && def)res = def;
	obj.value=res;
}

//限制只能输入英文
function replaceEng(obj)
{
 
}

//替换中文数字为有效数字, s=要替换的内容，dot=true|false　是否替换小数点
function replace_number(s, dot)
{
	var c = s.charCodeAt(0);
	//alert(c);
	if(c>=48&&c<=57)return s;
	if(c>=65296&&c<=65305)return String.fromCharCode(c-65248);
	if((c==12290 || c==46) && dot)return '.';
	return '';
}

//打开Js网址

function load_script(url) {
	try{
		var script = document.createElement("script");
		script.type = "text/javascript";
		script.src = url;
		document.getElementsByTagName("head")[0].appendChild(script);
	}catch(e){
		//alert(e);
	}

}
 

function load_script2(url, callback) {
	var f = arguments.callee;
	if (!("queue" in f))
		f.queue = {};
	var queue =  f.queue;
	if (url in queue) { // script is already in the document
		if (callback) {
			if (queue[url]) // still loading
				queue[url].push(callback);
			else // loaded
				callback();
		}
		return;
	}
	queue[url] = callback ? [callback] : [];
	var script = document.createElement("script");
	script.type = "text/javascript";
	script.onload = script.onreadystatechange = function() {
		if (script.readyState && script.readyState != "loaded" && script.readyState != "complete")
			return;
		script.onreadystatechange = script.onload = null;
		while (queue[url].length)
			queue[url].shift()();
		queue[url] = null;
	};
	
	script.src = url;
	document.getElementsByTagName("head")[0].appendChild(script);
}
var _ELEMENT_ID_CACHES = new Array();
function getID2_clearAll(){ 
	_ELEMENT_ID_CACHES = new Array();
}
function getID2(obj){ 
	return _ELEMENT_ID_CACHES[obj] ? _ELEMENT_ID_CACHES[obj] : _ELEMENT_ID_CACHES[obj] = getID(obj);
}
function getID(obj){ 
	var element = null;
	if(document.getElementById){
		element = document.getElementById(obj);
	}
	else if(document.all){
		element = document.all[obj];
	}
	else if(document.layers){
		element = document.layers[obj];
	} 
	return element;

} 
if(typeof($) == 'undefined')$=getID;

function set_html(id, html)
{
	getID(id).innerHTML=html;
}
function set_text(id, text)
{
	getID(id).innerTEXT=text;
}
function hide_obj(id){
	getID(id).style.display='none'
}
function show_obj(id){
	getID(id).style.display=''
}
function showhide_obj(id){
	if(getID(id).style.display==''){
		getID(id).style.display='none';
		return 'hide';
	}else{ 
		getID(id).style.display='';
		return 'show';
	}
}
function set_src(id, value){
	getID(id).src=value
}
function select_checkbox(form, sel, s)
{
	for (var i=0;i<form.elements.length;i++)
	{
		var e = form.elements[i];
		if (e.name.substring(0, sel.length) == sel)
			e.checked = s;
	}
}
function select_checkbox_id(form, sel, s)
{
	for (var i=0;i<form.elements.length;i++)
	{
		var e = form.elements[i];
		try{
			if (e.id.substring(0, sel.length) == sel)
				e.checked = s;
		}catch(e){}
	}
}
function select_all(form, s, sel)
{
	for (var i=0;i<form.elements.length;i++)
	{
		var e = form.elements[i];
		if (e.name.substring(0, sel.length) == sel)
		e.checked = s.checked;
	}
}
function unselect_all(form,  sel)
{
	for (var i=0;i<form.elements.length;i++)
	{
		var e = form.elements[i];
		if (e.name.substring(0, sel.length) == sel)
		e.checked = !e.checked;
	}
}
function select_submit(form, action)
{
	form.action = action;
	form.submit();
}


function btn_confirm(url, msg)
{
	if(confirm(msg))
		window.location=url;
	return false;
}
function get_value( label, t){  
	if(!label)return '';
	if(!label.length)return label.value;
	if(t == 'checkbox'){
		var v_list = new Array();
		var i=0;
		for(var j = label.length - 1; j >= 0; j--)
				if(label[j].checked)  v_list[i++] = label[j].value;
		return v_list.join(',');
	}

	for(var j = label.length - 1; j >= 0; j--)
		if(label[j].checked) return label[j].value;
	return label[0].value;


	
}
function set_default( form, label,value){
	for (var i=0;i<form.elements.length;i++)
	{
		var e = form.elements[i];
		switch(e.type){
			case 'radio':
			case 'checkbox':if(e.name == label && e.value == value)e.checked = true;break;
			case 'multiple':
			case 'select':
			case 'select-one':
				if(e.name == label){
					for (var d=0; d<e.options.length; d++){
						if(e.options[d].value == value ){
							e.selectedIndex = d;
						}
					}
				}
				break;
			default:
			break;
		}			
		
	}
}
function flash(url, w, h, vars){
	document.write(flash_html(url, w, h, vars));
}
function flash_html(url, w, h, vars){
	var str = "";
	str += ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ w +'" height="'+ h +'">');
	str += ('<param name="movie" value="' + url + '"><param name="quality" value="high">');
	str += ('<param name="menu" value="false"><param name=wmode value="opaque">');
	str += ('<param name="loop" value="true">');
	str += ('<param name="loop" value="true">');
	str += ('<param name="FlashVars" value="' + vars + '">');
	str += ('<embed src="' + url + '" width="'+ w +'" height="'+ h +'" wmode="opaque" loop="true" FlashVars="' + vars + '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'); 
	str += ('</object>'); 
	return str;
}
// alert( readCookie("myCookie") );
function readCookie(name)
{
	var cookieValue = "";
	var search = name + "=";
	if(document.cookie.length > 0)
	{ 
		offset = document.cookie.indexOf(search);
		if (offset != -1)
		{ 
			offset += search.length;
			end = document.cookie.indexOf(";", offset);
			if (end == -1) end = document.cookie.length;
				cookieValue = unescape(document.cookie.substring(offset, end))
		}
	}
	return cookieValue;
}

function writeCookie(name, value, hours)
{
	var expire = "";
	if(hours != null)
	{
		expire = new Date((new Date()).getTime() + hours * 3600000);
		expire = "; expires=" + expire.toGMTString();
	}
	document.cookie = name + "=" + escape(value) + expire;
}


function removeEvent(obj, name, func) {
	name = name.toLowerCase();
	// Add the hookup for the event.
	if(typeof(obj.addEventListener) != "undefined") {
		if(name.length > 2 && name.indexOf("on") == 0) name = name.substring(2, name.length);
			obj.removeEventListener(name, func, true);
	} else if(typeof(obj.attachEvent) != "undefined"){
		obj.detachEvent(name, func);
	} else {
		eval("obj." + name) = null;
	}
}

function addEvent(obj, name, func) {
	name = name.toLowerCase();
	// Add the hookup for the event.
	if(typeof(obj.addEventListener) != "undefined") {
		if(name.length > 2 && name.indexOf("on") == 0) name = name.substring(2, name.length);
			obj.addEventListener(name, func, false);
	} else if(typeof(obj.attachEvent) != "undefined"){
		obj.attachEvent(name, func);
	} else {
		if(eval("obj." + name) != null){
			// Save whatever defined in the event
			var oldOnEvents = eval("obj." + name);
			eval("obj." + name) = function(e) {
				try{
					func(e);
					eval(oldOnEvents);
				} catch(e){}
			};
		} else {
			eval("obj." + name) = func;
		}
	}
}

function get_left(obj) {
	return (obj.offsetParent==null ? obj.offsetLeft : obj.offsetLeft + get_left(obj.offsetParent));
}

function get_top(obj) {
	return (obj.offsetParent==null ? obj.offsetTop : obj.offsetTop + get_top(obj.offsetParent));
}

//<<xalt
var cfg_fade_switch=true;       
var cfg_xoffset=9;         
var cfg_yoffset=20;        
var cfg_mouse_follow=true;
var cfg_hide_delay=8000;    
var cfg_txt_tag='alt';
var cfg_is_show=true;
var cfg_xalt_disabled=false;

document.write("<style>.navtext_div{PADDING-RIGHT: 6px; PADDING-LEFT: 6px;PADDING-TOP: 2px; PADDING-BOTTOM: 1px; FONT-SIZE: 12px; Z-INDEX: 99;  COLOR: #333333; BORDER: 1px #8899AA solid;FONT-FAMILY: Courier New,tahoma,arial; POSITION: absolute; BACKGROUND-COLOR: #FFFFCC;}</style>");
document.write('<div id="navtext_div" class="navtext_div" style=" position:absolute; top:0px; left:-400px; z-index:10000; padding:3px"></div>');

function xalt_props(){
	this.w3c=(document.getElementById)?true:false;
	this.ns4=(document.layers)?true:false;
	this.ie4=(document.all && !this.w3c)?true:false;
	this.ie5=(document.all && this.w3c)?true:false;
	this.ns6=(this.w3c && navigator.appName.indexOf("Netscape")>=0 )?true:false;
	this.w_y=0;
	this.w_x=0;
	this.navtxt=null;
	this.boxheight=0;
	this.boxwidth=0;
	this.ishover=true;
	this.ieop=0;
	this.op_id=0;
	this.oktomove=true;
	this.dy=0;
	this._mousePos = new Object();
}
function xalt_kill_errors() {
	return true;
}

var XALT=new xalt_props();

function xalt_disabled(){
	cfg_xalt_disabled = true;
}
function xalt_enabled(){
	cfg_xalt_disabled = false;
}
function xalt_set_mouse_follow(mouse_follow){//true or false
	cfg_mouse_follow=mouse_follow;
}

function xalt_set_fade_switch(fade_switch){//true or false
	cfg_fade_switch=fade_switch;
	if(!cfg_fade_switch)XALT.ieop=100;
}

function xalt_get_window_dims(){
	XALT.w_y=(XALT.ie5||XALT.ie4)?document.body.clientHeight:window.innerHeight;
	XALT.w_x=(XALT.ie5||XALT.ie4)?document.body.clientWidth:window.innerWidth;
}

function xalt_get_box_width(){
	return parseInt(XALT.navtxt.offsetWidth, 10);
}

function xalt_get_box_height(){
	return parseInt(XALT.navtxt.offsetHeight, 10);
}

function xalt_body_width(){ 
	var w = 0;
	if (!document.all) {
		w = document.body.clientWidth > document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.clientWidth;
	}
	else{
		w = document.documentElement.clientWidth == 0 ? document.body.clientWidth : document.documentElement.clientWidth;
	}
	return parseInt(w, 10);
}
function xalt_body_height(){
	var h = 0;
	if (!document.all) {
		h = document.body.clientHeight > document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
	}
	else{
		h = document.documentElement.clientHeight == 0 ? document.body.clientHeight : document.documentElement.clientHeight;
	}
	return parseInt(h, 10);
}


function xalt_get_left(obj) {
	return (obj.offsetParent==null ? obj.offsetLeft : obj.offsetLeft + xalt_get_left(obj.offsetParent));
}

function xalt_get_top(obj) {
	return (obj.offsetParent==null ? obj.offsetTop : obj.offsetTop + xalt_get_top(obj.offsetParent));
}
function xalt_get_page_scrolly(){
	if(XALT.ie5||XALT.ie4){
		if(document.documentElement.scrollTop > 0) return document.documentElement.scrollTop;
		return document.body.scrollTop;
	}else return window.pageYOffset;
}

function xalt_get_page_scrollx(){
	if(XALT.ie5||XALT.ie4){
		if(document.documentElement.scrollLeft > 0) return document.documentElement.scrollLeft;
		return document.body.scrollLeft;
	}else return window.pageXOffset;
}

function xalt_write_in_div(text){
	XALT.navtxt.innerHTML=text;
}
/*
	onmouseover="xalt_show(this, '{row.catalog_name}')" onmouseout="xalt_show(this, 0)"
	onmouseover="xalt_show(this, '{row.catalog_name}')"
*/
function xalt_show(obj, text){
	xalt_write_txt(text);
	obj.onmouseout=function(){xalt_write_txt(0)};
}
function xalt_write_txt(text){
	if(cfg_xalt_disabled)return;
	if(cfg_fade_switch && (XALT.ie4||XALT.w3c))clearInterval(XALT.op_id);
	if(text!=0 && cfg_is_show ){
		XALT.navtxt.style.display="block";
		xalt_fixPos();
		if(!cfg_mouse_follow)clearTimeout(XALT.dy);
		XALT.oktomove=true;
		XALT.ishover=true;
		if(XALT.ns4)text='<div class="navtext_div">'+text+''+'</div>';
		if(XALT.w3c||XALT.ie4)XALT.navtxt.style.textAlign="left";
		xalt_write_in_div(text);

		
		xalt_get_box_height();
		if((XALT.w3c||XALT.ie4) && cfg_fade_switch){
			if(XALT.ie4||XALT.ie5)XALT.navtxt.style.filter="alpha(opacity=0)";
			if(XALT.ns6)XALT.navtxt.style.MozOpacity=0;
			XALT.ieop=0;
			XALT.op_id=setInterval('xalt_do_opacity()',10);
		}
		cfg_is_show=false;
	}else{
		cfg_is_show=true;
		if(cfg_mouse_follow)xalt_hide_alt_txt();
		else XALT.dy=setTimeout('xalt_hide_alt_txt()',cfg_hide_delay);
	}
}

function xalt_hide_alt_txt(){
	XALT.navtxt.style.display="none";
	xalt_write_in_div('');
	
}

function xalt_do_opacity(){
	if(XALT.ieop<=100){
	XALT.ieop+=32;
	if(XALT.ie4||XALT.ie5)XALT.navtxt.style.filter="alpha(opacity="+XALT.ieop+")";
	if(XALT.ns6)XALT.navtxt.style.MozOpacity=XALT.ieop/100;
	}else clearInterval(XALT.op_id);
}
function xalt_fixE(e){
	if (typeof e == 'undefined') e = window.event;
	if (typeof e.layerX == 'undefined') e.layerX = e.offsetX;
	if (typeof e.layerY == 'undefined') e.layerY = e.offsetY;
	if (typeof e.srcElement == 'undefined') e.srcElement = e.target;
	return e;
}
function xalt_fixPos(){
	var w_x = xalt_body_width();
	var w_y = xalt_body_height();
	var s_x = xalt_get_page_scrollx();
	var s_y =xalt_get_page_scrolly();

	var x = 0;
	var y = 0;

	if(Math.round( w_x - XALT._mousePos.X - cfg_xoffset) < xalt_get_box_width()){
		x = XALT._mousePos.X - xalt_get_box_width() + s_x - cfg_xoffset; 
	} else {
		x = XALT._mousePos.X + cfg_xoffset + s_x; 
	}
	if(Math.round( w_y - XALT._mousePos.Y - cfg_yoffset) < xalt_get_box_height()){
		y = XALT._mousePos.Y - xalt_get_box_height() + s_y - cfg_yoffset; 
	} else {
		y = XALT._mousePos.Y + s_y + cfg_yoffset; 
	}
 
	XALT.navtxt.style.left = x + "px";
	XALT.navtxt.style.top = y + "px";
	
}
function xalt_mousemove(e){
	if(cfg_xalt_disabled || (!cfg_mouse_follow && XALT.navtxt.style.display == 'block'))return;
	if(typeof(e) == 'undefined')e = event;
	XALT._mousePos.Y = e.clientY;
	XALT._mousePos.X = e.clientX;
	if(XALT.navtxt.style.display=="block")xalt_fixPos();
}

function xalt_scan_dom(curNode) {
	while(curNode )	{
		if(curNode.nodeType == 1){
			var txt = curNode.getAttribute(cfg_txt_tag);
			if (curNode.alt) curNode.alt = "";
			if (curNode.title) curNode.title = "";
			if(txt != null && txt != ''){
				curNode.setAttribute('xalt_txt', txt);
				curNode.setAttribute(cfg_txt_tag, '');
				curNode.onmouseover = function() {
					xalt_write_txt(this.getAttribute('xalt_txt'));
					if(!cfg_mouse_follow)XALT.dy=setTimeout('xalt_hide_alt_txt()',cfg_hide_delay);
				}
				curNode.onmouseout = function() {
					xalt_write_txt(0); 
					if(!cfg_mouse_follow)clearTimeout(XALT.dy);
				}
			}
			try{
				var el = curNode;
				var className = '';
				try{
					className = el.className;
				}catch(e){}
				if(className == null || className == '' || className == 'input' || className == 'textarea')
				switch (el.tagName.toLowerCase()) {
					case "input":
						if (/text|file|password/.test(el.type)){
							el.className = "input";

							addEvent(el, "onfocus", function() {
										var obj = document.all ? window.event.srcElement : this;
										
										obj.className = "input_focus";
									});
							addEvent(el, "onblur", function() {
										var obj = document.all ? window.event.srcElement : this;
										obj.className = "input";
									});
						}
						break;
					case "textarea":
						el.className = "textarea";

						addEvent(el, "onfocus", function() {
									var obj = document.all ? window.event.srcElement : this;
									obj.className = "textarea_focus";
								});
						addEvent(el, "onblur", function() {
									var obj = document.all ? window.event.srcElement : this;
									obj.className = "textarea";
								
								});
					break;
				}
			}catch(e){}
		}
		xalt_scan_dom(curNode.firstChild);
		curNode=curNode.nextSibling;
	}
}

function xalt_onload(){
	//window.onerror = xalt_kill_errors;
	if (!(XALT.w3c || XALT.ns4 || XALT.ie4 || XALT.ie5 || XALT.ns6)) return;
	if(XALT.ns4||XALT.ns6){
		window.document.captureEvents(Event.MOUSEMOVE);
		window.document.addEventListener("mousemove", xalt_mousemove, true);
		window.addEventListener("resize", xalt_get_window_dims, true);
	}else if(XALT.ie4||XALT.ie5||XALT.w3c){
		window.document.attachEvent("onmousemove", xalt_mousemove);
		window.attachEvent("onresize", xalt_get_window_dims);
	}
	
	XALT.navtxt=(XALT.ns4)?document.layers['navtext_div']:(XALT.ie4)?document.all['navtext_div']:(XALT.w3c)?document.getElementById('navtext_div'):null;
	XALT.navtxt.style.display='none';
	xalt_get_box_width();
	xalt_get_box_height();
	xalt_get_window_dims();
	if(XALT.ie4||XALT.ie5&&cfg_fade_switch)XALT.navtxt.style.filter="alpha(opacity=100)";
	xalt_scan_dom(document.body);
	
}

if(XALT.ns4||XALT.ns6){
	window.addEventListener("load", xalt_onload, true);
}else if(XALT.ie4||XALT.ie5||XALT.w3c){
	 window.attachEvent("onload", xalt_onload);
}
//>>xalt

 //判断键盘是否锁定大小写
function  checkCapsLock(event){
	var e = event||window.event;
	var o = e.target||e.srcElement;
	var keyCode  =  e.keyCode||e.which; // 按键的keyCode 
	var isShift  =  e.shiftKey ||(keyCode  ==   16 ) || false ; // shift键是否按住
	if (
	((keyCode >=   65   &&  keyCode  <=   90 )  &&   !isShift) // Caps Lock 打开，且没有按住shift键 
	|| ((keyCode >=   97   &&  keyCode  <=   122 )  &&  isShift)// Caps Lock 打开，且按住shift键
	){
		//msg_show("大写锁定键被按下，请注意大小写", msg_type);
		return true;
	}
	else{
		//msg_hide();
		return false;
	} 
}
function open_win(name, url,width,height)
{
	var popup = window.open(url, name, 'width='+width+',height='+height+',scrollbars=yes,resizable=no,status=yes');
    	if (!popup.opener) popup.opener = self;
	popup.focus();
}


function popup(url,width,height)
{
	var popup = window.open(url, '_blank', 'width='+width+',height='+height+',scrollbars=yes,resizable=yes,status=yes');
    	if (!popup.opener) popup.opener = self;
	popup.focus();
}
function strlen(s){
	var i,str1,str2,str3,nLen;
	str1 = s;
	nLen = 0;
	for(i=1;i<=str1.length;i++){
			str2=str1.substring(i-1,i)
			str3=escape(str2);
			if(str3.length>3){
				nLen = nLen + 2;
			}else{
				nLen = nLen + 1;
			}
	}
	return nLen;
}