﻿function AblWindow(){}AblWindow.stripProtocol=function(href){if(typeof href!=="string"){href=window.location.href}if(href.indexOf(window.location.protocol)===0){return href.substr(window.location.protocol.length)}else{return href}};AblWindow.stripLocation=function(href){if(typeof href!=="string"){href=window.location.href}var domain=window.location.protocol+'//'+window.location.hostname;if((window.location.port)&&(window.location.port.length>0)){domain+=":"+window.location.port}if(href.indexOf(domain)===0){return href.substr(domain.length)}else{return href}};AblWindow.stripQueryString=function(href){var s=href;if((typeof s==="string")){var i=s.indexOf("?");if(i>=0){s=s.substr(0,i)}}return s};AblWindow.parseQueryString=function(queryString){var result={};if(typeof queryString==="undefined"){queryString=location.search?location.search:''}if(queryString.charAt(0)==="?"){queryString=queryString.substring(1)}queryString=queryString.replace('+',' ');var queryComponents=queryString.split(/[&;]/g);for(var i=0;i<queryComponents.length;i++){var keyValuePair=queryComponents[i].split('=');var key=decodeURIComponent(keyValuePair[0]);var value=decodeURIComponent(keyValuePair[1]);result[key]=value}return result};function AblDialog(url,options){this.wndDialog=null;this.openingDialog=false;this.left="50%";this.top="30%";this.width=500;this.height=300;this.pageUrl=null;this.name="wDialog";this.autoClose=true;this.features={};this.features.toolbar=false;this.features.location=false;this.features.status=false;this.features.menubar=false;this.features.scrollbars=false;this.features.resizable=false;this.params={};if(options){this.init(url,options)}}AblDialog.prototype.init=function(url,options){this.pageUrl=url;var n=0;if(options){if(options.width){if(typeof options.width==="string"){n=parseInt(options.width,10);if(options.width.indexOf("%")>=0){n=Math.round(self.screen.width*n/100)}}else{n=options.width}this.width=Math.constrain(n,0,self.screen.width)}if(options.height){if(typeof options.height==="string"){n=parseInt(options.height,10);if(options.height.indexOf("%")>=0){n=Math.round(self.screen.height*n/100)}}else{n=options.height}this.height=Math.constrain(n,0,self.screen.height)}if(options.left){if(typeof options.left==="string"){n=parseInt(options.left,10);if(options.left.indexOf("%")>=0){n=Math.round((self.screen.width-this.width)*n/100)}}else{n=options.left}this.left=Math.constrain(n,0,self.screen.width-this.width)}if(options.top){if(typeof options.top==="string"){n=parseInt(options.top,10);if(options.top.indexOf("%")>=0){n=Math.round((self.screen.height-this.height)*n/100)}}else{n=options.top}this.top=Math.constrain(n,0,self.screen.height-this.height)}if(options.name){this.name=options.name}if(options.autoClose){this.autoClose=options.autoClose}if(options.toolbar){this.features.toolbar=options.toolbar}if(options.location){this.features.location=options.location}if(options.status){this.features.status=options.status}if(options.menubar){this.features.menubar=options.menubar}if(options.scrollbars){this.features.scrollbars=options.scrollbars}if(options.resizable){this.features.resizable=options.resizable}if(options.params){this.params=options.params}}};AblDialog.prototype.isOpen=function(){return((this.wndDialog)&&(!this.wndDialog.closed))};AblDialog.prototype.open=function(url,options){var me=this;if(this.openingDialog){return}else{this.openingDialog=true}if((this.wndDialog)&&(!this.wndDialog.closed)){this.close()}if(arguments.length>0){this.init(url,options)}var s="left="+this.left;s+=",top="+this.top;s+=",width="+this.width;s+=",height="+this.height;for(var property in this.features){s+=","+property+"="+((this.features[property])?"1":"0")}this.wndDialog=self.open(this.pageUrl,this.name,s,true);if(this.wndDialog.focus){this.wndDialog.focus()}this.openingDialog=false};AblDialog.prototype.close=function(){if(this.isOpen()){this.wndDialog.close()}this.openingDialog=false;this.wndDialog=null};AblDialog.getParams=function(){if((self.opener)&&(self.opener.dialog)&&(self.opener.dialog.params)){return self.opener.dialog.params}else{return null}};
