window.util=function(){
	var D=document,s=(D.compatMode=="CSS1Compat"),lf={},ani={
		d:80,t:0,s:0,y:0,tm:null,f:1000/60,e:function(a,b,c,d){if(a==0)return b;if(a==d)return b+c;if((a/=d/2)<1)return c/2*Math.pow(2,10*(a-1))+b;return c/2*(-Math.pow(2,-10*--a)+2)+b},
		r:function(){
			if(ani.t<=ani.d){
				window.scroll(0,ani.e(ani.t++,ani.s,ani.y,ani.d));
				ani.tm=window.setTimeout(ani.r,ani.f)
			}else ani.c;
		},
		c:function(){
			if(ani.tm){
				$(D).unbind('mousedown keydown',ani.c)
				if(window.removeEventListener)window.removeEventListener('DOMMouseScroll',ani.c,false);window.onmousewheel=D.onmousewheel=null;
				window.clearTimeout(ani.tm);
				ani.tm=null
			}
		}
	};
    function post(me){
        var x=$.extend((function(x){x=x.split(',');var w={};for(var i in x)w[x[i]]=1;x={};for(var i in me.param){if(!w[i])x[i]=me.param[i]};return x})('msg,timeoutMsg,before,exec,success'),{signature:me.name,timeout:me.timeout}); 
        $('#frmPrint').remove();
        var frm=$("<form style='display:none' id='frmPrint' method='post' action='print.ashx?v="+(+new Date)+"'></form>");
        switch(typeof(x)){
	        case 'number':x+='';
	        case 'string':
			        var inp = $('<input type="text" name="param"/>');
			        inp.val(x);
			        frm.append(inp);
		        break;
	        case 'object':
			        var inp;
			        for(var n in x){
				        inp = $('<input type="text"/>');
				        inp.attr('name',n);
				        inp.val(x[n]);
				        frm.append(inp);
			        };
		        break;
	        default:alert('Invalid post parameters detected.');return;
        };			
        $(document.body).append(frm);frm.submit();
        window.setTimeout(function(){frm.remove()},1000)
    };
    function CookieTimer(o,p){
        this.i=0;
        this.me=$(o);
        this.name=(+new Date()); 
        this.timeout=60;        
        this.timer=null;
        this.param=$.extend({	
		    msg:'Printing...',
            timeoutMsg:'Print has timed out. Please refresh this page and try again.',
            title:D.title,
            body:'',
            head:'',
            before:function(m){},
            exec:post,
            success:function(m){}
	    },p);
    };
    CookieTimer.prototype.run=function(){
        var me=this;
        if(this.param.before(me)==false)return false;
        this.me.hide().after("<span><img src='images/loading_spin_sm.gif'"+(this.param.msg==''?'':" style='vertical-align:middle;margin-right:10px'")+" />"+this.param.msg+"</span>");
        this.timer=setInterval(function(){
            if(++me.i>me.timeout){
                alert(me.param.timeoutMsg);
                clearInterval(me.timer);
                me.timer=null;
                me.me.show().next().remove();
				delete lf[me.me.attr('id')]
            }else if(D.cookie.indexOf('PdfRender'+me.name)>=0){
                clearInterval(me.timer);
                me.timer=null;
                me.me.show().next().remove();
                me.param.success(me);
				delete lf[me.me.attr('id')]
            }
        },1000);
        this.param.exec(me);
    };
	return{
		ceilRound:function(d,p){
			var i=Math.pow(10,p);
			return(Math.ceil(((d*i*1e4>>0)/1e4))/i).toFixed(p)
		},
		HtmlEncode:function(x){x+='';return x.replace(/&/g,'&amp;').replace(/"/g,'&quot;').replace(/</g,'&lt;').replace(/>/g,'&gt;')},
		HtmlDecode:function(x){x+='';return x.replace(/&quot;/ig,'"').replace(/&amp;/ig,'&').replace(/&lt;/ig,'<').replace(/&gt;/ig,'>')},
		document:{
			width:function(){return Math.max(s?D.documentElement.scrollWidth:D.body.scrollWidth,util.window.width())},
			height:function(){return Math.max(s?D.documentElement.scrollHeight:D.body.scrollHeight,util.window.height())}
		},		
		window:{
			width:function(){return s||$.browser.opera?($.browser.msie?D.documentElement.clientWidth:self.innerWidth):D.body.clientWidth},
			height:function(){return s||$.browser.opera?($.browser.msie?D.documentElement.clientHeight:self.innerHeight):D.body.clientHeight}
		},
		ajax:function(func,postObj,callback,beforeSendFunc,s){
			var x=window.location.pathname;
			$.ajax({
				type:"POST",
				url:(~func.search(/\/|\./)?func:x.slice(x.lastIndexOf('/')+1)+'/'+func),
				data:"{json:"+(typeof postObj==='object'?$.toJSON(postObj):'"'+postObj.replace(/"/g,'\\"')+'"')+"}",
				contentType:"application/json; charset=utf-8",
				dataType:"json",
				async:typeof s==="boolean"?s:true,
				error:function(a,b,c){
					alert(a.statusText+'\r\n\r\n'+a.responseText)
				},
				success:callback||function(){},
				beforeSend:beforeSendFunc||function(){}
			})
		},
        loadFile:function(p,cb,lo){
            if(lf[p]){alert(p+' has already been loaded.');return false}
            var x=null;if(!p)x='path';if(!cb)x='callback';
            if(x){alert('A '+x+' is required to load a file.');return false}
            if(typeof cb==='object'&&typeof lo==='function')$.post(p,cb,lo);else{
				if(lo)lf[p]=true;//load once
				$.get(p+(p.indexOf('?')>0?'&':'?')+'v='+(+new Date),cb);
			}
        },
        print:function(o,p){
			try{
				if(lf[o.id])return false;
				lf[o.id]=true;
				(new CookieTimer(o,p)).run()
			}catch(e){}			
		},
		scrollTo:function(o,t,d){
			ani.t=t||0;
			ani.d=d||80;
			if(!!o){
				switch(typeof(o)){
					case 'number':ani.y=o;break
					case 'object':ani.y=o.position().top;break;
					case 'string':ani.y=$('#'+o).position().top;break;
					default:return false
				};
				var D=$(document),dh=D.height(),wh=$(window).height();ani.s=D.scrollTop();
				if(dh-ani.y>=wh)ani.y-=ani.s;else ani.y=dh-wh-ani.s;
				$(document).bind('mousedown keydown',ani.c).bind('keypress',ani.c)
				try{if(window.addEventListener)window.addEventListener('DOMMouseScroll',ani.c,false);window.onmousewheel=document.onmousewheel=ani.c}catch(e){alert("ERROR 5: "+(e.message||e.description))} 
				window.clearTimeout(ani.tm);ani.r()
			}
		},
		GetPageInfo:function(){
			var sb=new StringBuilder()
			try{
				sb.append('\r\n==========================================\r\n')
				sb.append('Screen Resolution\r\n')
				sb.append('==========================================\r\n')
				sb.append('Screen: ' + window.screen.width + 'x' + window.screen.height + '\r\n')
				sb.append('Avail Screen: ' + window.screen.availWidth + 'x' + window.screen.availHeight + '\r\n')
				sb.append('Color Depth: ' + window.screen.colorDepth + '\r\n')
				sb.append('\r\n==========================================\r\n')
				sb.append('Window Resolution\r\n')
				sb.append('==========================================\r\n')
				sb.append('Window: ' + $(window).width() + 'x' + $(window).height() + '\r\n')
				sb.append('Page: ' + $(d).width() + 'x' + $(d).height() + '\r\n')
			} catch(err){}
			return sb.toString()
		},
		/**
		* this function allows javascript files to be lazy loaded as needed
		* src: path to the javascript file
		* test: function that test wether the script has been loaded. true means that the script has not been loaded
		* success: function to call once the script has been loaded
		**/
		RequireScript:function(src, test, success){
			var time = 0;
			var loop = function(){
				if(test()){
					time += 200;
					if(time>3000){
						Modal.showAlert('Critical Error... Unable to load script');
						return
					} else
						setTimeout(loop, 200);
				} else
					success();
			}
			if(test()){
				var script = document.createElement('script');
				script.type = 'text/javascript';
				document.getElementsByTagName("head")[0].appendChild(script);
				script.src = src;
				loop()
				return
			} else
				success();
		}
	};
}();

var dialog,JSON=function(){this.str=new Array()};JSON.prototype={add:function(x,y,isSafeString){this.str.push((this.str.length>0?', ':'')+'"'+(isSafeString?(x+'').toSafeString():x+'')+'":"'+(isSafeString?(y+'').toSafeString():y+'')+'"')},toString:function(){return'{'+this.str.join('')+'}'},clear:function(){this.str.length=0},toObject:function(){return this.toString().toObject()}};function formatNumber(v,d){v=(''+v).replace(/[^\d.]/g,'');if(d)v=(v*1).toFixed(d*1);x=v.split('.');x1=x[0];x2=x.length>1?'.'+x[1]:'';var rgx=/(\d+)(\d{3})/;while(rgx.test(x1)){x1=x1.replace(rgx,'$1'+','+'$2')}return(x1+x2)};function openWindow(x){try{var wd=800,ht=600;if(self.innerHeight){wd=self.innerWidth;ht=self.innerHeight}else if(window.document.documentElement&&window.document.documentElement.clientHeight){wd=window.document.documentElement.clientWidth;ht=window.document.documentElement.clientHeight}else if(window.document.body){wd=window.document.body.clientWidth;ht=window.document.body.clientHeight}if(typeof(x)=='object'){if(x.name==undefined)x.name='_blank';if(x.height==undefined)x.height=ht;if(x.width==undefined)x.width=wd;if(window[x.name]==undefined||window[x.name].closed)window[x.name]=window.open(x.url,x.name,'width='+x.width+',height='+x.height+',top='+((screen.height-x.height)/2-20)+',left='+((screen.width-x.width)/2-20)+',scrollbars='+(x.scroll?x.scroll:'yes')+',resizable='+(x.resize?x.resize:'yes')+',location=no');else{window[x.name].location.href=x.url;window[x.name].focus()}return window[x.name]}else return window.open(x,'_blank','width='+wd+',height='+ht+',top='+((screen.height-ht)/2-20)+',left='+((screen.width-wd)/2-20)+',scrollbars='+(x.scroll?x.scroll:'yes')+',resizable='+(x.resize?x.resize:'yes')+',location=no')}catch(err){alert(err.description);return null}};function fadeInClear(){if(!$.support.opacity){this.style.removeAttribute('filter')}};String.prototype.toObject=function(){try{var x=eval('('+this+')');if(typeof x=='object')return x;else return'Invalid JSON object detected.'}catch(e){return(!!e.description?e.description:e)}};String.prototype.toNumeric=function(){return this.replace(/[^\d.]/g,'')*1};String.prototype.toSafeString=function(){return this.replace(/["'%\r\n]/g,function(z){switch(z){case'%':return'%25';case'"':return'%22';case"'":return'%27';case"\r":return'%0D';case"\n":return'%0A'}})};String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")};String.prototype.noCommas=function(){return this.replace(new RegExp(',','g'),'')};function deserializeIt(str){var o,k=str.trim().split('&'),z=new Object();for(var i in k){o=k[i].split('=');z[o[0]]=unescape(o[1])};return z};String.prototype.isEmail=function(){return (new RegExp('^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}$','ig')).test(this.trim())};StringBuilder=function(){this.str=[]};StringBuilder.prototype={append:function(x){this.str.push(x)},toString:function(x){return this.str.join(x?x:'')},clear:function(){this.str.length=0}};if(!!window.$){(function($){if($.browser.mozilla){$.fn.disableTextSelect=function(){return this.each(function(){$(this).css({"MozUserSelect":"none"})})};$.fn.enableTextSelect=function(){return this.each(function(){$(this).css({"MozUserSelect":""})})}}else{if($.browser.msie){$.fn.disableTextSelect=function(){return this.each(function(){$(this).bind("selectstart.disableTextSelect",function(){return false})})};$.fn.enableTextSelect=function(){return this.each(function(){$(this).unbind("selectstart.disableTextSelect")})}}else{$.fn.disableTextSelect=function(){return this.each(function(){$(this).bind("mousedown.disableTextSelect",function(){return false})})};$.fn.enableTextSelect=function(){return this.each(function(){$(this).unbind("mousedown.disableTextSelect")})}}};$.fn.ieDropDownFixedWidth=function(){if(!$.browser.msie)return;return this.each(function(){if(this.tagName!='SELECT')return;var me=this,o=$(me),wd=o.outerWidth(true)+'px',ddl=o.clone().addClass('noadd').attr('tabIndex','-1').removeAttr('id').removeAttr('title').css({position:'absolute',top:0,left:0,width:'auto',opacity:0}).change(function(){me.selectedIndex=this.selectedIndex;o.trigger('change')});if(wd==='0px')wd=o.css('width');o.wrap("<span style='position:relative' />").wrap("<span style='position:absolute;top:0;left:0;overflow:hidden;width:"+wd+"' />").before(ddl);o.parent().after($("<select />").css({width:wd,visibility:'hidden'}))})};$.fn.serializeIt=function(z){var x=[],e=$(this).find(':input:not(.noadd)');if(z&&typeof(z)=='object')z=$.extend({remove:'',excludeDisabled:0,excludeHidden:0},z);else z={remove:z,excludeDisabled:0,excludeHidden:0};$.each(e,function(){var o=$(this);if((z.excludeDisabled&&o.attr('disabled'))||(z.excludeHidden&&!o.is(':visible')))return;if (this.id && /text|hidden|password|radio|checkbox|select/i.test(this.type)){x.push(escape(!!z.remove?this.id.replace(z.remove,''):this.id)+"=" + escape(/radio|checkbox/i.test(this.type)?$(this).attr('checked'):$(this).val()))}});return x.join("&")};$.fn.filterKey=function(a){var allow='';if(a&&a.allow)allow+=a.allow;function checkVal(o,e){var i=e.charCode||e.keyCode||e.which;if(i<32||((e.ctrlKey||e.metaKey)&&(i==97||i==110||i==116||i==65||i==120||i==88||i==99||i==67||i==122||i==121||i==90||i==118||i==86))||(e.shiftKey&&i==45)||(e.charCode==0&&(e.keyCode==37||e.keyCode==39||e.keyCode==46)))return true;if(i==46&&isValid('.')){return(o.value.indexOf('.')<0)}else if(i>64&&i<91)i+=32;return isValid(String.fromCharCode(i))}function isValid(x){return(allow.indexOf(x.toLowerCase())>=0)}return this.each(function(){var me=this;$(this).bind('keypress',function(e){e=e||window.event;return checkVal(me,e)}).bind('paste',function(){setTimeout(function(){var x=me.value.split('');for(var j in x){if(!isValid(x[j])){me.value='';break}}},0);return true})})};$.fn.numeric=function(a){var x='0123456789';if(a&&a.allow)x+=a.allow;return this.each(function(){$(this).filterKey({allow:x})})};$.fn.currency=function(s,d){function seek(input,t,cp){var i=0;for(var ln=t.length;cp>0&&i<ln;++i){if((new RegExp('\\d','g')).test(t.charAt(i)))--cp};input.val(t).caret(input.d?Math.max(i,1):i)};return this.each(function(){var input=$(this),oriVal=input.val(),mx=input.attr('maxlength'),pos=null,def={showDollar:true,length:-1,decimalPlace:2},ret=false,a,p;if(typeof(s)==='object'){def=$.extend(def,s);a=def.showDollar;p=def.decimalPlace>0}else{a=((s&&s===true)||s===undefined);p=((d&&d===true)||d===undefined)};var fl=input.attr('len'),fd=input.attr('dec'),sd=input.attr('showDollar');if(fl!=undefined)def.length=fl*1;if(fd!=undefined){def.decimalPlace=fd*1;p=(def.decimalPlace>0)};if(sd!=undefined){def.showDollar=(sd=='1');a=def.showDollar};if(def.length>=0){mx=Math.ceil(def.length/3)-1;mx+=def.length;if(def.showDollar)++mx;if(def.decimalPlace>0)mx+=def.decimalPlace+1;input.attr('maxlength',mx)};function c(v){var x=v.replace(/[^\d\.]+/g,'').split('.'),rgx=/(\d+)(\d{3})/,x1=x[0].replace(/^0+(\d+)$/g,'$1'),x2='';if(x.length==2)x2=(p?'.'+x[1]:'');if(def.length>=0){x1=x1.substr(0,def.length);if(def.decimalPlace>0)x2=x2.substr(0,def.decimalPlace+1)};while(rgx.test(x1)){x1=x1.replace(rgx,'$1'+','+'$2')};if(a)return('$'+x1+x2);return(x1+x2)};this.currencyRefresh=function(){input.val(c(input.val()))};input.d=a;input.bind('focus',function(e){oriVal=input.val()}).bind('keydown',function(e){var k=e.keyCode;if(!p&&(k===110||k===190)){ret=true;return false};pos=input.caret();var sc=(pos.begin==pos.end),ov=input.val(),dc=ov.indexOf('.');ret=false;if(k==8||k==46){var l=ov.substr(0,pos.begin),r=ov.substr(pos.end),cp=l.replace(/\D+/g,'').length;if((new RegExp('\\.[\\d,]','g')).test(l))return true;if(k==8){if((new RegExp('\\.$','g')).test(l)&&sc)ov=c(l.replace(/\.$/g,'')+''+r);else if(sc){if(l=='$'){ret=true;return false};ov=c(l.replace(/(?:,?\d|\d,?)$/g,'')+''+r);--cp}else ov=c(l+''+r)}else if((new RegExp('^\\.','g')).test(r)&&sc)ov=c(l+''+r.substr(1));else ov=c(l+''+(sc?r.replace(/^(?:,?\d|\d,?)/g,''):r));seek(input,ov,cp);ret=true;return false}else if(k==27){setTimeout(function(){seek(input,oriVal,pos.begin)},0);ret=true;return false}else if((k==190||k==110)&&ov!=''&&dc<0){var l=ov.substr(0,pos.begin),r=ov.substr(pos.end).replace(/\D+/g,'');ov=c(l);input.val(ov+'.'+r).caret(ov.length+1);ret=true;return false}else{var l=ov.substr(0,pos.begin).replace(/[^\d\.]+/g,''),tp=def.length>0;if(tp){rs=(dc>=0&&pos.begin>dc),tp=(((k>47&&k<58)||(k>95&&k<106))&&((!rs&&ov.substr(0,dc<0?ov.length:dc).replace(/[^\d]+/g,'').length>=def.length)||(rs&&ov.substr(dc+1).length>=def.decimalPlace)))};if((pos.end-pos.begin)<1&&(tp||(e.shiftKey&&k==52)||k==188||((k==96||k==48)&&l.indexOf('.')<0&&l*1<=0&&ov.replace(/[^\d\.]+|\.\d+$/g,'').length>0&&sc)||((k==16||k==37)&&l.length<1))){ret=true;return false}}}).bind('keypress',function(e){if(ret)return false;e=e||window.event;var k=e.charCode||e.keyCode||e.which;if(k>47&&k<58){setTimeout(function(){var v=input[0].value,b=v.length;if(mx>0&&b>mx)return false;input.val(c(v)).caret(pos.begin+(b===input[0].value.length?1:2))},0)}}).bind('paste',function(){setTimeout(function(){var t=input.val();seek(input,c(t),t.substr(0,input.caret().begin).replace(/\D+/g,'').length)},0)}).filterKey({allow:(p?'.':'')+'0123456789,'+(a?'$':'')}).val(c(oriVal))})};$.fn.caret=function(b,e){if(this.length==0)return;if(typeof b=='number'){e=(typeof e=='number')?e:b;return this.each(function(){if(this.setSelectionRange){this.focus();this.setSelectionRange(b,e)}else if(this.createTextRange){var r=this.createTextRange();r.collapse(true);r.moveEnd('character', e);r.moveStart('character', b);r.select()}})}else{if(this[0].setSelectionRange){b=this[0].selectionStart;e=this[0].selectionEnd}else if(document.selection&&document.selection.createRange){var r=document.selection.createRange();b=0-r.duplicate().moveStart('character',-100000);e=b+r.text.length}return{begin:b,end:e}}};$.fn.alpha=function(a){var x='abcdefghijklmnopqrstuvwxyz';if(a&&a.allow)x+=a.allow;return this.each(function(){$(this).filterKey({allow:x})})};$.fn.toUpperCase=function(){return this.each(function(){$(this).css('text-transform','uppercase')})};$.fn.toLowerCase=function(){return this.each(function(){$(this).css('text-transform','lowercase')})}})(jQuery);(function($){var curr=null,q=0,j=null,k=null,timer=null;$.fn.tooltip=function(a){var def=$.extend({locked:false,padding:8,background:'',width:-1,offsetX:0,offsetY:0,zIndex:2000},a);function over(e){if(curr===this&&q)ct();else{if(q)cr();curr=this;var param=$(curr).data('param');$(document.body).append("<div id='xTipS' style='position:absolute;z-index:"+param.zIndex+";display:none;background:#aaa;filter:alpha(opacity=60);opacity:0.6;-moz-opacity:0.6'></div><div id='xTip' style='"+param.css+"'>"+param.tip+"</div>");j=$('#xTip');if(param.width>0)j.css('width',param.width);if(param.background!='')j.css('background',param.background);j.data('parent',this).hover(function(){if(j.data('parent')===curr)ct()},n).css({padding:param.padding,zIndex:param.zIndex+1}).fadeIn();k=$('#xTipS').css({width:(param.width>0?param.width+2:j.outerWidth(true)-16),height:j.outerHeight(true)-16,padding: param.padding}).fadeIn();move(e,param.offsetX*1,param.offsetY*1)}};function move(e,x,y){j.css({'left':(e.pageX+x+20)+'px','top':(e.pageY+y-10)+'px'});k.css({'left':(e.pageX+x+23)+'px','top':(e.pageY+y-7)+'px'})};function ct(){q=0;window.clearTimeout(timer)};function cr(){ct();j.unbind('mouseenter').unbind('mouseleave').remove();k.unbind('mouseenter').unbind('mouseleave').remove()};function n(){q=1;timer=window.setTimeout(cr,500)};return this.each(function(){var tip=this.title,css='';if(!tip)return;if(tip.match(/^\#\w+$/g)){var m=$(tip);tip=m.html();css=m.attr('style').replace(/(display|position|(padding|margin)(-\w+)?) *: *\w[^;]+;?/ig,'')};var o=$(this),param=$.extend({},def,{locked:o.attr('locked'),padding:o.attr('padding'),background:o.attr('background'),width:o.attr('TipWidth'),offsetX:o.attr('offsetX'),offsetY:o.attr('offsetY'),tip:tip,css:css});param.padding*=1;param.width*=1;param.offsetX*=1;param.offsetY*=1;o.data('param',param);o.removeAttr('title').hover(over,n);if(!param.locked)o.mousemove(function(e){move(e,param.offsetX*1,param.offsetY*1)})})}})(jQuery);function callServer(func,postData,successFunc,beforeSendFunc,s){var x=window.location.pathname;$.ajax({type:"POST",url:(func.lastIndexOf('/')>0?func:x.substring(x.lastIndexOf('/')+1)+'/'+func),data:"{'str':'"+postData+"'}",contentType:"application/json; charset=utf-8",dataType:"json",async:(s!=undefined&&typeof(s)=='boolean')?s:true,error:function(a,b,c){alert(a.statusText+'\r\n\r\n'+a.responseText)},success:!!successFunc?function(z){if(z&&z.d2h!=undefined)z.get=function(f){for(var i=0,ln=z.d2h;i<ln;++i){f(i)}};successFunc(z)}:function(){},beforeSend:!!beforeSendFunc?beforeSendFunc:function(){}})};$(function(){if(!!($.ui&&$.ui.dialog)){$.extend($.ui.dialog.overlay,{isOpen:function(){return this.instances.length>1}});dialog={show:function(me,id,obj){var o=$('#'+id);if(o.dialog('isOpen')==undefined)o.dialog($.extend({modal:true,closeOnEscape:false,width:400,maxWidth:800,minWidth:300,maxHeight:600,minHeight:100,resizable:false},obj));else{dialog.x(o.data("dialog").uiDialog);if(obj){if(obj.width)o.dialog('option','width',obj.width);if(obj.title)o.dialog('option','title',obj.title)};o.dialog('open')};if($.ui.dialog.overlay.isOpen()&&!!me){var p=$(me).parents('div.ui-dialog');o.data("dialog").uiDialogTitlebar.find('a.ui-dialog-titlebar-close').bind('click',function(){dialog.x(p);return false});var wd='100%',ht='100%';if($.browser.msie&&$.browser.version<7){wd=p.outerWidth(true)+'px';ht=p.outerHeight(true)+'px'};p.append("<div class='modalLayer' style='position:absolute;top:0;left:0;width:"+wd+";height:"+ht+";background:#000;filter:alpha(opacity=40);opacity:0.4;-moz-opacity:0.4'></div>");o.data('modal',p).data("dialog").overlay.$el.css("opacity",0)}},x:function(x){x.find('div.modalLayer').remove()},css:function(x,css){if(typeof(x)=='string')x=$('#'+x);else if(!(x instanceof jQuery))x=$(x);x=x.parent();if(x.hasClass('ui-dialog'))x.css(css)},hide:function(me){if(!!me){if(typeof(me)=='string')me=document.getElementById(me);var o=$(me).data('modal');if(o)dialog.x(o);$(me).dialog("close")}else $('body > div.ui-dialog > div.ui-dialog-titlebar > a.ui-dialog-titlebar-close').trigger('click')}}};$.validate={spriteSrc:'images/icoValidate1.gif',spriteSize:21,reqMsg:'This field is required.',errMsg:'An error has been detected here.'};$.fn.extend({validate:function(settings){settings=$.extend({color:'#000',tipColor:'#c0c0c0',invalidColor:'#e00',invalidBgColor:'#EF9F7A',validColor:'#0e0',validBgColor:'#B8E894',showIcon:true,reqMsg:$.validate.reqMsg,tipMsgDisplay:'inside',invalidMsgDisplay:'outside'},settings);var exp={email:"^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}$",phone:"^(?:(?:\\(\\d{3}\\) )|(?:\\d{3}-))\\d{3}-\\d{4}(?: x\\d+)?$",ss:"^\\d{3}(-)?\\d{2}\\1\\d{4}$",zipcode:"^\\d{5}(?:-\\d{4})?$",date:"^\\d{1,2}(/|\\.|-)\\d{1,2}\\1\\d{2,4}$"};return this.each(function(){if(this.val)return;var tip=false,me=$(this).addClass('validate'),bgc=me.css('backgroundColor'),pw=null;this.req=me.hasClass('req');this.ico=(me.attr('ico')=='*');this.noBGClr=(me.attr('noBGClr')=='true');this.tip=$.trim(me.attr('tip'));var x,valid=function(){return true};if(settings.exp&&typeof settings.exp=='function')valid=settings.exp;else{if(settings.exp)x=settings.exp;else{if(me.attr('exp'))x=me.attr('exp');else{alert('No expression found for ID '+this.id+'.');return}}if(x.match(/^.+\(\)$/ig))valid=window[x.replace('()','')];else if(x.match(/^\{(?:req|require)\}$/ig))valid=function(v){return v.length>0};else if(x.match(/^\{\w+\}$/ig))valid=function(v){return(new RegExp(exp[x.replace(/^\{|\}$/g,'')],'ig')).test(v)};else valid=function(v){return(new RegExp(x,'ig')).test(v)}};if(settings.offsetX)this.offsetX=settings.offsetX;else if(me.attr('offsetX'))this.offsetX=me.attr('offsetX');else this.offsetX=0;if(settings.offsetY)this.offsetY=settings.offsetY;else if(me.attr('offsetY'))this.offsetY=me.attr('offsetY');else this.offsetY=0;if(settings.err)this.err=settings.err;else if(me.attr('err'))this.err=me.attr('err');else this.err=$.validate.errMsg;if(settings.tipMsgDisplay=='outside'&&settings.invalidMsgDisplay=='outside'){me.after("<div class='invalidMsgDisplay' style='display:none' />").data('tip',me.next());tip=(settings.invalidMsgDisplay=='outside')};if(settings.parentWidth)pw=settings.parentWidth;else if(me.attr('parentWidth')){pw=me.attr('parentWidth');me.removeAttr('parentWidth')};if(settings.showIcon){var d=this.tagName.match(/^(fieldset|div|table|ul|ol|dl|p|form|pre|center|h\d+)$/ig);me.wrap("<"+(d?'div':'span')+" style='"+(d?'':'font-size:medium;')+"position:relative;zoom:1;margin-left:1px"+(pw?';width:'+pw+'px':'')+"' />").after("<span style=\"position:absolute;top:"+(this.offsetY*1)+"px;right:"+(($.validate.spriteSize+4+(this.offsetX*1))*-1)+"px;background:url('"+$.validate.spriteSrc+"') 0 0 no-repeat;"+(settings.showIcon&&this.req?'':'display:none')+"\"><img src='"+$.validate.spriteSrc+"' width='"+$.validate.spriteSize+"' height='"+$.validate.spriteSize+"' style='visibility:hidden' /></span>");d=null};function bg(c){if(/msie/i.test(navigator.userAgent))setTimeout(function(){me.css('backgroundColor',c)});else me.css('backgroundColor',c)};function showGrn(){if(tip){me.data('tip').hide().html('')}else if(settings.invalidMsgDisplay.match(/^#\w+$/ig)){$(settings.invalidMsgDisplay).hide().html('')};if(settings.showIcon)me.data('ico').removeAttr('title').css({'backgroundPosition':'0 '+($.validate.spriteSize*-1)+'px','cursor':'default'}).show()};function showErr(v){var t=me[0].err.replace('{$}',!!v?v:"'blank'");if(settings.showIcon)me.data('ico').removeAttr('title').css({'backgroundPosition':'0 '+(v=='*'?'0':$.validate.spriteSize*-2)+'px','cursor':'default'}).show();if(tip){me.data('tip').css('color',settings.invalidColor).show().html(t)}else if(settings.invalidMsgDisplay.match(/^#\w+$/ig)){$(settings.invalidMsgDisplay).css('color',settings.invalidColor).show().html(t)}else if(settings.showIcon)me.data('ico').attr('title',t).css('cursor','help')};function req(){if(settings.showIcon){if(me[0].req){me.data('ico').attr('title',settings.reqMsg).css({'backgroundPosition':'0 0','cursor':'help'}).show();return true}else{me.data('ico').hide();return false}}else return me[0].req};function clrTip(){if(tip){me.data('tip').hide().html('')}else if(settings.invalidMsgDisplay.match(/^#\w+$/ig)){$(settings.invalidMsgDisplay).hide().html('')}}if(settings.showIcon){me.data('ico',me.next().removeAttr('title').css('cursor','default'))};if(this.tagName.match(/input|textarea/ig)){if(this.type.match(/text|password|textarea/ig)){this.resetVal=function(x){if(!this.noBGClr)me.css('backgroundColor',bgc);me.css('color',settings.color).val('');if(x)this.val();else{req();clrTip()}};this.val=function(){var v=$.trim(this.value);if(valid(v,this)){this.valid=true;showGrn();if(!this.noBGClr)bg(settings.validBgColor)}else{this.valid=false;if(v==''){if(!this.noBGClr)bg(bgc);if(settings.tipMsgDisplay=='inside'){if(this.tip)me.css('color',settings.tipColor).val(this.tip);if(tip){me.data('tip').hide().html('')}else if(settings.invalidMsgDisplay.match(/^#\w+$/ig)){$(settings.invalidMsgDisplay).hide().html('')}}else if(tip&&settings.tipMsgDisplay=='outside'){me.data('tip').css('color',settings.tipColor).show().html(this.tip)}else if(settings.invalidMsgDisplay.match(/^#\w+$/ig)){$(settings.invalidMsgDisplay).hide().html('')}if(req()){if(!this.noBGClr)bg(settings.invalidBgColor);if(tip){me.data('tip').css('color',settings.invalidColor).show().html(settings.reqMsg)}else if(settings.invalidMsgDisplay.match(/^#\w+$/ig)){$(settings.invalidMsgDisplay).css('color',settings.invalidColor).show().html(settings.reqMsg)}}}else{showErr(v);if(!this.noBGClr)bg(settings.invalidBgColor)}}return this.valid};me.focus(function(){if(settings.tipMsgDisplay=='inside'&&$.trim(this.value)==this.tip)me.css('color',settings.color).val('')}).blur(this.val)}else if(this.type.match(/checkbox|radio/ig)){this.resetVal=function(x){this.checked=false;if(x)this.val();else{req();clrTip()}};this.val=function(){if(!this.req)return true;var v=this.checked;if(valid(v,this)){this.valid=true;showGrn()}else{this.valid=false;showErr(v)}return this.valid};me.click(function(){me[0].val()})}}else{var isDDL=(this.tagName=='SELECT');this.val=function(){if(!this.req)return true;if(valid(this)){this.valid=true;showGrn();if(isDDL&&!this.noBGClr)bg(settings.validBgColor)}else{this.valid=false;showErr(this.ico?'*':null);if(isDDL&&!this.noBGClr)bg(settings.invalidBgColor)}return this.valid};if(isDDL){this.resetVal=function(x){this.selectedIndex=(this.type=='select-multiple'?-1:0);if(!this.noBGClr)this.style.backgroundColor=bgc;if(x)this.val();else{req();clrTip()}};me.change(this.val)}else{this.resetVal=function(x){me.find('input:checkbox,input:radio,input:text,input:password,select,textarea').each(function(){if(this.resetVal)this.resetVal();else{var t=this.type,o=$(this);if(t.match(/textarea|text|password/ig)){if(!this.noBGClr)o.css('backgroundColor',bgc);o.css('color',settings.color).val('')}else if(t.match(/radio|checkbox/ig)){this.checked=false}else{this.selectedIndex=(t=='select-multiple'?-1:0);if(!this.noBGClr)this.style.backgroundColor=bgc}}});if(x)this.val();else{req();clrTip()}};me.find('input:checkbox,input:radio,input:text,input:password,select,textarea').each(function(){var t=this.type,o=$(this);if(t.match(/textarea|text|password/ig))o.blur(function(){me[0].val()});else if(t.match(/radio|checkbox/ig))o.click(function(){me[0].val()});else o.change(function(){me[0].val()})})}}this.val()})},isValid:function(f,b){if(typeof(b)==='boolean'&&!b)b='';else b=':visible';function val(x){if(x.tagName.match(/input|textarea/ig)&&x.type.match(/text|password|textarea/ig)){var t=$.trim(x.value);if(x.req||(t!=''&&t!=x.tip))return x.val();return true}else return x.val()};if(this.is('.validate'+b)){var r=val(this[0]);if(f&&typeof(f)=='function'){var t=$.trim(this[0].value),err=this.attr('err').replace('{$}',!!t?t:"'blank'");if(!r){if(this.is(':visible')&&!this.attr('disabled'))this[0].focus();if(err.length>0)f(err)}};return r}else{var v=true,p=(f&&typeof(f)=='function'),sb=[],o=null;this.find('.validate'+b).each(function(){if(!val(this)){v=false;if(p){if(!o)o=this;var m=$(this),t=$.trim(this.value),err=m.attr('err').replace('{$}',!!t?t:"'blank'");if(err)sb.push(err)}else return false}});if(o&&$(o).is(':visible')&&!o.disabled)o.focus();if(p&&sb.length>0)f(sb.join('\n'));return v}},Required:function(b){this.attr('req',b);b=this.attr('val');if(b&&typeof(b)==='function'){b()}else{this.attr('err',this.descName+' is required.').addClass('req').validate({showIcon:false,invalidMsgDisplay:'none',exp:'{req}'})};this.trigger('blur')},resetValidate:function(validateOnReset,b){if(typeof(b)==='boolean'&&!b)b='';else b=':visible';if(this.is('.validate'+b))this[0].resetVal(validateOnReset);else this.find('.validate'+b).each(function(){this.resetVal(validateOnReset)})}})})}

//Xai - //a mod version of Aaron's isDate Function
String.prototype.parseDate=function(){if((new RegExp('^(\\d{1,2})(\\/|\\.|-)(\\d{1,2})\\2(\\d{2}|\\d{4})$','ig')).test(this)){var y=(RegExp.$4.length==2?'20'+RegExp.$4:RegExp.$4),x=RegExp.$1+'/'+RegExp.$3+'/'+y,d=new Date(x);if((d.getMonth()+1)==RegExp.$1&&d.getDate()==RegExp.$3&&d.getFullYear()==y&&d.getFullYear()>=1900&&d.getFullYear()<=2079)return x};return ''}

var Modal
$(function() {
    if ($('form').length > 0) $('form').append("<div id='modalPopupDiv'></div><div id='modalObjectArea' style='display:none'></div>");
    else $('body').append("<div id='modalPopupDiv'></div><div id='modalObjectArea' style='display:none'></div>");
    Modal = {
        Block: $('#modalPopupDiv'),
        PreserveObj: false,
        Obj: null,
        Y: 0,
        OrigHt: 0,
        OrigWd: 0,
        InBlock: false,
        InIFrame: window != window.top,
        setMouseY: function(evt) { if (!evt) var evt = window.event; if (evt.pageY) Modal.Y = evt.pageY; else if (evt.clientY) Modal.Y = evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); },
        left: function(wd) { return (util.window.width() - wd) / 2 + 'px' },
        top: function(ht) { return (util.window.height() - ht) / 2 + 'px' },
        resetBlock: function() { if (Modal.PreserveObj) { $('#modalObjectArea').append(Modal.Obj); Modal.Obj = null; Modal.PreserveObj = false } Modal.Block.removeAttr("style"); Modal.Block.css({ padding: '25px', color: '#666', cursor: 'default', display: 'none', backgroundColor: '#FFF', margin: '0' }) },
        resetWindow: function() { if (Modal.PreserveObj) { $('#modalObjectArea').append(Modal.Obj); Modal.Obj = null; Modal.PreserveObj = false } Modal.Block.removeAttr("style"); Modal.Block.css({ padding: '10px', color: '#666', cursor: 'default', display: 'none', backgroundColor: '#FFF', margin: '0' }) },
        showWindow: function(input/*title*/, obj, wd, ht) {
            var title, dynamicContent = false, x = false, y = false, bindEvents = true;
            Modal.resetWindow()
            if (typeof (input) == 'object') {
                if (input.title != null) title = input.title
                if (input.obj != null) obj = $(input.obj)
                if (input.wd != null) wd = input.wd
                if (input.ht != null) ht = input.ht
                if (input.preserve) Modal.PreserveObj = true
                if (input.dynamicContent) dynamicContent = true
                if (input.x) x = input.x
                if (input.y) y = input.y
                if (typeof (input.bindEvents) == 'boolean') bindEvents = input.bindEvents;
                if (input.closeEvent) Modal.closeWindowEvent = input.closeEvent;
                else Modal.closeWindowEvent = function() { Modal.hide(); };
            } else {
                title = input;
                if(!(obj instanceof $)) obj = $(obj);// <--- double jquery
                Modal.closeWindowEvent = function() { Modal.hide(); };
            }
            Modal.Obj = obj
            Modal.InBlock = true;
            var top = $(document.createElement('div')), body = $(document.createElement('div'))
            top.html("<div style='background-color:#D6D6D6;border-bottom:2px solid #999999;font:bold 11px verdana;margin-bottom:10px;padding:8px;height:19px'><div style='float:left;margin-top:3px'>" + title + "</div><div style='float:right;background-image:url(\"https://www.loansifter.com/images/btn2_close.gif\");width:44px;height:19px;cursor:pointer' onclick='Modal.closeWindowEvent()'></div></div>")
            body.append(obj)
            Modal.Block.html(top)
            Modal.Block.append(body)
            $.blockUI({ message: Modal.Block, css: { border: 'none', background: 'transparent', cursor: 'default', padding: '0' }, overlayCSS: { cursor: 'not-allowed' }, bindEvents: bindEvents })
            if (!wd) wd = Modal.Block.outerWidth(true);
            Modal.OrigWd = wd;
            var wwd = util.window.width()
            if (wd > wwd - 15) {
                wd = wwd - 15 - (body.outerWidth(true) - body.width())
                body.css({ width: wwd - 35 - (body.outerWidth(true) - body.width()) + 'px', overflow: 'auto' })
            }
            if (!ht) ht = Modal.Block.outerHeight(true);
            Modal.OrigHt = ht;
            var wht = util.window.height()
            if (ht > wht - 35) {
                body.css({ height: wht - 35 - top.outerHeight(true) - (body.outerHeight(true) - body.height()) + 'px', overflow: 'auto' })
                ht = Modal.Block.outerHeight(true);
            } else if (dynamicContent) { body.css({ height: body.outerHeight(true) + 'px', overflow: 'auto' }) }
            if (Modal.InIFrame) {
                var m = Modal.Y - ht / 2
                if (m < 10) m = 10
                if (m + 10 + ht > wht) m = wht - ht - 10
            }
            var itop = (y ? y : (Modal.InIFrame ? m : (wht - ht) / 2));
            if (!Modal.InIFrame && $.browser.msie && parseFloat($.browser.version) < 7)
                itop = itop + $(window).scrollTop();
            Modal.Block.parent().css({ overflow: 'hidden', top: itop + 'px', height: ht + 'px', left: (x ? x : (wwd - wd) / 2) + 'px', width: wd + 'px' })
            $('form').append(Modal.Block.parent())
        },
        showModal: function(obj, wd, ht) {
            $.blockUI({ message: obj, css: { border: 'none', background: 'transparent', cursor: 'default', padding: '0' }, overlayCSS: { cursor: 'not-allowed'} })
            obj = $(obj)
            Modal.Obj = obj
            if (!wd) wd = obj.outerWidth(true);
            Modal.OrigWd = wd;
            var wwd = util.window.width()
            if (wd > wwd - 15) {
                wd = wwd - 15 - (obj.outerWidth(true) - obj.width())
                obj.css({ width: wwd - 15 - (obj.outerWidth(true) - obj.width()) + 'px', overflow: 'auto' })
            }
            if (!ht) ht = obj.outerHeight(true);
            Modal.OrigHt = ht;
            var wht = util.window.height()
            if (ht > wht - 15) {
                obj.css({ height: wht - 15 - (obj.outerHeight(true) - obj.height()) + 'px', overflow: 'auto' })
                ht = obj.outerHeight(true)
            }
            if (Modal.InIFrame) {
                var m = Modal.Y - ht / 2
                if (m < 10) m = 10
                if (m + 10 + ht > wht) m = wht - ht - 10
            }
            var itop = (Modal.InIFrame ? m : (wht - ht) / 2);
            if (!Modal.InIFrame && $.browser.msie && parseFloat($.browser.version) < 7)
                itop = itop + $(window).scrollTop();
            obj.parent().css({ overflow: 'hidden', top: itop + 'px', height: ht + 'px', left: (wwd - wd) / 2 + 'px', width: wd + 'px' })
            $('form').append(Modal.Obj.parent())
        },
        showSaving: function() {
            Modal.resetBlock();
            Modal.Block.html("<img src='images/loading_spin_sm.gif' style='vertical-align:middle' /> &nbsp; Saving, please wait...");
            Modal.showModal(Modal.Block, 300)
        },
        showLoading: function() {
            Modal.resetBlock();
            Modal.Block.html("<img src='images/loading_spin_sm.gif' style='vertical-align:middle' /> &nbsp; Loading, please wait...");
            Modal.showModal(Modal.Block, 300)
        },
        showProcessing: function(message) {
            Modal.resetBlock();
            Modal.Block.html("<img src='images/loading_spin_sm.gif' style='vertical-align:middle' /> &nbsp; " + message);
            Modal.showModal(Modal.Block, 300)
        },
        showMessage: function(obj, wd) {
            Modal.resetBlock();
            Modal.Obj = obj
            Modal.Block.html(obj)
            if (!wd) wd = 300
            Modal.showModal(Modal.Block, wd)
        },
        showAlert: function(message, wd) {
            Modal.resetBlock();
            Modal.Block.html(message + "<div style='clear:both;'><input type='button' value='OK' style='margin:8px auto;width:63px' onclick='Modal.hide()' /></div>")
            if (!wd) wd = 300
            Modal.showModal(Modal.Block, wd)
        },
        showConfirm: function(message, fn, wd) {
            Modal.resetBlock();
            Modal.Block.html(message + "<div style='clear:both;margin:8px auto;height:18px;width:140px'><input type='button' value='OK' style='float:left;width:63px' onclick=\"Modal.hide();setTimeout(function(){Modal.fn(true)},500)\" /><input type='button' value='Cancel' style='float:left;margin-left:14px;width:63px' onclick=\"Modal.hide();setTimeout(function(){Modal.fn(false)},500)\" /></div>")
            Modal.fn = fn
            if (!wd) wd = 300
            Modal.showModal(Modal.Block, wd)
        },
        showQuestion: function(input/*message*/, btn1, btn2, fn, wd) {
            var message, btn1W = 63, btn2W = 63
            if (typeof (input) == 'object') {
                if (input.message != null) message = input.message
                if (input.btn1 != null) btn1 = input.btn1
                if (input.btn2 != null) btn2 = input.btn2
                if (input.fn != null) fn = input.fn
                if (input.wd != null) wd = input.wd
                if (input.btn1W) btn1W = input.btn1W
                if (input.btn2W) btn2W = input.btn2W
            } else { message = input; }
            Modal.resetBlock();
            Modal.Block.html(message + "<div style='clear:both;margin:8px auto;height:18px;width:" + (btn1W + btn2W + 14) + "px'><input type='button' value='" + btn1 + "' style='float:left;width:" + btn1W + "px' onclick=\"Modal.hide();setTimeout(function(){Modal.fn(true)},500)\" /><input type='button' value='" + btn2 + "' style='float:left;margin-left:14px;width:" + btn2W + "px' onclick=\"Modal.hide();setTimeout(function(){Modal.fn(false)},500)\" /></div>")
            Modal.fn = fn
            if (!wd) wd = 300
            Modal.showModal(Modal.Block, wd)
        },
        showPrompt: function(message, fn, wd) {
            Modal.resetBlock();
            Modal.Block.html(message + "<div style='clear:both;margin:4px auto'><input style='width:100%' id='tbModalPrompt_tmp' type='text' /></div><div style='height:18px;margin:8px 0'><input type='button' value='Cancel' style='float:right;margin-left:14px;width:63px;' onclick=\"Modal.hide();setTimeout(function(){Modal.fn(false)},500)\" /><input type='button' value='OK' style='float:right;width:63px' onclick=\"Modal.hide();setTimeout(function(){Modal.fn($('#tbModalPrompt_tmp').val())},500)\" /></div>")
            Modal.fn = fn
            if (!wd) wd = 300
            Modal.showModal(Modal.Block, wd)
        },
        hide: function() { $.unblockUI({ fadeOut: 400 }) },
        resizeModal: function(obj, reCalc) {
            obj = $(obj)
			if(obj.is(':visible')){
				var wd = (reCalc ? obj.outerWidth(true) : Modal.OrigWd);
				var wwd = util.window.width()
				if (wd > wwd - 15) {
					wd = wwd - 15 - (obj.outerWidth(true) - obj.width())
					obj.css({ width: wwd - 15 - (obj.outerWidth(true) - obj.width()) + 'px', overflow: 'auto' })
				}
				var ht = (reCalc ? obj.outerHeight(true) : Modal.OrigHt);
				var wht = util.window.height()
				if (ht > wht - 15) {
					obj.css({ height: wht - 15 - (obj.outerHeight(true) - obj.height()) + 'px', overflow: 'auto' })
					ht = obj.outerHeight(true)
				}
				if (Modal.InIFrame) {
					var m = Modal.Y - ht / 2
					if (m < 10) m = 10
					if (m + 10 + ht > wht) m = wht - ht - 10
				}
				var itop = (Modal.InIFrame ? m : (wht - ht) / 2);
				if (!Modal.InIFrame && $.browser.msie && parseFloat($.browser.version) < 7)
					itop = itop + $(window).scrollTop();
				if (Modal.InBlock) { Modal.Block.parent().css({ overflow: 'hidden', top: itop + 'px', height: ht + 'px', left: (wwd - wd) / 2 + 'px', width: wd + 'px' }); }
				else obj.parent().css({ overflow: 'hidden', top: itop + 'px', height: ht + 'px', left: (wwd - wd) / 2 + 'px', width: wd + 'px' });
			}
        }
    }
    if (Modal.InIFrame && document.onmousemove == undefined) {
        document.onmousemove = Modal.setMouseY
    }
})

//remove characters from string - example: '(55)..9'.remove('().')=='559'
String.prototype.remove=function(chars){
    var sb = new StringBuilder(), re = /^[a-zA-Z_0-9]$/
	sb.append('[')
	for(var i=0,l=chars.length;i<l;i++)
		sb.append((re.test(chars.charAt(i))?'':'\\') + chars.charAt(i))
	sb.append(']')
	var reg = new RegExp(sb.toString(),'g')
	return this.toString().replace(reg,'')
}

//captures the html of the current page
function takeSnapshot(){
	var body = jQuery('html').html()
	if(window.location.href.toLowerCase().indexOf('primesearch.aspx')>0){
		var start = body.indexOf('<scr' + 'ipt ',body.indexOf("    ShowCashout($get('c")-50)
		var end = body.indexOf('</sc' + 'ript>',start) + 9
		body = body.substr(0,start) + body.substr(end,body.length-end)
	}
	var controls = new Array()
	$('select,input,textarea').each(function(){
		if(this.type.toLowerCase()=='checkbox' || this.type.toLowerCase()=='radio')
			controls.push({checked:this.checked})
		else controls.push({val:this.value})
	})
	return {body:body,controls:$.toJSON(controls)}
}

//reports an error to developer
function reportNewError(application, exception, subject, body, type){
	util.RequireScript(
		'include?folder=JavaScripts&file=jquery.JSON.js,stacktrace.js',
		function(){return typeof($.toJSON)=='undefined' || typeof(printStackTrace)=='undefined'},
		function(){
			var obj = {}, trace = printStackTrace();
			try{
				obj = takeSnapshot()
			} catch(e){}
			obj.application = application
			obj.name = exception.name
			if(body!=undefined && body.length>0)
				obj.message = exception.message + '<br /><hr /><br />' + body
			else
				obj.message = exception.message
			obj.subject = subject
			obj.url = location.href
			obj.trace = '&nbsp;&nbsp;&nbsp;&nbsp;' + trace.join('<br />&nbsp;&nbsp;&nbsp;&nbsp;')
			if(!isNaN(Number(type))){
				obj.type = type
			}
			jQuery.ajax({
				type: "POST",
				url: "ReportError.aspx",
				dataType: "json",
				data:obj
			});
		}
	)
}

$(function() { $(window).resize(function() { if (Modal.Obj != null) Modal.resizeModal(Modal.Obj); }); });

//blockUI v2.33 - Should really be on it's own file
//Modified by Xai so no events will be suppressed if msg is null
(function(b){function r(c,a){var e=c==window,d=a&&a.message!==undefined?a.message:undefined;a=b.extend({},b.blockUI.defaults,a||{});a.overlayCSS=b.extend({},b.blockUI.defaults.overlayCSS,a.overlayCSS||{});var g=b.extend({},b.blockUI.defaults.css,a.css||{}),i=b.extend({},b.blockUI.defaults.themedCSS,a.themedCSS||{});d=d===undefined?a.message:d;e&&k&&o(window,{fadeOut:0});if(d&&typeof d!="string"&&(d.parentNode||d.jquery)){var h=d.jquery?d[0]:d,f={};b(c).data("blockUI.history",f);f.el=h;f.parent=h.parentNode;f.display=h.style.display;f.position=h.style.position;f.parent&&f.parent.removeChild(h)}f=a.baseZ;var l=b.browser.msie||a.forceIframe?b('<iframe class="blockUI" style="z-index:'+f++ +';display:none;border:none;margin:0;padding:0;position:absolute;width:100%;height:100%;top:0;left:0" src="'+a.iframeSrc+'"></iframe>'):b('<div class="blockUI" style="display:none"></div>');h=b('<div class="blockUI blockOverlay" style="z-index:'+f++ +';display:none;border:none;margin:0;padding:0;width:100%;height:100%;top:0;left:0"></div>');f=b(a.theme&&e?'<div class="blockUI blockMsg blockPage ui-dialog ui-widget ui-corner-all" style="z-index:'+f+';display:none;position:fixed"><div class="ui-widget-header ui-dialog-titlebar blockTitle">'+(a.title||"&nbsp;")+'</div><div class="ui-widget-content ui-dialog-content"></div></div>':a.theme?'<div class="blockUI blockMsg blockElement ui-dialog ui-widget ui-corner-all" style="z-index:'+f+';display:none;position:absolute"><div class="ui-widget-header ui-dialog-titlebar blockTitle">'+(a.title||"&nbsp;")+'</div><div class="ui-widget-content ui-dialog-content"></div></div>':e?'<div class="blockUI blockMsg blockPage" style="z-index:'+f+';display:none;position:fixed"></div>':'<div class="blockUI blockMsg blockElement" style="z-index:'+f+';display:none;position:absolute"></div>');if(d)if(a.theme){f.css(i);f.addClass("ui-widget-content")}else f.css(g);if(!a.applyPlatformOpacityRules||!(b.browser.mozilla&&/Linux/.test(navigator.platform)))h.css(a.overlayCSS);h.css("position",e?"fixed":"absolute");if(b.browser.msie||a.forceIframe)l.css("opacity",0);g=[l,h,f];var z=e?b("body"):b(c);b.each(g,function(){this.appendTo(z)});a.theme&&a.draggable&&b.fn.draggable&&f.draggable({handle:".ui-dialog-titlebar",cancel:"li"});g=A&&(!b.boxModel||b("object,embed",e?null:c).length>0);if(s||g){e&&a.allowBodyStretch&&b.boxModel&&b("html,body").css("height","100%");if((s||!b.boxModel)&&!e){g=n(c,"borderTopWidth");i=n(c,"borderLeftWidth");var t=g?"(0 - "+g+")":0,u=i?"(0 - "+i+")":0}b.each([l,h,f],function(B,C){var j=C[0].style;j.position="absolute";if(B<2){e?j.setExpression("height","Math.max(document.body.scrollHeight, document.body.offsetHeight) - (jQuery.boxModel?0:"+a.quirksmodeOffsetHack+') + "px"'):j.setExpression("height",'this.parentNode.offsetHeight + "px"');e?j.setExpression("width",'jQuery.boxModel && document.documentElement.clientWidth || document.body.clientWidth + "px"'):j.setExpression("width",'this.parentNode.offsetWidth + "px"');u&&j.setExpression("left",u);t&&j.setExpression("top",t)}else if(a.centerY){e&&j.setExpression("top",'(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"');j.marginTop=0}else if(!a.centerY&&e){var D="((document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "+(a.css&&a.css.top?parseInt(a.css.top):0)+') + "px"';j.setExpression("top",D)}})}if(d){a.theme?f.find(".ui-widget-content").append(d):f.append(d);if(d.jquery||d.nodeType)b(d).show()}if((b.browser.msie||a.forceIframe)&&a.showOverlay)l.show();if(a.fadeIn){g=a.onBlock?a.onBlock:p;l=a.showOverlay&&!d?g:p;g=d?g:p;a.showOverlay&&h._fadeIn(a.fadeIn,l);d&&f._fadeIn(a.fadeIn,g)}else{a.showOverlay&&h.show();d&&f.show();a.onBlock&&a.onBlock()}if(!!a.message)v(1,c,a);if(e){k=f[0];m=b(":input:enabled:visible",k);a.focusInput&&setTimeout(w,20)}else E(f[0],a.centerX,a.centerY);if(a.timeout){d=setTimeout(function(){e?b.unblockUI(a):b(c).unblock(a)},a.timeout);b(c).data("blockUI.timeout",d)}}function o(c,a){var e=c==window,d=b(c),g=d.data("blockUI.history"),i=d.data("blockUI.timeout");if(i){clearTimeout(i);d.removeData("blockUI.timeout")}a=b.extend({},b.blockUI.defaults,a||{});v(0,c,a);var h;h=e?b("body").children().filter(".blockUI").add("body > .blockUI,form > .blockUI"):b(".blockUI",c);if(e)k=m=null;if(a.fadeOut){h.fadeOut(a.fadeOut);setTimeout(function(){x(h,g,a,c)},a.fadeOut)}else x(h,g,a,c)}function x(c,a,e,d){c.each(function(){this.parentNode&&this.parentNode.removeChild(this)});if(a&&a.el){a.el.style.display=a.display;a.el.style.position=a.position;a.parent&&a.parent.appendChild(a.el);b(d).removeData("blockUI.history")}typeof e.onUnblock=="function"&&e.onUnblock(d,e)}function v(c,a,e){var d=a==window;a=b(a);if(!(!c&&(d&&!k||!d&&!a.data("blockUI.isBlocked")))){d||a.data("blockUI.isBlocked",c);!e.bindEvents||c&&!e.showOverlay||(c?b(document).bind("mousedown mouseup keydown keypress",e,y):b(document).unbind("mousedown mouseup keydown keypress",y))}}function y(c){if(c.keyCode&&c.keyCode==9)if(k&&c.data.constrainTabKey){var a=m,e=c.shiftKey&&c.target==a[0];if(!c.shiftKey&&c.target==a[a.length-1]||e){setTimeout(function(){w(e)},10);return false}}if(b(c.target).parents("div.blockMsg").length>0)return true;return b(c.target).parents().children().filter("div.blockUI").length==0}function w(c){if(m)(c=m[c===true?m.length-1:0])&&c.focus()}function E(c,a,e){var d=c.parentNode,g=c.style,i=(d.offsetWidth-c.offsetWidth)/2-n(d,"borderLeftWidth");c=(d.offsetHeight-c.offsetHeight)/2-n(d,"borderTopWidth");if(a)g.left=i>0?i+"px":"0";if(e)g.top=c>0?c+"px":"0"}function n(c,a){return parseInt(b.css(c,a))||0}if(/1\.(0|1|2)\.(0|1|2)/.test(b.fn.jquery)||/^1.1/.test(b.fn.jquery))alert("blockUI requires jQuery v1.2.3 or later!  You are using v"+b.fn.jquery);else{b.fn._fadeIn=b.fn.fadeIn;var p=function(){},q=document.documentMode||0,A=b.browser.msie&&(b.browser.version<8&&!q||q<8),s=b.browser.msie&&/MSIE 6.0/.test(navigator.userAgent)&&!q;b.blockUI=function(c){r(window,c)};b.unblockUI=function(c){o(window,c)};b.growlUI=function(c,a,e,d){var g=b('<div class="growlUI"></div>');c&&g.append("<h1>"+c+"</h1>");a&&g.append("<h2>"+a+"</h2>");if(e==undefined)e=3E3;b.blockUI({message:g,fadeIn:700,fadeOut:1E3,centerY:false,timeout:e,showOverlay:false,onUnblock:d,css:b.blockUI.defaults.growlCSS})};b.fn.block=function(c){return this.unblock({fadeOut:0}).each(function(){if(b.css(this,"position")=="static")this.style.position="relative";if(b.browser.msie)this.style.zoom=1;r(this,c)})};b.fn.unblock=function(c){return this.each(function(){o(this,c)})};b.blockUI.version=2.33;b.blockUI.defaults={message:"<h1>Please wait...</h1>",title:null,draggable:true,theme:false,css:{padding:0,margin:0,width:"30%",top:"40%",left:"35%",textAlign:"center",color:"#000",border:"3px solid #aaa",backgroundColor:"#fff",cursor:"wait"},themedCSS:{width:"30%",top:"40%",left:"35%"},overlayCSS:{backgroundColor:"#000",opacity:0.5,cursor:"wait"},growlCSS:{width:"350px",top:"10px",left:"",right:"10px",border:"none",padding:"5px",opacity:0.5,cursor:"default",color:"#fff",backgroundColor:"#000","-webkit-border-radius":"10px","-moz-border-radius":"10px","border-radius":"10px"},iframeSrc:/^https/i.test(window.location.href||"")?"javascript:false":"about:blank",forceIframe:false,baseZ:1E3,centerX:true,centerY:true,allowBodyStretch:true,bindEvents:true,constrainTabKey:true,fadeIn:200,fadeOut:400,timeout:0,showOverlay:true,focusInput:true,applyPlatformOpacityRules:true,onBlock:null,onUnblock:null,quirksmodeOffsetHack:4};var k=null,m=[]}})(jQuery);
