
$.data("root","/webui");

//global variable
var app_data ={
        cur_dirid:0,
        cur_tab:0
};


$.ajaxSetup({ 
    error: function(xhr, status, err) { 
        if (xhr.status == 401) {
        	window.location.href="/sites/portal/login_register.html";
        }
    } 
});


function register(){
	window.open("/sites/portal/login_register.html?type=register",'_blank');
}


function login(){
	window.open("sites/portal/login_refister.html",'_blank');
}

function isLogin(){
	
	if($.cookie('userid')){
		var result;
		$.ajax({
			type: "POST",
			dataType:'json',
			async:false,
			url: "/gzfbsvr/checkLogin",
			success: function(data){
		       if(data.__result__.data){
						result=true;
			  }else{
						result=false;
			  }
			}
		});
		return result;
	}else{
		return false;
	}
	
}

function show_login_dialog(opts){

	 var op = opts;
	  $.modalbox.show({           
		            modal: true,
		            contentType: "html",
		            content: "/blocks/login.dialog.html",
		            width: 300,
		            height: 200,
		            title : "用户登录",
		            showOk : false,
		            showCancel : false,
		            onInitDialog: function(){
		                
		  
		                 var params={};     
		                 if(op){
		                	 if(op.info){
		                	   params.info = op.info;
		                	 }
		                	
		                	params.onsuccess = function(){         	     
		           		         $.modalbox.close();
		           		         
		           		         $("#loginFormHeadDiv").load("/blocks/g_login.html");
		           		      
		        		         if(op && op.callback){
		        		    	      op.callback(op);
		        		          }
		                      };
		                 }
		                 
		                 create_login_form(params);
		                  
		                 
	                }
		        });
	  
	}

/*
 * 获取文档格式
 * @param path
 * @return
 */
function equer_doc_type(path){
	var type; //1、图片，2、文档，3、视频，4、表格,连接
	var suffix = (path.substring(path.lastIndexOf(".") + 1,path.length)).toLowerCase();
	switch(suffix){
	case "avi":
	case "flv":
	case "wmv":
	case "wmr":
		type = 3;
		break;
	case "jpg":
	case "gif":
	case "png":
	case "jpeg":
	case "bmp":
	case "psd":
		type = 1;
		break;
	case "doc":
	case "docx":
	case "pdf":
	case "tif":
	case "rar":
	case "zip":
		type = 2;
		break;
	case "xls":
		type = 4;
		break;
	}
	return type;
}

function webLinkNo(path){
	var type;
	var suffix = (path.substring(path.lastIndexOf(".") + 1,path.length)).toLowerCase();
	switch(suffix){
	case "avi":
	case "flv":
	case "wmv":
	case "wma":
		type="video";
		break;
		default:
			type="webLink";
	}
	return type;
}

var nomonenumMSG = "<p class='tip_img_small'></p>";
