//document.write("<script src=\"/FCKeditor/fckconfig.js\" type=\"text/javascript\"></script>");
// global variables
var TIMER = 2;
var SPEED = 20;
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;
}

// 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)
{
	message = "<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font size=\"+1\"><strong>" + message + "</font></strong>";
	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 * 300));
  } else {
	dialogclose.style.visibility = "visible";
  }
  
}

// hide the dialog box //
function hideDialog(loginUrl) {
  var dialog = document.getElementById('dialog');
  clearInterval(dialog.timer);
  dialog.timer = setInterval("fadeDialog(0)", TIMER);
  if(loginUrl!=null&&typeof loginUrl!='undefined'&&loginUrl!='')
  {
  	window.setTimeout(loginUrl, (TIMER * 300));
  }
}
// hide the dialog box //
function closeDialog() {
  var dialog = document.getElementById('dialog');
  clearInterval(dialog.timer);
  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 if(flag == 0){
    value = dialog.alpha - SPEED;
  }
  dialog.alpha = value;
  dialog.style.opacity = (value / 100);
  dialog.style.filter = 'alpha(opacity=' + value + ')';
  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(boxChecked.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 processResponse(response, callback) {
	var responseData = eval("(" + response.responseText.replace(/[\r\n]/g,"") + ")");
	//alert(responseData);
	//alert(responseData.result);
	if (responseData.result == 0) {
		//成功
		if (callback) {
			callback();
		}
		return true;
	}
	
	switch (responseData.result) {
	case 1: //未登录
		//blog_login('/user/login.jhtml');
		alert(responseData.message);
		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;
	default:
		alert(responseData.message);
	
	}
	
	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="/auth/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,returnPath, 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.6 + 20;
		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 + '&returnPath=' + returnPath + '&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 showExcelDownLoadDialog(filePath){
	var title = "数据导出成功！";
	var message = "<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href = "+filePath+" onclick=hideDialog('window.location.reload();') >点击这里下载Excel文档</a>";
	var type = "success";
	showDialog(title,message,type,false,"\"window.location.reload();\"");
}

function accessLocation(url){
	window.location.href = url;
}

go_simplePager = function(url,start){
	if(url.indexOf("?") == -1){
		url = url + "?start=" + start;
	}else{
		url = url + "&start=" + start;
	}
	window.location.href = url;
}
	
	function go_bfzy_admin_menu(flag){
		//alert('dd');
		var opt = {method: "post", parameters: "flag=" + flag, evalScripts:true};
		new Ajax.Updater("menuDiv", toUTF8("/admin/goMenu.jhtml"),opt);	
	}
		
var dispDiv;
var w;
var i=0;
function openWindow(title,tableName){
	dispDiv = "base_info_" + i;
	i++;
		//alert(dispDiv);
		var tabs = new Ext.TabPanel({
            region    : 'center',
            margins   : '3 3 3 0', 
            activeTab : 0,
            defaults  : {
				autoScroll : true
			},
            items     : [{
                title    : tableName,
                html     : "<div id='"+ dispDiv +"'></div>",
				height   : 300
             }]
        });
        closeWindow();
       	this.w = new Ext.Window({
			//contentEl:"beanconfig",//主体显示的html元素，也可以写为el:"win"
			closable : true,
            width    : 620,
            height   : 350,
            plain    : true,
           // layout   : 'border',
		    items : [tabs],
			title: title
		});
		this.w.show();
	return dispDiv;
}

//打开对话框
function openDiv(title,tableName){
	dispDiv = "base_info_" + i;
	i++;
		//alert(dispDiv);
		var tabs = new Ext.Panel({
            region    : 'center',
            margins   : '10 10 10 20', 
            activeTab : 0,
            defaults  : {
				autoScroll : true
			},
            //items     : [{
                title    : tableName,
                html     : "<div id='"+ dispDiv +"'></div>",
				height   : 240
           //  }]
        });
       	this.w = new Ext.Window({
			//contentEl:"beanconfig",//主体显示的html元素，也可以写为el:"win"
			closable : true,
            width    : 470,
            height   : 270,
            plain    : true,
           // layout   : 'border',
		    items : [tabs],
			title: title
		});
		
		 this.w.on("beforedestroy",function(){
		 	//$("mask").style.visibility='hidden';
		 	//$("mask").hide();
		 	closeWindow();
			return false;
		 });
		this.w.show();
		
	return dispDiv;
}

function closeWindow(){
	if(typeof this.w != 'undefined'){
		this.w.close();
	}
}
function hideWindow(){
	if(typeof this.w != 'undefined'){
		this.w.hide();
	}
}

function delHtmlParm(diva) {
        if($(diva) != null && typeof $(diva) != 'undefined'){
			
			Element.remove(diva);
			closeWindow();
		} 
    }  

function fileUpload(returnParamName, returnPath , returnView, fileType, fileLimitSize,returnSizeParamName){
		var dispDiv = openDiv("文件上传", '文件上传');
		window.setTimeout('refreshUpload("' + dispDiv + '","' + returnParamName + '","' + returnPath + '","' + returnView + '","' + fileType + '","' + fileLimitSize + '","' + returnSizeParamName + '")',1);
}
function refreshUpload(dispDiv,returnParamName,returnPath,returnView,fileType,fileLimitSize,returnSizeParamName){
	Element.update(dispDiv, '<iframe id="upload_frame" name="upload_frame" src="/filePage/goUpFile.jhtml?returnParamName=' + returnParamName + '&returnPath=' + returnPath + '&returnView=' + returnView + '&fileType=' + fileType + '&fileLimitSize=' + fileLimitSize + '&returnSizeParamName=' + returnSizeParamName + '" scrolling="no" frameborder="0" width="100%" height="350px" ></iframe>');	
}
//左边树伸缩
function show_Col2Left(){
     var leftDiv = document.getElementById("Col2Left");
	 var showDiv = document.getElementById("showDiv");	 
	 var hiddenDiv = document.getElementById("hiddenDiv");	
	 
	if(leftDiv.style.display == 'none'){
		leftDiv.style.display = 'block';
		var rightDiv = document.getElementById("Col2Right_two");
		rightDiv.id = "Col2Right";
		hiddenDiv.style.display = 'none';
		showDiv.style.display = 'block';
	}
	else{
		leftDiv.style.display = 'none';
		var rightDiv = document.getElementById("Col2Right");
		showDiv.style.display = 'none';
		hiddenDiv.style.display = 'block';
		rightDiv.id = "Col2Right_two";
	}
}
function showFrame(){
	var id = document.getElementById('search_self_div');
	if(id.style.display == ""){
		id.style.display = "none";
	}else{
		id.style.display = "";
	}
	
}

function hiddenSelect() {
	if ($id("leftcnt")) {
		var items = $id("leftcnt").getElementsByTagName("select");
		for (var i = 0; i < items.length; i++) {
			items[i].style.visibility = "hidden";
		}
	}
}
function showSelect() {
	if ($id("leftcnt")) {
		var items = $id("leftcnt").getElementsByTagName("select");
		for (var i = 0; i < items.length; i++) {
			items[i].style.visibility = "visible";
		}
	}
}

//ext 层  自定义查询层	
go_search_div = function(url, title){
	var dispDiv = openWindow(title + "自定义查询", "查询属性");
	new Ajax.Updater(dispDiv, toUTF8(url),{method: "post", parameters: "dispDiv=" + dispDiv,evalScripts:true});
}

//ext 层  下载页面	
go_upload_div = function(url, title){
	var dispDiv = openWindow(title + "下载", "资料下载");
	
	new Ajax.Updater(dispDiv, toUTF8(url),{method: "post", parameters: "dispDiv=" + dispDiv,evalScripts:true});
}

function resetForm()
{
		var eles = document.getElementsByTagName("span");
		for(var i = 0; i < eles.length; i++)
		{
			var obj = eles[i];
			var name = obj.id;
			if(name.indexOf("_error") > 0)
				obj.innerHTML="";
		}
}
//控制页面大小
//totalHeight 页面总高
//subHeight 页面总高所要减去的页面元素的集合
//elementHeight 当前页面元素的集合
controlPageSizeByDivId = function(totalHeight,subHeight,elementHeight){
	var total_height = document.getElementById(totalHeight).offsetHeight;
	var sub_height_arr = new Array();
	sub_height_arr = subHeight;
	var sum_sub_height = 0;
	for(var i=0;i<sub_height_arr.length;i++){
		sum_sub_height += document.getElementById(sub_height_arr[i]).offsetHeight;
	}
	var page_element_height_arr = new Array();
	page_element_height_arr = elementHeight;
	for(var i=0;i<page_element_height_arr.length;i++){
		document.getElementById(page_element_height_arr[i]).style.height = (total_height - sum_sub_height) / 2 + "px";
	}
}
//控制页面大小
controlPageSize = function(){
	var total_height = document.getElementById("Col2").offsetHeight;
	var arr_blockBar_height = document.getElementsByClassName("BlockBar");
	var arr_spaceVertical_height = document.getElementsByClassName("space-vertical");
	var sum_divLengthByClassName = 0;
	
	if(arr_blockBar_height.length == 1){
		sum_divLengthByClassName += arr_blockBar_height[0].offsetHeight;
	}else{
		for(var i=0;i<arr_blockBar_height.length;i++){
			sum_divLengthByClassName += arr_blockBar_height[i].offsetHeight;
		}
	}
	
	if(arr_spaceVertical_height.length == 1){
		sum_divLengthByClassName += arr_spaceVertical_height[0].offsetHeight;
	}else{
		for(var i=0;i<arr_spaceVertical_height.length;i++){
			sum_divLengthByClassName += arr_spaceVertical_height[i].offsetHeight;
		}
	}
	
	
	var arr_blockEdit = document.getElementsByClassName("BlockEdit");
	var arr_blockEditTwo = document.getElementsByClassName("BlockEdit_two");
	var arr_blockBody = document.getElementsByClassName("BlockBody");
	var arr_blockBodyTwo = document.getElementsByClassName("BlockBody_two");
	
	//var arr_blockBodyer = document.getElementsByClassName("BlockBodyer");
	//var arr_operation = document.getElementsByClassName("operation");
	//if(arr_blockBodyer != "" || arr_operation !="" ){
	//	arr_operation[0].style.width = arr_blockBodyer[0].offsetWidth + "px";
	//}
	
	if(arr_blockEditTwo.length == 1 && arr_blockBodyTwo.length == 1){
		arr_blockEditTwo[0].style.height = (total_height - sum_divLengthByClassName) / 2 + "px";
		arr_blockBodyTwo[0].style.height = (total_height - sum_divLengthByClassName) / 2 + "px";
	}else{
		if(arr_blockEdit.length == 1){
			arr_blockEdit[0].style.height = (total_height - sum_divLengthByClassName) + "px";
		}
		if(arr_blockBody.length == 2){
			arr_blockBody[1].style.height = (total_height - sum_divLengthByClassName) + "px";
		}else{
			//arr_blockBody[0].style.height = (total_height - sum_divLengthByClassName) + "px";
		}	
	}
}


/****
xxh  唯一性验证 checkUnique
提交表单时加上：	if(uniqueArray.length > 0) return;   进行唯一性验证
加一个 属性名+Hidden 的隐藏元素保存原始值， 
如：<input type="hidden" id="nameHidden" name="nameHidden" value="${(name)!''}" />

参数：
objName 对象名，要验证的属性所属的对象
fieldList: 要验证的属性列表，以 ","分隔
typeList: 属性类型列表 以 ","分隔  ，取值：  i---整数; f---小数; l---长整数; s---字符串
msgSpan: 提示信息显示容器
field: 要验证的属性

*****/
var uniqueArray = new Array();
var currentField = "";
checkUnique = function(objName, fieldList, typeList, msgSpan, field)
{
	//alert("hello");
	currentField = field;
	var orginValue = $(field +　"Hidden").value;
	if(orginValue == $(field).value) return;
	var fieldArray = fieldList.split(",");
	var value = "";
	var field = "";
	//if(uniqueFlag > 0) return;
	for(var i = 0; i < fieldArray.length; i++)
	{
		if($(fieldArray[i]).value == '') return ;
		var temp = fieldArray[i];
		var foreign = "";
		if(temp.indexOf("Id") > 0)
		{
			temp = temp.substring(0, temp.indexOf("Id")) + ".id";
		}
		if(i == 0)
		{
			field = field + temp;
			value = value + $(fieldArray[i]).value;
		}
		else
		{
			field = field + "," + temp;
			value = value + "," + $(fieldArray[i]).value;
		}
	}
	
	var param = "objName=" + objName + "&field=" + field + "&value=" + value + "&msgSpan=" + msgSpan + "&typeList=" + typeList;
	
	//alert(param);
	var opt = {
				method: 'post',
				postBody: param,
				onSuccess: checkUnique_Success,
				onFailure: processFailure
			  }
	new Ajax.Request("/check/doCheck.jhtml",opt);
}

checkUnique_Success = function(response)
{
	var model = response.responseText.evalJSON();
	if(model.data.suc == '1')
	{
		$(model.data.msgSpan).innerHTML = "<font color='red'>已经存在！</font>";
		if(!fieldIsExist(currentField))
			if(currentField != "")
				uniqueArray.add(currentField);
		currentField = "";
	}
	else
	{
		$(model.data.msgSpan).innerHTML = "";
		uniqueArray.remove(currentField);
		currentField = "";
	}
	//alert(uniqueArray.length + "|" + uniqueArray);
}

fieldIsExist = function(val)
{
	for(var i = 0; i < uniqueArray.length; i++)
	{
		if(uniqueArray[i] == val) return true;
	}
	return false;
	
}

Array.prototype.add = function(val)
{
	this[this.length] = val;
}

Array.prototype.remove = function(val)
{
	//this[this.length] = val;
	if(this.length > 0)
	{
	    var tempArr = new Array();
	    var x= 0;
		for(var i = 0; i < this.length; i++)
		{
		    if(this[i] != val)
		    {
		       tempArr[x++] = this[i];
		    }
		}
		
		this.length = tempArr.length;
		
		for(var i = 0; i < tempArr.length; i++)
		{
		    this[i] = tempArr[i];
		}
	}
}

Array.prototype.contains = function(val)
{
	if(this.length > 0)
	{
		for(var i = 0; i < this.length; i++)
		{
		    if(this[i] == val)
		    {
		       return true;
		    }
		}
		
		return false;
	}
}

Array.prototype.likeContains = function(val)
{
	if(this.length > 0)
	{
		for(var i = 0; i < this.length; i++)
		{
		    if(this[i].indexOf(val) >= 0)
		    {
		       return true;
		    }
		}
		
		return false;
	}
}

function HashTable()
{
	this._hash = new Object();
	
	//增加key-value对
	this.add = function(key,value){
		if(typeof(key)!="undefined")
		{
			if(this.contains(key)==false){
		    	this._hash[key]=typeof(value)=="undefined"?null:value;
		    	return true;
		    }else{
		    	return false;
		    }
	    }else {
	    	return false;
	    }
	}
 
	this.remove = function(key){delete this._hash[key];}
	this.count = function(){var i=0;for(var k in this._hash){i++;} return i;}
	this.items = function(key){return this._hash[key];}
	this.contains = function(key){ return typeof(this._hash[key])!="undefined";}
	this.clear = function(){for(var k in this._hash){delete this._hash[k];}}
}


changeRowBg = function(id, obj)
{
	var rows = document.getElementsByName("checkAllRow");
	for(var i = 0; i < rows.length; i++)
	{
		rows[i].checked = false;
	}

	for(var i = 1; i <= 10; i++)
	{
		if($("dataRow" + i) != null && typeof $("dataRow" + i) != 'undefined')
		{
			$('dataRow' + i).className = 'row align-center';
		} 
		if($("dataRow1" + i) != null && typeof $("dataRow1" + i) != 'undefined')
		{
			$('dataRow1' + i).className = 'row align-center';
		}
	}
	Element.removeClassName('dataRow' + id, 'row align-center');
	Element.addClassName('dataRow' + id, 'row sel align-center');
	
	Element.removeClassName('dataRow1' + id, 'row align-center');
	Element.addClassName('dataRow1' + id, 'row sel align-center');
	
	obj.checked = true;
}
function createFCk(name){
	var oFCKeditor = new FCKeditor(name) ;
	oFCKeditor.ToolbarSet = 'Default' ;
	oFCKeditor.Width = '100%' ;
	oFCKeditor.Height = '200' ;
	oFCKeditor.Value = '' ;
	//oFCKeditor.Create() ;
	oFCKeditor.ReplaceTextarea();
}

function createBasicFck(name){
	var oFCKeditor = new FCKeditor(name) ;
	oFCKeditor.BasePath = '/FCKeditor/' ;	
	oFCKeditor.ToolbarSet = 'Basic' ; 	
	oFCKeditor.Width = '100%' ;
	oFCKeditor.Height = '300' ;
	oFCKeditor.Value = '' ; 		
	oFCKeditor.ReplaceTextarea();
}


function createFCkSelf(name, value){
	var oFCKeditor = new FCKeditor(name) ;
	oFCKeditor.ToolbarSet = 'Basic' ;
	oFCKeditor.Width = '100%' ;
	oFCKeditor.Height = '200' ;
	oFCKeditor.Value = value ;
	oFCKeditor.Create() ;
	//oFCKeditor.ReplaceTextarea();
}

createFCKWH =	function(width, height)
{	
	var oFCKeditor = new FCKeditor('content');
	oFCKeditor.BasePath = '/FCKeditor/' ;	
	oFCKeditor.ToolbarSet = 'Basic' ; 	
	oFCKeditor.Width = width ; 	
	oFCKeditor.Height = height ; 	
	oFCKeditor.Value = '' ; 		
	oFCKeditor.ReplaceTextarea();
}

function createFCKWHContent(name, width, height){
	var oFCKeditor = new FCKeditor(name) ;
	oFCKeditor.BasePath = '/FCKeditor/' ;	
	oFCKeditor.ToolbarSet = 'Default' ; 	
	oFCKeditor.Width = width ; 	
	oFCKeditor.Height = height ; 	
	oFCKeditor.Value = '' ; 		
	oFCKeditor.ReplaceTextarea();
}

function getEditorHTMLContents(name)
{
	var edit = FCKeditorAPI.GetInstance(name);
	return (edit.GetXHTML(true));
}



//JS验证开始
var errEmptyMsg = "不能为空";
var typeArr = new Array(); //未通过验证的类型
var objArr = new Array(); //未通过非空验证的对象
var empObj = null;
//var nameArr = new Array();
/********************************************************************************************
function validate()
{
 	return nameArr.length;
}
 * type['Phone','Mobile','Email','NotEmpty','Len','PostCode','IdCardNo','Ip','Float','Int','Betwin(0,5)']
 * param1:type,验证类型，多种验证用','号分隔。必须 
 * param2:objName,要检测的字段ID 必须
 * param3:str,提示信息。必须 ['错误信息','正确信息']
 * param4:errObjName,验证结果显示ID 必须
 * param5:num,验证字段内容的最大长度
 *********************************************************************************************/
function fieldCheck()
{
	var len= arguments.length; 
	var errObjName;
	var errObj = null;
	var type = eval(arguments[0]);
	var objName = arguments[1];
	var str = eval(arguments[2]);
	var obj =  typeof(objName) == 'object' ? objName : document.getElementById(objName);
	if(len == 4)
	{
		var errObjName = arguments[3];
		var errObj = typeof(errObjName) == 'object' ? errObjName : document.getElementById(errObjName);
	}
	
	
	var err = 1;
	
	if(len==5)
	{
		var num = arguments[4];
		var lenStr = str.length > 1 ? str[1] : str[0];
		type.remove("Len");
		if(!lenCheck(obj, errObj, num, lenStr)) err = 0;
	}
	
	if(!type.likeContains('NotEmpty') && obj.value == "")
	{
		if(errObj != null)
		{
			errObj.innerHTML = "";
		}
		return true;	
	}
	
	for(var i = 0; i < type.length; i++)
	{
		var method = '';
		if(type[i].indexOf('Betwin') >= 0) 
			method = '(obj.value).' + type[i];
		else
			method = '(obj.value).is' + type[i] + '()';
		if(eval(method))
		{
			//非空验证处理
			if(empObj != null) empObj = null;
			
			if(err == 1)
			{
				if(errObj != null)
				{
					errObj.innerHTML = "";
				}
			}
			return true;
		}
		else
		{
			err = 0;
			//nameArr.add(objName);
			//非空验证的处理
			if(empObj != null && empObj != obj)
			{
				empObj.focus();
				
				return ;
			}else if(empObj == null) empObj = obj;
			
			if(str.length > 0)
			{
				if(errObj != null)
				{
					errObj.innerHTML = str[0];
				}
				else
				{
					alert(str[0]);
					setTimeout( function(){obj.focus(); }, 0);
				} 
			} 
			else
			{
				if(errObj != null)
				{
					errObj.innerHTML = errEmptyMsg;
				}
				else
				{
					alert(errEmptyMsg);
					setTimeout( function(){obj.focus(); }, 0);
				} 
			}
			
			return false;
		}
	}
	
}
function lenCheck(objName, errObjName, num, str)
{
	var obj = objName;
	var errObj = errObjName;
	
	if(obj.value.replace(/[^\x00-\xff]/g,"aa").length > num)
	{
		//nameArr.add(objName);
		if(errObj != null)
			errObj.innerHTML = str[0];
		else
		{
			alert(str[0]);
			//obj.focus();
			setTimeout( function(){obj.focus(); }, 0);
			return ;
		} 
		return false;
	}else{
	    //nameArr.remove(objName);
		if(errObj != null)
			errObj.innerHTML = "";
		return true;
	}
}
//JS验证结束

notEmptyChechWithForm = function(frm)
{
	var eles = Form.getElements(frm);
	var eles1 = Form.getElements(frm);
    for(var i = 0; i < eles.length; i++)
    {
	    if(eles[i].name == 'validateSpan')
	    {
		    var ele = eles[i].value;
		    for(var j = 0; j < eles1.length; j++)
		    {
			    if(eles1[j].name == ele)
			    {
				    var e = eles1[j];
				    var value = e.onblur();
				    if(!value)	return false;
			    }
		  	}
	    }
  	}
  	return true;
}

//列表页跳转新增页事件
go_create_html = function(url){
	window.location.href = url;	
}

//JS下拉出列表
go_common_select = function(disField, model, label, value, defaultValue)
{
	var opt = {method: "post",  parameters: "field=" + disField + "&model=" + model + "&label=" + label + "&value=" + value + "&defaultValue=" + defaultValue, onFailure: processFailure};
	new Ajax.Updater(disField+"Span", "/check/goSelect.jhtml", opt)
}
page_go_common_select = function(disField, model, label, value, defaultValue)
{
	var opt = {method: "post",  parameters: "field=" + disField + "&model=" + model + "&label=" + label + "&value=" + value + "&defaultValue=" + defaultValue, onSuccess:page_go_common_select_success,onFailure: processFailure};
	new Ajax.Request("/check/goSelectPage.jhtml", opt)
}
page_go_common_select_success = function(response)
{
	document.write(response.responseText);
}

//JS下拉出列表
go_category_select = function(disField, model, defaultValue)
{
	var opt = {method: "post",  parameters: "field=" + disField + "&model=" + model + "&defaultValue=" + defaultValue, onFailure: processFailure};
	new Ajax.Updater(disField+"Span", "/check/goSelectCategory.jhtml", opt)
}
page_go_category_select = function(disField, model, defaultValue)
{
	var opt = {method: "post",  parameters: "field=" + disField + "&model=" + model + "&defaultValue=" + defaultValue, onSuccess:page_go_category_select_success,onFailure: processFailure};
	new Ajax.Request("/check/goSelectCategoryPage.jhtml", opt)
}
page_go_category_select_success = function(response)
{
	document.write(response.responseText);
}

function setSearch(div_value)
{
	document.getElementById("name").value = div_value;
	document.getElementById("search_suggest").className = 'none';
}
function suggestOver(div_value)
{
	div_value.className = 'suggest_link_over';
}

function suggestOut(div_value)
{
	div_value.className = 'suggest_link';
}


function copyToClipboard(txt) {   
      if(window.clipboardData) {   
              window.clipboardData.clearData();   
              window.clipboardData.setData("Text", txt);   
              alert("已复制到剪贴板！");
      } else if(navigator.userAgent.indexOf("Opera") != -1) {   
           window.location = txt;   
      } else if (window.netscape) {   
           try {   
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");   
           } catch (e) {   
                alert("被浏览器拒绝！\n请在浏览器地址栏输入'about:config'并回车\n然后将'signed.applets.codebase_principal_support'设置为'true'");   
           }   
           var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);   
           if (!clip)   
                return;   
           var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);   
           if (!trans)   
                return;   
           trans.addDataFlavor('text/unicode');   
           var str = new Object();   
           var len = new Object();   
           var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);   
           var copytext = txt;   
           str.data = copytext;   
           trans.setTransferData("text/unicode",str,copytext.length*2);   
           var clipid = Components.interfaces.nsIClipboard;   
           if (!clip)   
                return false;   
           clip.setData(trans,null,clipid.kGlobalClipboard);   
           alert("复制成功！")   
      }   
  }

/**
 * 字符串trim处理
 */
function trim(str){
	return str.replace(/(^\s*)|(\s*$)/, "");
}

/*
 * 空值判断处理函数，当传入的对象为string时会做空字符校验
 * 需要依赖jquery的trim函数
 *
 * @param obj : 需要判断的对象
 * @return : 空位true，非空为false
 */
function isNull(obj){
	var result = true;
	var type = typeof(obj);
	/*undefined or null return false*/
	if(type == "undefined"
		|| obj == null){
		result = true;
	} 
	/*type is string */
	else if (type == "string"){
		obj = trim(obj);
		if( obj==""
			|| obj == "undefined"){
			result = true;
		}else {
			result = false;
		}
	} 
	/*other object */
	else{
		result = false;
	}
	return result;
}

/**
 * 字符串以XX结尾的判断
 */
function endWith(source,str) {
	if(isNull(str) || isNull(source)){
		return false;
	}
	if(source.substr(source.length-str.length)==str){
		return true;
	} else {
		return false;
	}
}

/**
 * 公用上传处理
 * options
 * width:宽 默认500
 * height:高 默认450
 * callBack:每一个文件上传完以后执行的回调，参数必须为event, ID, fileObj, response, data
 * queueLimit:可上传文件数的最大值
 * sizeLimit:可上传文件大小的最大值
 * fileExt:可上传文件扩展列表，格式如*.jpg;*.gif;*.png
 * autoUpload:是否自动上传
 * uploadFolder:上传的保存目录
 * isSave:是否做数据库保存
 */
function commonUpload(options){
  	var uploadPage = "/template/common/uploadFile/upload.jsp?ran="+Math.random();
	if(!isNull(options)){
	  	if(!isNull(options.callBack)){
	  		uploadPage += "&callBack="+options.callBack;
	  	}
	  	if(!isNull(options.queueLimit)){
	  		uploadPage += "&queueLimit="+options.queueLimit;
	  	}
	  	if(!isNull(options.sizeLimit)){
	  		uploadPage += "&sizeLimit="+options.sizeLimit;
	  	}
	  	if(!isNull(options.fileExt)){
	  		uploadPage += "&fileExt="+options.fileExt;
	  	}
	  	if(!isNull(options.autoUpload)){
	  		uploadPage += "&autoUpload="+options.autoUpload;
	  	}
	  	if(!isNull(options.uploadFolder)){
	  		uploadPage += "&uploadFolder="+options.uploadFolder;
	  	}
	  	if(!isNull(options.isSave)){
	  		uploadPage += "&isSave="+options.isSave;
	  	}
	  	// 设置默认宽
	  	if(isNull(options.width)){
	  		options.width = 500; 
	  	}
	  	// 设置默认高
	  	if(isNull(options.height)){
	  		options.height = 450; 
	  	}
	}else{
		options = {'width':500,'height':450};
	}
	var frameDivId = "uploadFrameDiv"; 
	var frameDiv = $(frameDivId);
	if(isNull(frameDiv)){
		frameDiv = document.createElement("div");
		Element.extend(frameDiv);
		frameDiv.id = frameDivId;
		document.body.appendChild(frameDiv);
	}
	frameDiv.hide();
	frameDiv.innerHTML = "<iframe id=\"uploadFrame\" name=\"uploadFrame\" frameborder=\"0\" src=\""
		+uploadPage
		+"\" width=\"100%\" height=\""
		+(options.height-50)
		+"\"></iframe>";
	try{
  		Lightbox.showBoxByID(frameDivId,options.width,options.height);
  	}catch(e){
  		Lightbox.init();
  		Lightbox.showBoxByID(frameDivId,options.width,options.height);
  	}
}

