﻿//=========================================================================
//@author: ziyangjiayi
//E-mail : ziyangjiayi@163.com
//@date  : 200912225
//=========================================================================
//消除空格
String.prototype.trimZ = function(){
return this.replace(/(^\s*)|(\s*$)/g, "");
}

function SetCookie(name,value)//两个参数，一个是cookie的名子，一个是值
{
    var Days = 7; //此 cookie 将被保存 30000 天
    var exp  = new Date();
    exp.setTime(exp.getTime() + Days*24*60*60*1000);
    document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString()+";domain=" +"sichinamag";
}

function getCookieValue(name){
     var strCookie=document.cookie;
    var arrCookie=strCookie.split(";");
    for(var i=0;i<arrCookie.length;i++)
    { // 遍历cookie数组，处理每个cookie对
      var arr=arrCookie[i].split("="); 
      if(arr[0]==name)return arr[1];
    }
    return "";
}

function delCookie(name){//为了删除指定名称的cookie，可以将其过期时间设定为一个过去的时间
	var date = new Date();
	date.setTime(date.getTime() - 10000);
	document.cookie = name + "=a; expires=" + date.toGMTString();
}

function deleteAllCookie(){
     var strCookie=document.cookie;
    var arrCookie=strCookie.split(";");
    var cnames ="";
    for(var i=0;i<arrCookie.length;i++)
    { // 遍历cookie数组，处理每个cookie对
      var arr=arrCookie[i].split("=");
      delCookie(arr[0]);
      cnames += arr[0]+" ";
    }
    alert('delete success:'+arrCookie.length+"个 "+ cnames);
}
//获取地址栏参数
function getUrlPara(paraName){  
	var sUrl  =  location.href; 
	var sReg  =  "(?:\\?|&){1}"+paraName+"=([^&]*)" 
	var re=new RegExp(sReg,"gi"); 
	re.exec(sUrl); 
return RegExp.$1; 
} 
//应用实例：test_para.html?a=11&b=22&c=33 
//alert(getUrlPara("a"));


//用于系统tab页的切换，替换以前的切换方法function initRollTabs(rtImgClass, classname, rtArr, rtindex, rtNum, rtSelected)，新方法不需要遍例文档，提供性能
function changeTab_ext(_tabName , _key ,_currentIndex ,_tabsize){				
	for(var _key_i=1;_key_i<=_tabsize;_key_i++){
		//alert('tab'+_key+'-'+_key_i);
		document.getElementById(_tabName+_key+'-'+_key_i).className='lioff';
		//if('hometab'==_tabName)alert('tab_ext_'+_key+'-'+_key_i+'-'+_key_i);
		document.getElementById('tab_ext_'+_key+'-'+_key_i+'-'+_key_i).style.display='none';
		if(_key_i==_currentIndex){
			//if('hometab'==_tabName)alert('tab_ext_'+_key+'-'+_key_i+'-'+_key_i+'\n'+document.getElementById('tab_ext_'+_key+'-'+_key_i+'-'+_key_i).innerHTML);
			document.getElementById(_tabName+_key+'-'+_key_i).className='lion';
			document.getElementById('tab_ext_'+_key+'-'+_key_i+'-'+_key_i).style.display='block';
		}
	}

}


//多层切换 - ZIYANG USERD FROM aysun 
function ChangeManyLayer(obj) {
    //obj 当前li或div

    var objParentDiv = obj.parentNode;

    var IsDiv = false;
    //判断obj上父级是不是div
    if (objParentDiv.nodeName == 'DIV') {
        IsDiv = true;
    }

    //循环设置obj平级的样式为空
    for (var i = 0; i < objParentDiv.childNodes.length; i++) {
        objParentDiv.childNodes[i].className = "";
    }
    //如果obj的父级不是div,那再向上找一层
    if (IsDiv == false) {
        objParentDiv = objParentDiv.parentNode;
        //再判断obj父级的父级是不是div
        if (objParentDiv.nodeName == 'DIV') {
            IsDiv = true;
        }
    }


    //如果父级是div
    if (IsDiv == true) {
        //再次获取父级的上层父级对象
        var rootNode = objParentDiv.parentNode;

        var LayerRootNode;
        //得到obj的相对的内容的大div对象
        for (var i = 0; i < rootNode.childNodes.length; i++) {
            if (rootNode.childNodes[i].nodeName == 'DIV') {
                if (rootNode.childNodes[i].id != objParentDiv.id) {
                    LayerRootNode = rootNode.childNodes[i];
                }

            }
        }

        //循环找到obj对应的内容对象显示出现,其它内容则隐藏        
        for (var i = 0; i < LayerRootNode.childNodes.length; i++) {
            if (LayerRootNode.childNodes[i].nodeName == 'DIV' || LayerRootNode.childNodes[i].nodeName == 'UL') {
                if (LayerRootNode.childNodes[i].id == obj.id + 'layer') {
                    LayerRootNode.childNodes[i].style.display = 'block';
                }
                else {
                    LayerRootNode.childNodes[i].style.display = 'none';
                }
            }
        }

        //最后对obj的样式进行标识一下
        obj.className = 'active';

    }
    
}




  //用于系统tab页的切换
function changeHotNav(_tabName,_selectedIndex,_currentIndex,_tabsize){

	for(var _key_i=1;_key_i<=_tabsize;_key_i++){
		document.getElementById(_tabName+_key_i).className='';
		
		if(_key_i==_currentIndex){
			document.getElementById(_tabName+_key_i).className='on';
		}
	}
	//document.getElementById(_tabName+_selectedIndex).className='on';
}
function changeHotNav_lose(_tabName,_selectedIndex,_currentIndex){
	for(var _key_i=1;_key_i<=_tabsize;_key_i++){
		if(_selectedIndex!=_currentIndex){
			document.getElementById(_tabName+_currentIndex).className='';
		}
	}
}

function changeHotNav_lose_2(_tabName,_currentIndex){
	document.getElementById(_tabName+_currentIndex).className='';
}



function addBookmark(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(obj,vrl){
   try{
           obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);
   }
   catch(e){
           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',vrl);
            }
   }
}


//===================================
//index

//index top search start
function searchNewsFun(defaultValue){
	var searchNews_ = document.getElementById('searchNews').value;
	if(searchNews_ != ''){
		if(defaultValue==searchNews_){
			 alert('请输入正确的搜索条件');
        	return;
		}
		//window.open("/search/searchArticles.action?command.query="+encodeURIComponent(searchNews_),"_blank");
		document.getElementById('searchArticlesAction').submit();
	}
}
function LableOnFocus(e, text) {
    if (e.value == text) {
        e.value = "";
    }
    e.select();
    e.style.color = "black";
}
function LableOnBlur(e, text) {
    if (e.value == '') {
        e.value = text;
    } 
}
//index top search end



//初始化 chat div size reinitIframeForIndexChatDiv
function CD(){
	document.getElementById('tPartDivLoadImg').style.display="none";
}
function CDTT(){
	document.getElementById('tPartDivLoadImg').style.display="none";				
	var iframe_allChatDiv = document.getElementById("allChatDiv");
	var cs = iframe_allChatDiv.contentWindow.document.getElementById("x").innerHTML;
	$('m0').innerHTML=$('mtext').innerHTML =cs;
}
function rificd(){
	var iframe_allChatDiv = document.getElementById("allChatDiv");
	try{
		var bHeight = iframe_allChatDiv.contentWindow.document.body.scrollHeight;
		var dHeight = iframe_allChatDiv.contentWindow.document.documentElement.scrollHeight;
		var height = Math.max(bHeight, dHeight);
		iframe_allChatDiv.height =  height;
	}catch (ex){}
}




//====
//eletter subscription start
function changeOc(){
	var emailText_ = $('emailText').value;
	if(emailText_=='请输入Email地址'){
		$('emailText').value='';
	}
}
function  subscibe(){
	var emailText_ = $('emailText').value;
	if(emailText_=='' || emailText_=='请输入Email地址'){
		alert('填写正确的Email地址');
		//$('emailText').focus();
		return;
	}
	var cCount="";
     		var checkA = document.getElementsByName('checkAll');
     		for (var i=0; i<checkA.length; i++) {
		if(checkA[i].checked){
			cCount+=checkA[i].value+"_";
		}					
	}
	if(cCount==""){
		alert('请先选择订阅选项');
		return;
	}
	var callBack_funE = function(data){
		if(data != null && data != 'undefined'){
			alert(data.operateMessage);
		}
	}
	eletterService.eletterOperation(emailText_ , cCount ,0, callBack_funE);
}
function  countermand(){
	var emailText_ = $('emailText').value;
	if(emailText_=='' || emailText_=='请输入Email地址'){
		alert('填写正确的Email地址');return;
	}
	var cCount="";
     		var checkA = document.getElementsByName('checkAll');
     		for (var i=0; i<checkA.length; i++) {
		if(checkA[i].checked){
			cCount+=checkA[i].value+"_";
		}					
	}
	if(cCount==""){
		alert('请先选择订阅选项');
		return;
	}
	var callBack_funE = function(data){
		if(data != null && data != 'undefined'){
			alert(data.operateMessage);
		}
	}
	eletterService.eletterOperation(emailText_ , cCount ,1, callBack_funE);
}
//eletter subscription end
//====

function tagOver(a){
	clearTimeout(fodTime);fodTime=0;fodTime = setTimeout(function(){swTabs(a)},100);if(a.id=="defTail"){$("map").className="undis";}if(a.id=="tailorxxx"&&$("map").innerHTML==""){setTimeout(function(){loadNewsMap();},300);}}
	

var managerEguideId = "";


function toolbarLoginSuccessMessage(person){
	//alert(person.weblog.status);
	if(person.weblog.status=="2"){
		return '对不起您的帐号已被禁用！·';
		
	}else
		return '欢迎您：<A title="进入我的空间" href="'+person.weblog.linkUrl+'" >'+person.nickname+'</A> <A title="管理我的空间" href="'+systemPath+'/myspace/manager/searchLogWithCheck.action" >管理我的空间</A> <A href="javascript:systemLogout();" >[登出]</A>·';
}
function systemLogin() {
	var loginSuccess_callback = function(transport) {
		var resultHtml = transport.responseText || '';
		
		
		if(resultHtml != ''){
		
			
			
			//var person = JSON.parse(resultHtml);
			var person = eval("("+resultHtml+")");
			
			//$('login_user_info').innerHTML = resultHtml;
			//alert($('login_user_info').innerHTML);
			//$('login_user_info').style.display='block';
			
			//适用首页 文章页
			try{
				$('abcd').innerHTML=$('abcd').innerHTML= toolbarLoginSuccessMessage(person);
			}catch(e){
				//alert('该页面不包含toolbar');
			};
			
			
			//填充页面中的currentUserId
		    try{
				$('currentUserId').value=person.id;
			}catch(e){
				//alert('该页面不包含 currentUserId input');
			};
			
			
			
			//适用页面中包含二次登陆的按钮
			try{
				$('content_login_user_info').style.display='none';
				$('input_commentTitle').readOnly=true;
			}catch(e){
				//alert('该页面不包含二次登陆的按钮模块');
			};
			
			
			//适用comment.htm
			try{
				$('anonymousName').value=person.nickname;
				$('currentUserId').value=person.id;
				$('anonymousName').readOnly=true;
				$('anonymousName').disabled = true;
				
				$('cmt_login_btn').innerHTML ="欢迎您，"+person.nickname;
				
				pinglunOLDAnonymousName = $('anonymousName').value;
			}catch(e){
				//alert('该页面不包含评论div模块');
			};
			
			//适用commentList.htm
			try{
				$('top_anonymousName').value=person.nickname;
				$('currentUserId').value=person.id;
				pinglunOLDAnonymousName = $('top_anonymousName').value;
			}catch(e){
				//alert('该页面不包含评论div模块');
			};
			
			//适用博客页面，打开前台博客设置按钮
			try{
				//alert(person.id +" "+$('weblogUserId').value);
				showManagerWeblogFromFront(person.id , $('weblogUserId').value);
			}catch(e){
				//alert('该页面不包含评论div模块');
			};
			
			//显示博客博主删除帖子按钮
			try{
				//alert(person.id +" "+$('weblogUserId').value);
				showManagerBLogDeleteForumCommentBtn(person.id , $('weblogUserId').value);
			}catch(e){
				//alert('该页面不包含评论div模块');
			};
			
			//适用eguide页面，打开eguide后台管理设置按钮
			//try{
				//if(person.eguide != null && person.eguide !='undefined')
				//	managerEguideId = person.eguide.id;
				//	if($('currentEguideId').value !="" && $('currentEguideId').value==managerEguideId){
				//		$('manageEguideDIV').style.display='block';
				//	}
			//}catch(e){
				//alert('该页面不包含eguide页面');
			//};
			
			
			//适用前台文章页面，打开文章内容
			try{
				showArticleByUser(person);
			}catch(e){
				//alert('该页面不包含文章div模块');
			};
			
			//适用论坛文章页面，判断是否为版主,添加跟帖删除按钮
			try{
				showManagerDeleteForumCommentBtn(person);
				
			}catch(e){
				//alert('该页面不包含论坛div模块');
			};
			
			
			//适用论坛版块列表类页面，判断是否为版主,添加帖子管理按钮 (论坛版块列表类)
			try{
				showManagerForumCommentBtn(person);
			
			}catch(e){
				//alert('该页面不包含论坛div模块');
			};
			
			

			
			//适用论坛文章页面，判断是否为楼主,添加修改按钮
			//try{
				
			//	if(person.id==$('currentForumCommentLZ').value){
			//		$('modifyForumCommentZT').style.display='inline';
			//	}
			//}catch(e){
				//alert('该页面不包含论坛div模块');
			//};
			
		}
		
	}
	// 使用 prototype 进行ajax调用
	//var action =systemPath +"/user/checkLogin.action?"+new Date();
	var action =systemPath +"/user/checkLogin.action?"+new Date();
	//var action ="http://localhost:8000/semi/user/checkLogin.action";
	
	//alert(action);
	new Ajax.Request(action, {method: 'get', onSuccess: loginSuccess_callback, onFailure: function(){; } });
	
	
	//======================================================================
	
	//var writeImpressionRecord_callback = function(transport) {}
	//var action_impressionRecord =systemPath +"/customstat/addImpressionRecord.action?"+new Date();
	//alert(action_impressionRecord);
	//new Ajax.Request(action_impressionRecord, {method: 'get', onSuccess: writeImpressionRecord_callback, onFailure: function(){; } });
	//======================================================================
}

function systemUserLogin(){
	var j_uname = $('j_username').value;
	var j_upass = $('j_password').value;
	
	if(j_uname =='' || j_upass ==''){
		alert('用户名或密码不能为空！');return;
	}
	var success_callback = function(transport) {
		var resultHtml = transport.responseText || '';
		//alert(resultHtml);
		if(resultHtml != ''){
			//var person = JSON.parse(resultHtml);
			var person = eval("("+resultHtml+")");
			//$('login_user_info').innerHTML = resultHtml;
			//alert($('login_user_info').innerHTML);
			//$('login_user_info').style.display='block';
			$('abcd').innerHTML= toolbarLoginSuccessMessage(person);
			
			//removeObj();
			//document.body.removeChild(bgObj);//删除背景层Div
		    //document.getElementById("msgDiv").removeChild(title);//删除提示框的标题栏
		    //document.body.removeChild(msgObj);//删除提示框层
		    
		    
		    try{
				Lightview.hide();
			}catch(e){
				//alert('关闭登陆窗口出错');
			};
		    
		    
		    //在article页登陆时，刷新评论页面
		    try{
				$('jjk').src = $('jjk').src+"&"+new Date();
			}catch(e){
				//alert('该页面不包含评论div模块');
			};
		    
		    
		    
		    //填充页面中的currentUserId
		    try{
				$('currentUserId').value=person.id;
			}catch(e){
				//alert('该页面不包含 currentUserId input');
			};
			
			//填充页面中的anonymousName
		    try{
				$('anonymousName').value=person.nickname;
				$('anonymousName').disabled = true;
				$('cmt_login_btn').innerHTML ="欢迎您，"+person.nickname;
			}catch(e){
				//alert('该页面不包含 anonymousName input');
			};
			
			
			//适用页面中包含二次登陆的按钮
			try{
				$('content_login_user_info').style.display='none';
				
			}catch(e){
				//alert('该页面不包含二次登陆的按钮模块');
			};
			
			//适用博客页面，打开前台博客设置按钮
			try{
				//alert(person.id +" "+$('weblogUserId').value);
				showManagerWeblogFromFront(person.id , $('weblogUserId').value);
			}catch(e){
				//alert('该页面不包含评论div模块');
			};
			
			//显示博客博主删除帖子按钮
			try{
				//alert(person.id +" "+$('weblogUserId').value);
				showManagerBLogDeleteForumCommentBtn(person.id , $('weblogUserId').value);
			}catch(e){
				//alert('该页面不包含评论div模块');
			};
			
			//适用eguide页面，打开eguide后台管理设置按钮
			//try{
			//	if(person.eguide != null && person.eguide !='undefined')
			//		managerEguideId = person.eguide.id;
			//		if($('currentEguideId').value !="" && $('currentEguideId').value==managerEguideId){
			//			$('manageEguideDIV').style.display='block';
			//		}
			//}catch(e){
				//alert('该页面不包含eguide页面');
			//};
			
			//适用前台文章页面，打开文章内容
			try{
				showArticleByUser(person);
			}catch(e){
				//alert('该页面不包含文章div模块');
			};
			
			
			
			
			
			//适用论坛文章页面，判断是否为版主,添加跟帖删除按钮
			try{
				showManagerDeleteForumCommentBtn(person);
			}catch(e){
				//alert('该页面不包含论坛div模块');
			};
			
			//适用论坛版块列表类页面，判断是否为版主,添加帖子管理按钮 (论坛版块列表类)
			try{
				showManagerForumCommentBtn(person);
			
			}catch(e){
				//alert('该页面不包含论坛div模块');
			};
			
			//适用论坛文章页面，判断是否为楼主,添加修改按钮
			//try{
				
			//	if(person.id==$('currentForumCommentLZ').value){
			//		$('modifyForumCommentZT').style.display='inline';
			//	}
			//}catch(e){
				//alert('该页面不包含论坛div模块');
			//};
			

		}else{
			$('wronguserpass').style.display='block';
		}
		
	}
	var action =systemPath +"/user/login.action";
	var params = "j_username="+j_uname+"&j_password="+j_upass+"&reqid=" +new Date();
	new Ajax.Request(action, {method: 'post',parameters:params, onSuccess: success_callback, onFailure: function(){ alert('暂时无法登陆...') } });
}

function gotoRegisters(){
	location.href=systemPath+"/user/registUserMax.action";
}


var indexWeblogPageName ="/weblog/index.html";
function gotoWeblogIndex(url){
	//location.href= url;
	location.href=systemPath+indexWeblogPageName;
}




function systemLogout(){
	var logoutSuccess_callback = function(transport) {
		parent.window.location.reload(true);
	}
	
	
	// 使用 prototype 进行ajax调用
	var action =systemPath +"/user/logout.action?"+new Date();
	//alert(action);
	new Ajax.Request(action, {method: 'get', onSuccess: logoutSuccess_callback, onFailure: function(){; } });

}

function showArticleByUser(person){
	//适用前台文章页面，打开文章内容
	try{
		var v_article_readType = $('article_readType').value;
		if(v_article_readType =='1'){//登陆用户
			$('endText').style.display='block';
			$('articleMessageBox').style.display='none';
		}
		if(v_article_readType==2 && person.usertype==1){//vip用户
			$('endText').style.display='block';
			$('articleMessageBox').style.display='none';
		}else  if(v_article_readType==2 && person.usertype==0){//普通用户改变提示信息
			$('articleMessageBox').innerHTML='对不起，只有vip用户方可看到该文章的具体内容！';
		}
	}catch(e){
		//alert('该页面不包含文章div模块');
	};
}

function showManagerWeblogFromFront(currentUserId , weblogUserId){
	if(currentUserId != 'undefined' && weblogUserId != 'undefined' && currentUserId != null && currentUserId != "" && weblogUserId != null && weblogUserId != "" ){
		if(currentUserId==weblogUserId){
			$('optionNav').style.display='block';
		}
	}
}







//显示博客博主删除帖子按钮
function showManagerBLogDeleteForumCommentBtn(currentUserId , weblogUserId){
	if(currentUserId != 'undefined' && weblogUserId != 'undefined' && currentUserId != null && currentUserId != "" && weblogUserId != null && weblogUserId != "" ){
		
		if(currentUserId==weblogUserId){
			var v_tdc = document.getElementsByName('blogToDeleteComment');
			if(v_tdc != null && v_tdc !='undefined'){
				for(var v_ti=0;v_ti<v_tdc.length;v_ti++){
					v_tdc[v_ti].style.display='block';
				}
			}
		}
	}			
	
}








//显示版主删除帖子按钮
function showManagerDeleteForumCommentBtn(person){
	var currentForumCategoryId = document.getElementById('currentForumCategoryId');
	//alert(currentForumCategoryId);
				
	if(currentForumCategoryId != 'undefined' && currentForumCategoryId != null && currentForumCategoryId != ""){
		var myForumHostIdList = person.myForumHostIdList;
		if(myForumHostIdList != null && myForumHostIdList != 'undefined'){
			for(var mi=0;mi<myForumHostIdList.length;mi++){
				if(currentForumCategoryId.value==myForumHostIdList[mi]){
					//alert('成功:'+managerForumIds[mi]);
					var v_tdc = document.getElementsByName('toDeleteComment');
					if(v_tdc != null && v_tdc !='undefined'){
						for(var v_ti=0;v_ti<v_tdc.length;v_ti++){
							v_tdc[v_ti].style.display='inline';
						}
					}
					//document.getElementById('manageForumSpan').style.display='block';
					return;
				}
			}
		}
	}
}
//显示帖子管理按钮(论坛版块列表类)
function showManagerForumCommentBtn(person){
	var currentForumColumn = document.getElementById('currentForumColumnId');
	var factorybbsBtn = document.getElementById('factorybbs');
	
	if(currentForumCategoryId != 'undefined' && currentForumCategoryId != null && currentForumCategoryId != ""){
		var myForumHostIdList = person.myForumHostIdList;
		if(myForumHostIdList != null && myForumHostIdList != 'undefined'){
			for(var mi=0;mi<myForumHostIdList.length;mi++){
				if(currentForumCategoryId.value==myForumHostIdList[mi]){
					//alert('成功:'+managerForumIds[mi]);
					if(factorybbsBtn != null && factorybbsBtn !='undefined'){
						factorybbsBtn.style.display='inline';
					}
					//document.getElementById('manageForumSpan').style.display='block';
					return;
				}
			}
		}
	}			
	
}






function openPopup(url,windowname,w,h){
  var intTop = 0;
  var intLeft = 0;
  var winWidth = window.screen.availWidth-12;
  var winHeight = window.screen.availHeight-50;
  var scrollNorY='no';
  if(parseInt(h) == 8888){
	 //如果高度为8888,那么全屏显示
	 w=window.screen.availWidth-12;
	 h=window.screen.availHeight-50;}
  else{ //从中间呈现


		intTop = (window.screen.availHeight-parseInt(h))/2;
		intLeft = (window.screen.availWidth-parseInt(w))/2;
		if (intTop < 30)	intTop = 0;
		if (intLeft < 30)	intLeft = 0;}
  if(w > winWidth){
     w=winWidth;
	 scrollNorY='yes';
  }
  if(h > 699) scrollNorY='yes';
  if(h > winHeight){
     if(h==5555) scrollNorY='no';
	 else scrollNorY='yes';
	 h=winHeight;
  }
  var windowconfig = "status=no,scrollbars=" + scrollNorY + ",top="+ intTop +",left="+ intLeft  +",resizable=0,width=" + w + ",height=" + h;
  subwin=window.open(url, windowname, windowconfig);
  if(subwin){
	 subwin.focus();
	 return subwin;
  }
}












var initWronguserpass = "用户名或密码错误<br/>";
var loginFormHTML ="<span id='wronguserpass' style='color:red;display:none;'>"+initWronguserpass+"</span>用户名:<input type='text' id='j_username'  name='j_username' class='text' size=20 value=''/><br/><br/>密&nbsp;&nbsp;码:<input type='password' id='j_password'  name='j_password' class='text'   size=21  value=''/><br/><br/>"+"<input type='button' value='登录' class='button' style='height:20px;' onclick='javascript:systemUserLogin();'/>&nbsp;&nbsp;"+"<input type='button' value='注册' style='height:20px;' class='button' onclick='gotoRegisters();'/>";

var bgObj;
var msgObj;
var title;
function sAlert(str){
  //alert();
  str = loginFormHTML;
  var msgw,msgh,bordercolor;
  msgw=300;//提示窗口的宽度
  msgh=200;//提示窗口的高度
  titleheight=25 //提示窗口标题高度
  bordercolor="#336699";//提示窗口的边框颜色
  titlecolor="#99CCFF";//提示窗口的标题颜色

  var sWidth,sHeight;
  sWidth=document.body.offsetWidth;//浏览器工作区域内页面宽度
  sHeight=screen.height;//屏幕高度（垂直分辨率）


  //背景层（大小与窗口有效区域相同，即当弹出对话框时，背景显示为放射状透明灰色）
  //var bgObj=document.createElement("div");//创建一个div对象（背景层）
  bgObj=document.createElement("div");//创建一个div对象（背景层）
  //定义div属性，即相当于
  //<div id="bgDiv" style="position:absolute; top:0; background-color:#777; filter:progid:DXImagesTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75); opacity:0.6; left:0; width:918px; height:768px; z-index:10000;"></div>
  bgObj.setAttribute('id','bgDiv');
  bgObj.style.position="absolute";
  bgObj.style.top="0";
  bgObj.style.background="#777";
  bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
  bgObj.style.opacity="0.6";
  bgObj.style.left="0";
  bgObj.style.width=sWidth + "px";
  bgObj.style.height=sHeight + "px";
  bgObj.style.zIndex = "10000";
  document.body.appendChild(bgObj);//在body内添加该div对象


 // var msgObj=document.createElement("div")//创建一个div对象（提示框层）
  msgObj=document.createElement("div")//创建一个div对象（提示框层）
  //定义div属性，即相当于
  //<div id="msgDiv" align="center" style="background-color:white; border:1px solid #336699; position:absolute; left:50%; top:50%; font:12px/1.6em Verdana,Geneva,Arial,Helvetica,sans-serif; margin-left:-225px; margin-top:npx; width:400px; height:100px; text-align:center; line-height:25px; z-index:100001;"></div>
  msgObj.setAttribute("id","msgDiv");
  msgObj.setAttribute("align","center");
  msgObj.style.background="white";
  msgObj.style.border="1px solid " + bordercolor;
  msgObj.style.position = "absolute";
  msgObj.style.left = "50%";
  msgObj.style.top = "50%";
  msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
  msgObj.style.marginLeft = "-225px" ;
  msgObj.style.marginTop = -75+document.documentElement.scrollTop+"px";
  msgObj.style.width = msgw + "px";
  msgObj.style.height =msgh + "px";
  msgObj.style.textAlign = "center";
  msgObj.style.lineHeight ="25px";
  msgObj.style.zIndex = "10001";
  
  //var title=document.createElement("h4");//创建一个h4对象（提示框标题栏）
  title=document.createElement("h4");//创建一个h4对象（提示框标题栏）
  //定义h4的属性，即相当于
  //<h4 id="msgTitle" align="right" style="margin:0; padding:3px; background-color:#336699; filter:progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100); opacity:0.75; border:1px solid #336699; height:18px; font:12px Verdana,Geneva,Arial,Helvetica,sans-serif; color:white; cursor:pointer;" onclick="">关闭</h4>
  title.setAttribute("id","msgTitle");
  title.setAttribute("align","right");
  title.style.margin="0";
  title.style.padding="3px";
  title.style.background=bordercolor;
  title.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);";
  title.style.opacity="0.75";
  title.style.border="1px solid " + bordercolor;
  title.style.height="18px";
  title.style.font="12px Verdana, Geneva, Arial, Helvetica, sans-serif";
  title.style.color="white";
  title.style.cursor="pointer";
  title.innerHTML="关闭";
  title.onclick=removeObj;

  //var button=document.createElement("input");//创建一个input对象（提示框按钮）
  //定义input的属性，即相当于//<input type="button" align="center" style="width:100px; align:center; margin-left:250px; margin-bottom:10px;" value="关闭">
  //button.setAttribute("type","button");
  //button.setAttribute("value","关闭");
 // button.style.width="60px";
 // button.style.align="center";
  //button.style.marginLeft="250px";
  //button.style.marginBottom="10px";
 //button.style.background=bordercolor;
 // button.style.border="1px solid "+ bordercolor;
 // button.style.color="white";
  //button.onclick=removeObj;
  
  function removeObj(){//点击标题栏触发的事件
    document.body.removeChild(bgObj);//删除背景层Div
    document.getElementById("msgDiv").removeChild(title);//删除提示框的标题栏
    document.body.removeChild(msgObj);//删除提示框层
  }
  document.body.appendChild(msgObj);//在body内添加提示框div对象msgObj
  document.getElementById("msgDiv").appendChild(title);//在提示框div中添加标题栏对象title

  var txt=document.createElement("p");//创建一个p对象（提示框提示信息）
  //定义p的属性，即相当于
  //<p style="margin:1em 0;" id="msgTxt">测试效果</p>
  txt.style.margin="1em 0"
  txt.setAttribute("id","msgTxt");
  txt.innerHTML=str;//来源于函数调用时的参数值
  document.getElementById("msgDiv").appendChild(txt);//在提示框div中添加提示信息对象txt
  //document.getElementById("msgDiv").appendChild(button);//在提示框div中添加按钮对象button
}



function checkIsLogin(){
	var flag = false;
	var currentUserId_ = $('currentUserId').value;
	if(currentUserId_==""){
		alert("您还没有登陆,请先登陆!");
		Lightview.show('ajaxformLogin');
	}else{
		flag = true;
	}
	return flag;
}

function showMagazine(url){
	if(!checkIsLogin()){
		return;
	}else
		window.location.href=url;
}





function gotoPageByCheckIsLogin(url){
	if(!checkIsLogin()){
		return;
	}else
		window.open(url);
		//window.location.href=url;
}

function turnToPageByCheckIsLogin(url){
	if(!checkIsLogin()){
		return;
	}else
		window.location.href=url;
}
function resourceUploadCheckIsLogin(){
	if(!checkIsLogin()){
		return;
	}else
		window.location.href=systemPath +"/myspace/manager/addResource.action";
}


//JS获取客户端IP
function GetLocalIPAddress()
{
    var obj = null;
    var rslt = "";
    try
    {
        obj = new ActiveXObject("rcbdyctl.Setting");
        rslt = obj.GetIPAddress;
        obj = null;
    }
    catch(e)
    {
        //异常发生
    }
   
    return rslt;
}


function getLocalCurrentDate(){
	var myDate = new Date();
	var _year = myDate.getYear();       //获取当前年份(2位)
    var _month = myDate.getMonth();      //获取当前月份(0-11,0代表1月)
    var _date = myDate.getDate();       //获取当前日(1-31)
    //myDate.toLocaleDateString();  //获取当前日期
    
    return _year+""+_month+""+_date;
}

var sitePrefix ="";
function getPrefixCookieName(channelType){
	if(channelType=="1")
		return sitePrefix+ "index";
	if(channelType=="2")
		return sitePrefix+ "news";
	if(channelType=="3")
		return sitePrefix+ "forum";
	if(channelType=="4")
		return sitePrefix+ "blog";
	if(channelType=="5")
		return sitePrefix+ "group";
	if(channelType=="6")
		return sitePrefix+ "magazine";
	if(channelType=="8")
		return sitePrefix+ "eguide";

}


function writeUniqueHost(channelType){
	
	//alert(channelType);
	var myCookieName = "myfootprint1";
	//SetCookie(myCookieName,"xy");
	//deleteAllCookie();
	//delCookie(myCookieName);
	
	var currentChannelCookieFlag =false;
	var myfootprintValue = getCookieValue(myCookieName);
	//alert("a1:"+myfootprintValue);
	var myfootprintArr=myfootprintValue.split("*"); 
	var currentChannelTypePosition= -1;
	for(var i=0;i<myfootprintArr.length;i++){
		var channel_ = myfootprintArr[i].split("_"); 
		if(channel_[0]==getPrefixCookieName(channelType)){
			currentChannelTypePosition = i;
      		if(channel_[1]==getLocalCurrentDate()){
      			currentChannelCookieFlag=true;
      		}
      	}
	}
	if(!currentChannelCookieFlag){
		var myfootprintNewValue="";
		for(var i=0;i<myfootprintArr.length;i++){
			var channel_ = myfootprintArr[i].split("_"); 
			if(channel_ != 'undefined' && channel_.length >1){
				if(channel_[0]==getPrefixCookieName(channelType)){
					myfootprintNewValue = myfootprintNewValue + channel_[0] + "_" + getLocalCurrentDate()+"*";
		      	}else{
		      		myfootprintNewValue = myfootprintNewValue + channel_[0] + "_" + channel_[1]+"*";
		      	}
			}
		}
		if(currentChannelTypePosition == -1){
			myfootprintNewValue = myfootprintNewValue + getPrefixCookieName(channelType) +"_"+getLocalCurrentDate()+"*";
		}
		//alert('setting ' + "组装完后的值:"+myfootprintNewValue);
		SetCookie(myCookieName,myfootprintNewValue);
		
		
		var writeFootprint_callback = function(transport) {}
		var action =systemPath +"/customstat/writeUniqueHost.action?channelType="+channelType+"&"+new Date();
		new Ajax.Request(action, {method: 'get', onSuccess: writeFootprint_callback, onFailure: function(){; } });
		
		
		//myfootprintValue = getCookieValue(myCookieName);
		//alert(myfootprintValue);
	}
		
		//deleteAllCookie();
	
}

function writeImpressionRecordArticle(articleId , categoryId){
	var writeImpressionRecordArticle_callback = function(transport) {}
	var action_writeImpressionRecordArticle =systemPath +"/customstat/writeImpressionRecordArticle.action?articleId="+articleId+"&categoryId="+categoryId+"&"+new Date();
	//alert(action_writeImpressionRecordArticle);
	new Ajax.Request(action_writeImpressionRecordArticle, {method: 'get', onSuccess: writeImpressionRecordArticle_callback, onFailure: function(){; } });
		
}



function writeImpressionRecordWeblog(weblogId , weblogEntryId , categoryId){
	var writeImpressionRecordWeblog_callback = function(transport) {}
	var params="";
	if(weblogId != 'undefined' && weblogId != ""){
		params="?weblogId="+weblogId;
		if(weblogEntryId != 'undefined' && weblogEntryId != ""){
			params +="&weblogEntryId="+weblogEntryId;
			if(categoryId != 'undefined' && categoryId != ""){
				params +="&categoryId="+categoryId;
				
			}
		}
		params +="&"+new Date();
	}
	var action_writeImpressionRecordWeblog =systemPath +"/customstat/writeImpressionRecordWeblog.action"+params;
	//alert(action_writeImpressionRecordWeblog);
	new Ajax.Request(action_writeImpressionRecordWeblog, {method: 'get', onSuccess: writeImpressionRecordWeblog_callback, onFailure: function(){; } });
		
}


function writeImpressionRecordForumComment(forumCommentId , categoryId){
	var writeImpressionRecordForumComment_callback = function(transport) {}
	var params="";
	if(forumCommentId != 'undefined' && forumCommentId != ""){
		params="?forumCommentId="+forumCommentId;
		if(categoryId != 'undefined' && categoryId != ""){
			params +="&categoryId="+categoryId;
		}
		params +="&"+new Date();
	}
	var action_writeImpressionRecordForumComment =systemPath +"/customstat/writeImpressionRecordForumComment.action"+params;
	//alert(action_writeImpressionRecordWeblog);
	new Ajax.Request(action_writeImpressionRecordForumComment, {method: 'get', onSuccess: writeImpressionRecordForumComment_callback, onFailure: function(){; } });
		
}

function writeEguideDictionary(){
	var writeEguideDictionary_callback = function(transport) {}
	var params="?"+new Date();
	var action_writeEguideDictionary =systemPath +"/customstat/writeImpressionRecordEguideDictionary.action"+params;
	//alert(action_writeEguideDictionary);
	new Ajax.Request(action_writeEguideDictionary, {method: 'get', onSuccess: writeEguideDictionary_callback, onFailure: function(){; } });
		
}	

function updateWeblogVistitMap(visitWid){
	var updateWeblogVistitMap_callback = function(transport) {}
	var params="&"+new Date();
	var action_updateWeblogVistitMap =systemPath +"/weblog/component/updateWeblogVistitMap.action?visitWid="+visitWid+params;
	new Ajax.Request(action_updateWeblogVistitMap, {method: 'get', onSuccess: updateWeblogVistitMap_callback, onFailure: function(){; } });
		
}

