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=new Array()};StringBuilder.prototype={append:function(x){this.str.push(x)},toString:function(){return this.str.join('')},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(f){if(!$.browser.msie)return false;return this.each(function(){if(this.tagName!='SELECT')return;var me=$(this),wd=me.outerWidth(),c=this.className,s=me.attr('style'),z=true,dv=null,d=this.style.display,v=this.style.visibility;if(f||wd<1){var o=me.clone().css({position:'absolute',left:-1000,top:0,display:'',visibility:''}).appendTo('body');wd=o.outerWidth();var n=o.css('width','auto').outerWidth()<wd;o.remove();o=null;if(f&&n)return};function rst(){if(z)return;z=true;me[0].style.width=wd+'px';me[0].style.removeAttribute('filter');dv.options[0].innerHTML=me[0].options[me[0].selectedIndex].innerHTML};me.wrap("<div class='ddlFixedWidth' style='display:"+(d?d:'inline')+";position:relative;background:#fff"+(v?';visibility:'+v:'')+"'><div style='position:absolute;top:0;left:0;overflow:hidden;width:"+wd+"px'>").parent().after("<select class='noadd"+(c?' '+c:'')+"' style='width:"+wd+"px"+(s?';'+s:'')+"'><option>"+this.options[this.selectedIndex].innerHTML+"</option></select>");me.bind('mousedown',function(){me.css({opacity:0,width:'auto'});z=false}).blur(rst).change(rst);dv=me.parent().next()[0];if(d){dv.style.display='';this.style.display=''};if(v){dv.style.visibility='';this.style.visibility=''};me.data('ddlFixedWidth',{show:function(){me.parent().parent()[0].style.display='inline'},hide:function(){me.parent().parent()[0].style.display='none'}})})};$.fn.serializeIt=function(z){var x=[],e=$(this).find(':input:not(.noadd)');$.each(e,function(){if(this.id&&/text|hidden|password|radio|checkbox|select/i.test(this.type)){x.push(escape(!!z?this.id.replace(z,''):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(a){a=((a&&a===true)||a===undefined);var pos=null,ret=false;function c(v){var x=v.replace(/[^\d.]/g,'').split('.'),x1=x[0].replace(/^0+(\d+)$/g,'$1'),x2=(x.length>1?'.'+x[1]:''),rgx=/(\d+)(\d{3})/;while(rgx.test(x1)){x1=x1.replace(rgx,'$1'+','+'$2')}if(a)return('$'+x1+x2);return(x1+x2)};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(a?Math.max(i,1):i)};return this.each(function(){var input=$(this),oriVal=input.val(),mx=input.attr('maxlength');input.bind('focus',function(e){oriVal=input.val()}).bind('keydown',function(e){var k=e.keyCode;pos=input.caret();var sc=(pos.begin==pos.end),ov=input.val();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!=''&&ov.indexOf('.')<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,'');if((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:'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 r=null,q=0,y=null,j=null,k=null;function ct(){q=0;clearTimeout(r)};function cr(){ct();j.remove();k.remove()};function n(){q=1;r=window.setTimeout(cr,500)};function o(e){if(j){j.css({'left':e.pageX+20,'top':e.pageY-10});k.css({'left':e.pageX+23,'top':e.pageY-7})}};$.fn.tooltip=function(a){var b=$.extend({locked:false,padding:8,background:'',zIndex:2000},a);return this.each(function(){var t;if(this.title){$(this).hover(function(e){if(y==this&&q)ct();else{if(q)cr();var w='',x=null;if(this.title!=''){t=this.title;this.title=''}y=this;if(t.match(/^\#\w+$/g)){var m=$(t);x=m.html();w=m.attr('style').replace(/(display|position|(padding|margin)(-\w+)?) *: *\w[^;]+;?/ig,'')}else x=t;$('body').append("<div id='xTipS' style='position:absolute;z-index:"+b.zIndex+";display:none;background:#aaa;filter:alpha(opacity=60);opacity:0.6;-moz-opacity:0.6'></div><div id='xTip' style='"+w+"'>"+x+"</div>");j=$('#xTip').css({padding:b.padding,background:b.background,zIndex:b.zIndex+1});k=$('#xTipS');o(e);if(b.locked)j.hover(ct,n).fadeIn();else j.fadeIn();k.css({width:j.outerWidth(true)-16,height:j.outerHeight(true)-16,padding:b.padding}).fadeIn()}},function(){if(b.locked)n();else cr()});if(!b.locked)$(this).mousemove(o)}})}})(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')}}};$.validateImageIcon={src:'images/icoValidate1.gif',size:21};$.fn.validate=function(settings){settings=$.extend({color:'#000',tipColor:'#c0c0c0',invalidColor:'#e00',invalidBgColor:'#EF9F7A',validColor:'#0e0',validBgColor:'#B8E894',showIcon:true,defaultMsgDisplay:'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.tip=$.trim(this.value);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(/^\{\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='An error has been detected here.';if(settings.defaultMsgDisplay=='outside'||settings.invalidMsgDisplay=='outside'){me.after("<div class='invalidMsgDisplay' style='display:none' />").data('tip',me.next());tip=(settings.invalidMsgDisplay=='outside')};if(this.tagName=='INPUT'&&(this.type=='text'||this.type=='password')){if(settings.defaultMsgDisplay=='outside'&&this.tip)me.removeAttr('value').data('tip').css('color',settings.tipColor).show().html(this.tip);else if(this.tip)me.css('color',settings.tipColor)};if(settings.parentWidth)pw=settings.parentWidth;else if(me.attr('parentWidth')){pw=me.attr('parentWidth');me.removeAttr('parentWidth')};me.wrap("<"+(this.tagName.match(/^(fieldset|div|table|ul|ol|dl|p|form|pre|center|h\d+)$/ig)?'div':'span')+" style='position:relative;zoom:1;margin-left:1px"+(pw?';width:'+pw+'px':'')+"' />").after("<span style=\"position:absolute;top:"+(this.offsetY*1)+"px;right:"+(($.validateImageIcon.size+4+(this.offsetX*1))*-1)+"px;background:url('"+$.validateImageIcon.src+"') 0 0 no-repeat;display:none\"><img src='"+$.validateImageIcon.src+"' width='"+$.validateImageIcon.size+"' height='"+$.validateImageIcon.size+"' style='visibility:hidden' /></span>");function req(){if(me[0].req){me.data('ico').attr('title','This field is required.').css({'backgroundPosition':'0 0','cursor':'help'}).show();return true}else{me.data('ico').hide();return false}};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 '+($.validateImageIcon.size*-1)+'px','cursor':'default'}).show()};function showErr(v){var t=me[0].err.replace('{$}',v);if(settings.showIcon)me.data('ico').removeAttr('title').css({'backgroundPosition':'0 '+($.validateImageIcon.size*-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')};if(settings.showIcon){me.data('ico',me.next().removeAttr('title').css('cursor','default'));if(me.is(':visible'))req()};if(this.tagName.match(/input|textarea/ig)){if(this.type.match(/text|password|textarea/ig)){function clk(){if(settings.defaultMsgDisplay=='inside'&&$.trim(me.val())==me[0].tip)me.css('color',settings.color).val('')};this.val=function(){var v=$.trim(this.value);if(valid(v,this)){this.valid=true;showGrn();bg(settings.validBgColor)}else{this.valid=false;if(v==''){bg(bgc);if(settings.defaultMsgDisplay=='inside'){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.defaultMsgDisplay=='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()){var t='This field is required.';bg(settings.invalidBgColor);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{showErr(v);bg(settings.invalidBgColor)}}return this.valid};me.focus(clk).blur(this.val)}else if(this.type.match(/checkbox|radio/ig)){this.val=function(){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{this.val=function(){if(valid(this)){this.valid=true;showGrn()}else{this.valid=false;showErr('')};return this.valid};if(this.tagName=='SELECT'){me.change(this.val)}else{me.find('input:checkbox,input:radio,input:text,input:password,select,textarea').each(function(){var t=this.type,o=$(this);if(t=='textarea'||t=='text'||t=='password')o.blur(function(){me[0].val()});else if(t=='radio'||t=='checkbox')o.click(function(){me[0].val()});else o.change(function(){me[0].val()})})}}})};$.fn.isValid=function(){var x=this[0];if(x.tagName=='INPUT'&&$(x).is('.validate:visible')){var t=$.trim(x.value);if(x.req||(t!=''&&t!=x.tip))return x.val();return true}else{var v=true,t;$(x).find('.validate:visible').each(function(){t=$.trim(this.value);if((this.req||(t!=''&&t!=this.tip))&&!this.val())v=false});return v}}})}

//Xai - //a mod version of Aaron's isDate Function
String.prototype.parseDate=function(){if(/^(\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,
		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 ($(window).width() - wd) / 2 + 'px' },
		top:function(ht) { return ($(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
			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
			} else{title = input; obj = $(obj)}
			Modal.Obj = obj
			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.hide()'></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' } })
			if(!wd) wd = Modal.Block.outerWidth(true);
			if (wd > $(window).width() - 15){
				body.css({width: $(window).width() - 35 - (body.outerWidth(true)-body.width()) + 'px', overflow: 'auto'})
				wd = $(window).width() - 15 - (body.outerWidth(true)-body.width())
			}
			if (!ht) ht = Modal.Block.outerHeight(true);
			if (ht > $(window).height() - 35){
				body.css({height: $(window).height() - 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>$(window).height()) m = $(window).height() - ht - 10
			}
			Modal.Block.parent().css({ overflow: 'hidden', top: (y?y:(Modal.InIFrame?m:($(window).height() - ht) / 2)) + 'px', height: ht + 'px', left: (x?x:($(window).width() - wd) / 2) + 'px', width: wd + 'px' })
		},
		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);
			if (wd > $(window).width() - 15){
				obj.css({width: $(window).width() - 15 - (obj.outerWidth(true)-obj.width()) + 'px', overflow: 'auto'})
				wd = obj.outerWidth(true)
			}
			if (!ht) ht = obj.outerHeight(true);
			if (ht > $(window).height() - 15){
				obj.css({height: $(window).height() - 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>$(window).height()) m = $(window).height() - ht - 10
			}
			obj.parent().css({ overflow: 'hidden', top: (Modal.InIFrame?m:($(window).height() - ht) / 2) + 'px', height: ht + 'px', left: ($(window).width() - wd) / 2 + 'px', width: wd + 'px' })
		},
		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 }) }
	}
	if(Modal.InIFrame && document.onmousemove==undefined){
		document.onmousemove = Modal.setMouseY
	}
})

//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){
	if(typeof($.toJSON)=='undefined' || typeof(printStackTrace)=='undefined'){
		var script = document.createElement('script');
		script.type = 'text/javascript';
		script.src = 'http://www.loansifter.com/include?folder=JavaScripts&file=jquery.JSON.js,stacktrace.js';
		document.getElementsByTagName("head")[0].appendChild(script);
		loadReportNewError(application, exception, subject)
		return false
	}

	var obj = {}, trace = printStackTrace();
	try{
		obj = takeSnapshot()
	} catch(e){}
	obj.application = application
	obj.name = exception.name
	obj.message = exception.message
	obj.subject = subject
	obj.url = location.href
	obj.trace = '&nbsp;&nbsp;&nbsp;&nbsp;' + trace.join('<br />&nbsp;&nbsp;&nbsp;&nbsp;')
	jQuery.ajax({
		type: "POST",
		url: "http://www.loansifter.com/ReportError.aspx",
		dataType: "json",
		data:obj
	});
}

function loadReportNewError(application, exception, subject){
	if(typeof($.toJSON)=='undefined' || typeof(printStackTrace)=='undefined')
		setTimeout(function(){loadReportNewError(application, exception, subject)}, 200)
	else
		reportNewError(application, exception, subject)
}

/*
 * jQuery blockUI plugin
 * Version 2.20 (19-MAY-2009)
 * @requires jQuery v1.2.3 or later
 *
 * Examples at: http://malsup.com/jquery/block/
 * Copyright (c) 2007-2008 M. Alsup
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 * Thanks to Amir-Hossein Sobhi for some excellent contributions!
 */
 ;(function($){if(/1\.(0|1|2)\.(0|1|2)/.test($.fn.jquery)||/^1.1/.test($.fn.jquery)){alert('blockUI requires jQuery v1.2.3 or later!  You are using v'+$.fn.jquery);return}$.fn._fadeIn=$.fn.fadeIn;var setExpr=(function(){if(!$.browser.msie)return false;var div=document.createElement('div');try{div.style.setExpression('width','0+0')}catch(e){return false}return true})();$.blockUI=function(opts){install(window,opts)};$.unblockUI=function(opts){remove(window,opts)};$.growlUI=function(title,message,timeout,onClose){var $m=$('<div class="growlUI"></div>');if(title)$m.append('<h1>'+title+'</h1>');if(message)$m.append('<h2>'+message+'</h2>');if(timeout==undefined)timeout=3000;$.blockUI({message:$m,fadeIn:700,fadeOut:1000,centerY:false,timeout:timeout,showOverlay:false,onUnblock:onClose,css:$.blockUI.defaults.growlCSS})};$.fn.block=function(opts){return this.unblock({fadeOut:0}).each(function(){if($.css(this,'position')=='static')this.style.position='relative';if($.browser.msie)this.style.zoom=1;install(this,opts)})};$.fn.unblock=function(opts){return this.each(function(){remove(this,opts)})};$.blockUI.version=2.20;$.blockUI.defaults={message:'<h1>Please wait...</h1>',css:{padding:0,margin:0,width:'30%',top:'40%',left:'35%',textAlign:'center',color:'#000',border:'3px solid #aaa',backgroundColor:'#fff',cursor:'wait'},overlayCSS:{backgroundColor:'#000',opacity:0.5,cursor:'wait'},growlCSS:{width:'350px',top:'10px',left:'',right:'10px',border:'none',padding:'5px',opacity:0.6,cursor:null,color:'#fff',backgroundColor:'#000','-webkit-border-radius':'10px','-moz-border-radius':'10px'},iframeSrc:/^https/i.test(window.location.href||'')?'javascript:false':'about:blank',forceIframe:false,baseZ:1000,centerX:true,centerY:true,allowBodyStretch:true,bindEvents:true,constrainTabKey:true,fadeIn:200,fadeOut:400,timeout:0,showOverlay:true,focusInput:true,applyPlatformOpacityRules:true,onUnblock:null,quirksmodeOffsetHack:4};var ie6=$.browser.msie&&/MSIE 6.0/.test(navigator.userAgent);var pageBlock=null;var pageBlockEls=[];function install(el,opts){var full=(el==window);var msg=opts&&opts.message!==undefined?opts.message:undefined;opts=$.extend({},$.blockUI.defaults,opts||{});opts.overlayCSS=$.extend({},$.blockUI.defaults.overlayCSS,opts.overlayCSS||{});var css=$.extend({},$.blockUI.defaults.css,opts.css||{});msg=msg===undefined?opts.message:msg;if(full&&pageBlock)remove(window,{fadeOut:0});if(msg&&typeof msg!='string'&&(msg.parentNode||msg.jquery)){var node=msg.jquery?msg[0]:msg;var data={};$(el).data('blockUI.history',data);data.el=node;data.parent=node.parentNode;data.display=node.style.display;data.position=node.style.position;if(data.parent)data.parent.removeChild(node)}var z=opts.baseZ;var lyr1=($.browser.msie||opts.forceIframe)?$('<iframe class="blockUI" style="z-index:'+(z++)+';display:none;border:none;margin:0;padding:0;position:absolute;width:100%;height:100%;top:0;left:0" src="'+opts.iframeSrc+'"></iframe>'):$('<div class="blockUI" style="display:none"></div>');var lyr2=$('<div class="blockUI blockOverlay" style="z-index:'+(z++)+';display:none;border:none;margin:0;padding:0;width:100%;height:100%;top:0;left:0"></div>');var lyr3=full?$('<div class="blockUI blockMsg blockPage" style="z-index:'+z+';display:none;position:fixed"></div>'):$('<div class="blockUI blockMsg blockElement" style="z-index:'+z+';display:none;position:absolute"></div>');if(msg)lyr3.css(css);if(!opts.applyPlatformOpacityRules||!($.browser.mozilla&&/Linux/.test(navigator.platform)))lyr2.css(opts.overlayCSS);lyr2.css('position',full?'fixed':'absolute');if($.browser.msie||opts.forceIframe)lyr1.css('opacity',0.0);$([lyr1[0],lyr2[0],lyr3[0]]).appendTo(full?'body':el);var expr=$.browser.msie&&($.browser.version<8||!$.boxModel)&&(!$.boxModel||$('object,embed',full?null:el).length>0);if(ie6||(expr&&setExpr)){if(full&&opts.allowBodyStretch&&$.boxModel)$('html,body').css('height','100%');if((ie6||!$.boxModel)&&!full){var t=sz(el,'borderTopWidth'),l=sz(el,'borderLeftWidth');var fixT=t?'(0 - '+t+')':0;var fixL=l?'(0 - '+l+')':0}$.each([lyr1,lyr2,lyr3],function(i,o){var s=o[0].style;s.position='absolute';if(i<2){full?s.setExpression('height','Math.max(document.body.scrollHeight, document.body.offsetHeight) - (jQuery.boxModel?0:'+opts.quirksmodeOffsetHack+') + "px"'):s.setExpression('height','this.parentNode.offsetHeight + "px"');full?s.setExpression('width','jQuery.boxModel && document.documentElement.clientWidth || document.body.clientWidth + "px"'):s.setExpression('width','this.parentNode.offsetWidth + "px"');if(fixL)s.setExpression('left',fixL);if(fixT)s.setExpression('top',fixT)}else if(opts.centerY){if(full)s.setExpression('top','(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"');s.marginTop=0}else if(!opts.centerY&&full){var top=(opts.css&&opts.css.top)?parseInt(opts.css.top):0;var expression='((document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + '+top+') + "px"';s.setExpression('top',expression)}})}if(msg){lyr3.append(msg);if(msg.jquery||msg.nodeType)$(msg).show()}if(($.browser.msie||opts.forceIframe)&&opts.showOverlay)lyr1.show();if(opts.fadeIn){if(opts.showOverlay)lyr2._fadeIn(opts.fadeIn);if(msg)lyr3.fadeIn(opts.fadeIn)}else{if(opts.showOverlay)lyr2.show();if(msg)lyr3.show()}bind(1,el,opts);if(full){pageBlock=lyr3[0];pageBlockEls=$(':input:enabled:visible',pageBlock);if(opts.focusInput)setTimeout(focus,20)}else center(lyr3[0],opts.centerX,opts.centerY);if(opts.timeout){var to=setTimeout(function(){full?$.unblockUI(opts):$(el).unblock(opts)},opts.timeout);$(el).data('blockUI.timeout',to)}};function remove(el,opts){var full=el==window;var $el=$(el);var data=$el.data('blockUI.history');var to=$el.data('blockUI.timeout');if(to){clearTimeout(to);$el.removeData('blockUI.timeout')}opts=$.extend({},$.blockUI.defaults,opts||{});bind(0,el,opts);var els=full?$('body').children().filter('.blockUI'):$('.blockUI',el);if(full)pageBlock=pageBlockEls=null;if(opts.fadeOut){els.fadeOut(opts.fadeOut);setTimeout(function(){reset(els,data,opts,el)},opts.fadeOut)}else reset(els,data,opts,el)};function reset(els,data,opts,el){els.each(function(i,o){if(this.parentNode)this.parentNode.removeChild(this)});if(data&&data.el){data.el.style.display=data.display;data.el.style.position=data.position;if(data.parent)data.parent.appendChild(data.el);$(data.el).removeData('blockUI.history')}if(typeof opts.onUnblock=='function')opts.onUnblock(el,opts)};function bind(b,el,opts){var full=el==window,$el=$(el);if(!b&&(full&&!pageBlock||!full&&!$el.data('blockUI.isBlocked')))return;if(!full)$el.data('blockUI.isBlocked',b);if(!opts.bindEvents||(b&&!opts.showOverlay))return;var events='mousedown mouseup keydown keypress';b?$(document).bind(events,opts,handler):$(document).unbind(events,handler)};function handler(e){if(e.keyCode&&e.keyCode==9){if(pageBlock&&e.data.constrainTabKey){var els=pageBlockEls;var fwd=!e.shiftKey&&e.target==els[els.length-1];var back=e.shiftKey&&e.target==els[0];if(fwd||back){setTimeout(function(){focus(back)},10);return false}}}if($(e.target).parents('div.blockMsg').length>0)return true;return $(e.target).parents().children().filter('div.blockUI').length==0};function focus(back){if(!pageBlockEls)return;var e=pageBlockEls[back===true?pageBlockEls.length-1:0];if(e)e.focus()};function center(el,x,y){var p=el.parentNode,s=el.style;var l=((p.offsetWidth-el.offsetWidth)/2)-sz(p,'borderLeftWidth');var t=((p.offsetHeight-el.offsetHeight)/2)-sz(p,'borderTopWidth');if(x)s.left=l>0?(l+'px'):'0';if(y)s.top=t>0?(t+'px'):'0'};function sz(el,p){return parseInt($.css(el,p))||0}})(jQuery);