function validatePopup(){var a=Validate(document.getElementById("popupForm"));return a}function openPopup(b,c,a){closePopup();sizePopup(c,a);makeRequest(b,"popup");showPopup()}function closePopup(){hidePopup();hardcodeContents(document.getElementById("popupTemplate").innerHTML,"popup")}function sizePopup(b,a){document.getElementById("popup").style.width=b+"px";document.getElementById("popup").style.height=a+"px";if(window.innerWidth==undefined){ww=(document.body.clientWidth);wh=(document.body.clientHeight)}else{ww=window.innerWidth;wh=window.innerHeight}x=Math.round((ww/2)-(b/2));y=Math.round((wh/2)-(a/2));y+=document.body.scrollTop;document.getElementById("popup").style.left=x+"px";document.getElementById("popup").style.top=y+"px"}function hidePopup(){document.getElementById("popup").style.display="none";if(isIeLessThan7()){ShowSelects()}}function showPopup(){document.getElementById("popup").style.display="block";if(isIeLessThan7()){HideSelects(document.getElementById("popup"))}}function submitPopup(a){submitToDivPopup(a,"popup")}function sizeAndSubmitPopup(c,b,a){hidePopup();document.getElementById("popupContents").style.display="none";submitPopup(c);sizePopup(b,a);showPopup()}function submitToDivAndClosePopup(b,a){submitToDivPopup(b,a);closePopup()}function submitToDivPopup(b,a){submitFormToDiv("popupForm",b,a)}function submitFormToDivAndClosePopup(a,c,b){submitFormToDiv(a,c,b);closePopup()}function submitFormToDiv(b,e,d){var c=document.getElementById(b);var a=buildQueryString(c);makePOSTRequest(e,d,a)}function submitFormOpenPopup(a,b,d,c){closePopup();sizePopup(d,c);submitFormToDiv(a,b,"popup");showPopup()}function submitPopupToPage(a){document.getElementById("popupForm").action=a;document.getElementById("popupForm").method="post";document.getElementById("popupForm").submit()}function buildQueryString(b){var c="";var d,a=0;while((d=b.elements[a++])!=null){var e=toQueryComponent(d);if(e!=""){c+="&"+e}}return c.substring(1)}function toQueryComponent(d){if(!d.name||d.disabled){return""}var b=urlencode(d.name);switch(d.type){case"text":case"password":case"submit":case"hidden":return b+"="+urlencode(d.value);case"textarea":var c=d.value.split(/\r\n|\r|\n/).join("\r\n");return b+"="+urlencode(c);case"checkbox":case"radio":if(!d.checked){return""}var c=getRealValue(d);if(c===null){c="on"}return b+"="+urlencode(c);case"select-one":case"select-multiple":var f=[];var e,a=0;while((e=d.options[a++])!=null){if(e.selected){var c=getRealValue(e);if(c===null){c=e.text}f[f.length]=b+"="+urlencode(c)}}return f.join("&");default:return""}}function urlencode(c){var b;try{b=encodeURIComponent(c)}catch(a){b=escape(c)}return b.replace(/%20/g,"+")}function getRealValue(a){var b=a.getAttributeNode("value");return(b&&b.specified)?a.getAttribute("value"):null}function HideSelects(l){var f=new RecurseOffset(l);var n=f.offsetLeft;var c=f.offsetTop;var d=n+f.offsetWidth;var g=c+f.offsetHeight;var e=document.getElementsByTagName("select");if(e.length==0){return}for(var a=0;a<e.length;a++){var b=e[a];var j=new RecurseOffset(b);var o=j.offsetLeft;var m=j.offsetTop;var k=o+j.offsetWidth;var h=m+j.offsetHeight;if((k>n-30)&&(h>c-5)&&(o<d+30)&&(m<g+45)){b.style.visibility="hidden"}}}function ShowSelects(){var b=document.getElementsByTagName("select");if(b.length==0){return}for(var a=0;a<b.length;a++){b[a].style.visibility="visible"}}function RecurseOffset(a){this.ParentObj=null;this.CurrentObj=a;this.offsetLeft=a.offsetLeft;this.offsetTop=a.offsetTop;this.offsetWidth=a.offsetWidth;this.offsetHeight=a.offsetHeight;RecurseOffset.prototype.Init=function(){if(this.CurrentObj.offsetParent!=null){do{this.ParentObj=this.CurrentObj.offsetParent;this.offsetLeft+=this.ParentObj.offsetLeft;this.offsetTop+=this.ParentObj.offsetTop;this.CurrentObj=this.ParentObj}while(this.CurrentObj.offsetParent!=null)}};this.Init()}function updateContents(c,a){if(c.readyState==4){if(c.status==200){document.getElementById(a).innerHTML=(c.responseText)}else{if(c.status!=0){var b="There was a problem with the request:"+c.status;if(a=="popup"){document.getElementById(a).innerHTML='<div class="gabrielsPopupInterior"><div class="gabrielsPopupTitle" align="right"><a href="javascript:closePopup()">Close</a></div><BR><div id="popupContents">'+b+"</div></div>"}else{document.getElementById(a).innerHTML=b}}}}}function makeRequest(a,c){var d=false;if(window.XMLHttpRequest){d=new XMLHttpRequest();if(d.overrideMimeType){d.overrideMimeType("text/html")}}else{if(window.ActiveXObject){try{d=new ActiveXObject("Msxml2.XMLHTTP")}catch(b){try{d=new ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}}}if(!d){alert("Giving up :( Cannot create an XMLHTTP instance");return false}re=new RegExp("[?]");if(re.exec(a)){qsChar="&"}else{qsChar="?"}d.onreadystatechange=function(){updateContents(d,c)};d.open("GET",a+qsChar+"live="+new Date().getTime(),true);d.send(null)}function makePOSTRequest(a,c,d){http_request=false;if(window.XMLHttpRequest){http_request=new XMLHttpRequest();if(http_request.overrideMimeType){http_request.overrideMimeType("text/html")}}else{if(window.ActiveXObject){try{http_request=new ActiveXObject("Msxml2.XMLHTTP")}catch(b){try{http_request=new ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}}}if(!http_request){alert("Cannot create XMLHTTP instance");return false}http_request.onreadystatechange=function(){updateContents(http_request,c)};http_request.open("POST",a,true);http_request.setRequestHeader("Content-type","application/x-www-form-urlencoded");http_request.setRequestHeader("Content-length",d.length);http_request.setRequestHeader("Connection","close");http_request.send(d)}function hardcodeContents(b,a){document.getElementById(a).innerHTML=(b)}function $AJAX(){}$AJAX.PostToObject=function(c,a,b){var d=function(f){c.innerHTML=f};var e=new AJAXObject(d);e.GetPage(a,b)};$AJAX.GetToObject=function(b,a){var c=function(e){b.innerHTML=e};var d=new AJAXObject(c);d.GetPage(a)};$AJAX.GetForDelegate=function(b,a){var c=new AJAXObject(b);c.GetPage(a)};$AJAX.PostForDelegate=function(c,a,b){var d=new AJAXObject(c);d.GetPage(a,b)};$AJAX.GetAlertResponse=function(a){var b=new AJAXObject(function(c){window.alert(c)});b.GetPage(a)};$AJAX.PostAlertResponse=function(a,b){var c=new AJAXObject(function(d){window.alert(d)});c.GetPage(a,b)};function AJAXObject(a){this.ResponseDelegate=a;AJAXObject.prototype.resetHandler=function(b){this.ResponseDelegate=b};AJAXObject.prototype.GetPage=function(c,b){var d=this;var e=this.createXMLHttpRequest();if(!e){alert("Cannot create an XML HTTP instance");return false}e.onreadystatechange=function(){if(e.readyState==4){if(e.status==200){if(e.getResponseHeader("Content-Type").toLowerCase().indexOf("text/xml")>-1){d.ResponseDelegate(e.responseXML)}else{d.ResponseDelegate(e.responseText)}}else{window.alert("The server returned response: "+e.status);return}}};if(b==undefined){e.open("GET",c,true);e.send(null)}else{e.open("POST",c,true);e.setRequestHeader("Content-type","application/x-www-form-urlencoded");e.setRequestHeader("Content-length",b.length);e.setRequestHeader("Connection","close");e.send(b)}};AJAXObject.prototype.createXMLHttpRequest=function(){var d=["Microsoft.XMLHTTP","MSXML2.XMLHTTP.5.0","MSXML2.XMLHTTP.4.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP"];for(var b=0;b<d.length;b++){try{return new ActiveXObject(d[b])}catch(c){}}try{return new XMLHttpRequest()}catch(c){}return false}}function Validate(objForm){var arrValidated=new Array();for(var i=0;i<objForm.elements.length;i++){var element=objForm.elements[i];var elName=element.name;if((!elName)||(elName.length==0)||(arrValidated[elName])){continue}arrValidated[elName]=true;var validationType=element.getAttribute("validate");var minLength=element.getAttribute("minlength");if(minLength!=undefined){if(minLength.length>0){if(element.value.length<minLength){message="Minimum length for "+element.name+" is "+minLength;if(element.getAttribute("error")!=null){message=element.getAttribute("error")}InsertError(element,message);return false}}}if((!validationType)||(validationType.length==0)){continue}var strMessages=element.getAttribute("msg");if(!strMessages){strMessages=""}var arrMessages=strMessages.split("|");var arrValidationTypes=validationType.split("|");for(var j=0;j<arrValidationTypes.length;j++){var curValidationType=arrValidationTypes[j];var blnValid=true;switch(curValidationType){case"not_empty":blnValid=ValidateNotEmpty(element);break;case"integer":blnValid=ValidateInteger(element);break;case"number":blnValid=ValidateNumber(element);break;case"email":blnValid=ValidateEmail(element);break;case"phone":blnValid=ValidatePhone(element);break;default:try{blnValid=eval(curValidationType+"(element)")}catch(ex){blnValid=true}}if(blnValid==false){var message="invalid value for "+element.name;if(element.getAttribute("error")!=null){message=element.getAttribute("error")}if((j<arrMessages.length)&&(arrMessages[j].length>0)){message=arrMessages[j]}InsertError(element,message);if((typeof element.focus=="function")||(element.focus)){element.focus()}return false}}}return true}function ValidateNotEmpty(a){var b=GetElementValue(a);var c=true;if(allTrim(b)==""){c=false}return c}function ValidateInteger(b){var a=GetElementValue(b);return ValidateIntegerString(a)}function ValidateIntegerString(b){var c="0123456789";var a;var d=true;for(i=0;i<b.length&&d==true;i++){a=b.charAt(i);if(c.indexOf(a)==-1){d=false}}return d}function ValidateNumber(c){var b=GetElementValue(c);var d=",.0123456789";var a;var e=true;for(i=0;i<b.length&&e==true;i++){a=b.charAt(i);if(d.indexOf(a)==-1){e=false}}return e}function ValidateEmail(e){var g=GetElementValue(e);var b=g.indexOf(" ");if(b!=-1){return false}var f=g.length;var d=g.indexOf("@");var c=g.lastIndexOf("@");if(d!=c){return false}if(d==-1||d==0||f<6){return false}var a=g.lastIndexOf(".");if(a-d<2||a==(f-1)){return false}}function ValidatePhone(d){var a="()- ";var c=a+"+";var b=9;var e=GetElementValue(d);s=stripCharsInBag(e,c);return(ValidateIntegerString(s)&&s.length>=b)}function GetElementValue(c){var b="";switch(c.type){case"text":case"hidden":case"textarea":case"password":b=c.value;break;case"select-one":case"select":if(c.selectedIndex>=0){b=c.options[c.selectedIndex].value}break;case"radio":case"checkbox":for(var a=0;a<c.form.elements.length;a++){if(c.form.elements[a].name==c.name){if(c.form.elements[a].checked){b+=c.form.elements[a].value+","}}}break}return b}function InsertError(b,a){alert(a);return}function allTrim(b){var a=false;while(a==false){if(b.length==0){return b}if(b.indexOf(" ")==0){b=b.substring(1);a=false;continue}else{a=true}if(b.lastIndexOf(" ")==b.length-1){b=b.substring(0,b.length-1);a=false;continue}else{a=true}}return b}function stripCharsInBag(d,e){var b;var a="";for(b=0;b<d.length;b++){var f=d.charAt(b);if(e.indexOf(f)==-1){a+=f}}return a}function isIeLessThan7(){if(navigator.appName=="Microsoft Internet Explorer"){temp=navigator.appVersion.split("MSIE");ieVer=parseInt(temp[1]);if(ieVer<7){return true}else{return false}}else{return false}}function toggleSaveRemove(a){if(document.getElementById("save"+a).style.display!="none"){document.getElementById("save"+a).style.display="none";document.getElementById("delete"+a).style.display="block"}else{document.getElementById("save"+a).style.display="block";document.getElementById("delete"+a).style.display="none"}}var WindowBounds=new Object();WindowBounds.PageWidth=0;WindowBounds.PageHeight=0;WindowBounds.VisibleTop=0;WindowBounds.VisibleLeft=0;WindowBounds.VisibleWidth=0;WindowBounds.VisibleHeight=0;function GetWindowBounds(){if(window.innerHeight&&window.scrollMaxY){WindowBounds.PageWidth=window.innerWidth+window.scrollMaxX;WindowBounds.PageHeight=window.innerHeight+window.scrollMaxY}else{if(document.body.scrollHeight>document.body.offsetHeight){WindowBounds.PageWidth=document.body.scrollWidth;WindowBounds.PageHeight=document.body.scrollHeight}else{WindowBounds.PageWidth=document.body.offsetWidth+document.body.offsetLeft;WindowBounds.PageHeight=document.body.offsetHeight+document.body.offsetTop}}if(document.documentElement&&document.documentElement.scrollTop){WindowBounds.VisibleTop=document.documentElement.scrollTop;WindowBounds.VisibleLeft=document.documentElement.scrollLeft;WindowBounds.VisibleWidth=document.documentElement.clientWidth;WindowBounds.VisibleHeight=document.documentElement.clientHeight}else{if(document.body){WindowBounds.VisibleTop=document.body.scrollTop;WindowBounds.VisibleLeft=document.body.scrollLeft;WindowBounds.VisibleWidth=document.body.clientWidth;WindowBounds.VisibleHeight=document.body.clientHeight}else{WindowBounds.VisibleTop=window.pageYOffset;WindowBounds.VisibleLeft=window.pageXOffset;WindowBounds.VisibleWidth=window.innerWidth;WindowBounds.VisibleHeight=window.innerHeight}}if(navigator.userAgent.indexOf("Safari")>-1){WindowBounds.VisibleHeight=window.innerHeight}return WindowBounds}function Trim(a){while((a.substring(0,1)==" ")||(a.substring(0,1)=="\n")||(a.substring(0,1)=="\r")){a=a.substring(1,a.length)}while((a.substring(a.length-1,a.length)==" ")||(a.substring(a.length-1,a.length)=="\n")||(a.substring(a.length-1,a.length)=="\r")){a=a.substring(0,a.length-1)}return a}function toggleDiv(a){if(document.getElementById(a).style.display=="block"){document.getElementById(a).style.display="none"}else{document.getElementById(a).style.display="block"}}function toggleDivWithImage(b,a){if(document.getElementById(b).style.display=="block"){document.getElementById(b).style.display="none";document.getElementById(a).src="images/minus2plus.gif"}else{document.getElementById(b).style.display="block";document.getElementById(a).src="images/plus2minus.gif"}}function setOptionsWithValues(c,a,b){clearOptions(c);for(i=0;i<a.length;i++){appendOptionLastWithValue(c,a[i],b[i])}}function setOptions(b,a){clearOptions(b);for(i=0;i<a.length;i++){appendOptionLast(b,a[i])}}function appendOptionLastWithOptionId(f,a,d){var b=document.createElement("option");b.text=a;b.value=a;b.id=d;var e=document.getElementById(f);if(e!=undefined){try{e.add(b,null)}catch(c){e.add(b)}}}function appendOptionLastWithValue(f,a,d){var b=document.createElement("option");b.text=a;b.value=d;var e=document.getElementById(f);if(e!=undefined){try{e.add(b,null)}catch(c){e.add(b)}}}function appendOptionLast(b,a){appendOptionLastWithValue(b,a,a)}function clearOptions(c){var b=document.getElementById(c);if(b!=undefined){var a;for(a=b.length-1;a>=0;a--){b.remove(a)}}}function execInputString(id){var code=document.getElementById(id).value;eval(code)}function getKey(a){var b;if(a&&a.which){a=a;b=a.which}else{a=event;b=a.keyCode}return b}function isKeyEnter(a){return(a==13)?true:false}function isKeyNumber(a){return((a>=48)&&(a<=57))?true:false}var gabrielsTimer;function moveDivHorizontal(Direction,innerDivId,contentWidth,outerWidth,stepSpeed,overflowFn,movedFn){var obj=document.getElementById(innerDivId);var newVal=parseInt(obj.style.left)+(stepSpeed*Direction);obj.style.left=((newVal>0)?"0":((newVal<outerWidth-contentWidth)?parseInt(outerWidth-contentWidth):newVal))+"px";if((Direction<0&&newVal<outerWidth-contentWidth)||(Direction>0&&newVal>0)){eval(overflowFn)}else{eval(movedFn)}gabrielsTimer=setTimeout("moveDivHorizontal("+Direction+', "'+innerDivId+'", '+contentWidth+", "+outerWidth+", "+stepSpeed+', "'+overflowFn+'", "'+movedFn+'");',50)}function moveDivHorizontalNo(){clearTimeout(gabrielsTimer)};
