var isIE6=false;
document.write("<!--[if IE 6]><script>isIE6=true;</scr"+"ipt><![endif]-->");

/* PNG修复(<img> and background)
 * 要修复背景PNG,请在PNG背景图前加下划线(_)
 * Jin @ 2011.12.02
 */ 
if(isIE6){document.write('<script type="text/javascript" defer="defer" src="javascript:void(0)" onreadystatechange="pngfix()"><\/script>');}
function pngfix(){
	var els=document.getElementsByTagName('*'),al="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='",i=els.length;
	while(i-->0){
		var el=els[i],es=el.style;
		if(el.src && el.src.match(/\.png/i) && !es.filter){
			es.height=el.height;
			es.width=el.width;
			es.filter=al+el.src+"',sizingMethod='crop')";
			el.src="/bbx/images/transparent.gif";
		}else{
			var elc=el.currentStyle,elb=elc.backgroundImage;
			if(elb.match(/_.*\.png/i)){
				var path=elb.split('"'),rep=(elc.backgroundRepeat=='no-repeat')?'crop':'scale',elkids=el.getElementsByTagName('*'),j=elkids.length;
				es.filter=al+path[1]+"',sizingMethod='"+rep+"')";
				es.height=el.clientHeight+'px';
				es.backgroundImage='none';
				if(j!=0){
					if(elc.position!="absolute")es.position='static';
					while(j-->0)if(!elkids[j].style.position)elkids[j].style.position="relative";
				}
			}
		}
	}
}


/*得到Html参数,Code By Nicenic.com, IceFire*/
function Request(strName){
	var strHref = window.document.location.href;
	var intPos = strHref.indexOf("?");
	var strRight = strHref.substr(intPos + 1);
	var arrTmp = strRight.split("&");
	for(var i=0,len=arrTmp.length; i<len; i++){ 
		var arrTemp = arrTmp[i].split("=");
		if(arrTemp[0].toUpperCase() == strName.toUpperCase()){
		if(arrTemp[1].indexOf("#")!=-1) arrTemp[1] = arrTemp[1].substr(0, arrTemp[1].indexOf("#"));
			return arrTemp[1]; 
		}
	}
	return "";
}
function showUrl(){document.write(window.location.hostname);}

//cookie相关
function checkNum(nubmer){
    var re = /^[0-9]+.?[0-9]*$/;   //判断字符串是否为数字     //判断正整数 /^[1-9]+[0-9]*]*$/  
    if (re.test(nubmer))return true;
	return false;
}
function SetCookie(name,value,hours){
	var hourstay = 30*24*60*60*1000; //此 cookie 将被默认保存 30 天
	if(checkNum(hours)){
		hourstay = hours;
	}
    var exp  = new Date();
    exp.setTime(exp.getTime() + hourstay*60*60*1000);
    document.cookie = name + "="+ escape(value) + ";expires=" + exp.toGMTString();
}
function getCookie(name){     
    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
    if(arr != null) return unescape(arr[2]); return null;
}
function delCookie(name){
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval=getCookie(name);
    if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}
//表单是否显示
function showForm(){
	if(getCookie('userlogin')==1){
		var formIsShow = document.getElementsByTagName('div');
		for(var i=0;i<formIsShow.length;i++){
			if(formIsShow[i].getAttribute("name")=="formIsShow"&&formIsShow[i].getAttribute("value")==1){
				formIsShow[i].style.display='block';
			}
		}
	}
}
