/*bK Js Tools v1.0.0.1 LastTime:2009-11-21*/
var userAgent=navigator.userAgent.toLowerCase();
var is_opera=userAgent.indexOf('opera')!=-1&&opera.version();
var is_moz=(navigator.product == 'Gecko')&&userAgent.substr(userAgent.indexOf('firefox')+8,3);
var is_ie=(userAgent.indexOf('msie')!=-1&&!is_opera)&&userAgent.substr(userAgent.indexOf('msie')+5,1);

function _$(s){return document.getElementById(s);}
function trim(str){return (str+'').replace(/(\s+)$/g,'').replace(/^\s+/g,'');}
function stripscript(s){return s.replace(/<script.*?>.*?<\/script>/ig,'');}
function c_trim(string) {var temp="";string=''+string;splitstring=string.split(" ");for(i=0;i<splitstring.length;i++){temp+=splitstring[i];}return temp;}
function f_trim(inputString){if(typeof inputString!='string'){return inputString;}var retValue=inputString;var ch=retValue.substring(0,1);while(ch==' '||ch=='\r'||ch=='\n'){retValue=retValue.substring(1,retValue.length);ch=retValue.substring(0,1);}ch=retValue.substring(retValue.length-1,retValue.length);while(ch==' '||ch=='\r'||ch=='\n'){retValue=retValue.substring(0,retValue.length-1);ch=retValue.substring(retValue.length-1,retValue.length);}return retValue;}
function isEmail(strEmail) { if (strEmail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) return 1; else return 0; }
function is_num(str){var strSource ="0123456789";var ch;var i;var temp;for(i=0;i<=(str.length-1);i++){ch=str.charAt(i);temp=strSource.indexOf(ch);if(temp==-1){return 0;}}if(strSource.indexOf(ch)==-1){return 0;}else{return 1;} }
function is_domain(str){var strSource ="0123456789abcdefghijklmnopqrstuvwxyz_";var ch;var i;var temp;for(i=0;i<=(str.length-1);i++){ch=str.charAt(i);temp=strSource.indexOf(ch);if(temp==-1){return 0;}}if(strSource.indexOf(ch)==-1){return 0;}else{return 1;}}
function isUndefined(variable){return typeof variable=='undefined'?true:false;}
function strlen(str){return (is_ie&&str.indexOf('\n')!= -1)?str.replace(/\r?\n/g,'_').length:str.length;}
function setcopy(s,a){if(is_ie){window.clipboardData.setData('text',''+s);}else if(prompt('Press Ctrl+C Copy to Clipboard',s));if(a){alert(a);}}
//Cookies
function Ajax_SetCookie(n,v,e){var t=new Date();t.setTime(t.getTime());if(!e)e=365;e=e*1000*60*60*24;var e_date=new Date(t.getTime()+e);document.cookie=n+'='+encodeURIComponent(v)+';expires='+e_date.toGMTString()+';path=/;domain='+WW_domain+'';}
function Ajax_GetCookie(n){var c=document.cookie.split("; "); for(var i=0; i<c.length; i++) { var p=c[i].split("="); if(n == p[0]) try{return decodeURIComponent(p[1])}catch(e){return null} } return null;}
/**/
function Ajax_Loading(str){
	$("#Ajax_WebDI").css({"opacity":"0.6"});
	if(str!=null){/*定义了方法的:show:页面没有在加载完成就执行;read:只显示黑色背景,不显示正在加载;Hide:隐藏;this:通用方法;*/
		if(str=="show"){Ajax_LoadAPI("d");Ajax_Load_App();}
		else if(str=="read"){Ajax_LoadAPI("f");}
		else if(str=="hide"){Ajax_LoadAPI("close");return false;}
		else if(str=="w"){Ajax_LoadAPI("d");$("#Ajax_WebDom").css({"top":20,"left":50});}
		else if(str=="c"){Ajax_LoadAPI("d");Ajax_Load_App();}
	}
	if(is_ie=="6"){$("select").hide();}$("#Ajax_WebDI").show();
}
function Ajax_LoadAPI(act){
if(act=="a"){/*关闭所有Ajax提示*/$("#Ajax_WebDI").hide();$("#Ajax_WebDom").hide();$("#UserTipDiv").hide();$("#UserCardDom").hide();$("#App_Ajax_Win").hide();$("#App_Ajax_Win_Bg").hide();if(is_ie=="6"){$("select").show();}$(document).unbind("mousemove").unbind("selectstart");}
else if(act=="close"){$("#Ajax_WebDI").hide();$("#Ajax_WebDom").hide();if(is_ie=="6"){$("select").show();}}/*关闭Load*/
/*else if(act=="c"){var z="<div id=\"Ajax_WebDI\"></div><div id=\"Ajax_WebDom\"></div>";$("body").append(z);}/*创建Load..*/
else if(act=="d"){$("#Ajax_WebDom").html("<div id=\"Ajax_CloseLoad\"><a href=\"javascript:void(0);\" onclick=\"Ajax_LoadAPI('close');\"><img src=\"/commin/images/close.gif\" alt='关闭Loading' /></a></div><div id=\"Ajax_Loadcns\"><span class=\"newSpanT\">数据正在加载..</span></div>");$("#Ajax_WebDom").show();}/*显示Load..*/
/*else if(act=="e"){Ajax_Load_App();}一开始就显示AjaxL..("show")*/
else if(act=="f"){if(is_ie=="6"){$("#Ajax_WebDI").css({"height":$("body").height()+"px"});}}//点击后显示
}
function Ajax_Load_App(){
var w=$("body").width();var wH=$(window).height();
var nTop=((wH-100)/2);var nLeft=((w-100)/2);
if(is_ie=="6"){var sT=$(this).scrollTop();var h=$("body").height();var d=Math.floor(sT/wH);nTop=(nTop+(d*wH))+(wH/2)-100;if(h<wH){h=wH;}$("#Ajax_WebDI").css("height",h)}
$("#Ajax_WebDom").css({"top":nTop+"px","left":nLeft+"px"});
}

function Ajax_Win(url){
if($("#App_Ajax_Win").length>0&&url&&url!=""){
Ajax_Loading("read");var w=$("body").width();var h=$("body").height();var sT=$(this).scrollTop();var wH=$(window).height();
var nTop=((wH-385)/2);var nLeft=((w-525)/2);
if(is_ie=="6"){var d=Math.floor(sT/wH);nTop=nTop+(d*wH);}
$("#App_Ajax_Win").css({"top":nTop+"px","left":nLeft+"px"});
$("#App_Ajax_Win_Bg").css({"top":nTop+"px","left":nLeft+"px","width":525,"height":385,"opacity":"0.5"});
$("#App_Ajax_Win").show(150);$("#App_Ajax_IFR").attr("src",url);Ajax_WinMove("ready");
}}

var Win_Moving=false;
var down_x,down_y,cx,cy;
function Ajax_WinMove(act){
if(act=="ready"){
$("#App_Ajax_Win_Bg").bind("mouseup",function(e){WinMouseUp(e)});
$("#App_Ajax_Win").bind("mousedown",function(e){WinMouseDown(e)});
}}
function GetDoc(){var w,h,de;de=document.documentElement;w=self.innerWidth||(de&&de.clientWidth)||document.body.clientWidth;h=self.innerHeight||(de&&de.clientHeight)||document.body.clientHeight;return {height:h,width:w};}
function WinMouseDown(e){
var evt=e||event;
down_x=evt.clientX;
down_y=evt.clientY;
cx=(parseInt($("#App_Ajax_Win").css('left'))|0);
cy=(parseInt($("#App_Ajax_Win").css('top'))|0);
Win_Moving=true;
$(document).bind("mousemove",function(e){WinMouseMove(e)}).bind("selectstart",function(){return false;});
$("#App_Ajax_Win").css({"opacity":"0.8"});
$("#App_Ajax_Win_Bg").show();
}
function WinMouseMove(e){
var left,top,doo;
if(Win_Moving){
var evt=e||event;
left=evt.clientX+cx-down_x;top=evt.clientY+cy-down_y;
doo=GetDoc();
if(left+525>doo.width){left=(doo.width-10-525);}
if(is_ie!="6"){
if(top+385>doo.height){top=(doo.height-10-385);}
}else{if(top>$("body").height()){top=$("body").height()-10-385;}}
if(left<10){left=10;}
if(top<10){top=10;}
$("#App_Ajax_Win_Bg").css({"left":left+'px',"top":top+'px'});
}}
function WinMouseUp(e){
if(Win_Moving){
var left=$("#App_Ajax_Win_Bg").css("left")
var top=$("#App_Ajax_Win_Bg").css("top")
$("#App_Ajax_Win").css({"left":left,"top":top,"opacity":"1"});
}
Win_Moving=false;
$(document).unbind("mousemove").unbind("selectstart");
$("#App_Ajax_Win_Bg").hide();
}
function Ajax_WinCreat(){var obj="<div id='App_Ajax_Win_Bg'></div><div id='App_Ajax_Win'><iframe  id='App_Ajax_IFR' height='385' width='525' frameborder='0' scrolling='no' border='0' frameborder='0' style='z-index:30001;'></iframe></div>";$("body").append(obj);$(document).keypress(function(e){if((e.keyCode==27)&&($("#Ajax_WebDI:visible").length>0)){if(confirm("确认要关闭所有的行为窗口吗?")){Ajax_LoadAPI("a");}}});
}
/*关闭显示ajax窗口*/
function Ajax_Win_Clo(){$("#Ajax_WebDI").hide(180);$("#App_Ajax_Win").hide(180);$("#App_Ajax_Win_Bg").hide(180);$("#App_Ajax_IFR").attr("src","about:blank");if(is_ie=="6"){$("select").show();}}
function Ajax_BK_Code(obj){
var t=new Date;var e=t.getTime();
$("#Ajax_Code").html("<a href=\"javascript:Ajax_BK_Code('"+obj+"');\"><img src=\"/commin/code/code.asp?e="+e+"\" alt='点击可刷新验证码' /></a>");$("#"+obj+"").unbind("focus");}
/*For AjaxWinLoading*/
function Ajax_Win_Loading(str){
	if(str==null){
		$("#Ajax_Win_LoadDOM").css({"width":525+"px","height":385+"px","opacity":0.5,"top":0,"left":0,"padding":20+"px"});
		$("#Ajax_Win_LoadDOM").html('正在加载..');
	}else{$("#Ajax_Win_LoadDOM").hide();}
}
/*new_AjaxXml o:obj,u:url,z:type,t:maxtime,c:cache,d:request_type*/
function Ajax_Api_Load(o,u,z,t,c,d){
if(u){
	if(!c)c=false;
	if(!t)t=8000;
	if(!d)d="html";
	if(!z)z="get";
		$.ajax({
			type:z,url:u,cache:c,dataType:d,
			error: function(msg){
				//if(o){$(o).html('<div class="pd10 txt_c">E<br/><br/><a href=\"javascript:this.location.reload();\">点击这里重新加载</a></div>');}
				//else{alert("程序加载失败");}
			},
			success: function(msg){
				if(o){$(o).html(msg);}else{$("#Ajax_WebDom").after(msg);}
			}
		});
}
}
