﻿(function(){
	if(isMaxthon()&&window.ActiveXObject){
		var cookieObj=getCookieObj();
		if(cookieObj["maxthonTispFlag"])return;
		addEvent(window,'load',function(){
			document.body.appendChild(getDiv());createStyle();
			var mdiv=$('maxthon_tips_div'),cbox=$("maxthon_tips_chkbox"),closeBtn=$("maxthon_tips_close"),closeX=$("maxthon_tips_close_x");
			mdiv.style.cssText='position:fixed;bottom:20px;right:20px;z-index:999999;_position:absolute;_bottom:auto;_top: expression(documentElement.scrollTop + documentElement.clientHeight-180 + "px");';
			addEvent(closeBtn,'click',function(){
				if(cbox.checked){
					setCookie("maxthonTispFlag=1;",24*60*60*1000*10000);
				}
				mdiv.style.display="none";
			});
			addEvent(closeX,'click',function(){
				if(cbox.checked){
					setCookie("maxthonTispFlag=1;",24*60*60*1000*10000);
				}
				mdiv.style.display="none";
			});
		});
		//ie6 png透明处理
		var isIE6 = !!window.ActiveXObject && !window.XMLHttpRequest;
		if(isIE6){
			EvPNG.fix('div, ul, img, li, input ,h3');
		}
	}

	function createStyle(){
		
		var tmpAry=[];
		tmpAry.push('#maxthon_tips_div.tc_div { width:277px;color:#000}');
		tmpAry.push('#maxthon_tips_div.tc_div * {margin:0; padding:0;}');
		tmpAry.push('#maxthon_tips_div.tc_div input {vertical-align:middle;}');
		tmpAry.push('#maxthon_tips_div.tc_div h3 {height:29px; line-height:29px; padding:0 17px; background:url(/public/images/tcDivP_top.png) no-repeat; margin:0; }');
		tmpAry.push('#maxthon_tips_div.tc_div h3 span {float:left; font-size:12px; font-weight:bold; color:#f1690e;}');
		tmpAry.push('#maxthon_tips_div.tc_div h3 a {background:url(/public/images/tcClose.png) no-repeat; float:right; margin-top:5px; display:block; width:18px; height:17px; font-size:0; text-indent:-999em; line-height:0}');
		tmpAry.push('#maxthon_tips_div.tc_div h3 a:hover {background-position:0 -17px;}');
		tmpAry.push('#maxthon_tips_div.tc_div .tc_mid {min_height:125px;_height:125px; padding:0 17px; line-height:24px; background:url(/public/images/tcDivP_bot.png) no-repeat bottom; font-size:12px; line-height:22px;}');
		tmpAry.push('#maxthon_tips_div.tc_div .tc_work {color:#666; height:40px; margin-top:5px;}');
		tmpAry.push('#maxthon_tips_div.tc_div .tc_work label {float:left;}');
		tmpAry.push('#maxthon_tips_div.tc_div .tc_work a.button {background:url(/public/images/tcDivP_isee.png) no-repeat; width:66px; height:20px; line-height:20px; text-align:center; color:#f1690e; display:block; float:right; text-decoration:none;}');
		tmpAry.push('#maxthon_tips_div.tc_div .tc_work a.button:hover { color:#e10618;}');
		if(document.createStyleSheet){
			var style=document.createStyleSheet();
			style.cssText=tmpAry.join('');
		}else{
			var style = document.createElement('style'); 
			style.type = 'text/css'; 
			style.innerHTML=tmpAry.join('');; 
			document.getElementsByTagName('head').item(0).appendChild(style); 
		}
	}
	function getDiv(){
		var div=document.createElement('div');
		div.id='maxthon_tips_div';
		div.className='tc_div';
		var tmpAry=[];
		//tmpAry.push('<div class="tc_div" id="maxthon_tips_div">');
		tmpAry.push('	<h3><span>友情提示</span><a href="#" id="maxthon_tips_close_x">*</a></h3>');
		tmpAry.push('    <div class="tc_mid">');
		tmpAry.push('    	<p>为了您正常使用该网站，请到菜单栏“工具 > 广告猎手”里，将“启用弹出窗口过滤、启用页面内容过滤”、“启用浮动广告过滤”和“启用文本过滤”均设为不启用。</p>');
		tmpAry.push('        <div class="tc_work">');
		tmpAry.push('        	<label>');
		tmpAry.push('        	  <input type="checkbox" name="checkbox" id="maxthon_tips_chkbox" /> 以后不再提示');
		tmpAry.push('        	</label>');
		tmpAry.push('            <a href="#" class="button" id="maxthon_tips_close">我知道了</a>');
		tmpAry.push('            <div style="clear:both;"></div>');
		tmpAry.push('        </div>');
		tmpAry.push('    </div>');
		//tmpAry.push('</div>');
		div.innerHTML=tmpAry.join('');
		return div;
	}

	function $(id){return document.getElementById(id);}
	//注册事件
	function addEvent(o,e,fn){
		if(o.attachEvent){
			o.attachEvent("on"+e,fn);
		}else{
			o.addEventListener(e,fn,false);
		}
	}
	function removeEvent(o,e,fn){
		if ( o.detachEvent ) { 
			o.detachEvent("on"+e, fn ); 
		} else{
			o.removeEventListener( e, fn, false ); 
		}
	}
	//遨游浏览器判断
	function isMaxthon(){    
		try{    
				return !!window.external.max_version; 
		}catch(e){return false;}
	}
	//获得cookie对象
	function getCookieObj(){
		var ary=document.cookie.split(';'),cookieObj={};
		for(var i=0,n=ary.length;i<n;i++){
			var t=ary[i].split('=');
			if(t.length==2)cookieObj[trim(t[0])]=t[1];
		}
		return cookieObj;
	}
	/*
		value: cookie中保留的参数,可以是String或Object,String格式为: name1=value1;name2=value2;
		time : cookie设置的过期时间数,为毫秒数,如:一小时 1*60*60*1000
	*/
	function setCookie(value,time){
		var timer = new Date(),cookieStr="",time=time||1*60*60*1000;
		timer.setTime(timer.getTime() + time );
		if(typeof value =='string'){
			cookieStr=window.encodeURI(value);
		}else{
			for(var name in value){
				cookieStr+=name+"="+window.encodeURIComponent(value[name])+";";
			}
		}
		document.cookie = cookieStr+" expires=" + timer.toGMTString();; 
	}
	function trim(t){
		return (t||"").replace(/^(\s|\u00A0)+|(\s|\u00A0)+$/g,"");
	}
})()
