
function ie8arrayCompatiblity()
{if(!('bind'in Function.prototype))
{Function.prototype.bind=function(owner)
{var that=this;if(arguments.length<=1)
{return function()
{return that.apply(owner,arguments);};}else
{var args=Array.prototype.slice.call(arguments,1);return function()
{return that.apply(owner,arguments.length===0?args:args.concat(Array.prototype.slice.call(arguments)));};}};}
if(!('trim'in String.prototype))
{String.prototype.trim=function()
{return this.replace(/^\s+/,'').replace(/\s+$/,'');};}
if(!('indexOf'in Array.prototype))
{Array.prototype.indexOf=function(find,i)
{if(i===undefined)i=0;if(i<0)i+=this.length;if(i<0)i=0;for(var n=this.length;i<n;i++)
if(i in this&&this[i]===find)
return i;return-1;};}
if(!('lastIndexOf'in Array.prototype))
{Array.prototype.lastIndexOf=function(find,i)
{if(i===undefined)i=this.length-1;if(i<0)i+=this.length;if(i>this.length-1)i=this.length-1;for(i++;i-->0;)
if(i in this&&this[i]===find)
return i;return-1;};}
if(!('forEach'in Array.prototype))
{Array.prototype.forEach=function(action,that)
{for(var i=0,n=this.length;i<n;i++)
if(i in this)
action.call(that,this[i],i,this);};}
if(!('map'in Array.prototype))
{Array.prototype.map=function(mapper,that)
{var other=new Array(this.length);for(var i=0,n=this.length;i<n;i++)
if(i in this)
other[i]=mapper.call(that,this[i],i,this);return other;};}
if(!('filter'in Array.prototype))
{Array.prototype.filter=function(filter,that)
{var other=[],v;for(var i=0,n=this.length;i<n;i++)
if(i in this&&filter.call(that,v=this[i],i,this))
other.push(v);return other;};}
if(!('every'in Array.prototype))
{Array.prototype.every=function(tester,that)
{for(var i=0,n=this.length;i<n;i++)
if(i in this&&!tester.call(that,this[i],i,this))
return false;return true;};}
if(!('some'in Array.prototype))
{Array.prototype.some=function(tester,that)
{for(var i=0,n=this.length;i<n;i++)
if(i in this&&tester.call(that,this[i],i,this))
return true;return false;};}}
(function($)
{$.fn.format=function()
{$this=$(this);$this.formattedVal($this.formattedVal());};$.fn.formattedVal=function(value)
{if(arguments.length>0)
{$this=$(this);var textVal=value;if($this.hasClass('DateValue')||$this.hasClass('Date'))
{var date=Date.parseExact(value,'yyyy-MM-dd');date=date?date:Date.parse(value);if($this.hasClass('Friendly'))
textVal=date?date.toString('dd MMM yyyy'):"";else
textVal=date?date.toString('d/MM/yyyy'):"";}
else if($this.hasClass('DateTime'))
{var date=Date.parseExact(value,'s');date=date?date:Date.parse(value);textVal=date?date.toString('F'):"";}
else if($this.hasClass('Time'))
{var date=Date.parseExact(value,'s');date=date?date:Date.parse(value);textVal=date?date.toString('hh:mm tt'):"";}
else if($this.hasClass('DecimalValue'))
{if(!(textVal==''&&$this.hasClass('Nullable')))
{var number=Number(textVal);if($this.hasClass('money'))
{textVal=number.numberFormat("$#,##0.00;($#,##0.00);$0.00");}
else if($this.hasClass('money6'))
{textVal=number.numberFormat("$#,##0.000000;($#,##0.000000);$0.000000");}
else if($this.hasClass('quantity'))
{textVal=number.numberFormat("#,##0;;0");}
else if($this.hasClass('decimal'))
{var negativeMask=$this.hasClass('allownegative')?"-#,##0.00":"";textVal=number.numberFormat("#,##0.00;"+negativeMask+";0.00");}
else if($this.hasClass('units'))
{var negativeMask=$this.hasClass('allownegative')?"-#,##0.00000":"";textVal=number.numberFormat("#,##0.00000;"+negativeMask+";0.00000");}
else if($this.hasClass('proportion'))
{textVal=number.numberFormat("0.0000;;0.0000");}
else if($this.hasClass('proportion2'))
{textVal=number.numberFormat("0.000000;;0.000000");}
else if($this.hasClass('holding'))
{textVal=number.numberFormat("#,##0.000000;;0.000000");}
else if($this.hasClass('percentage'))
{var negativeMask=$this.hasClass('allownegative')?"-#,##0.00":"";textVal=number.numberFormat("##0.00;"+negativeMask+";0.00");}
else if($this.hasClass('percentage2'))
{textVal=number.numberFormat("##0.00;;0.00");}
else if($this.hasClass('percentage3'))
{textVal=number.numberFormat("##0.000;;0.000");}
else if($this.hasClass('percentage6'))
{textVal=number.numberFormat("##0.000000;;0.000000");}
else if($this.hasClass('dollars'))
{textVal=number.numberFormat("$#,##0;($#,##0);$0");}
else if($this.hasClass('numeric'))
{textVal=number.numberFormat("0;;0");}
else
{textVal=textVal;}}}
else
{textVal=value;}
if($this.is('input')||$this.is('textarea'))
$this.val(textVal);else if($this.is('span')||$this.is('a'))
$this.text(textVal);}
else
{$this=$(this);var textVal="";if($this.is('input[type=checkbox]'))
textVal=$this.checked();else if($this.is('input')||$this.is('select'))
textVal=$this.val();else if($this.is('span')||$this.is('a')||$this.is('textarea'))
textVal=$this.text();if($this.hasClass('DateValue')||$this.hasClass('Date'))
{var date;if(textVal.match(/^[0-9]{8}$/))
date=Date.parseExact(textVal,'ddMMyyyy');else
{var match=textVal.match(/^(\d{4})\D?(0?\d|\d{2})\D?(0?\d|\d{2})$/);if(match)
date=Date.parseExact(match[1]+'/'+match[2]+'/'+match[3],'yyyy/M/d');else
date=Date.parse(textVal);}
if($(this).hasClass('Friendly'))
textVal=date?date.toString('dd MMM yyyy'):"";else
textVal=date?date.toString('yyyy-MM-dd'):"";}
else if($this.hasClass('DateTime'))
{var date=Date.parse(textVal);textVal=date?date.toString('s'):"";}
else if($this.hasClass('DecimalValue'))
{if($this.hasClass('money')||$this.hasClass('money6')||$this.hasClass('quantity')||$this.hasClass('units')||$this.hasClass('dollars')||$this.hasClass('decimal')||$this.hasClass('numeric'))
{if(!($this.hasClass('Nullable')&&textVal==''))
{var strippedString="";for(var i=0;i<textVal.length;i++)
{if(textVal.charAt(i)=='(')
strippedString=strippedString+"-";else if(textVal.charAt(i)!='$'&&textVal.charAt(i)!=','&&textVal.charAt(i)!=')')
strippedString=strippedString+textVal.charAt(i);}
if($this.hasClass('dollars')&&strippedString.indexOf('.')!=-1)
strippedString=strippedString.substring(0,strippedString.indexOf('.'));var number=Number(strippedString);textVal=String(number);}}
else
{if($.trim(textVal)=="")
{if($this.hasClass('Nullable'))
textVal=undefined;else
textVal="0";}}}
if($this.hasClass('Nullable')&&textVal=='')
textVal=undefined;return textVal;}};$.fn.formattedDatePicker=function()
{if(!this.hasClass('NakedDateValue'))
{$(this).datepicker({beforeShow:function()
{if(!$(this).enabled())
throw"";},onSelect:function(dateStr,inst,ctl)
{var nextControl=$(this).parent().parent().nextAll().find('input, textarea, select, radio');nextControl.each(function()
{if($(this).enabled()&&$(this).is(':visible'))
{$(this).focus();return false;}});$(this).trigger('change');$(this).trigger('dateChanged',dateStr,inst);}});$(this).change(function()
{$(this).format();});$(this).change();}
else
{$(this).change(function()
{$(this).format();});$(this).each(function(i,x){$(x).format();});}};$.fn.formattedNumeric=function()
{if($.fn.numeric)
$(this).numeric();$(this).change(function(){$(this).format();});$(this).blur(function(){$(this).format();});$(this).each(function(){$(this).format();});};$.initialiseFormatting=function()
{if(typeof kendo!='undefined')
kendo.culture("en-AU");if(typeof superIpKendo!='undefined')
superIpKendo.initialise();$.datepicker.setDefaults
({showOn:'button',buttonImageOnly:true,buttonImage:'/common/images/calendar.gif',buttonText:'Calendar',dateFormat:'dd/mm/yy',changeMonth:true,changeYear:true,constrainInput:false});$(document).initialiseFormatting();if(typeof superIpNav!='undefined')
superIpNav.initialise();};$.fn.initialiseFormatting=function()
{$('input[type!=hidden].DateValue',this).formattedDatePicker();$('input[type!=hidden].Date',this).formattedDatePicker();$('input.DecimalValue',this).formattedNumeric();$('span.DecimalValue',this).formattedNumeric();$('input[type!=button][type!=hidden],select,textarea',this).dblclick(function()
{if($(this).enabled())
$(this).focus();});$("select option",this).attr("title","");$("select option",this).each(function(i)
{this.title=this.text;});if($("select",this).tooltip!=undefined)
$("select",this).tooltip({left:25});};$.fn.serializeFormatted=function()
{return jQuery.param(this.serializeFormattedArray());}
$.fn.serializeFormattedArray=function()
{return this.map(function()
{return this.elements?jQuery.makeArray(this.elements):this;}).filter(function()
{return this.name&&(!this.disabled||/sip-not-editable/i.test(this.className))&&(this.checked||/select|textarea/i.test(this.nodeName)||/text|hidden|password/i.test(this.type));}).map(function(i,elem)
{var val=jQuery(this).formattedVal();return val==null?null:jQuery.isArray(val)?jQuery.map(val,function(val,i)
{return{name:elem.name,value:val};}):{name:elem.name,value:val};}).get();};$.fn.clearChangeHistory=function()
{this.removeData('_change_data');};})(jQuery);function showProcessingImage(bDisplay,type)
{if(bDisplay)
{$('#processingImage').show();if($.isFunction($.blockUI))
{if(arguments.length==2&&type=='spinner')
$.blockUI({message:null,fadeIn:0});else
$.blockUI({message:'<br/><h1 class="sip-block-ui-caption">Please wait....</h1><br/>',fadeIn:0,fadeOut:0,centerY:true});}}
else
{$('#processingImage').hide();if($.isFunction($.blockUI))
{if(arguments.length==2&&type=='spinner')
$.unblockUI({fadeOut:150});else
$.unblockUI();}}}
$.fn.fixDialogTabbing=function()
{var id=$(this).attr('id');$('#'+id+' ~ .ui-dialog-buttonpane').find('button').css('float','left');$('#'+id+' ~ .ui-dialog-buttonpane').find('button').wrapAll("<div style='float:right'></div>");};String.prototype.capitalize=function()
{return this.replace(/\S+/g,function(a)
{return a.charAt(0).toUpperCase()+a.slice(1).toLowerCase();});};String.prototype.format=function()
{var args=arguments;return this.replace(/\{\{|\}\}|\{(\d+)\}/g,function(m,n)
{if(m=="{{"){return"{";}
if(m=="}}"){return"}";}
return args[n];});};String.prototype.getScopeUrl=function()
{var regex=/http[s]{0,1}:\/\/[^/]*(.*\/)components\/.*/i;var match=regex.exec(this);return match!=null?match[1]:null;};$.ajaxSetup({cache:false,error:onError,contentType:"application/xml",dataType:"xml"});function hasCorrelationId(request)
{var corrId="";try{corrId=request.getResponseHeader("SuperIP-CorrelationId");}catch(e){}
return(corrId!=null&&corrId.length!=0)}
$(document).ajaxError(function(event,request,ajaxOptions,thrownError){var superIPMsg="";var superIPMsgUnexpected="";var corrId="";try{corrId=request.getResponseHeader("SuperIP-CorrelationId");}catch(e){}
if(corrId!=null){if(corrId.length!=0){var extendedInfo="";try{extendedInfo=request.getResponseHeader("SuperIP-ErrorType");}catch(e){}
superIPMsgUnexpected='An unexpected error has occurred. Please call the Class help desk about error id: '+corrId+'\r\n\r\nSee the Contact Us page for our details.';if(extendedInfo!=null)
{if(extendedInfo.length!=0&&extendedInfo.indexOf("StaleObjectState")!=-1)
superIPMsg='Another user has modified this item, please refresh your screen and try again';else
superIPMsg=superIPMsgUnexpected;}
else
superIPMsg=superIPMsgUnexpected;}}
if(superIPMsg.length!=0){try{window.external.HandleSuperIPAjaxError(superIPMsg);}
catch(e){alert(superIPMsg);}}});function onError(request,textStatus,errorThrown)
{try
{if(hasCorrelationId(request))
location.replace('/common/error.html');if(request.status==503)
location.replace('/common/site-unavailable.html');var superIPMsg="";if(request.status==400)
{var errorCodes=$(request.responseXML).find('RestValidation > Error');if(errorCodes==null||errorCodes==undefined||errorCodes.length==0)
{superIPMsg='An unexpected error has occurred';}
else
{if(errorCodes.length==1)
superIPMsg='An error has occurred. The error message was:\r\n   ';else
superIPMsg='An error has occurred. The error messages were:\r\n   ';errorCodes.each(function()
{superIPMsg+=$(this).text()+"\r\n";});}}
else if(request.status==500)
{var errorPageText=request.responseText||'';superIPMsg='An unexpected error has occurred. The error message was:\r\n   ';var titleStart=errorPageText.indexOf('<title>');var titleEnd=errorPageText.indexOf('</title>');if(titleStart==-1||titleEnd==-1)
superIPMsg+="Bad Request";else
superIPMsg+=errorPageText.substring(titleStart+7,titleEnd);}
else
{superIPMsg='An unexpected error has occurred ('+request.status+')';}
if(superIPMsg.length!=0)
{try
{window.external.HandleSuperIPAjaxError(superIPMsg);}
catch(e)
{alert(superIPMsg);}}}
catch(e)
{}
location.replace('/common/error.html');}
function getDisabledEls(frmName)
{var a=[];var $theForm=$('#'+frmName);$('select,input,textarea',$theForm).each(function(){var $elem=$(this);var $elemDisabledAttr=!$elem.enabled();if($elemDisabledAttr)
{a.push(this.name);}});return a;}
function toggleDisabledEls(elArray)
{for(var i=0;i<elArray.length;i++)
{var el=$('#'+elArray[i]);if(!el.enabled())
el.enable();else
el.disable();}}
(function($){$.fn.disableView=function()
{$(this).enableView(false);};$.fn.enableView=function(enable)
{if(arguments.length==0)enable=true;$('input[type!=hidden],select,textarea',this).enable(enable);$('button[type=button]',this).enable(enable);$('.quickadd,.calcbtn,.autodisable',this).enable(enable);$('button.sip-quick-add',this).enable(enable);if(enable)
{$('.ui-datepicker-trigger',this).show();$('a.sip-add-button,a.sip-remove-button',this).show();$('.autohide',this).show();}
else
{$('.ui-datepicker-trigger',this).hide();$('a.sip-add-button,a.sip-remove-button',this).hide();$('.autohide',this).hide();}
$('.sip-not-editable').enable(false);};$.fn.ajaxDebounce=function(callback)
{$(this).keyup(doKeyUp);$(this).ajaxStart(doAjaxStart).ajaxStop(doAjaxStop);var ajaxRunning=false;var keyUp=false;var timerRunning=false;function doAjaxStart()
{ajaxRunning=true;};function doAjaxStop()
{ajaxRunning=false;if(keyUp&&!timerRunning)
{keyUp=false;callback();}};function doKeyUp(keyEvent)
{if((keyEvent.which>=0x30&&keyEvent.which<0x70)||(keyEvent.which>=0xBA&&keyEvent.which<0xE2)||keyEvent.which==8||keyEvent.which==9||keyEvent.which==0x20||keyEvent.which==0x2E)
{if(ajaxRunning)
{keyUp=true;}
else
{keyUp=false;if(!timerRunning)
{timerRunning=true;setTimeout(function()
{timerRunning=false;if(!keyUp)
callback();},250);}}}};};var usePropCache=undefined;function useProp()
{if(usePropCache!=undefined)
return usePropCache;var ver=$(document).jquery.split('.');usePropCache=Number(ver[0])>1||Number(ver[1])>=6;return usePropCache;}
$.fn.enable=function(enable)
{if(useProp())
{if(arguments.length==1)
$(this).prop('disabled',!enable);else
$(this).prop('disabled',false);if($(this).data('kendoDatePicker')!=undefined)
$(this).data('kendoDatePicker').enable(enable);}
else
{if(arguments.length==1)
$(this).attr('disabled',!enable);else
$(this).attr('disabled',false);}
return this;};$.fn.disable=function()
{if(useProp())
{$(this).prop('disabled',true);if($(this).data('kendoDatePicker')!=undefined)
$(this).data('kendoDatePicker').enable(false);}
else
$(this).attr('disabled',true);return this;};$.fn.readonly=function(isReadonly)
{if(useProp())
{if(arguments.length==1)
$(this).prop('readonly',isReadonly);else
$(this).prop('readonly',true);}
else
{if(arguments.length==1)
{if(isReadonly)
$(this).attr("readonly","readonly");else
$(this).removeAttr("readonly");}
else
$(this).attr("readonly","readonly");}
return this;};$.fn.enabled=function()
{return!$(this).is(':disabled');};$.fn.check=function(check)
{if(useProp())
{if(arguments.length==1)
$(this).prop('checked',check);else
$(this).prop('checked',true);}
else
{if(arguments.length==1)
$(this).attr('checked',check);else
$(this).attr('checked',true);}
return this;};$.fn.uncheck=function()
{if(useProp())
$(this).prop('checked',false);else
$(this).attr('checked',false);return this;};$.fn.checked=function()
{return $(this).is(':checked');};$.fn.select=function(selected)
{if(useProp())
{if(arguments.length==1)
$(this).prop('selected',selected);else
$(this).prop('selected',true);}
else
{if(arguments.length==1)
$(this).attr('selected',selected);else
$(this).attr('selected',true);}
return this;};$.fn.unselect=function()
{if(useProp())
$(this).prop('selected',false);else
$(this).attr('selected',false);return this;};$.fn.selected=function()
{return $(this).is(':selected');};$.fn.lightbox=function(action)
{if(action=='open')
{$.blockUI({overlayCSS:{opacity:0.5,cursor:'auto'},message:null,bindEvents:false,fadeIn:0});$(this).show();$('input:not(:disabled):first',this).focus();if($(this).draggable!=undefined)
$(this).draggable();}
else if(action=='close')
{$(this).hide();$.unblockUI({fadeOut:150});}};$.fn.validateForm=function()
{if(!$(this).valid())
{superIpError.promoteMVCValidations();return false;}
return true;};$.fn.getCaretPosition=function()
{var caretPos=0;var ctrl=this;if(document.selection)
{var sel=document.selection.createRange();sel.moveStart('character',-ctrl.val().length);caretPos=sel.text.length;}
else if(ctrl.get(0).selectionStart||ctrl.get(0).selectionStart=='0')
{caretPos=ctrl.get(0).selectionStart;}
return caretPos;};$.fn.setCaretPosition=function(pos)
{var ctrl=this.get(0);if(ctrl.setSelectionRange)
{ctrl.setSelectionRange(pos,pos);}
else if(ctrl.createTextRange)
{var range=ctrl.createTextRange();range.collapse(true);range.moveStart('character',pos);range.moveEnd('character',pos);range.select();}};$.fn.setSelection=function(start,end)
{var ctrl=this.get(0);if(ctrl.setSelectionRange)
{ctrl.setSelectionRange(start,end);}
else if(ctrl.createTextRange)
{var range=ctrl.createTextRange();range.collapse(true);range.moveStart('character',start);range.moveEnd('character',end);range.select();}};$.fn.hasSelection=function()
{if(document.selection)
{var sel=document.selection.createRange();return sel.text.length!=0;}
else
{var ctrl=this;return ctrl.get(0).selectionStart!=ctrl.get(0).selectionEnd;}};$.overrideMaxUIWidth=function(pixels)
{$('.sip-header > div').css('max-width',pixels+'px');$('.sip-content').css('max-width',pixels+'px');};})(jQuery);var sipQuickAddButtonId;function doQuickAddButton(e)
{var btnId='';if(e.currentTarget!=undefined)
btnId='#'+e.currentTarget.id;else
btnId='#'+e.srcElement.id;var url=$(btnId).nextAll('input.sip-quick-add-editor:hidden').val();showProcessingImage(true);sipQuickAddButtonId=btnId;navigateTab(url,true,undefined,function(){doQuickAddRefresh(sipQuickAddButtonId);});}
function doQuickAddRefresh(btnId)
{var refresh=$(btnId).nextAll('input.sip-quick-add-refresh:hidden').val();if(refresh!=undefined&&refresh!='')
{var currentValue=$(btnId).prevAll('select.sip-dropdown').val();if(currentValue!='')
refresh+='?selected='+escape(currentValue);$.ajax({type:'GET',url:refresh,success:function(response)
{$(btnId).prevAll('select.sip-dropdown').html(response);showProcessingImage(false);},error:function()
{showProcessingImage(false);},dataType:"html"});}
else
{showProcessingImage(false);}}
var superIpCriteria=new superIpCriteriaContainer();function superIpCriteriaContainer()
{var keys;var values;var hash;this.findParamStart=function(query)
{var idx=query.indexOf('?');if(idx!=-1)
{return idx;}
idx=query.indexOf('#');if(idx!=-1)
{return idx;}
return-1;};this.parse=function(query)
{keys=new Array();values=new Array();var hashIndex=query.indexOf('#');if(hashIndex!=-1)
{hash=query.substring(hashIndex);query=query.substring(0,hashIndex);if(hash.length>1)
{hash=hash.substring(1);}
if(query==null||query.length==0)
return;}
else
{hash=null;}
var kvpairs=query.substring(1).split('&');var y=0;for(var x=0;x<kvpairs.length;x++)
{if(kvpairs[x]!='')
{var tmp=kvpairs[x].split('=');keys[y]=tmp[0];values[y]=unescape(tmp[1]);y++;}}};this.parseUrl=function(url)
{var paramsStartIdx=this.findParamStart(url);if(paramsStartIdx!=-1)
return this.parse(url.substring(paramsStartIdx));return this.parse('?');};this.baseUrl=function(url,stripHtml){if((stripHtml!=undefined)&&stripHtml==true){url=url.replace(".html","");}
var paramsStartIdx=this.findParamStart(url);var rv='';if(paramsStartIdx==-1){rv=url;}else{rv=url.substring(0,paramsStartIdx);}
if(rv.length>1&&rv.charAt(rv.length-1)=='/')
return rv.substring(0,rv.length-1);return rv;};this.create=function()
{var query='';if(keys.length!=0)
{query='?';for(var x=0;x<keys.length;x++)
{query+=keys[x]+'='+escape(values[x]);if(x!=keys.length-1)
query+='&';}}
if(hash!=null&&hash.length>0)
{query+='#'+hash;}
return query;};this.createUrl=function(url)
{return this.baseUrl(url)+this.create();};this.retrieve=function(key)
{for(var x=0;x<keys.length;x++)
{if(key==keys[x])
return unescape(values[x]);}
return null;};this.retrieveUrl=function(url,key)
{this.parseUrl(url);for(var x=0;x<keys.length;x++)
{if(key==keys[x])
return unescape(values[x]);}
return null;};this.add=function(key,value)
{var l=keys.length;keys[l]=key;values[l]=escape(value);};this.addOrUpdate=function(key,value)
{for(var x=0;x<keys.length;x++)
{if(key==keys[x])
{values[x]=escape(value);return;}}
this.add(key,value);};this.getHash=function()
{return hash;};this.setHash=function(hashValue)
{hash=hashValue;};this.remove=function(key)
{for(var x=0;x<keys.length;x++)
{if(key==keys[x])
{for(var y=x;y<keys.length-1;y++)
{keys[y]=keys[y+1];values[y]=values[y+1];}
keys.pop();values.pop();break;}}};this.getSipParametersToPreserve=function()
{var parametersToPreserve=new Array();for(var x=0;x<keys.length;x++)
{if(keys[x].slice(0,4)=='sip_')
{parametersToPreserve.push({'key':keys[x],'value':values[x]});}}
return parametersToPreserve;};this.mapObjectToParameters=function(obj)
{for(var propt in obj)
{this.addOrUpdate(propt,obj[propt]);}};this.getObjectAsQueryString=function(obj)
{var crit=new superIpCriteriaContainer();crit.parseUrl('');crit.mapObjectToParameters(obj);return crit.create();};this.mapParametersToObject=function(obj)
{for(var propt in obj)
{obj[propt]=this.retrieve(propt);}};}
function restFromHtml(url)
{return url.replace('.html','');}
function stripQuery(url)
{return url.substr(0,url.indexOf('.html'))+'.html';}
function baseUrl(url)
{if(url.indexOf('.html')!=-1)
return url.substr(0,url.indexOf('.html'));if(url.indexOf('?')!=-1)
return url.substr(0,url.indexOf('?'));if(url.indexOf('#')!=-1)
return url.substr(0,url.indexOf('#'));return url;}
(function($){var defaults={dataName:'superIpPassword',newPwdId:'newPassword',confimPwdId:'confirmNewPassword',policyTableId:'policyTable',progessBarId:'progBar',passwordPolicy:{"RequiresMixedCase":false,"RequiresNumbers":false,"RequiresSpecial":false,"CharFrequencyReducesStrength":false,"MinimumCharacterSets":3,"MinimumLength":6},policyResult:{hasUpper:false,hasLower:false,hasNumbers:false,hasSpecial:false,minLength:false,minCharSets:false,passwordStrength:0,passesPolicy:false,numberOfPoliciesMet:0},afterCheckPassword:function(policyResult){}};var methods={init:function(options){return this.each(function(){var e1=$(this);var opts=$.extend({},defaults,$(e1).data(defaults.dataName),options);e1.data(opts.dataName,opts);$('#'+opts.newPwdId).keyup(function(event){methods.checkPassword($(this).val(),opts);});methods._initPolicyTable(opts);methods.checkPassword('');});},_initPolicyTable:function(options){var baseSelector='#'+options.policyTableId;$(baseSelector+' .policyMinCharSets').text(options.passwordPolicy.MinimumCharacterSets.toString());$(baseSelector+' .policyMinLength').text(options.passwordPolicy.MinimumLength.toString());},_setPolicyStatusField:function(policyTableId,fieldId,isSuccess){var baseSelector='#'+policyTableId+' .'+fieldId+'> ';if(isSuccess){$(baseSelector+' .met').show();$(baseSelector+' .unmet').hide();}else{$(baseSelector+' .met').hide();$(baseSelector+' .unmet').show();}},_setQualityWord:function(progBarId,quality,policiesMet,minLengthMet,passwordPolicy){var text='';var percent=0;var color='';if(policiesMet==0){text='';color='#D70505';percent=0;}
else if(policiesMet==1){text="Very Poor";color='#D70505';percent=14;}else if(policiesMet==2){text="Poor";percent=28;color='#E56C54';}else if(policiesMet==3||!minLengthMet){text="Weak";percent=42;color='#DDE57A';}else{percent=60;color='#70E555';var baseScore=passwordPolicy.MinimumCharacterSets*10+passwordPolicy.MinimumLength*4;if(quality>baseScore*1.75){text="Very Strong";percent=100;color='#31E52F';}else if(quality>baseScore*1.4){text="Strong";percent=80;color='#55E547';}else{text="Good";}}
var baseSelector='#'+progBarId+' ';$(baseSelector+' .text').text(text);$(baseSelector+' .slider').css('width',percent+'%');$(baseSelector+' .slider').css('background-color',color);},_passwordStrength:function(password,passwordPolicy){var charSetCount=0;var charsFrequency=new Array();var currChar='';var result={hasUpper:false,hasLower:false,hasNumbers:false,hasSpecial:false,minLength:false,minCharSets:false,passwordStrength:0,passesPolicy:false,numberOfPoliciesMet:0};for(var i=0;i<password.length;++i){currChar=password.charAt(i);if(charsFrequency[currChar]==undefined){charsFrequency[currChar]=1;}else{charsFrequency[currChar]=charsFrequency[currChar]+1;}
if(currChar.match(/[0-9]/g)){result.hasNumbers=true;}else if(currChar.match(/[A-Z]/g)){result.hasUpper=true;}else if(currChar.match(/[a-z]/g)){result.hasLower=true;}else if(currChar.match(/[^a-zA-Z0-9_]/g)){result.hasSpecial=true;}}
if(result.hasLower)charSetCount++;if(result.hasUpper)charSetCount++;if(result.hasNumbers)charSetCount++;if(result.hasSpecial)charSetCount++;var numPolTypesMet=charSetCount;if(password.length>=passwordPolicy.MinimumLength)numPolTypesMet++;result.numberOfPoliciesMet=numPolTypesMet;var effectiveLength=password.length;if(passwordPolicy.CharFrequencyReducesStrength){effectiveLength=0;for(var idx in charsFrequency){effectiveLength+=charsFrequency[idx]==1.0?1.0:(1.0/charsFrequency[idx]);}}
result.passwordStrength=(effectiveLength*4)+(charSetCount*10);result.minLength=(password.length>=passwordPolicy.MinimumLength);result.minCharSets=(charSetCount>=passwordPolicy.MinimumCharacterSets);result.passesPolicy=(result.minLength&&result.minCharSets);return result;},_showPolicyResult:function(policyResult,policyTableId){methods._setPolicyStatusField(policyTableId,'minLength',policyResult.minLength);methods._setPolicyStatusField(policyTableId,'minCharSets',policyResult.minCharSets);methods._setPolicyStatusField(policyTableId,'hasLower',policyResult.hasLower);methods._setPolicyStatusField(policyTableId,'hasUpper',policyResult.hasUpper);methods._setPolicyStatusField(policyTableId,'hasNumbers',policyResult.hasNumbers);methods._setPolicyStatusField(policyTableId,'hasSpecial',policyResult.hasSpecial);},checkPassword:function(password,options){var e1=$(this);var opts=$.extend({},defaults,$(e1).data(defaults.dataName),options);var results=methods._passwordStrength(password,opts.passwordPolicy);defaults.policyResult=results;methods._showPolicyResult(results,opts.policyTableId);methods._setQualityWord(opts.progessBarId,results.passwordStrength,results.numberOfPoliciesMet,results.minLength,opts.passwordPolicy);opts.afterCheckPassword(results);}};$.fn.superIpPassword=function(method){if(methods[method]){return methods[method].apply(this,Array.prototype.slice.call(arguments,1));}else if(typeof method==='object'||!method){return methods.init.apply(this,arguments);}else{$.error('Method '+method+' does not exist on jQuery.superIpPassword');}};})(jQuery);
(function($){var defaults={dataName:'superIpTabs',selectByIdTag:'selTabId',selectByPosTag:'selTab',locationUrl:location.href,useId:true,encodeInAnchor:true};var methods={init:function(options,tabOptions){return this.each(function(){var e1=$(this);var opts=$.extend({},defaults,$(e1).data(defaults.dataName),options);e1.data(opts.dataName,opts);e1.tabs(tabOptions);e1.bind("tabsactivate",function(event,ui){var hashTag="";if(opts.useId){hashTag='#'+opts.selectByIdTag+":"+methods._getHash(ui.newTab);}else{hashTag='#'+opts.selectByPosTag+":"+(ui.index-1);}
window.location.replace(hashTag);return true;});var tabSelector=methods._getTabSelectorFromUrl(opts.locationUrl,opts,true);if(tabSelector!=null){e1.tabs('option','active',tabSelector);}});},markupUrl:function(tabIdentifier,url,options){return methods._markupUrl($(this),tabIdentifier,url,options);},copyToUrl:function(targetUrl,sourceUrl,options){var e1=$(this);var sourceUrl=(sourceUrl==undefined)?location.href:sourceUrl;var opts=$.extend({},defaults,$(e1).data(defaults.dataName),options);var currMarkup=methods._getTabSelectorFromUrl(sourceUrl,opts);if(currMarkup!=null)currMarkup=currMarkup.substr(1);return methods._markupUrl(e1,currMarkup,targetUrl,options);},_getHash:function(tab)
{var hash=tab.find("[href]").get(0).hash;if(hash)
{if(hash.substring(0,1)==='#')
{return hash.substr(1);}}
return hash;},_markupUrl:function(e1,tabIdentifier,url,options){var opts=$.extend({},defaults,e1.data(defaults.dataName),options);var tabIdToUse=tabIdentifier;var urlToUse=(url==undefined||url==null)?opts.locationUrl:url;if(tabIdentifier==undefined||tabIdentifier==null){if(opts.useId){tabIdToUse=methods._getSelectedTabId(e1);}else{tabIdToUse=e1.tabs('option','selected');}}
superIpCriteria.parseUrl(urlToUse);if(opts.encodeInAnchor){superIpCriteria.setHash((opts.useId?opts.selectByIdTag:opts.selectByPosTag)+':'+tabIdToUse);}else{var existingHash=superIpCriteria.getHash();superIpCriteria.setHash(null);superIpCriteria.addOrUpdate((opts.useId?opts.selectByIdTag:opts.selectByPosTag),tabIdToUse);}
return superIpCriteria.createUrl(urlToUse);},_getSelectedTabId:function(e1){var currItem=e1.tabs('option','selected');var li=$("> ul li",e1).eq(currItem);var id=$("a",li).attr("href");return id.substr(1);},_getTabSelectorFromUrl:function(url,opts,mapHashToIndex){url=(url==undefined||url==null)?opts.locationUrl:url;superIpCriteria.parseUrl(url);var toSplit=superIpCriteria.getHash();if(toSplit==null){var selTabTag=superIpCriteria.retrieve(opts.selectByIdTag);if(selTabTag!=null){if(mapHashToIndex)
{var index=$('a[href="#'+selTabTag+'"]').parent().index();return index;}
return'#'+selTabTag;}
selTabTag=superIpCriteria.retrieve(opts.selectByPosTag);if(selTabTag!=null){return selTabTag;}
return null;}
var vals=toSplit.split(":");if(vals.length==2){if(vals[0]==opts.selectByPosTag)
return vals[1];if(vals[0]==opts.selectByIdTag)
{if(mapHashToIndex)
{var index2=$('a[href="#'+vals[1]+'"]').parent().index();return index2;}
return'#'+vals[1];}}
return null;}};$.fn.superIpTabs=function(method){if(methods[method]){return methods[method].apply(this,Array.prototype.slice.call(arguments,1));}else if(typeof method==='object'||!method){return methods.init.apply(this,arguments);}else{$.error('Method '+method+' does not exist on jQuery.superIpTabs');}};})(jQuery);
(function($){$.fn.numeric=function(config,callback)
{if(typeof config==='boolean')
{config={decimal:config};}
config=config||{};if(typeof config.negative=="undefined"){config.negative=true;}
var decimal=(config.decimal===false)?"":config.decimal||".";var negative=(config.negative===true)?true:false;callback=(typeof(callback)=="function"?callback:function(){});return this.data("numeric.decimal",decimal).data("numeric.negative",negative).data("numeric.callback",callback).keypress($.fn.numeric.keypress).keyup($.fn.numeric.keyup).blur($.fn.numeric.blur);};$.fn.numeric.keypress=function(e)
{var decimal=$.data(this,"numeric.decimal");var negative=$.data(this,"numeric.negative");var key=e.charCode?e.charCode:e.keyCode?e.keyCode:0;if(key==13&&this.nodeName.toLowerCase()=="input")
{return true;}
else if(key==13)
{return false;}
var allow=false;if((e.ctrlKey&&key==97)||(e.ctrlKey&&key==65)){return true;}
if((e.ctrlKey&&key==120)||(e.ctrlKey&&key==88)){return true;}
if((e.ctrlKey&&key==99)||(e.ctrlKey&&key==67)){return true;}
if((e.ctrlKey&&key==122)||(e.ctrlKey&&key==90)){return true;}
if((e.ctrlKey&&key==118)||(e.ctrlKey&&key==86)||(e.shiftKey&&key==45)){return true;}
if(key<48||key>57)
{var value=$(this).val();if(key==45&&negative&&$.fn.formattedVal!=undefined)
{var fvalue=$(this).formattedVal();if(fvalue!=0&&fvalue!=undefined)
{var sel=$(this).getSelection();if(sel.length>0)
return sel.start==0;if(fvalue.charAt(0)=='-')
this.value=fvalue.substr(1);else
this.value='-'+fvalue;$(this).change();return false;}}
if(value.indexOf("-")!==0&&negative&&key==45&&(value.length===0||parseInt($.fn.getSelectionStart(this),10)===0)){return true;}
if(decimal&&key==decimal.charCodeAt(0)&&value.indexOf(decimal)!=-1)
{allow=false;}
if(key!=8&&key!=9&&key!=13&&key!=35&&key!=36&&key!=37&&key!=39&&key!=46)
{allow=false;}
else
{if(typeof e.charCode!="undefined")
{if(e.keyCode==e.which&&e.which!==0)
{allow=true;if(e.which==46){allow=false;}}
else if(e.keyCode!==0&&e.charCode===0&&e.which===0)
{allow=true;}}}
if(decimal&&key==decimal.charCodeAt(0))
{if(value.indexOf(decimal)==-1)
{allow=true;}
else
{var sel=$(this).getSelection();if(sel.length>0&&sel.text.indexOf(decimal)!=-1)
return true;allow=false;}}}
else
{allow=true;}
return allow;};$.fn.numeric.keyup=function(e)
{var val=$(this).value;if(val&&val.length>0)
{var carat=$.fn.getSelectionStart(this);var decimal=$.data(this,"numeric.decimal");var negative=$.data(this,"numeric.negative");if(decimal!==""&&decimal!==null)
{var dot=val.indexOf(decimal);if(dot===0)
{this.value="0"+val;}
if(dot==1&&val.charAt(0)=="-")
{this.value="-0"+val.substring(1);}
val=this.value;}
var validChars=[0,1,2,3,4,5,6,7,8,9,'-',decimal];var length=val.length;for(var i=length-1;i>=0;i--)
{var ch=val.charAt(i);if(i!==0&&ch=="-")
{val=val.substring(0,i)+val.substring(i+1);}
else if(i===0&&!negative&&ch=="-")
{val=val.substring(1);}
var validChar=false;for(var j=0;j<validChars.length;j++)
{if(ch==validChars[j])
{validChar=true;break;}}
if(!validChar||ch==" ")
{val=val.substring(0,i)+val.substring(i+1);}}
var firstDecimal=val.indexOf(decimal);if(firstDecimal>0)
{for(var k=length-1;k>firstDecimal;k--)
{var chch=val.charAt(k);if(chch==decimal)
{val=val.substring(0,k)+val.substring(k+1);}}}
this.value=val;$.fn.setSelection(this,carat);}};$.fn.numeric.blur=function()
{var decimal=$.data(this,"numeric.decimal");var callback=$.data(this,"numeric.callback");var val=this.value;if(val!=="")
{var re=new RegExp("^\\d+$|^\\d*"+decimal+"\\d+$");if(!re.exec(val))
{callback.apply(this);}}};$.fn.removeNumeric=function()
{return this.data("numeric.decimal",null).data("numeric.negative",null).data("numeric.callback",null).unbind("keypress",$.fn.numeric.keypress).unbind("blur",$.fn.numeric.blur);};$.fn.getSelectionStart=function(o)
{if(o.createTextRange)
{var r=document.selection.createRange().duplicate();r.moveEnd('character',o.value.length);if(r.text===''){return o.value.length;}
return o.value.lastIndexOf(r.text);}else{return o.selectionStart;}};$.fn.setSelection=function(o,p)
{if(typeof p=="number"){p=[p,p];}
if(p&&p.constructor==Array&&p.length==2)
{if(o.createTextRange)
{var r=o.createTextRange();r.collapse(true);r.moveStart('character',p[0]);r.moveEnd('character',p[1]);r.select();}
else if(o.setSelectionRange)
{o.focus();o.setSelectionRange(p[0],p[1]);}}};})(jQuery);
(function(){function b(d){this.all=function(g){if(typeof g!=="function"){throw"predicate must be a function"}for(var e=0,f=d.length;e<f;++e){if(!g(d[e])){return false}}return true};this.any=function(g){if(!g){return d.length>0}else{if(typeof g!=="function"){throw"predicate must be a function"}}for(var e=0,f=d.length;e<f;++e){if(g(d[e])){return true}}return false};this.average=function(e){if(typeof e!=="function"){e=function(f){return f}}return this.sum(e)/d.length};this.cast=function(e){if(e===Boolean||e==="boolean"){return this.select(function(f){return!!f})}else{if(e===Number||e==="number"){return this.select(function(f){return(+f)})}else{if(e===String||e==="string"){return this.select(function(f){return new String(f)})}}}throw"type not recognized"};this.contains=function(f,e){if(!e){e=function(g,h){return g===h}}else{if(typeof e!=="function"){throw"comparer must be a function"}}return this.any(function(g){return e(g,f)})};this.count=function(e){if(!e){return d.length}else{if(typeof e!=="function"){throw"predicate must be a function"}}var f=0;this.each(function(g){if(e(g)){++f}});return f};this.crossJoin=function(h,f){h=new b(h);if(!f){f=function(i,j){var k={};for(prop in i){if(Object.prototype.hasOwnProperty.call(i,prop)){k[prop]=i[prop]}}for(prop in j){if(Object.prototype.hasOwnProperty.call(j,prop)){k[prop]=j[prop]}}return k}}else{if(typeof f!=="function"){throw"joiner must be a function"}}var e=[];var g=new b(e);this.each(function(i){h.each(function(j){e.push(f(i,j))})});return g};this.distinct=function(f){if(!f){f=function(h,i){return h===i}}else{if(typeof f!=="function"){throw"comparer must be a function"}}var e=[];var g=new b(e);this.each(function(h){if(!g.any(function(i){return f(h,i)})){e.push(h)}});return g};this.each=function(g){if(typeof g!=="function"){throw"operation must be a function"}for(var e=0,f=d.length;e<f;e++){g(d[e])}return this};this.elementAt=function(e){e=(+e);if(e<0||e>=d.length){throw"index is less than 0 or greater than or equal to the number of elements in the array"}return d[e]};this.elementAtOrDefault=function(f,e){f=(+f);if(f<0||f>=d.length){return e}return d[f]};this.except=function(g,e){g=new b(g);if(!e){e=function(h,i){return h===i}}else{if(typeof e!=="function"){throw"comparer must be a function"}}var f=[];this.each(function(h){if(!g.contains(h,e)){f.push(h)}});return new b(f)};this.first=function(h){if(!h){h=function(i){return true}}else{if(typeof h!=="function"){throw"predicate must be a function"}}for(var f=0,g=d.length;f<g;++f){var e=d[f];if(h(e)){return e}}throw"no elements satisfied the condition"};this.firstOrDefault=function(m,h){var o=null,n=null;for(var e=0,f=arguments.length;e<f;++e){var g=arguments[e];if(typeof g==="function"&&!o){o=g}else{if(g&&!n){n=g}}}if(!o){o=function(i){return true}}for(var k=0,l=d.length;k<l;++k){var j=d[k];if(o(j)){return j}}return n};this.groupBy=function(g,f){if(typeof g!=="function"){throw"keySelector must be a function"}if(!f){f=function(i,j){return i===j}}else{if(typeof f!=="function"){throw"comparer must be a function"}}var e=[];var h=new b(e);this.each(function(i){var k=g(i);var j=h.firstOrDefault(function(l){return f(l.key,k)});if(j===null){j={key:k,values:[]};e.push(j)}j.values.push(i)});return h.select(function(i){return{key:i.key,values:new b(i.values)}})};this.indexOf=function(g){if(typeof g!=="function"){throw"predicate must be a function"}for(var e=0,f=d.length;e<f;++e){if(g(d[e])){return e}}return-1};this.intersect=function(g,e){g=new b(g);if(!e){e=function(h,i){return h===i}}else{if(typeof e!=="function"){throw"comparer must be a function"}}var f=[];this.distinct(e).each(function(h){if(g.contains(h,e)){f.push(h)}});return new b(f)};this.join=function(i,g,f){i=new b(i);if(typeof g!=="function"){throw"predicate must be a function"}if(!f){f=function(j,k){var l={};for(prop in j){if(Object.prototype.hasOwnProperty.call(j,prop)){l[prop]=j[prop]}}for(prop in k){if(Object.prototype.hasOwnProperty.call(k,prop)){l[prop]=k[prop]}}return l}}else{if(typeof f!=="function"){throw"joiner must be a function"}}var e=[];var h=new b(e);this.each(function(j){i.where(function(k){return g(j,k)}).each(function(k){e.push(f(j,k))})});return h};this.last=function(g){if(!g){g=function(h){return true}}else{if(typeof g!=="function"){throw"predicate must be a function"}}for(var f=d.length-1;f>=0;--f){var e=d[f];if(g(e)){return e}}throw"no elements satisfied the condition"};this.lastIndexOf=function(f){if(typeof f!=="function"){throw"predicate must be a function"}for(var e=d.length-1;e>=0;--e){if(f(d[e])){return e}}return-1};this.lastOrDefault=function(l,h){var n=null,m=null;for(var e=0,f=arguments.length;e<f;++e){var g=arguments[e];if(typeof g==="function"&&!n){n=g}else{if(g&&!m){m=g}}}if(!n){n=function(i){return true}}for(var k=d.length-1;k>=0;--k){var j=d[k];if(n(j)){return j}}return m};this.max=function(f){if(!f){f=function(g){return g}}else{if(typeof f!=="function"){throw"selector must be a function"}}if(!d.length){throw"array contains no elements"}var e=null;this.each(function(g){var h=f(g);if(h>e||!e){e=h}});return e};this.min=function(f){if(!f){f=function(g){return g}}else{if(typeof f!=="function"){throw"selector must be a function"}}if(!d.length){throw"array contains no elements"}var e=null;this.each(function(g){var h=f(g);if(h<e||!e){e=h}});return e};this.ofType=function(f){var e=[];if(typeof f==="string"){this.each(function(g){if(typeof g===f||(f==="boolean"&&g instanceof Boolean)||(f==="null"&&g===null)||(f==="object"&&g instanceof Object)||(f==="number"&&g instanceof Number)||(f==="string"&&g instanceof String)||(f==="undefined"&&g===undefined)){e.push(g)}})}else{this.each(function(g){if((f!==undefined&&f!==null&&g instanceof f)||(f===Boolean&&typeof g==="boolean")||(f===null&&g===null)||(f===Object&&typeof g==="object")||(f===Number&&typeof g==="number")||(f===String&&typeof g==="string")||(f===undefined&&g===undefined)){e.push(g)}})}return new b(e)};this.orderBy=function(h){if(!h){h=[{a:function(i){return i}}]}else{if(typeof h==="function"){return this.orderBy([{a:h}])}else{if(h instanceof b){h=h.toArray()}else{if(!(h instanceof Array)){throw"keySelectors must be a function or an array"}}}}for(var e=0,f=h.length;e<f;++e){var g=h[e];if(typeof g.a!=="function"&&typeof g.d!=="function"){throw"keySelector at index "+e+" does not define either an ascending (a) or descending (d) function"}else{if(typeof g.a==="function"&&typeof g.d==="function"){throw"keySelector at index "+e+" defines both an ascending (a) and descending (d) function, which is illegal"}}}var j=d.slice();j.sort(function(k,l){var m=function(s){var t=null,r=false;if(s.a){t=s.a}else{t=s.d;r=true}var i=t(k);var q=t(l);if(i<q){return r?1:-1}else{if(i>q){return r?-1:1}}return 0};var n=0;for(var o=0,p=h.length;o<p;++o){n=m(h[o]);if(n){break}}return n});return new b(j)};this.orderByDescending=function(e){if(!e){e=function(f){return f}}else{if(typeof e!=="function"){throw"keySelector must be a function"}}return this.orderBy([{d:e}])};this.outerJoin=function(i,g,f){i=new b(i);if(typeof g!=="function"){throw"predicate must be a function"}if(!f){f=function(k,l){var m={};for(prop in k){if(Object.prototype.hasOwnProperty.call(k,prop)){m[prop]=k[prop]}}for(prop in l){if(Object.prototype.hasOwnProperty.call(l,prop)){m[prop]=l[prop]}}return m}}if(typeof f!=="function"){throw"joiner must be a function"}var e=[];var h=new b(e);this.each(function(k){i.where(function(l){return g(k,l)}).each(function(l){e.push(f(k,l))})});var j=this;this.where(function(k){return!i.any(function(l){return g(k,l)})}).each(function(k){e.push(f(k,null))});i.where(function(k){return!j.any(function(l){return g(l,k)})}).each(function(k){e.push(f(null,k))});return h};this.select=function(f){if(typeof f!=="function"){throw"selector must be a function"}var e=[];this.each(function(g){e.push(f(g))});return new b(e)};this.sequenceEqual=function(f,e){f=new b(f);if(!e){e=function(h,i){return h===i}}else{if(typeof e!=="function"){throw"comparer must be a function"}}var g=this;if(d.length!==f.count()){return false}else{if(this.any(function(h){return!f.contains(h)})){return false}else{if(f.any(function(h){return!g.contains(h)})){return false}}}return true};this.single=function(l){if(!l){l=function(i){return true}}else{if(typeof l!=="function"){throw"predicate must be a function"}}var j=null,k=0;for(var g=0,h=d.length;g<h;g++){var f=d[g];if(l(f)){j=f;if(++k>1){throw new"more than one element satisfied the condition"}}}if(k==0){throw"no elements satisfied the condition"}return j};this.singleOrDefault=function(p,j){var r=null,q=null;for(var f=0,g=arguments.length;f<g;++f){var h=arguments[f];if(typeof h==="function"&&!r){r=h}else{if(h&&!q){q=h}}}if(!r){r=function(i){return true}}var n=null,o=0;for(var l=0,m=d.length;l<m;l++){var k=d[l];if(r(k)){n=k;if(++o>1){throw new"more than one element satisfied the condition"}}}if(o==0){return q}return n};this.skip=function(e){var h=[];for(var f=(+e),g=d.length;f<g;++f){h.push(d[f])}return new b(h)};this.skipWhile=function(g){if(typeof g!=="function"){throw"predicate must be a function"}var h=[];var e=0,f=d.length;while(e<f){if(!g(d[e])){break}++e}while(e<f){h.push(d[e]);++e}return new b(h)};this.sum=function(f){if(!f){selection=function(g){return g}}else{if(typeof f!=="function"){throw"selector must be a function"}}var e=0;this.each(function(g){e+=f(g)});return e};this.take=function(e){var h=[];for(var f=0,g=e<d.length?e:d.length;f<g;++f){h.push(d[f])}return new b(h)};this.takeWhile=function(h){if(typeof h!=="function"){throw"predicate must be a function"}var j=[];for(var f=0,g=d.length;f<g;++f){var e=d[f];if(!h(e)){break}j.push(e)}return new b(j)};this.toArray=function(){return d.slice()};this.toString=function(){return d.toString()};this.union=function(h,f){h=new b(h);if(!f){f=function(i,j){return i===j}}else{if(typeof f!=="function"){throw"comparer must be a function"}}var e=this.distinct().toArray();var g=new b(e);h.each(function(i){if(!g.contains(i)){e.push(i)}});return g};this.where=function(e){if(typeof e!=="function"){throw"predicate must be a function"}var f=[];this.each(function(g){if(e(g)){f.push(g)}});return new b(f)}}var a=function c(d){if(d instanceof Array){return new b(d)}else{if(d instanceof b){return d}else{if(d.toArray){c(d.toArray())}else{return new b(Array.prototype.slice.call(d))}}}};a.isQuery=function(d){return d instanceof b};a.range=function(h,d){var g=[];for(var e=h,f=h+d;e<=f;++e){g.push(e)}return new b(g)};if(!Array.prototype.toQuery){Array.prototype.toQuery=function(){return new b(this)}}if(typeof module!=="undefined"&&module.exports){module.exports=a}else{if(typeof window!=="undefined"){window.AQ=a;if(jQuery!=="undefined"&&!jQuery().aq){(function(d){d.fn.aq=function(){return a(this.toArray())};d.aq=function(e){return a(e)}})(jQuery)}}}}());