// global variables //
var TIMER = 4;
var SPEED = 10;
var WRAPPER = 'content_all';

// calculate the current window width //
function pageWidth() 
{
  return window.innerWidth != null ? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
}
//退出
do_user_logout = function(){
	var opt = {method: "post",onSuccess: do_user_logout_success,onFailure: processFailure} 
	new Ajax.Request(toUTF8("/user/doLogout.jhtml"), opt);	
}

//退出成功
do_user_logout_success = function(response){
		if (!processResponse(response)) {
			return;
		}
		isLogout = true;
		alert("退出成功");
		location.href ="/user/login.jhtml";
}
// calculate the current window height //
function pageHeight() 
{
  return window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;
}

// calculate the current window vertical offset //
function topPosition() 
{
  return typeof window.pageYOffset != 'undefined' ? window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;
}

// calculate the position starting at the left of the window //
function leftPosition() 
{
  return typeof window.pageXOffset != 'undefined' ? window.pageXOffset : document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;
}
function showSuccessDialog(message,autohide,loginUrl)
{
	showDialog("成功信息",message,"success",autohide,loginUrl);
}
function showErrorDialog(message,autohide,loginUrl) 
{  
	showDialog("错误信息",message,"error",autohide,loginUrl);
}
 
function showPromptDialog(title,message) 
{  
	showDialog(title,message,"prompt",false,'');
}


//拖动
//o表示div的id,是指标题栏,div表示整个的要移动的div
function dragDiv(o,div,s)  
{  

    if (typeof o == "string") o = document.getElementById(o);  
    if (typeof div == "string") div = document.getElementById(div);  
    o.orig_x = parseInt(o.style.left) - document.body.scrollLeft;  
    o.orig_y = parseInt(o.style.top) - document.body.scrollTop;  
    o.orig_index = o.style.zIndex;  
          
    o.onmousedown = function(a)  
    {  
        //this.style.cursor = "move";  
        this.style.zIndex = 10000;  
        var d=document;  
        if(!a)a=window.event;
 
        var x = a.clientX+d.body.offsetLeft-div.offsetLeft;  
        var y = a.clientY+d.body.offsetTop-div.offsetTop;  
        //author: www.longbill.cn  
        d.ondragstart = "return false;"  
        d.onselectstart = "return false;"  
        d.onselect = "document.selection.empty();"  
                  
        if(o.setCapture)  
            o.setCapture();  
        else if(window.captureEvents)  
            window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);  

        d.onmousemove = function(a)  
        {  
            if(!a)a=window.event;  
            div.style.left = a.clientX+document.body.offsetLeft-x;  
            div.style.top = a.clientY+document.body.offsetTop-y;  
            div.orig_x = parseInt(o.style.left) - document.body.scrollLeft;  
            div.orig_y = parseInt(o.style.top) - document.body.scrollTop;  
        }  

        d.onmouseup = function()  
        {  
            if(o.releaseCapture)  
                o.releaseCapture();  
            else if(window.captureEvents)  
                window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);  
            d.onmousemove = null;  
            d.onmouseup = null;  
            d.ondragstart = null;  
            d.onselectstart = null;  
            d.onselect = null;  
            o.style.cursor = "normal";  
            o.style.zIndex = o.orig_index;  
        }  
    }  
      
    if (s)  
    {  
        var orig_scroll = window.onscroll?window.onscroll:function (){};  
        window.onscroll = function ()  
        {  
            orig_scroll();  
            o.style.left = o.orig_x + document.body.scrollLeft;  
            o.style.top = o.orig_y + document.body.scrollTop;  
        }  
    }  
}

//加载页面时加载CSS  
var cssTag = document.createElement('link');
cssTag.setAttribute('rel','stylesheet');
cssTag.setAttribute('type','text/css');
cssTag.setAttribute('href','/css/dialog_box.css');
window.document.getElementsByTagName('head')[0].appendChild(cssTag);
	
// build/show the dialog box, populate the data and call the fadeDialog function //
function showDialog(title,message,type,autohide,loginUrl) {
  if(!type) {
	type = 'error';
  }

  var dialog;
  var dialogheader;
  var dialogclose;
  var dialogtitle;
  var dialogcontent;
  var dialogmask;
  if(!document.getElementById('dialog')) {
    dialog = document.createElement('div');
    dialog.id = 'dialog';
    dialogheader = document.createElement('div');
    dialogheader.id = 'dialog-header';
    dialogtitle = document.createElement('div');
    dialogtitle.id = 'dialog-title';
	dialogclose = document.createElement('div');
    dialogclose.id = 'dialog-close'
    dialogcontent = document.createElement('div');
    dialogcontent.id = 'dialog-content';
    dialogmask = document.createElement('div');
    dialogmask.id = 'dialog-mask';
    document.body.appendChild(dialogmask);
    document.body.appendChild(dialog);
    dialog.appendChild(dialogheader);
	dialogheader.appendChild(dialogtitle);
	dialogheader.appendChild(dialogclose);
    dialog.appendChild(dialogcontent);;
	dialogclose.setAttribute('onclick','closeDialog()');
	dialogclose.onclick = closeDialog;
  } else {
    dialog = document.getElementById('dialog');
    dialogheader = document.getElementById('dialog-header');
    dialogtitle = document.getElementById('dialog-title');
    dialogclose = document.getElementById('dialog-close');
    dialogcontent = document.getElementById('dialog-content');
	dialogmask = document.getElementById('dialog-mask');
    dialogmask.style.visibility = "visible";
    dialog.style.visibility = "visible";

  }
  if(!autohide)
      dragDiv("dialog-header","dialog");
       
  dialog.style.opacity = .00;
  dialog.style.filter = 'alpha(opacity=0)';
  dialog.alpha = 0;
  var width = pageWidth();
  var height = pageHeight();
  var left = leftPosition();

  var top = topPosition();
  var dialogwidth = dialog.offsetWidth;
  var dialogheight = dialog.offsetHeight;
  var topposition = top + (height / 3) - (dialogheight / 2);
  var leftposition = left + (width / 2) - (dialogwidth / 2);
  dialog.style.top = topposition + "px";
  dialog.style.left = leftposition + "px";
  dialogheader.className = type + "header";
  dialogtitle.innerHTML = title;
  dialogcontent.className = type;
  dialogcontent.innerHTML = message;
  //var content = document.getElementById(WRAPPER);
  //dialogmask.style.height = content.offsetHeight + 'px';
  dialogmask.style.height = document.body.offsetHeight+'px';
  dialog.timer = setInterval("fadeDialog(1)", TIMER);
  if(autohide) {
	dialogclose.style.visibility = "hidden";
	//alert(autohide);
    window.setTimeout("hideDialog("+loginUrl+")", (TIMER * 1000));

  } else {
	dialogclose.style.visibility = "visible";
  }
  
}

// hide the dialog box //
function hideDialog(loginUrl) {
  var dialog = document.getElementById('dialog');
  dialog.timer = setInterval("fadeDialog(0)", TIMER);
  if(loginUrl!=null&&typeof loginUrl!='undefined'&&loginUrl!='')
  {
  	window.setTimeout(loginUrl,1000);
  }
}
// hide the dialog box //
function closeDialog() {
  var dialog = document.getElementById('dialog');
  dialog.timer = setInterval("fadeDialog(0)", TIMER);
}
// fade-in the dialog box //
function fadeDialog(flag) {
  if(flag == null) {
	flag = 1;
  }
  var dialog = document.getElementById('dialog');
  var value;
  if(flag == 1) {
    value = dialog.alpha + SPEED;
  } else {
    value = dialog.alpha - SPEED;
  }
  dialog.alpha = value;
  dialog.style.opacity = (value / 100);
  dialog.style.filter = 'alpha(opacity=' + value + ')';
  if(value >= 99) {
    clearInterval(dialog.timer);
  } else if(value <= 1) {
    dialog.style.visibility = "hidden";
    document.getElementById('dialog-mask').style.visibility = "hidden";
	clearInterval(dialog.timer);
  }
}



function showDIV(){
	var createId = document.getElementById(arguments[0]);
	var operateId = document.getElementById(arguments[1]);
	createId.style.display='none';
	operateId.style.display='block';
	//createId.style.setProperty('display','none','');
	//operateId.style.setProperty('display','block','');
}

function hiddenDIV(){
	var createId = document.getElementById(arguments[0]);
	var operateId = document.getElementById(arguments[1]);
	createId.style.display='block';
	operateId.style.display='none';
}

function toUTF8(szInput){ 
 var wch,x,uch="",szRet="";
 for (x=0; x<szInput.length; x++){
  wch=szInput.charCodeAt(x);
  if (!(wch & 0xFF80)){
   szRet += szInput.charAt(x);
  }
  else if (!(wch & 0xF000)){
   uch = "%" + (wch>>6 | 0xC0).toString(16) + 
      "%" + (wch & 0x3F | 0x80).toString(16);
   szRet += uch; 
  }
  else{
   uch = "%" + (wch >> 12 | 0xE0).toString(16) + 
      "%" + (((wch >> 6) & 0x3F) | 0x80).toString(16) +
      "%" + (wch & 0x3F | 0x80).toString(16);
   szRet += uch; 
  }
 }
 return(szRet);
}


//
function goSelectAll(ids){
		var boxChecked = document.getElementsByName(ids);
		var flag = true;
		for(var i = 0 ; i < boxChecked.length; i++)
		{
			if (boxChecked[i].checked == false){
				flag = false;
				break;
			}
		}
		//alert(flag);
		if( flag == true ){
			for(var i = 0 ; i < boxChecked.length; i++){
				boxChecked[i].checked = false;
			}
		}else{
			for(var i = 0 ; i < boxChecked.length; i++){
				boxChecked[i].checked = true;
			}
		}
}
goDelete = function(id){
	goSelect.call(this,id,'ids');
	doDelete();
}

//
function goSelect(id,ids){
	var boxChecked = document.getElementsByName(ids);
	for(var i = 0 ; i < boxChecked.length; i++){
		if(boxChecked[i].value == id){
			boxChecked[i].checked = true;
		}
	}
}
//
function  goValidationSelect(ids){
	var boxChecked = document.getElementsByName(ids);
	var flag = false;
	//alert(ids.length);
	for(var i = 0 ; i < boxChecked.length; i++){
		if(boxChecked[i].checked == true){
		  flag = true;
		}
	}
	//alert(flag);
	return flag;
}

//
function requestController(formName,controllerPage,processSuccess){
	opt = {method: 'post',postBody: Form.serialize($(formName)),onSuccess:processSuccess,onFailure:processFailure}
	new Ajax.Request(controllerPage,opt);
} 

	processFailure = function(){
		alert('网络访问中断，请检查您的网络!');
	}
	
	
function goExchangeEditPage(userName)
{
	var exchangeCategory = document.getElementById("exchangeCategory").value;
	do_blog_exchange_edit(userName, exchangeCategory);
}
//
function   Unicode2Str(str){    
    var   re=/&#[\da-fA-F]{1,5};/ig;    
    var   arr=str.match(re);    
    if(arr==null)return( " ");    
    var   size=arr.length;    
    var   arr2=new   Array(size);    
    for(var   i=0;i <arr.length;i++){    
        arr2[i]=String.fromCharCode(arr[i].replace(/[&#;]/g, " "));    
    }    
    for(var   i=0;i <arr.length;i++){    
        str=str.replace(arr[i],arr2[i]);    
    }    
    //return(arr.toString().replace(/,/g, " "))    
    return   str;    
}  




function processResponse(response, callback) {

	var responseData = eval("(" + response.responseText.replace(/[\r\n]/g,"") + ")");
	if (responseData.result == 0) {
		//成功
		if (callback) {
			callback();
		}
		return true;
	}
	
	switch (responseData.result) {
	case 1: //未登录
		blog_login('/user/login.jhtml');
		break;
 	case 2:	//没有权限
		alert(responseData.message);
		break;
	case 3: //验证异常
		alert(responseData.message);
		break;
	case 4: //服务错误
		alert(responseData.message);
		break;
	case 5: //服务器内部错误
		alert(responseData.message);
		break;
	}
	
	return false;
}

function checkAim(object)
{
	if (object.value == 0)
	{
		document.getElementById("userByReceiveUserId").disabled=false;
		document.getElementById("friendRelationId").disabled=true;
	}
	else if (object.value == 1)
	{
		document.getElementById("userByReceiveUserId").disabled=true;
		document.getElementById("friendRelationId").disabled=false;
	}
	else
	{
		document.getElementById("userByReceiveUserId").disabled=true;
		document.getElementById("friendRelationId").disabled=true;
	}
}

//-----------------------------ajax history begin---------------------------------------------
//ajax历史记录
//需要使用<script src="/js/dhtmlHistory.js" type="text/javascript"></script>
//同时在<body onload="historyInit('cont');">其中cont是默认加载的ElementId
hash_num=0;//历史记录桢
function historyTrack(rn)//rn是xmlhttp请求成功后返回的对象
{	
	hash_num++;
	$(this.elementId).innerHTML=rn.responseText;
	new_hash="track" + hash_num;

	//给dhtmlHistory增加一个容器，以new_hash为指针保存返回的数据，并把hash改为#new_hash
	dhtmlHistory.add(new_hash,rn.responseText);
	
}


//初始化history
function historyInit(elementId)
{
	 this.elementId = elementId
     dhtmlHistory.initialize();
	 //建立一个监听，当有回退或前进动作发生，这个监听函数将会执行
	dhtmlHistory.addListener(changeHistory);

}

//当有前进或后退动作发生，执行这个changeHistory
//current_hash 当前的hash
//v 当前hash下的值
function changeHistory(new_hash,v)
{
	$(this.elementId).innerHTML=v;
}
//-------------------------------ajax history end-------------------------------------------

function showFCK(){
  var oFCKeditor = new FCKeditor( 'fbContent' ) ;
  oFCKeditor.BasePath = '/FCKeditor/' ;
  oFCKeditor.ToolbarSet = 'Default' ;
  oFCKeditor.Width = '100%' ;
  oFCKeditor.Height = '400' ;
  oFCKeditor.ReplaceTextarea() ;
 }

function selectIEOrFireFox(){
	var navigatorType = ""; 
  	if(navigator.userAgent.indexOf("MSIE")>0) { 
        navigatorType = "MSIE"; 
   	} 
   	if(isFirefox=navigator.userAgent.indexOf("Firefox")>0){ 
        navigatorType = "Firefox"; 
   	} 
	return navigatorType;
}


//显示或隐藏指定的容器
//function showNodes(opDiv){
//var oDiv = document.getElementById(opDiv);
//	if(oDiv.style.display == 'none'){
		//oDiv.style.displaya = 'block';
//		Element.show(oDiv);
//	}else{
//		Element.hide(oDiv);
		//oDiv.style.displaya = 'none';
//	}
//}

function showNodes(opDiv,opSpan){
	var oDiv = $(opDiv);
	var oSpan = $(opSpan);
     var objDiv = document.getElementsByTagName("div");	 
	 var objSpan = document.getElementsByTagName("td");
	 
	 for (var i=0;i<objDiv.length;i++)
	 {
		  var id = objDiv.item(i).id; 
 
		  if(id.slice(0,5)=="show_" && oDiv.id != id ){
			
			$(id).style.display = 'none';
			
		}
	}
	for (var j=0;j<objSpan.length;j++)
	 {
		var sid = objSpan.item(j).id;
		 
		if(sid.slice(0,4) == "span"){
			if(oSpan.id != sid){
				$(sid).style.background = 'url(/images/+.gif) ';
			}
		}
	}
	if(oDiv.style.display == 'none'){
		oDiv.style.display = 'block';
		
		oSpan.style.background = 'url(/images/03.JPG) ';
		Element.show(oDiv);
	}
	else{
		
		Element.hide(oDiv);
		oDiv.style.display = 'none';
		oSpan.style.background = 'url(/images/+.gif) ';
	}
}

function go_admin_index(){
	window.parent.location.href="/admin/index.jhtml";	
}

//验证用户名是否存在！
//需要参数（form名称，按钮ID）
function validationName(formName, button){
	this.button = button;
	var userName = document.getElementById("name").value;
	
	if(userName != ""){
		var opt = {method: "post", postBody: Form.serialize($(formName)), onSuccess: validationName_success, onFailure: processFailure};
		new Ajax.Request(toUTF8("/user/doValidation.jhtml"), opt);
	}
}

function validationName_success(response){
	if (!processResponse(response)) {
		return;
	}
	var responseData = eval("(" + response.responseText.replace(/[\r\n]/g,"") + ")");
	//alert(responseData.data.returnMessage);
	
	if(responseData.data.returnMessage == ""){
		Element.update("validateName_error","");
		$(this.button).disabled = false;
	}else{
		Element.update("validateName_error","<font color='red'>对不起，用户名已被占用！</font>");
		$(this.button).disabled = true;
	}
}

//除去字符串的空格
 validatorTrim = function(s) {
	 	if(s == "undefined"){
			return "";
		}
    	var m = s.match(/^\s*(\S+(\s+\S+)*)\s*$/);
   		return (m == null) ? "" : m[1];
	}

//检验空值	
validateNull = function(currentObj, submitDiv){
	var showObj = currentObj.id + "_error";
	var s_div = $(submitDiv);
	if(validatorTrim(currentObj.value) == ""){
		Element.show($(showObj));
		s_div.disabled = true;
	}else{
		Element.hide($(showObj));
		s_div.disabled = false;
	}
}


//从文档节点中删除某一节点
hiddenDiv = function(pDiv){
	var oDiv = $(pDiv);
	document.body.removeChild(oDiv);
	Element.hide(oDiv);
}

_isDelete = function(){
	if(confirm("您确定删除吗?此操作将不能恢复!")){
			return true;
		}else{
			return false;
		}
}
function UrlEncode(str)
{
		var i,c,ret="",strSpecial="!\"#$%&'()*+,/:;<=>?@[\]^`{|}~%";
		for(i=0;i<str.length;i++){
		if(str.charCodeAt(i)>=0x4e00){
		c=qswhU2GB[str.charCodeAt(i)-0x4e00];
		ret+="%"+c.slice(0,2)+"%"+c.slice(-2);
		}else{
		c=str.charAt(i);
		if(c==" ")
		ret+="+";
		else if(strSpecial.indexOf(c)!=-1)
		ret+="%"+str.charCodeAt(i).toString(16);
		else
		ret+=c;
		}
		}
		return ret;
}

function UrlDecode(str)
{
		var i,c,d,t,p,ret="";
		function findPos(str){
		for(var j=0;j<qswhU2GB.length;j++){
		if(qswhU2GB[j]==str){return j;}
		}
		return -1;
		}
		for(i=0;i<str.length;){
		c=str.charAt(i);i++;
		if(c!="%"){
		if(c=="+"){
		ret+=" ";
		}else{
		ret+=c;
		}
		}else{
		t=str.substring(i,i+2);i+=2;
		if(("0x"+t)>0xA0){
		d=str.substring(i+1,i+3);i+=3;
		p=findPos(t+d);
		if(p!=-1){
		ret+=String.fromCharCode(p+0x4e00);
		}
		}else{
		ret+=String.fromCharCode("0x"+t);
		}
		}
		}
		return ret;
}

function upFileResult(f_name){
	alert(f_name)
	op_method = f_name;
	}
	
//文件上传JS	 参数有五个action, methodName,returnDiv, fileType, fileSize.
	//前两个参数为必填, 后两个参数如果不填写，用空符串表示''.
	//action: 'open' 表示打开窗口. 'close' 表示关窗口
	//methodName:  上传完成后回调的JS处理方法.
	//returnDiv:
	//filleType: 文件上传的类型,必须带小数点，多种类型中间用逗号分开（例如:'.jpg' ; '.jpg,.gif,.txt'
	//fileSize: 文件上传大小最大值.以B为单位）;
function uplodFile(action,methodName,returnDiv,fileType,fileSize ) {
	//alert(methodName);
	var objs = document.getElementsByTagName("OBJECT");
	if(action == 'open') {
	m_name = methodName;
		for(i = 0;i < objs.length; i ++) {
			if(objs[i].style.visibility != 'hidden') {
				objs[i].setAttribute("oldvisibility", objs[i].style.visibility);
				objs[i].style.visibility = 'hidden';
			}
		}
		var clientWidth = document.body.clientWidth;
		var clientHeight = document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
		var scrollTop = document.body.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop;
		var pmwidth = 500;
		var pmheight = clientHeight * 0.2 + 70;
		if(!$('messageBoxDiv')) {
			div = document.createElement('div');div.id = 'messageBoxDiv';
			div.style.width = pmwidth + 'px';
			div.style.height = pmheight + 'px';
			div.style.left = ((clientWidth - pmwidth) / 2) + 'px';
			div.style.position = 'absolute';
			div.style.zIndex = '999';
			$('append_parent').appendChild(div);
			$('messageBoxDiv').innerHTML = '<div style="width: 500px; background: #ccc; margin: 5px auto; text-align: left">' +
				'<div style="width: 500px; height: ' + pmheight + 'px; padding: 1px; border: 1px solid #7597B8; border-bottom: 1px solid #eee; position: relative; left: -6px; top: -3px">' +
				'<div onmouseover="pmwindrag(this)" style="cursor: move; position: relative; left: 0px; top: 0px; width: 500px; height: 30px; margin-bottom: -30px;"></div>' +
				'<a href="###" onclick="uplodFile(\'close\')"><img style="position: absolute; right: 15px; top: 12px; border:0px;" src="/images/close.gif" title="关闭" /></a>' +
				'<div id="pmwinmask" style="margin-top: 30px; position: absolute; width: 100%; height: 100%; display: none"></div><iframe id="pmframe" name="pmframe" style="width:' + pmwidth + 'px;height:100%" allowTransparency="true" frameborder="0"></iframe></div>'+
				'<div style="width: 500px; height: ' + 28 + 'px; padding: 1px; background: #FFFFFF; border: 1px solid #7597B8; border-top:none; position: relative; left: -6px; top: -3px"><div style="position: absolute; right: 70px; top:4px; border:solid 1px #7597B8; width:50px; height:20px; background: url(/images/ubb/headerbg.gif) repeat-x 50%; text-align:center; font-weight:bold; font-size:14px; vertical-align: middle"><a id="submitButton" style="text-decoration:none; color:#005C89;" href="javascript:void(0)" onclick="uplodFile(\'submit\')">确定</a></div><div style="position: absolute; right: 10px; top:4px; border:solid 1px #7597B8; width:50px; height:20px;  background: url(/images/ubb/headerbg.gif) repeat-x 50%; text-align:center; font-weight:bold; font-size:14px; vertical-align: middle"><a style="text-decoration:none; color:#005C89;" href="javascript:;" onclick="uplodFile(\'submit\')">取消</a></div></div>';
		}
		$('messageBoxDiv').style.display = '';
		$('messageBoxDiv').style.top = ((clientHeight - pmheight) / 11 + scrollTop) + 'px';
		pmframe.location = '/filePage/goUpFile.jhtml?returnDiv=' + returnDiv + '&fileType=' + fileType + '&fileSize=' + fileSize;
		
	} else if(action == 'close') {
		for(i = 0;i < objs.length; i ++) {
			if(objs[i].attributes['oldvisibility']) {
			objs[i].style.visibility = objs[i].attributes['oldvisibility'].nodeValue;
				objs[i].removeAttribute('oldvisibility');
			}
		}
		hiddenobj = new Array();
		$('messageBoxDiv').style.display = 'none';
		//eval(m_name);
	}else if(action == 'submit'){
		for(i = 0;i < objs.length; i ++) {
			if(objs[i].attributes['oldvisibility']) {
			objs[i].style.visibility = objs[i].attributes['oldvisibility'].nodeValue;
				objs[i].removeAttribute('oldvisibility');
			}
		}
		hiddenobj = new Array();
		$('messageBoxDiv').style.display = 'none';
		eval(m_name);
	}
}

function goParentPage(href){
	var opDiv = window.parent.document.getElementById('frmright');
	opDiv.src = href;
}

function openOperationDiv(op,id){
		//背景层div
		var newMask = document.createElement("div");
		newMask.id = "mask";
		newMask.style.position = "absolute";
		newMask.style.zIndex = "9999";
		newMask.style.width = screen.availWidth + "px";
		newMask.style.height = screen.availHeight + "px";
		newMask.style.top = "0px";
		newMask.style.left = "0px";
		newMask.style.background = "#ffffff";
		newMask.style.filter = "alpha(opacity=40)";
		newMask.style.opacity = "0.40";
		document.body.appendChild(newMask);
		//显示层div
		var newDiv = document.createElement("div");
		newDiv.id = "operationsDiv";
		newDiv.style.position = "absolute";
		newDiv.style.zIndex = "9999";
		newDiv.style.width = "auto";
		newDiv.style.height = "auto";
		newDiv.style.top = "40px";
		newDiv.style.left = (parseInt(screen.availWidth) - 900) / 2 + "px";
		newDiv.style.background = "#fff";
		newDiv.style.border = "1px solid ";
		newDiv.style.padding = "5px";
		document.body.appendChild(newDiv);
		
		if(op == "edit") go_recruitment_operationEdit(id);
		if(op == "open") go_model_info(id);
		
}

function closeDiv(){
			document.body.removeChild($("operationsDiv"));
			document.body.removeChild($("mask"));
}

function encodeHex( formet ) {

        var str = formet.thisCode.value;
        var result = "";

        for( var i=0; i<str.length; i++ ) {

                if( str.substring(i,i+1).match(/[^\x00-\xff]/g) != null ) {
                        result += escape(str.substring(i,i+1), 1).replace(/%/g,'\\');
                } else {
                        result += pad(toHex(str.substring(i,i+1).charCodeAt(0)&0xff),2,'0');
                }
        }

        formet.thisResult.value = result;
}

function decodeHex( formet ) {

        var str = formet.thisCode.value;
        var result = "";

        str = str.replace(new RegExp("s/[^0-9a-zA-Z/\/\]//g"));

        result = str.replace(/\\x/g,'%');
        result = result.replace(/\\u/g,'%u');

        formet.thisResult.value = unescape(result);

}
///二级头部导航

function switchTag(tag,content)
{
	for(i=1; i <6; i++)
	{
		if ("tag"+i==tag)
		{
			document.getElementById(tag).getElementsByTagName("a")[0].className="selectli"+i;document.getElementById(tag).getElementsByTagName("a")[0].getElementsByTagName("span")[0].className="selectspan"+i;
		}
		else
		{
			document.getElementById("tag"+i).getElementsByTagName("a")[0].className="";document.getElementById("tag"+i).getElementsByTagName("a")[0].getElementsByTagName("span")[0].className="";
		}
	}
}
function init(){
	//var urt = new String(window.location.href);
	//var result = urt.slice(urt.length -1);
	//alert(result);
	//if(result=='')result=1;
	//alert(t);
	//switchTag('tag'+result);
}

function goLocatUrl(enterName,url)
{
  var s=window.location.href;
   if(enterName =="" ||enterName == 'undefined')
   {
     alert("对不起!您只有填写完\"企业信息\"之后,才能进行其他操作!");
     return ;
   }
   if( enterName !="" && enterName !='undefined' && s.indexOf('/enterprise/goEdit.jhtml?#3')!=-1){
   	 if(!window.confirm("您确认要离开企业信息编辑状态吗？"))
     {
        return ;
     }
   }
   window.location.href=url;
}

function disp(n){
	//	alert(n)
		for (var i=0;i<7;i++)
		{
			if (!document.getElementById("left"+i)) return;			
			document.getElementById("left"+i).style.display="none";
		}
		document.getElementById("left"+n).style.display="";
	}
	
	function popUpDiv(opDiv){
		//背景层div
		if(document.getElementById("mask") == null){	
			var newMask = document.createElement("div");
			newMask.id = "mask";
			newMask.style.position = "absolute";
			newMask.style.zIndex = "2";
			newMask.style.width = (parseInt(screen.availWidth)) + "px";
			var heigth = parseInt(document.body.scrollHeight);
			newMask.style.height = heigth + "px";
			newMask.style.top = "0px";
			newMask.style.left = "0px";
			newMask.style.background = "#000";
			newMask.style.filter = "alpha(opacity=40)";
			newMask.style.opacity = "0.40";
			document.body.appendChild(newMask);
		}
		//弹出层div
		if(document.getElementById(opDiv) == null){	
			var newDiv = document.createElement("div");
			newDiv.id = opDiv;
		}else{
			var newDiv = document.getElementById(opDiv);
		}
		newDiv.style.display = "";
		newDiv.style.position = "absolute";
		newDiv.style.zIndex = "9999";
		newDiv.style.width = "324px";
		newDiv.style.top = "250px";
		newDiv.style.background = "#ffffff";
		newDiv.style.left = (parseInt(screen.availWidth) - 300) / 2 + "px";
		newDiv.style.padding = "5px";
		document.body.appendChild(newDiv);
		
	}
	
	//关闭弹出层
	function closeUpDiv(opDiv){
		document.body.removeChild($(opDiv));
		document.body.removeChild($("mask"));
	}
	
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
	
