var _REQUEST={
};
jQuery.extend({
	parseRURL:function(){
		try{
			var sSearchArr=unescape(location.search.substring(1)).split('&');
			for(i=0;i<sSearchArr.length;i++){
				var sCurArr=sSearchArr[i].split('=');
				_REQUEST[sCurArr[0]]=sCurArr[1]
			}
		}
		catch(e){
		}
	}
	,isempty:function(p){
		return typeof(p)=='undefined'||p==null||(p+'').length==0
	}
	,str_mwidth:function(sString){
		var sStr,iCount,i,strTemp;
		var iCount=0;
		sStr=sString.split("");
		for(i=0;i<sStr.length;i++){
			strTemp=escape(sStr[i]);
			if(strTemp.indexOf("%u",0)==-1){
				iCount=iCount+1
			}
			else{
				iCount=iCount+2
			}
		}
		return iCount
	}
	,toNumber:function(s){
		if(s==null||s==""){
			return null
		}
		try{
			s=Number(s);
			if(isNaN(s))return null;
			return s
		}
		catch(e){
			return null
		}
	}
	,date:function(tp){
		if($.isempty(tp)||tp<100)return new Date();
		return new Date(parseInt(tp)*1000)
	}
	,formatStr:function(str,len,bLeftAlign,fillChar){
		var oL=String(str).length;
		if(oL>=len)return str;
		var sA='';
		for(var i=oL;i<len;i++)sA+=fillChar;
		if(bLeftAlign)return str+sA;
		else return sA+str
	}
	,ucfirst:function(str){
		return str.substr(0,1).toUpperCase()+str.substr(1)
	}
	,rndnum:function(min,max){
		return parseInt(Math.random()*(max-min+1)+min)
	}
	,sprintf:function(){
		if(typeof arguments=="undefined"){
			return null
		}
		if(arguments.length<1){
			return null
		}
		if(typeof arguments[0]!="string"){
			return null
		}
		if(typeof RegExp=="undefined"){
			return null
		}
		var string=arguments[0];
		var exp=new RegExp(/(%([%]|(\-)?(\+|\x20)?(0)?(\d+)?(\.(\d)?)?([bcdfosxX])))/g);
		var matches=new Array();
		var strings=new Array();
		var convCount=0;
		var stringPosStart=0;
		var stringPosEnd=0;
		var matchPosEnd=0;
		var newString='';
		var match=null;
		var convert=function(match,nosign){
			if(nosign){
				match.sign=''
			}
			else{
				match.sign=match.negative?'-':match.sign
			}
			var l=match.min-match.argument.length+1-match.sign.length;
			var pad=new Array(l<0?0:l).join(match.pad);
			if(!match.left){
				if(match.pad=="0"||nosign){
					return match.sign+pad+match.argument
				}
				else{
					return pad+match.sign+match.argument
				}
			}
			else{
				if(match.pad=="0"||nosign){
					return match.sign+match.argument+pad.replace(/0/g,' ')
				}
				else{
					return match.sign+match.argument+pad
				}
			}
		};
		while(match=exp.exec(string)){
			if(match[9]){
				convCount+=1
			}
			stringPosStart=matchPosEnd;
			stringPosEnd=exp.lastIndex-match[0].length;
			strings[strings.length]=string.substring(stringPosStart,stringPosEnd);
			matchPosEnd=exp.lastIndex;
			matches[matches.length]={
				match:match[0],left:match[3]?true:false,sign:match[4]||'',pad:match[5]||' ',min:match[6]||0,precision:match[8],code:match[9]||'%',negative:parseInt(arguments[convCount])<0?true:false,argument:String(arguments[convCount])
			}
		}
		strings[strings.length]=string.substring(matchPosEnd);
		if(matches.length==0){
			return string
		}
		if((arguments.length-1)<convCount){
			return null
		}
		var code=null;
		var match=null;
		var i=null;
		for(i=0;i<matches.length;i++){
			if(matches[i].code=='%'){
				substitution='%'
			}
			else if(matches[i].code=='b'){
				matches[i].argument=String(Math.abs(parseInt(matches[i].argument)).toString(2));
				substitution=convert(matches[i],true)
			}
			else if(matches[i].code=='c'){
				matches[i].argument=String(String.fromCharCode(parseInt(Math.abs(parseInt(matches[i].argument)))));
				substitution=convert(matches[i],true)
			}
			else if(matches[i].code=='d'){
				matches[i].argument=String(Math.abs(parseInt(matches[i].argument)));
				substitution=convert(matches[i])
			}
			else if(matches[i].code=='f'){
				matches[i].argument=String(Math.abs(parseFloat(matches[i].argument)).toFixed(matches[i].precision?matches[i].precision:6));
				substitution=convert(matches[i])
			}
			else if(matches[i].code=='o'){
				matches[i].argument=String(Math.abs(parseInt(matches[i].argument)).toString(8));
				substitution=convert(matches[i])
			}
			else if(matches[i].code=='s'){
				matches[i].argument=matches[i].argument.substring(0,matches[i].precision?matches[i].precision:matches[i].argument.length);
				substitution=convert(matches[i],true)
			}
			else if(matches[i].code=='x'){
				matches[i].argument=String(Math.abs(parseInt(matches[i].argument)).toString(16));
				substitution=convert(matches[i])
			}
			else if(matches[i].code=='X'){
				matches[i].argument=String(Math.abs(parseInt(matches[i].argument)).toString(16));
				substitution=convert(matches[i]).toUpperCase()
			}
			else{
				substitution=matches[i].match
			}
			newString+=strings[i];
			newString+=substitution
		}
		newString+=strings[i];
		return newString
	}
	,unselectContents:function(){
		if(window.getSelection)window.getSelection().removeAllRanges();
		else if(document.selection)document.selection.empty()
	}
	,isKeyTrigger:function(e,keyCode){
		var argv=jQuery.isKeyTrigger.arguments;
		var argc=jQuery.isKeyTrigger.arguments.length;
		var bCtrl=false;
		if(argc>2){
			bCtrl=argv[2]
		}
		var bAlt=false;
		if(argc>3){
			bAlt=argv[3]
		}
		var nav4=window.Event?true:false;
		if(typeof e=='undefined'){
			e=event
		}
		if(bCtrl&&!((typeof e.ctrlKey!='undefined')?e.ctrlKey:e.modifiers&Event.CONTROL_MASK>0)){
			return false
		}
		if(bAlt&&!((typeof e.altKey!='undefined')?e.altKey:e.modifiers&Event.ALT_MASK>0)){
			return false
		}
		var whichCode=0;
		if(nav4)whichCode=e.which;
		else if(e.type=="keypress"||e.type=="keydown")whichCode=e.keyCode;
		else whichCode=e.button;
		return(whichCode==keyCode)
	}
	,getDbPicUri:function(picid){
		if($.isempty(picid))return'';
		var step=3;
		var n=picid.length;
		var rets='';
		for(var i=0;i<n;i+=step){
			rets+=picid.substring(i,i+step)+'/'
		}
		return rets
	}
	,getDbPicNameNoExt:function(picid,sizeid){
		return picid+'_'+sizeid+'_'
	}
}
);
var hoverPopupBoxCache=({
}
);
jQuery.fn.extend({
	selectContents:function(){
$(this).each(function(i){
	var node=this;
	var selection,range,doc,win;
	if((doc=node.ownerDocument)&&(win=doc.defaultView)&&typeof win.getSelection!='undefined'&&typeof doc.createRange!='undefined'&&(selection=window.getSelection())&&typeof selection.removeAllRanges!='undefined'){
		range=doc.createRange();
		range.selectNode(node);
		if(i==0){
			selection.removeAllRanges()
		}
		selection.addRange(range)
	}
	else if(document.body&&typeof document.body.createTextRange!='undefined'&&(range=document.body.createTextRange())){
		range.moveToElementText(node);
		range.select()
	}
}
)
}
,setCaret:function(){
if(!$.browser.msie)return;
var initSetCaret=function(){
	var textObj=$(this).get(0);
	textObj.caretPos=document.selection.createRange().duplicate()
};
$(this).click(initSetCaret).select(initSetCaret).keyup(initSetCaret)
}
,insertAtCaret:function(textFeildValue){
var textObj=$(this).get(0);
if(document.all&&textObj.createTextRange&&textObj.caretPos){
	var caretPos=textObj.caretPos;
	caretPos.text=caretPos.text.charAt(caretPos.text.length-1)==''?textFeildValue+'':textFeildValue
}
else if(textObj.setSelectionRange){
	var rangeStart=textObj.selectionStart;
	var rangeEnd=textObj.selectionEnd;
	var tempStr1=textObj.value.substring(0,rangeStart);
	var tempStr2=textObj.value.substring(rangeEnd);
	textObj.value=tempStr1+textFeildValue+tempStr2;
	textObj.focus();
	var len=textFeildValue.length;
	textObj.setSelectionRange(rangeStart+len,rangeStart+len);
	textObj.blur()
}
else{
	textObj.value+=textFeildValue
}
}
,loadImgWithResize:function(imgsrc,maxImgWidth,maxImgHeight,extraParams){
var extraAttrs=jQuery.extend({
	'loadingImg':'','loadingWidth':12,'loadingHeight':12,'imgpos':'center','loadingBorder':'','okBorder':'','okCallback':null
}
,extraParams);
var getPaddingForLoadImg=function(type,w,h,mw,mh){
	var c_w=mw-w;
	var c_h=mh-h;
	if(c_w<0)cw=0;
	if(c_h<0)ch=0;
	if(c_w<=0&&c_h<=0)return'0px';

	switch(type){
		case'center':var mc_w=Math.floor(c_w/2);
		var mc_h=Math.floor(c_h/2);
		return mc_h+'px '+mc_w+'px';
		case'lefttop':return'0 '+c_w+'px '+c_h+'px 0';
		case'leftbottom':return c_h+'px '+c_w+'px 0 0';
		case'righttop':return'0 0 '+c_h+'px '+c_w+'px';
		case'rightbottom':return c_h+'px 0 0 '+c_w+'px'
	}
};
var imgPreloader=new Image();
var pImg=$(this);
if(!jQuery.isempty(extraAttrs.loadingImg)){
	if(extraAttrs.loadingBorder.length>0){
		pImg.css('border',extraAttrs.loadingBorder)
	}
	pImg.attr({
		width:extraAttrs.loadingWidth,height:extraAttrs.loadingHeight,src:extraAttrs.loadingImg
	}
	).css({
		margin:getPaddingForLoadImg(extraAttrs.imgpos,extraAttrs.loadingWidth,extraAttrs.loadingHeight,maxImgWidth,maxImgHeight)
	}
	)
}
imgPreloader.onload=function(){
	imgPreloader.onload=null;
	var x=maxImgWidth;
	var y=maxImgHeight;
	var imageWidth=imgPreloader.width;
	var imageHeight=imgPreloader.height;
	if(imageWidth>x){
		imageHeight=imageHeight*(x/imageWidth);
		imageWidth=x;
		if(imageHeight>y){
			imageWidth=imageWidth*(y/imageHeight);
			imageHeight=y
		}
	}
	else if(imageHeight>y){
		imageWidth=imageWidth*(y/imageHeight);
		imageHeight=y;
		if(imageWidth>x){
			imageHeight=imageHeight*(x/imageWidth);
			imageWidth=x
		}
	}
	if(extraAttrs.okBorder.length>0){
		pImg.css('border',extraAttrs.okBorder)
	}
	pImg.attr({
		width:imageWidth,height:imageHeight,src:imgsrc
	}
	).css({
		margin:getPaddingForLoadImg(extraAttrs.imgpos,imageWidth,imageHeight,maxImgWidth,maxImgHeight)
	}
	);
	if(typeof extraAttrs.okCallback=="function"){
		extraAttrs.okCallback(pImg)
	}
};
imgPreloader.src=imgsrc
}
,alignOffset:function(attrs,returnObject){
attrs=$.extend({
	hAlignment:0,vAlignment:0,width:0,height:0
}
,attrs);
var pos=this.offset({
	margin:false,scroll:true,relativeTo:$(document.body)
}
);
var w=this.outerWidth(),h=this.outerHeight();
try{
	if(/^input$/i.test(this[0].tagName)){
		w=this.innerWidth()
	}
}
catch(e){
}
switch(attrs.vAlignment){
	case 1:;
	break;
	case 2:pos.top+=(h-attrs.height)/2;
	break;
	case 3:pos.top-=attrs.height;
	break;
	default:pos.top+=h;
	break
}
switch(attrs.hAlignment){
	case 1:pos.left+=(w-attrs.width);
	break;
	case 2:pos.left+=(w-attrs.width)/2;
	break;
	case 3:pos.left+=w;
	break;
	case 4:pos.left-=attrs.width;
	break;
	default:;
	break
}
if(returnObject){
	$.extend(returnObject,pos);
	return this
}
else{
	return pos
}
}
,hoverPopupBox:function(attrs){
phoverTimer=null;
var pHolder=$(this);
attrs=$.extend({
	onload:function(resp){
		return resp
	}
	,content:null,url:'',img:'',width:100,height:30,maxImgWidth:400,maxImgHeight:400,hAlignment:0,vAlignment:0,hoverDelay:500,zindex:30002,loadingClass:'ac_loading',boxClass:'hoverpopbox',boxHandlerName:'zealHoverPopupBox'
}
,attrs);
var onHoverAct=function(){
	$('*',$('#'+attrs.boxHandlerName)).unbind();
	if($('#'+attrs.boxHandlerName).length<1){
		var initDivContent='';
		initDivContent+='<div id="'+attrs.boxHandlerName+'" class="'+attrs.boxClass+'" style="position: absolute; top: '+attrs.top+'px; left: '+attrs.left+'px; z-index: '+attrs.zindex+'; display: none;';
		if(attrs.width>0)initDivContent+=' width: '+attrs.width+'px;';
		initDivContent+='text-align:center;margin:auto;"><h2 class="'+attrs.boxClass+' small" style="width:100%;">单击进入固定模式，ESC 或 \'E\' (Maxthon下) 键退出</h2><div id="contentHolder_'+attrs.boxHandlerName+'" style="';
		if(attrs.width>0)initDivContent+=' width: '+attrs.width+'px;';
		if(attrs.height>0)initDivContent+=' height: '+attrs.height+'px;';
		initDivContent+=' overflow:auto;';
		initDivContent+='"></div></div>';
		$(document.body).append(initDivContent)
	}
	$('#'+attrs.boxHandlerName).css($.extend(pHolder.alignOffset(attrs),{
		width:attrs.width,'z-index':attrs.zindex
	}
	)).show();
	$('#contentHolder_'+attrs.boxHandlerName).empty().css({
		width:attrs.width,height:attrs.height
	}
	).addClass(attrs.loadingClass);
	if(!$.isempty(attrs.content)){
		var thedetail='';
		if($.isFunction(attrs.content)){
			thedetail=attrs.content(pHolder)
		}
		else{
			thedetail=attrs.content
		}
		$('#contentHolder_'+attrs.boxHandlerName).removeClass(attrs.loadingClass).html(thedetail)
	}
	else if(!$.isempty(attrs.img)){
		var imgPreloader=new Image();
		imgPreloader.onload=function(){
			imgPreloader.onload=null;
			var x=attrs.maxImgWidth;
			var y=attrs.maxImgHeight;
			var imageWidth=imgPreloader.width;
			var imageHeight=imgPreloader.height;
			if(imageWidth>x){
				imageHeight=imageHeight*(x/imageWidth);
				imageWidth=x;
				if(imageHeight>y){
					imageWidth=imageWidth*(y/imageHeight);
					imageHeight=y
				}
			}
			else if(imageHeight>y){
				imageWidth=imageWidth*(y/imageHeight);
				imageHeight=y;
				if(imageWidth>x){
					imageHeight=imageHeight*(x/imageWidth);
					imageWidth=x
				}
			}
			attrs.width=imageWidth+2;
			$('#'+attrs.boxHandlerName).width(attrs.width);
			$('#contentHolder_'+attrs.boxHandlerName).removeClass(attrs.loadingClass).width(attrs.width).height(imageHeight+20).append('<div class="center"><img border="0" src="'+attrs.img+'" width="'+imageWidth+'" height="'+imageHeight+'" /></div>');
			attrs.height=$('#'+attrs.boxHandlerName).outerHeight();
			var pos=pHolder.alignOffset(attrs);
			$('#'+attrs.boxHandlerName).css(pos)
		};
		imgPreloader.src=attrs.img
	}
	else{
		if(!(attrs.url in hoverPopupBoxCache)){
			$.ajax({
				url:attrs.url,complete:function(res,status){
					$('#contentHolder_'+attrs.boxHandlerName).removeClass(attrs.loadingClass);
					if(status=="success"){
						$('*',$('#contentHolder_'+attrs.boxHandlerName)).unbind();
						var details=attrs.onload(res.responseText);
						hoverPopupBoxCache[attrs.url]=details;
						$('#contentHolder_'+attrs.boxHandlerName).html(details)
					}
				}
			}
			)
		}
		else{
			$('#contentHolder_'+attrs.boxHandlerName).removeClass(attrs.loadingClass).html(hoverPopupBoxCache[attrs.url])
		}
	}
};
var onOutAct=function(){
	$(document).unbind('keydown');
	clearTimeout(phoverTimer);
	$('#'+attrs.boxHandlerName).hide();
	pHolder.unbind('mouseout',onOutAct).mouseout(onOutAct)
};
$(this).mouseover(function(){
	onOutAct();
	phoverTimer=setTimeout(onHoverAct,attrs.hoverDelay)
}
).mouseout(onOutAct).click(function(){
	pHolder.unbind('mouseout',onOutAct);
$(document).keydown(function(e){
	var keyname='E';
	if($.isKeyTrigger(e,27,false)||$.isKeyTrigger(e,keyname.charCodeAt(0),false)){
		onOutAct()
	}
}
)
}
);
return this
}
,numberVal:function(){
var t=$.toNumber($(this).val());
return $.isempty(t)?0:t
}
,outerHTML:function(){
return $('<div>').append(this.eq(0).clone()).html()
}
,printme:function(css,cssurl){
try{
css=css||false;
cssurl=cssurl||false;
var printframe=$('iframe#zealHdPrintIF');
if(printframe.length<1){
	printframe=document.createElement("iframe");
	printframe.id='zealHdPrintIF';
	printframe.width=0;
	printframe.height=0;
	printframe.style.position='absolute';
	printframe.style.top='-100px';
	printframe.style.left='-100px';
	document.body.appendChild(printframe)
}
else{
	printframe=printframe[0]
}
var doc=printframe.contentDocument||printframe.contentWindow.document;
doc.open();
doc.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="zh">');
doc.write('<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />');
if(css){
	doc.write('<style type="text/css">'+css+'</style>')
}
if(cssurl){
	doc.write('<link rel="stylesheet" type="text/css" media="all" href="'+cssurl+'" />')
}
doc.write('</head><body>');
doc.write(this.outerHTML());
doc.write('</body></html>');
doc.close();
var fw=printframe.contentWindow||printframe;
fw.focus();
fw.focus();
fw.print();
printframe=null;
doc=null;
fw=null
}
catch(e){
alert('当前浏览器不支持此打印方式！请使用IE/Firefox')
}
}
}
);

