var newShowTime=60;

var showTimeSpan=0;
var setTimeoutObj;
function divOnMouse(r){
    showTimeSpan=0;
    var formRemindType=document.getElementById("FormRemindType");
    
    if(formRemindType==null)
    {
         document.getElementById("IsAlready").value="true";
    }
    
    if(document.getElementById("IsAlready").value=="false")
    {
        if(r=="1")
        {
            timeAdd('1');
        }
        else
        {
            clearTimeout(setTimeoutObj);
            showTimeSpan=0;
        }
    }
}
function timeAdd(r){
    showTimeSpan++;
    if(r=="2"){
        return;
    }
    setTimeoutObj=setTimeout("timeAdd()",1000);
    if(showTimeSpan>3){
       document.getElementById("IsAlready").value="true";
       SubmitModal(document.forms["RemindSubmitForm"]);
       clearTimeout(setTimeoutObj);
       return;
    }
}
function divOnClick(){
   clearTimeout(setTimeoutObj);
   if(document.getElementById("IsAlready").value=="false"){
       document.getElementById("IsAlready").value="true";
       SubmitModal(document.forms["RemindSubmitForm"]);
   }
}

var Groj = function() {
	this.initialize.apply(this, arguments);
}
// download by http://www.codefans.net
Groj.prototype = {
	initialize: function(url, options) {
    //	跨域请求
		this.url = url;
		this.setOptions(options);
		this.request();
	},
	
	setOptions: function(options) {
		this.options = {
			variable: '',
			step: 500,		//	循环问询间隔时间（毫秒为单位）
			timeout: 5000	//	超时时间（毫秒为单位）
		}
		for (var i in options) {
			this.options[i] = options[i];
		}
		this.varArr = this.options.variable.split(".");
	},
	
	request: function() {
		if (this.isVarValid()) {
			this.onResult();
			return;
		}
		
		var _this = this;
		
		var oHead = document.getElementsByTagName('head')[0];
		this.link = document.createElement('script');
		this.link.src = this.url;
		this.link.type = 'text/javascript';
		this.timer = window.setInterval(function() {_this.onCheck();}, this.options.step);
		oHead.appendChild(this.link);
		
		//	设置超时回调函数
		this.outTimer = window.setTimeout(function() {_this.onTimeout();}, this.options.timeout)
	},
	
	isVarValid: function() {
		var vari = this.getVar();
		return typeof(vari) != "undefined" && vari != null;
		//return (typeof(this.getVar()) != "undefined" );
	},
	
	getVar: function() {
		var vari = window;
		for (var i=0; i<this.varArr.length; i++) {
			vari = vari[this.varArr[i]];
			
			if (typeof(vari) == "undefined" || vari == null) break;
		}
		return vari;
	},
	clearVar:function(){
		var vari = window;
		for (var i=0; i<this.varArr.length; i++) {
			var vvv= vari[this.varArr[i]];
			if (typeof(vvv) == "undefined" || vvv == null) {
				break;
			}
			vari[this.varArr[i]]=null;
		}
	},
	onResult: function() {
		this.clearTimer();
		var currentVar=this.getVar();
		this.options.onSuccess(currentVar);
		
		//清除变量，移除该SCRIPT标签.
		this.clearVar();
		try{
		if(this.link){
			this.link.parentNode.removeChild(this.link);
		}
		}catch(e){};
	},
	
	onCheck: function() {
		if (this.isVarValid()) this.onResult();
		else return;
	},
	
	onTimeout: function() {
		this.clearTimer();
		//if (this.link) Element.remove(this.link);
		if(this.link){
			this.link.parentNode.removeChild(this.link);
		}
		else if (this.options.onFailure) this.options.onFailure();
	},
	
	clearTimer: function() {
		if (this.timer) {
			window.clearInterval(this.timer);
			this.timer = null;
		}
		window.clearTimeout(this.outTimer);
		this.outTimer = null;
	}
} 
////////////////////////////////////////////////////////////////////////
		function GR() {
			if (arguments.length < 1) return;
			for (var i=0; i<arguments.length; i++) {
				GRO(arguments[i]);
			}
		}
		function GRO(options) {
			if (typeof(options.interval) == "number" && options.interval > 0) {
				function run() {
					var url = typeof(options.url) == "function" ? options.url() : options.url;
					var variable = typeof(options.variable) == "function" ? options.variable() : options.variable;
					if (!!url && !!variable) {
						new Groj(url, {
						  variable: variable,
						  onSuccess: options.onSuccess,
						  onFailure: options.onFailure || function() {}
						});
					}
				}
				run();
				window[options.hold] = window.setInterval(run, options.interval);
			} else {
				var url = typeof(options.url) == "function" ? options.url() : options.url;
				var variable = typeof(options.variable) == "function" ? options.variable() : options.variable;
				if (!!url && !!variable) {
					new Groj(url, {
					  variable: variable,
					  onSuccess: options.onSuccess,
					  onFailure: options.onFailure || function() {}
					});
				}
			}
		}
////////////////////////////////////////////////////////////////////////		

var KuaiXun2008 = function() {
	this.initialize.apply(this, arguments);
}

KuaiXun2008.prototype = {
	initialize: function() {
		this.dataJsPath = "http://Rsc.vipcareer.com/Js/data.js";
		this.imagesPath = "http://Rsc.vipcareer.com/imgs";
	  	this.popDivs ='<style>';
		this.popDivs += '#olympic2008pop  *{color:#333;font-size:12px;font-family:"宋体";text-align:center;}';
		this.popDivs += '#olympic2008pop > div{margin-right:auto;margin-left:auto;text-align:center;}'; 
		this.popDivs += '#olympic2008pop div,#olympic2008pop form,#olympic2008pop ul,#olympic2008pop ol,#olympic2008pop li,#olympic2008pop p{margin:0;padding:0;border:0;}';
		this.popDivs += '#olympic2008pop img,#olympic2008pop a img{margin:0;padding:0;border:0;}';
		this.popDivs += '#olympic2008pop a{color:#004ab8;text-decoration:none; }';
		this.popDivs += '#olympic2008pop a:hover{color:#0365f9;text-decoration:underline;}';
		this.popDivs += '#olympic2008pop .htmcontent{width:275px;height:216px;FILTER:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled="true",sizingMethod="scale",src="'+this.imagesPath+'/pop_bg1.png");background:url('+this.imagesPath+'/pop_bg1.png)!important;background:none}';
		
		this.popDivs += '#olympic2008pop .htmcontent .kxtitle{display:inline;float:left;width:155px;height:15px;margin:34px 0 0 18px; color:#FFFFFF;text-align: left;}';
		this.popDivs += '#olympic2008pop .htmcontent .kxclose{ float:right;width:15px;height:15px;margin:34px 10px 0 0;display:inline;position:relative}';
		this.popDivs += '#olympic2008pop .htmcontent .kxsohu2008{clear:both;width:239px;height:22px;margin:0 auto;text-align:right; padding-right:10px;position:relative}';
		this.popDivs += '#olympic2008pop .neirongads240x40{ float:left; margin:5px 0 0;text-align:left; padding-left:18px;position:relative}';
		this.popDivs += '#olympic2008pop .htmcontent #neirongContent{float:left;width: 259px;height:90px;margin:15px 0 0 15px;display:inline;line-height: 22px;text-align:left;position:relative;word-wrap:break-word}';
		this.popDivs += '.an{}';
		this.popDivs += '.www {BORDER-RIGHT: #7b9ebd 1px solid; PADDING-RIGHT: 2px; BORDER-TOP: #7b9ebd 1px solid; PADDING-LEFT: 2px; FONT-SIZE: 12px; FILTER: progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#ffffff, EndColorStr=#cecfde); BORDER-LEFT: #7b9ebd 1px solid; CURSOR: hand; COLOR: black; PADDING-TOP: 2px; BORDER-BOTTOM: #7b9ebd 1px solid}';
		
		this.popDivs += '.zhuli{ width:100%; height:115px;; border-bottom:1px solid #aaa;}';
		this.popDivs += '.zhuli ul{ width:96%; margin:0px; list-style:none;text-align:left;}';
		this.popDivs += '.zhuli ul li{ font:"宋体"; line-height:22px; font-size:12px; color:#0642bd; text-decoration:none}';
		this.popDivs += '.zhuli ul li.z{ width:96%; padding-left:38px; float:left;}';
		this.popDivs += '.zhuli ul li img{ border:0px; padding-left:5px; padding-right:5px; float:left;}';
		this.popDivs += '.zhuli ul li span{ padding-left:5px; padding-right:5px;font:"宋体"; font-size:12px; color:#000;text-decoration:none}';
		this.popDivs += '.zhuli ul li span img{ padding-right:10px}';
		this.popDivs += '.zhuli ul li span.y{ font-family:Arial, Helvetica, sans-serif; font-size:10px; color:#aaa}';
		this.popDivs += '.zhuli ul li span.b{ font:"宋体"; font-size:12px; color:#336699;text-decoration:none; }';
		this.popDivs += '.zhuli ul li span.n{float:left;padding-left:5px; padding-right:5px;font:"宋体"; overflow:hidden; height:40px; font-size:12px; color:#aaa;text-decoration:none;}';
		this.popDivs += '.zhuli ul li span a:link{color:#069;;text-decoration:none}';
		this.popDivs += '.zhuli ul li span a:hover{text-decoration:underline}';
		this.popDivs += '.zhuli ul li a:link{color:#069;;text-decoration:none}';
		this.popDivs += '.zhuli ul li a:hover{text-decoration:underline}';
		this.popDivs += '</style>';
		
		
		this.popDivs += '<form name="RemindSubmitForm" id="RemindSubmitForm" method="post" action="/Log/LogToRead.aspx">';
		this.popDivs += '<input type="hidden" name="IsAlready" id="IsAlready"  value="false"/>';
		this.popDivs += '<div id="RemindSubmitFormDiv" name="RemindSubmitFormDiv">';
		this.popDivs += '</div></form>';
		this.popDivs += '<div onclick="divOnClick()" onmouseover="divOnMouse(\'1\')\" onmouseout="divOnMouse(\'2\')" id="olympic2008pop" name="olympic2008pop" style="Z-INDEX: 99999;VISIBILITY: hidden;POSITION:absolute;left:0px;top:0px;">';
		this.popDivs += '<div class="htmcontent">';
		this.popDivs += '<div class="kxclose"><a style="cursor:hand;" onclick="kuaixun2008.closeDiv();"><img src="'+this.imagesPath+'/close.png" width="15" height="15" alt="" /></a></div>';
		this.popDivs += '<div id="neirongContent">';
		
		this.popDivs += '<div id="MessContent" name="MessContent">';
		
		this.popDivs += '<div class="zhuli">';
		this.popDivs += '<ul>';
		this.popDivs += '<li style=" text-align:left;"><img src="http://Rsc.vipcareer.com/Images/icon_68.gif" width="20" height="19" /><span>网站公告</span><span class="y">04-16 13:42</span></li>';
		this.popDivs += '<li class="z">';
		this.popDivs += '<div style=" text-align:left;"><span><a href="#">系统升级，新增群内发布职位功能</a></span><span class="n" style=" text-align:left;">人才竞争成为企业竞争的核心和关键，它不仅能够提高员工综合素；人才竞争成为企业竞争的核心和关键，它不仅能够提高员工综合素</span></div>';
		this.popDivs += '</li>';
        this.popDivs += '<li style=" float:right;"><span><a href="#">[查看详细内容]</a></span></li>';
        this.popDivs += '</ul>';
        this.popDivs += '</div>';
        
        this.popDivs += '</div>';
        
        
        this.popDivs += '<div  class="neirongads240x40">&nbsp;&nbsp;';
        this.popDivs += '<label>';
        this.popDivs += '<input name="button" type="submit" class="www" onclick="window.location.href=\'/Log/LogRemind.aspx\'"  id="button" value="消息中心" />';
 //       this.popDivs += '<input name="button" type="submit" class="www" onclick="window.location.href=\'/User/AssistantLimit.aspx\'" id="button" value="设置" />';
//        this.popDivs += '<input name="button" type="submit" class="www" id="button" value="帮助" />';
        this.popDivs += '</label>';
        this.popDivs += '</div>';
        this.popDivs += '</div>';
        this.popDivs += '</div>';
        this.popDivs += '</div>';
        
        
        //this.popDivs += '<input name="button" type="button" onclick="window.location.href=\'/User/AssistantLimit.aspx\'" class="www"  value="设置" />';
        //this.popDivs += '<input name="button" type="button" class="www" id="button" value="帮助" />';
//        this.popDivs += '</label>';
//        this.popDivs += '</div>';

//		this.popDivs += '</div>';
//		this.popDivs += '</div>';
		this._initGlobal(newShowTime);
	},
	
	_initGlobal:function(nst) {
		this.docUrl = document.location.href;
		this.cookieDomain = "";
		this.CheckCookieDomain();
		
		this.kuaixun2008type = this.GetCookie("kuaixun2008type");
		this.kuaixun2008id = parseInt(this.GetCookie("kuaixun2008id"));
		
		this.timeDifference = 1000 * 60 * 10; //时间间隔10分钟
		this.kuaixun2008requestTime = this.GetCookie("kuaixun2008requestTime");
		
		this.isSHTML = document.compatMode=="CSS1Compat" ? true:false;
		
		this.divTop=0;
		this.divLeft=0;
		this.divWidth=0;
		this.divHeight = 0;
		this.docHeight = 0;
		this.docWidth = 0;
		this.objTimer = 0;
		this.timecounter = 0;
		this.showtimeout = nst; //显示关闭时间，单位为秒
		this.olympic2008pop = null;
		document.write(this.popDivs);
		
		this.olympic2008pop = document.getElementById("olympic2008pop");
		if (window.addEventListener) {
		    window.addEventListener("resize", this.resizeDiv, false);
		} else {
		    window.attachEvent("onresize", this.resizeDiv);
		}
		//window.onerror = window.onerror || function(e){}
	},
	start:function(nst) {
	    this.olympic2008pop=document.getElementById("olympic2008pop");
	    newShowTime=nst;
		var this_ = this;
		var getKuaixun = {
			url:function(){
				var date = new Date();
				return this_.dataJsPath+"?random="+date.getTime();
			},
			variable: "kuaixun",
			interval: -1,
			hold: "kuaixun_hold",
			onSuccess : function(data){
				if(data.id != null && data.id != "" && typeof(data.id)!= "undefined"){
					if( data.type == this_.kuaixun2008type && parseInt(data.id) == this_.kuaixun2008id ){
						
					}else{
						this_.kuaixun2008type = data.type;
						this_.kuaixun2008id = parseInt(data.id);
						this_.SetCookie("kuaixun2008type",data.type);
						this_.SetCookie("kuaixun2008id",data.id);
						if(data.type == "system"){
							this_.SetCookie("olympic2008kuaixunId",data.id);					
						}
						var logHtml=data.logHtml;
						
						var logType="";
						var logId="";
						var logForm="";
						if(data.logType!=null && data.logType.length>0){
						    logType=data.logType;
						    if(data.logId!=null && data.logId.length>0)
						    {
						       logId=data.logId;
						       logForm="<input type=\"hidden\" name=\"FormRemindId\" id=\"FormRemindId\"  value=\""+data.logId+"\"/><input type=\"hidden\" name=\"FormRemindType\" id=\"FormRemindType\"  value=\""+data.logType+"\"/>";
						    }
						}
						
						this_.initDiv(logHtml,logForm);
					}
				}
			}
		};
		
		//if( (new Date().getTime()-this.kuaixun2008requestTime) > this.timeDifference){
				this.SetCookie("kuaixun2008requestTime",new Date().getTime());
		    	GR(getKuaixun);
		//}
	
	},
	getStrLen:function(str){
		var len = 0;
		var cnstrCount = 0; 
		for(var i = 0 ; i <str.length ; i++){
		  if(str.charCodeAt(i)>255)
		   cnstrCount = cnstrCount + 1 ;
		}
		len = str.length + cnstrCount;
		return len;
	},
	substring:function(str,start,end){
		var retStr = "";
		var count = 0;
		for(var i=0;i<str.length;i++){
			if(str.charCodeAt(i)>255){
				count += 2;
			}else{
				count += 1;
			}
			if(count<=end){
				retStr += str.charAt(i);	
			}else{
				break;
			}
		}
		return retStr;
	},
	writeStr:function(str){
		var newStr = "";
		if(this.getStrLen(str)>100){
			newStr = this.substring(str,0,100)+"...";
		}else{
			newStr = str;
		}
		return newStr;
	},
	getCookieVal:function (offset){
	    var endstr = document.cookie.indexOf (";", offset);
	    if (endstr == -1)
	      endstr = document.cookie.length;
	    return unescape(document.cookie.substring(offset, endstr));
	},
	
	GetCookie:function (name){
	    var arg = name + "=";
	    var alen = arg.length;
	    var clen = document.cookie.length;
	    var i = 0;
	    while (i < clen) {
	      var j = i + alen;
	      if (document.cookie.substring(i, j) == arg)
	        return this.getCookieVal (j);
	      i = document.cookie.indexOf(" ", i) + 1;
	      if (i == 0) break;
	    }
	    return null;
	},
	SetCookie:function (name, value){
	    var argv = this.SetCookie.arguments;
	    var argc = this.SetCookie.arguments.length;
	    //var expires = (argc > 2) ? argv[2] : null;
	    var expiresTime = new Date("2008","8","10");
	    var expires = (argc > 2) ? argv[2] : expiresTime;
	    var path = (argc > 3) ? argv[3] : "/";
	    var domain = (argc > 4) ? argv[4] : this.cookieDomain;
	    var secure = (argc > 5) ? argv[5] : false;
	    document.cookie = name + "=" + escape (value) +((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +((path == null) ? "" : ("; path=" + path)) +((domain == null) ? "" : ("; domain=" + domain)) +((secure == true) ? "; secure" : "");
	},
	CheckCookieDomain:function(){
		var sohuMatrix = [".sohu.com",".sogou.com",".chinaren.com",".focus.cn",".17173.com",".goodfeel.com.cn",".go2map.com"];
		for(var i=0;i<sohuMatrix.length;i++){
			if(this.docUrl.indexOf(sohuMatrix[i])>=0){
				this.cookieDomain = sohuMatrix[i];
				break;
			}
		}
	},
	/********************** view Div **************************/
	//initDiv --> moveDiv --> resizeDiv --> closeDiv
	
	initDiv:function (logHtml,logForm){
			try{
				this.divTop = parseInt(this.olympic2008pop.style.top,10);//div上部的像素点
				this.divLeft = parseInt(this.olympic2008pop.style.left,10);//div左边的像素点
				this.divHeight = parseInt(this.olympic2008pop.offsetHeight,10);//div自身高度
				this.divWidth = parseInt(this.olympic2008pop.offsetWidth,10);//div自身宽度
				//+++在web标准声明下用document.documentElement; 如果是未声明用document.body+++用document.compatMode判断+++
				if(this.isSHTML){
					this.docHeight = document.documentElement.clientHeight;//页面高度 
					this.docWidth = document.documentElement.clientWidth;//页面宽度
					this.olympic2008pop.style.top = parseInt(document.documentElement.scrollTop,10) + this.docHeight + 10 + "px";//变换div上部的位置 
					this.olympic2008pop.style.left = this.docWidth - this.divWidth + parseInt(document.documentElement.scrollLeft,10) + "px";//变换div左边的位置
				}else{
					this.docHeight = document.body.clientHeight;//页面高度
					this.docWidth = document.body.clientWidth;//页面宽度
					this.olympic2008pop.style.top = parseInt(document.body.scrollTop,10) + this.docHeight + 10;//变换div上部的位置 
					this.olympic2008pop.style.left = this.docWidth - this.divWidth + parseInt(document.body.scrollLeft,10);//变换div左边的位置
				}
				document.getElementById("RemindSubmitFormDiv").innerHTML = logForm;//填充内容
				document.getElementById("MessContent").innerHTML = logHtml;//填充内容
//				document.getElementById("MessContent").innerHTML = content;//填充内容
//				document.getElementById("MessageUrl").innerHTML = MessUrl;//填充内容
//				document.getElementById("MessFrom").innerHTML = MessFrom;//填充内容
				this.olympic2008pop.style.visibility="visible";
				this.objTimer = window.setInterval("kuaixun2008.moveDiv()",1);
			}catch(e){
			}
	},
	
	moveDiv:function(){
		try{
			var tmpVar1;
			if(this.isSHTML){
				tmpVar1 = parseInt(document.documentElement.scrollTop,10);
			}else{
				tmpVar1 = parseInt(document.body.scrollTop,10);
			}
			
			if(parseInt(this.olympic2008pop.style.top,10) <= (this.docHeight - this.divHeight + tmpVar1)){
				if(this.objTimer){
					window.clearInterval(this.objTimer);
				}
				this.timecounter=0;
				this.resizeDiv();
				this.objTimer = window.setInterval("kuaixun2008.resizeDiv()",1000);//1秒调一次，实现showtimeout*1000ms的效果
			}else{
				this.divTop = parseInt(this.olympic2008pop.style.top,10);
				this.olympic2008pop.style.top = this.divTop - 5 +"px";
			}
		}catch(e){
		}
	},
	
	resizeDiv:function(){
		this.timecounter+=1;
		if((this.timecounter) >= newShowTime){//超过时间限制就隐藏Div
			if(this.objTimer) window.clearInterval(this.objTimer)
			this.objTimer = window.setInterval("kuaixun2008.closeDiv()",1);
		}
		try{
			this.divHeight = parseInt(this.olympic2008pop.offsetHeight,10);
			this.divWidth = parseInt(this.olympic2008pop.offsetWidth,10);
			if(this.isSHTML){
				this.docWidth = document.documentElement.clientWidth;
				this.docHeight = document.documentElement.clientHeight;
				this.olympic2008pop.style.top = this.docHeight - this.divHeight + parseInt(document.documentElement.scrollTop,10)+"px";
				this.olympic2008pop.style.left = this.docWidth - this.divWidth + parseInt(document.documentElement.scrollLeft,10)+"px";
			}else{
				this.docWidth = document.body.clientWidth;
				this.docHeight = document.body.clientHeight;
				this.olympic2008pop.style.top = this.docHeight - this.divHeight + parseInt(document.body.scrollTop,10);
				this.olympic2008pop.style.left = this.docWidth - this.divWidth + parseInt(document.body.scrollLeft,10);
			}
			
		}catch(e){
		}
	},
	
	closeDiv:function(){
		this.olympic2008pop.style.visibility="hidden";
		if(this.objTimer) window.clearInterval(this.objTimer);
	}
}

var kuaixun2008 = new KuaiXun2008();
//kuaixun2008.start();
