﻿var Namespace={Register:function(n){var chk=false;var cob="";var spc=n.split(".");for(var i=0;i<spc.length;i++){if(cob!=""){cob+=".";}cob+=spc[i];chk=this.Exists(cob);if(!chk){this.Create(cob);}}},Create:function(s){try{eval("window."+s+"=new Object();");}catch(e){}},Exists:function(s){var NE=false;if(s){NE=true;}else{NE=false;}}}
Namespace.Register('Sys.Page');
var _pbe,_pbHeight=136,ctid,tid,close='141px',open='229px',tabWidth='103px',green='green',red='#cc3300',timerID,formatPng=false,width,height,scrollX,scrollY;
var gPopupMask=null,gPopupContainer=null,gPopFrame=null,gReturnFunc,gPopupIsShown=false,gHideSelects=false,gOverrideHideSelects=true,offsetTop=0,offsetLeft=0,modalHeight=300,modalWidth=300,gTabIndexes=new Array(),gTabbableTags=new Array('A','BUTTON','TEXTAREA','INPUT','IFRAME');if(!document.all){document.onkeypress=keyDownHandler;}
function addEvent(obj,evType,fn){if (obj.addEventListener){obj.addEventListener(evType,fn,true);return true;}else if(obj.attachEvent){var r=obj.attachEvent("on"+evType, fn);return r;}else{return false;}}
function removeEvent(obj,evType,fn,useCapture){if(obj.removeEventListener){obj.removeEventListener(evType,fn,useCapture);return true;}else if(obj.detachEvent){var r=obj.detachEvent("on"+evType, fn);return r;}else{alert("Handler could not be removed");}}
function getViewportHeight(){if (window.innerHeight!=window.undefined) return window.innerHeight;if (document.compatMode=='CSS1Compat') return document.documentElement.clientHeight;if (document.body) return document.body.clientHeight;return window.undefined;}
function getViewportWidth(){if (window.innerWidth!=window.undefined) return window.innerWidth;if (document.compatMode=='CSS1Compat') return document.documentElement.clientWidth;if (document.body) return document.body.clientWidth;return window.undefined;}
function replace(a,b,c){while(a.indexOf(b)>-1){pos=a.indexOf(b);a=''+(a.substring(0, pos)+c+a.substring((pos + b.length),a.length));}return a;}
function $(id){return document.getElementById(id);}
function $callback(t,a){__doPostBack(t, a);}
function $tags(tag){return document.getElementsByTagName(tag);}
function $hide(id){$(id).style.display='none';}
function $show(id){$(id).style.display='block';}
function $showhide(id){if($(id).style.display=='none'){$(id).style.display='block';}else{$(id).style.display='none';}}
function $showhidetext(id,tc,b,n){if($(id).style.display=='block'){$get(tc).innerHTML=b;}else{$get(tc).innerHTML=n;}}
function $validate(s){return s.replace('<','&lt;').replace('>','&gt;')};
function $selectedIndex(id){var object=$(id);for(i=0;i<object.length;i++){if(object[i].checked){return object[i].value;}}return 1;}
function $visible(id){return $(id).style.display=='block';}
function $redirect(url){document.location.href=url;}
function $enable(id){$(id).disabled=false;}
function $disable(id){$(id).disabled=true;}
function $help(v){_ps.h(v);}
function $loginMessage(v){_ps.l(v);}
function $splashScreen(v){_ps.s(v);}
function $showHelp(a,id,c){if($visible(id)){a.innerHTML=Sys.Page.Res.Off;a.className='off';a.style.color=red;if($('icon')!=null){$('icon').style.top=close;}$hide(id);}else{a.innerHTML=Sys.Page.Res.On;a.className='on';a.style.color=green;if($('icon')!=null){if($visible(c)){$('icon').style.top=open;}else{$('icon').style.top=close;}}$show(id);}}
function $displayHelp(a,id,c){if($visible(id)){a.innerHTML=Sys.Page.Res.On;a.className='on';a.style.color=green;if($('icon')!=null){if($visible(c)){$('icon').style.top=open;}else{$('icon').style.top=close;}}$show(id);}else{a.innerHTML=Sys.Page.Res.Off;a.className='off';a.style.color=red;if($('icon')!=null){$('icon').style.top=close;}$hide(id);}}
function $updateHelp(id){if($visible(id)){$help(true);}else{$help(false);}}
function $random(){var chars="0123456789abcdefghiklmnopqrstuvwxyz";var l=12;var randomstring='';for(var i=0;i<l;i++){var rnum=Math.floor(Math.random()*chars.length);randomstring +=chars.substring(rnum,rnum+1);}return randomstring;}
function $sl(){$sc('left');} 
function $sr(){$sc('right');}
function $si(){if($('container') !=null){vp.getAll();var containerWidth=(vp.width-60);$('container').style.width=containerWidth+'px';$('left').style.left='1px';$('right').style.left=(parseInt($('container').style.width)+35)+'px';var count=parseInt($('count').value);var width=parseInt(tabWidth)*count;if(containerWidth > width){$hide('left');$hide('right');}else{$('tabs').style.width=width+'px';}}}
function $ss(){clearTimeout(timerID);}
function $exec(r){var s,d='',e =/<script[^>]*>([\s\S]*?)<\/script>/gi;while((s=e.exec(r)))d+=s[1]+'\n';if(d)(window.execScript)?window.execScript(d):window.setTimeout(d,0);}
function $sc(direction){var x=7;var containerWidth=parseInt(parseInt($('container').style.width));var maxScroll=parseInt($('tabs').style.width) - containerWidth;var position=parseInt($('count').value);if(maxScroll > 0){if (direction=='right' && position >=maxScroll){clearTimeout(timerID);$('right').style.display='none';}else if (direction=='left' && position<=0){clearTimeout(timerID);$('left').style.display='none';}else {if(direction=='right'){position=position + x;$('container').scrollLeft +=x;}else {position=position - x;$('container').scrollLeft -=x;}$('right').style.display='block';$('left').style.display='block';}$('count').value=parseInt(position);timerID=setTimeout('$sc(\'' + direction + '\')',5)}else{$('right').style.display='none';$('left').style.display='none';}}
var vp={getIECanvas: function(){var canv=null;if(!window.opera && document.all && typeof document.body.clientWidth !='undefined'){var cm=document.compatMode && document.compatMode=='CSS1Compat';canv=cm?document.documentElement:document.body;}return canv;},getWinWidth: function(){var canv;if(canv=this.getIECanvas()){this.width=canv.clientWidth;}else{this.width=window.innerWidth-18;}},getWinHeight: function(){var canv;if(canv=this.getIECanvas()){this.height=canv.clientHeight;}else{this.height=window.innerHeight-18;}},getScrollX: function(){var canv;if(canv=this.getIECanvas()){this.scrollX=canv.scrollLeft;}else if(window.pageXOffset){this.scrollX=window.pageXOffset;}else if(window.scrollX){this.scrollX=window.scrollX;}else{this.scrollX=0;}},getScrollY: function(){var canv;if(canv=this.getIECanvas()){this.scrollY=canv.scrollTop;}else if(window.pageYOffset){this.scrollY=window.pageYOffset;}else if(window.scrollY){this.scrollY=window.scrollY;}else{this.scrollY=0;}},getAll: function(){this.getWinWidth();this.getWinHeight();this.getScrollX();this.getScrollY();}};
function $selectAll(checkbox){if(checkbox.type=='checkbox'){var elements=checkbox.form.elements;var state=checkbox.checked;for(i=0;i<elements.length;i++) {if(elements[i].type=='checkbox' && elements[i].id !=checkbox.id && !elements[i].disabled) {if(elements[i].parentNode.getAttribute('itemid')!=null){if(elements[i].checked !=state){if(state){elements[i].checked=true;$select(elements[i]);}else{$deselect(elements[i]);elements[i].checked=false;}}}}}}}
function $selected(element){if(element.checked){$select(element);}else{$deselect(element);}}
function $select(element){var itemId=element.parentNode.getAttribute('itemid');if(itemId !=null){$addState(itemId);}}
function $deselect(element){var itemId=element.parentNode.getAttribute('itemid');if(itemId !=null){$removeState(itemId);}}
function commission(selectBox,id){var select=selectBox.options[selectBox.selectedIndex].value;var currency=$(id);if(select=='%'){currency.style.display='none';}else{currency.style.display='block';}}
function selectAllCheckboxes(spanChk){var oItem=spanChk.children;var theBox=(spanChk.type=='checkbox')? spanChk : spanChk.children.item[0];xState=theBox.checked;elm=theBox.form.elements;for(i=0;i<elm.length;i++) {if(elm[i].type=='checkbox' && elm[i].id!=theBox.id) {if(elm[i].checked!=xState) {elm[i].click();} } }}
function selectAllListboxOptions(id){var ref=$(id);for(i=0;i<ref.options.length;i++){ref.options[i].selected=true;}}
function deselectAllListboxOptions(id){var ref=$(id);for(i=0;i<ref.options.length;i++){ref.options[i].selected=false;}}
function enable(id){$(id).disabled=false;}
function disable(id){$(id).disabled=true;}
function enabledDisable(id){var i=$(id);if(i.disabled){i.disabled=false;}else{i.disabled=true;}}
function selectIncrementalCheckboxes(spanChk,controlId){var oItem=spanChk.children;var theBox=(spanChk.type=='checkbox')? spanChk : spanChk.children.item[0];xState=theBox.checked;elm=theBox.form.elements;for(i=0;i<elm.length;i++){if(elm[i].type=='checkbox' && elm[i].id !=theBox.id){elm[i].click();}}}
function selectIncrementalCheckbox(checkbox,controlId){var box=$(checkbox);var doc=$(controlId);if(box.checked==true) {var number=parseInt(doc.innerHTML);doc.innerHTML=number+1;} else {var number=parseInt(doc.innerHTML);doc.innerHTML=number-1;}} 
function checkUncheckAll(theElement){var theForm=theElement.form,z=0;for(z=0;z<theForm.length;z++) {if(theForm[z].type=='checkbox' && theForm[z].name !='checkall'){theForm[z].checked=theElement.checked;} } } 
function handleCheckbox(){var element=event.srcElement || event.target;if(element.tagName=='INPUT' && element.type=='checkbox') {var checkedState=element.checked;while(element.tagName !='TABLE') {element=element.parentNode;} unCheckParents(element);element=element.nextSibling;if(element==null){return;} var childTables=element.getElementsByTagName('TABLE');for(var tableIndex=0;tableIndex<childTables.length;tableIndex++) {checkTable(childTables[tableIndex],checkedState);} }}
function unCheckParents(table){if(table==null || table.rows[0].cells.length==2) {return;} var parentTable=table.parentNode.previousSibling;checkTable(parentTable,false);unCheckParents(parentTable);}
function checkTable(table,checked){var checkboxIndex=table.rows[0].cells.length-1;var cell=table.rows[0].cells[checkboxIndex];var checkboxes=cell.getElementsByTagName('INPUT');if(checkboxes.length==1) {checkboxes[0].checked=checked;}} 
function correctPNG(){if(formatPng){var arVersion=navigator.appVersion.split("MSIE");var version=parseFloat(arVersion[1]);if((version>=5.5&&version<7.0)&&(document.body.filters)){for(var i=0;i<document.images.length;i++){var img=document.images[i];var imgName=img.src.toUpperCase();if(imgName.substring(imgName.length-3,imgName.length)=="PNG"){var imgID=(img.id)?"id='"+img.id+"' ":"";var imgClass=(img.className)?"class='"+img.className+"' ":"";var imgTitle=(img.title)?"title='"+img.title+"' ":"title='"+img.alt+"' ";var imgStyle="display:inline-block;"+img.style.cssText;if(img.align=="left"){imgStyle="float:left;"+imgStyle;}if(img.align=="right"){imgStyle="float:right;"+imgStyle;}if(img.parentElement.href){imgStyle="cursor:hand;"+imgStyle;}var strNewHTML="<span "+imgID+imgClass+imgTitle + " style=\"" + "width:" + img.width + "px;height:" + img.height + "px;" + imgStyle + ";" + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>";img.outerHTML=strNewHTML;i=i-1;}}}}}
function pageInit(){gPopupMask=$('modal');gPopupContainer=$('modalContainer');gPopFrame=$('modalFrame');var brsVersion=parseInt(window.navigator.appVersion.charAt(0),10);if(brsVersion<=6 && window.navigator.userAgent.indexOf('MSIE')> -1){gHideSelects=true;}}
function showModal(url,width,height,returnFunc){gPopupIsShown=true;disableTabIndexes();gPopupMask.style.display='block';gPopupContainer.style.display='block';var titleBarHeight=0;vp.getAll();if(height > 500){if(vp.height<(height+20)) {height=vp.height-20;}}modalHeight=height;modalWidth=width;gPopupContainer.style.width=width+'px';gPopupContainer.style.height=(height+titleBarHeight)+'px';gPopFrame.style.width=(width+'px').toString();gPopFrame.style.height=(height+'px').toString();gPopFrame.src=url;gReturnFunc=returnFunc;if(gHideSelects==true){if(gOverrideHideSelects==true) {hideSelectBoxes();}}centerPopWin(width,height);gPopFrame.contentWindow.focus();}var gi=0;
function centerPopWin(width,height){if(gPopupIsShown==true){var scrollLeft=(document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);var scrollTop=(document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);var clientWidth;if(window.innerWidth){clientWidth=(window.__safari ? window.innerWidth : Math.min(window.innerWidth,document.documentElement.clientWidth));}else {clientWidth=document.documentElement.clientWidth;} var clientHeight;if(window.innerHeight){clientHeight=(window.__safari ? window.innerHeight : Math.min(window.innerHeight,document.documentElement.clientHeight));}else{clientHeight=document.documentElement.clientHeight;} gPopupMask.style.left=(scrollLeft-offsetLeft)+'px';gPopupMask.style.top=(scrollTop-offsetTop)+'px';gPopupMask.style.width=clientWidth+'px';gPopupMask.style.height=(clientHeight)+'px';gPopupContainer.style.left=(scrollLeft-offsetLeft)+((clientWidth-gPopupContainer.offsetWidth)/2)+'px';gPopupContainer.style.top=(scrollTop-offsetTop)+((clientHeight-gPopupContainer.offsetHeight)/2)+'px';}}
function hideModal(callReturnFunc){gPopFrame.src='/blank';gPopupIsShown=false;restoreTabIndexes();if(gPopupMask==null){return;}gPopupMask.style.display='none';gPopupContainer.style.display='none';if(callReturnFunc==true && gReturnFunc !=null){gReturnFunc(window.frames['modalFrame'].returnVal);}if(gHideSelects==true){if(gOverrideHideSelects==true) {displaySelectBoxes();}}try{afterModalComplete();}catch(ex){}}
function redirectModal(s){gPopFrame.src=s};

function keyDownHandler(e){if(gPopupIsShown && e.keyCode==9) return false;}
function disableTabIndexes(){if(document.all){var i=0;for(var j=0;j<gTabbableTags.length;j++){var tagElements=document.getElementsByTagName(gTabbableTags[j]);for(var k=0 ;k<tagElements.length;k++){gTabIndexes[i]=tagElements[k].tabIndex;tagElements[k].tabIndex='-1';i++;}}}}
function restoreTabIndexes(){if(document.all){var i=0;for(var j=0;j<gTabbableTags.length;j++){var tagElements=document.getElementsByTagName(gTabbableTags[j]);for(var k=0 ;k<tagElements.length;k++){tagElements[k].tabIndex=gTabIndexes[i];tagElements[k].tabEnabled=true;i++;}}}}
function getHeight(){return modalHeight;}
function getWidth(){return modalWidth;}
function setSize(width,height){var titleBarHeight=0;modalHeight=height;modalWidth=width;gPopupContainer.style.width=width+'px';gPopupContainer.style.height=(height+titleBarHeight)+'px';gPopFrame.style.width=(width+'px').toString();gPopFrame.style.height=(height+'px').toString();centerPopWin(width,height);}
function hideSelectBoxes(){for(var i=0;i<document.forms.length;i++){for(var e=0;e<document.forms[i].length;e++){if(document.forms[i].elements[e].tagName=='SELECT'){document.forms[i].elements[e].style.visibility='hidden';}}}}
function displaySelectBoxes(){for(var i=0;i<document.forms.length;i++){for(var e=0;e<document.forms[i].length;e++){if(document.forms[i].elements[e].tagName=='SELECT'){document.forms[i].elements[e].style.visibility='visible';}}}}
function initTimer(){tid=window.setTimeout(showAlert,Sys.Page.Session.Timeout);}
function reInitTimer(){clearTimer();initTimer();seconds=Sys.Page.Session.Warning;}
function resetTimer(a){reInitTimer();sa(false);__doPostBack(a,'');}
function clearTimer(){window.clearTimeout(tid);window.clearTimeout(ctid);}
function showAlert(){sa(true);counter();}
function counter(){if(seconds>0){seconds-=1;$('thead').innerHTML=Sys.Page.Res.ExpireSoon;$('counter').innerHTML=String.format(Sys.Page.Res.InactiveMsg,seconds,(seconds==1?Sys.Page.Res.SecondSingular:Sys.Page.Res.SecondPlural));ctid=setTimeout("counter()",1000);}else{setTimeout("signout()",6000);}}         
function signout(){document.location='/sign-out/-'+Sys.Page.Session.CurrentPage;}
function sa(v){$('timer').style.visibility=(v?'visible':'hidden');if(v){$show('timerModal');}else{$hide('timerModal');}}
String.format=function(){if(arguments.length==0)return null;var str=arguments[0];for(var i=1;i<arguments.length;i++){var re = new RegExp('\\{' + (i-1) + '\\}','gm');str=str.replace(re,arguments[i]);}return str;}
addEvent(window,'load',pageInit);
addEvent(window,'load',initTimer);
addEvent(window,"load",correctPNG);
addEvent(window,'resize',centerPopWin);
addEvent(window,"resize",$si);
addEvent(window,'scroll',centerPopWin);