﻿/*****
**姹熺瑧鐏碉细绯荤粺阃氱敤鑴氭湰鍑芥暟
**QQ:309900655
**2009.10.01
**/
var JFun; if (!JFun) JFun = {};

/**
 **铡婚敓鏂ゆ嫹澶村熬阌熺Ц闱╂嫹
 **/
JFun.Trim=function(str){
	  str=str.replace(/(^\s*)|(\s*$)/g, "");
	  return str;
};
  
 /**
 **锟叫讹拷锟角凤拷Email锟斤拷式
 **/
JFun.IsEmail=function(email){
   var reg=/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
   return reg.test(email);
};

JFun.IsImg=function(img){
	var ext=".jpg,.gif,.bmp,.png";
	var ind=img.lastIndexOf(".");
	var fileExt=img.substr(img.lastIndexOf(".")).toLowerCase();
	if(ext.indexOf(fileExt)==-1){
		return false;
		}
	return true;
}

	  /**
  **锟斤拷锟铰猴拷锟斤拷锟叫讹拷锟角凤拷锟斤拷锟斤拷确锟斤拷锟斤拷锟斤拷锟斤拷
  **锟斤拷锟斤拷欠锟斤拷锟絫rue,锟斤拷锟津返伙拷false
 **/
JFun.IsIntNum=function(str){
     var r = /^[1-9][0-9]*$/;阌熸枻鎷烽敓鏂ゆ嫹//阌熸枻鎷烽敓鏂ゆ嫹阌熸枻鎷?
	 if(r.test(str.replace(/(^\s*)|(\s*$)/g, ""))){
	    return true;
	 }
	 return false;
}

 /**
  **锟斤拷锟铰猴拷锟斤拷锟叫讹拷锟角凤拷锟斤拷锟斤拷确锟斤拷锟斤拷锟斤拷
 **/
JFun.IsInteger=function(str){
     var r = /^[-\+]?\d+$/; 
	 if(r.test(str.replace(/(^\s*)|(\s*$)/g, ""))){
	    return true;
	 }
	 return false;
}

JFun.Replace=function(urlstr){
	 if(urlstr.indexOf("?")>0) urlstr+="&jxlrandom="+Math.random();
	  else urlstr+="?jxlrandom="+Math.random();
	  location.replace(urlstr);
};

/**
* 系统锟斤拷锟斤拷要锟睫革拷图片路锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷使锟斤拷
*/
JFun.pubHideDiv=function(){
	var str="<div id=\"pub_hide_div\" style=\"display:none;position:absolute;z-index:3\">";
        str+="<div id=\"pub_hide_div_load\"></div>";
        str+="</div>";
		return str;
};

//=======jquery
/**
*页锟斤拷疟锟斤拷峤伙拷锟斤拷锟絧rams锟斤拷锟斤拷锟斤拷锟?formaction':'','formid':'' , 锟斤拷要锟斤拷锟斤拷一锟斤拷"锟?锟斤拷_msg"锟斤拷锟斤拷息锟斤拷示元锟截ｏ拷锟斤拷锟斤拷一锟斤拷"锟?锟斤拷_btn"锟斤拷锟结交锟斤拷钮
*锟斤拷选锟斤拷锟斤拷:prams.validate:锟斤拷证锟斤拷式 . callback为锟截碉拷锟斤拷锟斤拷
**/
JFun.AjaxFormSub=function(prams,callback){	
     var form=document.getElementById(prams.formid);
     var message=prams.formid+"_message";
     var subbtn=prams.formid+"_submit";
	 var validate=2; //默锟斤拷值为2
	 if(prams.validate) validate=prams.validate;
	 if(JValidator.Validate(form,validate)){
			$('#'+message).text("锟斤拷锟斤拷锟结交...");
			$('#'+subbtn).attr("disabled",true);  
			$.ajax({
				 type: "POST",
				 url: prams.formaction,
				 cache:false,
				 data: $(form).serialize(),
				 success: function(msg){
			       var json = eval( "("+msg+")" );
				   if(json.success){ 
					   if($('#'+message)) $('#'+message).text("锟斤拷示:"+json.message);
					   if($('#'+subbtn)) $('#'+subbtn).attr("disabled",true);  
					   if(callback)callback(json);
					}else{
					   if($('#'+message)) $('#'+message).text("锟斤拷锟斤拷:"+json.message);
					   if($('#'+subbtn)) $('#'+subbtn).attr("disabled",false);  
					}
				 }
			});                
   }   
};

//get锟斤拷式锟结交
JFun.AjaxLoad=function(prams,callback){	
	var message=prams.msg;
	var url=prams.url;	 
	

	if(url.indexOf("?")>0)
		url+="&t="+Math.random();
	else
	 	url+="?t="+Math.random();

	if(message) $('#'+message).text("锟斤拷锟节革拷锟斤拷锟斤拷荩锟斤拷锟斤拷院锟?..");
	$.get(url,function(msg){
			var json = eval( "("+msg+")" );
			//if(message) $('#'+message).text(json.message);
			if(callback)callback(json);
		});
};

JFun.clearLoad=function(){
	 setTimeout(function(){		   
        $('#loading').remove();
        $('#loading-mask').fadeOut({remove:true});
    }, 500);
 };
 //==锟斤拷锟斤拷锟斤拷要锟斤拷锟斤拷jquery1.3支锟斤拷
 
 

//=======ext
/**锟斤拷锟斤拷示锟斤拷
   JFun.showDlgWin(btnStr,urlStr,titleStr,widthStr,heightStr);
   锟斤拷
   var pram={btn:"btn-channind",url:"cont!htmlChann.do?sid=${sid}&cid=${cid}",title,width:200,height:100};
   Ext.onReady(showExtDlgWin,pram);
   //锟斤拷要锟斤拷锟矫碉拷锟斤拷Ext锟侥硷拷
*/
JFun.showDlgWin=function(btnStr,urlStr,titleStr,widthStr,heightStr){
	 var pram={btn:btnStr,url:urlStr,title:titleStr,width:widthStr,height:heightStr};
	 Ext.onReady(JFun.showExtDlgWin,pram);
};

JFun.showExtDlgWin=function(){
	  var width=this.width;
	  var height=this.height;
	  var urlstr=this.url;
	  var btnstr=this.btn;
	  var title=this.title;
	  var button = Ext.get(btnstr);
	  if(urlstr.indexOf("?")>0) urlstr+="&jxlrandom="+Math.random();
	  else urlstr+="?jxlrandom="+Math.random();
	  button.on('click', function(){			  
			var win = new Ext.Window({
				   id:'exechtml',
				   title: title, 
				   xtype:'window',
				   width:width,
				   height:height,
				   closeAction:'close',
				   plain: true,
				   modal : true,
				   autoLoad:{url:urlstr,noCache:true}
			   });
		 win.show();
	 });
};

JFun.disableInputs=function() {
	$(function() {
		$("input").attr("disabled","disabled");
	})
};
//锟斤拷锟斤拷锟斤拷要ext支锟斤拷
