// JScript File

IYWindowExt = function()
{
	var url;								// url of modal message
	var htmlOfModalMessage;					// html of modal message
	
	var divs_transparentDiv;				// Transparent div covering page content
	var divs_content;						// Modal message div.
	var iframe;								// Iframe used in ie
	var width;								// Width of message box
	var height;								// Height of message box
	
	var existingBodyOverFlowStyle;			// Existing body overflow css
	var dynContentObj;						// Reference to dynamic content object
	var cssClassOfMessageBox;				// Alternative css class of message box - in case you want a different appearance on one of them
	var shadowDivVisible;					// Shadow div visible ? 
	var shadowOffset; 						// X and Y offset of shadow(pixels from content box)
	var MSIE;
		
	this.url = '';							// Default url is blank
	this.htmlOfModalMessage = '';			// Default message is blank
	this.height = 200;						// Default height of modal message
	this.width = 400;						// Default width of modal message
	this.cssClassOfMessageBox = false;		// Default alternative css class for the message box
	this.shadowDivVisible = true;			// Shadow div is visible by default
	this.shadowOffset = 5;					// Default shadow offset.
	this.MSIE = false;
	
	this.cssText_modalDialog_contentDiv='border:3px solid #000;padding:2px;z-index:100;position:absolute;background-color:#FFF;';
	this.cssText_contentDiv_shadow='z-index:90;position:absolute;background-color:#555;filter:alpha(opacity=30);opacity:0.3;';
	this.cssText_modalDialog_transparentDivs='filter:alpha(opacity=60);opacity:0.6;background-color:#AAA;z-index:1;position:absolute;';
	
	if(navigator.userAgent.indexOf('MSIE')>=0) this.MSIE = true;
	
	this.comboBoxOff=false;
	this.argsComboBoxOffed=[];
	

}

IYWindowExt.prototype = {
	setHtmlContent : function(newHtmlContent)
	{
		this.htmlOfModalMessage = newHtmlContent;
		
	}
	,
	setSize : function(width,height)
	{
		if(width)this.width = width;
		if(height)this.height = height;		
	}
	,		
	setShadowOffset : function(newShadowOffset)
	{
		this.shadowOffset = newShadowOffset
					
	}
	,	
	display : function(ComboBoxOff)
	{
	    if (ComboBoxOff!=null){ this.comboBoxOff=ComboBoxOff; }
	    if (this.comboBoxOff==true){
	        var comboxs=document.getElementsByTagName("select");
			var cxs=[];
			for(var j=0;j<comboxs.length;j++){
				if (comboxs[j].style.display!="none"){
				    comboxs[j].style.LastDisplay=comboxs[j].style.display;
					comboxs[j].style.display="none";
					cxs.push(comboxs[j]);
				}
			}
			this.argsComboBoxOffed=cxs;
	    }
	    
	    
		if(!this.divs_transparentDiv){
			this.__createDivs();
		}	
		
		// Redisplaying divs
		this.divs_transparentDiv.style.display='block';
		this.divs_content.style.display='block';
		this.divs_shadow.style.display='block';		
		if(this.MSIE && this.comboBoxOff==false)this.iframe.style.display='block';	
		this.__resizeDivs();
		
		/* Call the __resizeDivs method twice in case the css file has changed. The first execution of this method may not catch these changes */
		window.refToThisModalBoxObj = this;		
		setInterval('window.refToThisModalBoxObj.__resizeDivs()',150);
		
		this.__insertContent();	// Calling method which inserts content into the message div.
	}
	,
	setShadowDivVisible : function(visible)
	{
		this.shadowDivVisible = visible;
	}
	,
	close : function()
	{
		//document.documentElement.style.overflow = '';	// Setting the CSS overflow attribute of the <html> tag back to default.
		
		/* Hiding divs */
		this.divs_transparentDiv.style.display='none';
		this.divs_content.style.display='none';
		this.divs_shadow.style.display='none';
		if(this.MSIE && this.comboBoxOff==false)this.iframe.style.display='none';
		if (this.comboBoxOff==true){
		    if (this.argsComboBoxOffed){
		        for(var j=0;j<this.argsComboBoxOffed.length;j++){
			        this.argsComboBoxOffed[j].style.display=this.argsComboBoxOffed[j].style.LastDisplay;
			        
			    }
			}
		}
		/*Remove divs*/
		this.divs_content.innerHTML="";
		
	}	
	,
	// {{{ __addEvent()
    /**
     *	Add event
     * 	
     *
     * @private	
     */		
	addEvent : function(whichObject,eventType,functionName,suffix)
	{ 
	  if(!suffix)suffix = '';
	  if(whichObject.attachEvent){ 
	    whichObject['e'+eventType+functionName+suffix] = functionName; 
	    whichObject[eventType+functionName+suffix] = function(){whichObject['e'+eventType+functionName+suffix]( window.event );} 
	    whichObject.attachEvent( 'on'+eventType, whichObject[eventType+functionName+suffix] ); 
	  } else 
	    whichObject.addEventListener(eventType,functionName,false); 	    
	} 
	// }}}	
	,
	// {{{ __createDivs()
    /**
     *	Create the divs for the modal dialog box
     * 	
     *
     * @private	
     */		
	__createDivs : function()
	{
		// Creating transparent div
		this.divs_transparentDiv = document.createElement('DIV');
		this.divs_transparentDiv.style.cssText=this.cssText_modalDialog_transparentDivs;
		this.divs_transparentDiv.style.left = '0px';
		this.divs_transparentDiv.style.top = '0px';
		
		document.body.appendChild(this.divs_transparentDiv);
		// Creating content div
		this.divs_content = document.createElement('DIV');
		this.divs_content.id = 'IY_modalBox_contentDiv';
		this.divs_content.style.cssText = this.cssText_modalDialog_contentDiv;
		this.divs_content.style.zIndex = 100000;
		
		if(this.MSIE && this.comboBoxOff==false){
			this.iframe = document.createElement('<IFRAME frameborder="0">');
			this.iframe.style.zIndex = 90000;
			this.iframe.style.position = 'absolute';
			this.iframe.style.left = this.divs_content.style.left;
 			this.iframe.style.top = this.divs_content.style.top;
 			this.iframe.style.width = this.divs_content.style.width;
 			this.iframe.style.height = this.divs_content.style.height;
 			this.iframe.style.cssText+=";filter:alpha(opacity=0);opacity:0;";
		    document.body.insertBefore(this.iframe,null);
		}
			
		// Creating shadow div
		this.divs_shadow = document.createElement('DIV');
		this.divs_shadow.style.cssText = this.cssText_contentDiv_shadow;
		this.divs_shadow.style.zIndex = 95000;
		document.body.insertBefore(this.divs_shadow,null);
		window.refToModMessage = this;
		document.body.appendChild(this.divs_content);
		this.addEvent(window,'scroll',function(e){ window.refToModMessage.__repositionTransparentDiv() });
		this.addEvent(window,'resize',function(e){ window.refToModMessage.__resizeDivs() });
		this.__repositionTransparentDiv();

	}
	// }}}
	,
	// {{{ __getBrowserSize()
    /**
     *	Get browser size
     * 	
     *
     * @private	
     */		
	__getBrowserSize : function()
	{
    	var bodyWidth = document.documentElement.clientWidth;
    	var bodyHeight = document.documentElement.clientHeight;
    	
		var bodyWidth, bodyHeight; 
		if (self.innerHeight){ // all except Explorer 
		 
		   bodyWidth = self.innerWidth; 
		   bodyHeight = self.innerHeight; 
		}  else if (document.documentElement && document.documentElement.clientHeight) {
		   // Explorer 6 Strict Mode 		 
		   bodyWidth = document.documentElement.clientWidth; 
		   bodyHeight = document.documentElement.clientHeight; 
		} else if (document.body) {// other Explorers 		 
		   bodyWidth = document.body.clientWidth; 
		   bodyHeight = document.body.clientHeight; 
		} 
		return [bodyWidth,bodyHeight];		
		
	}
	// }}}	
	,
	// {{{ __resizeDivs()
    /**
     *	Resize the message divs
     * 	
     *
     * @private	
     */	
    __resizeDivs : function()
    {
        var topOffset = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
    	if(!this.divs_transparentDiv)return;
    	
    	// Preserve scroll position
    	var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
    	var sl = Math.max(document.body.scrollLeft,document.documentElement.scrollLeft);
    	
    	window.scrollTo(sl,st);
    	setTimeout('window.scrollTo(' + sl + ',' + st + ');',10);

    	this.__repositionTransparentDiv();
    	

		var brSize = this.__getBrowserSize();
		var bodyWidth = brSize[0];
		var bodyHeight = brSize[1];
    	
    	// Setting width and height of content div
      	this.divs_content.style.width = this.width + 'px';
    	this.divs_content.style.height= this.height + 'px';
    	
    	// Creating temporary width variables since the actual width of the content div could be larger than this.width and this.height(i.e. padding and border)
    	var tmpWidth = this.divs_content.offsetWidth;	
    	var tmpHeight = this.divs_content.offsetHeight;
    	
    	
    	// Setting width and height of left transparent div
       	this.divs_content.style.left = Math.ceil((bodyWidth - tmpWidth) / 2) + 'px';;
    	this.divs_content.style.top = (Math.ceil((bodyHeight - tmpHeight) / 2) +  topOffset) + 'px';
    	
    	this.divs_shadow.style.left = (this.divs_content.style.left.replace('px','')/1 + this.shadowOffset) + 'px';
    	this.divs_shadow.style.top = (this.divs_content.style.top.replace('px','')/1 + this.shadowOffset) + 'px';
    	this.divs_shadow.style.height = tmpHeight + 'px';
    	this.divs_shadow.style.width = tmpWidth + 'px';
    	
    	if(!this.shadowDivVisible)this.divs_shadow.style.display='none';	// Hiding shadow if it has been disabled
    }
    // }}}	
    ,
	// {{{ __insertContent()
    /**
     *	Insert content into the content div
     * 	
     *
     * @private	
     */	    
    __repositionTransparentDiv : function()
    {
    	this.divs_transparentDiv.style.top = Math.max(document.body.scrollTop,document.documentElement.scrollTop) + 'px';
    	this.divs_transparentDiv.style.left = Math.max(document.body.scrollLeft,document.documentElement.scrollLeft) + 'px';
		var brSize = this.__getBrowserSize();
		var bodyWidth = brSize[0];
		var bodyHeight = brSize[1];
    	this.divs_transparentDiv.style.width = bodyWidth + 'px';
    	this.divs_transparentDiv.style.height = bodyHeight + 'px';		
    	
    	if(this.MSIE && this.comboBoxOff==false){
 		  	this.iframe.style.left = this.divs_transparentDiv.style.left;
 			this.iframe.style.top = this.divs_transparentDiv.style.top;
 			this.iframe.style.width = this.divs_transparentDiv.style.width;
 			this.iframe.style.height = this.divs_transparentDiv.style.height;
 		}
		   	
    }
	// }}}	
	,
	// {{{ __insertContent()
    /**
     *	Insert content into the content div
     * 	
     *
     * @private	
     */	
    __insertContent : function()
    {
		if(this.url){	// url specified - load content dynamically
			alert("Это не раелизовано");
		}else{	// no url set, put static content inside the message box
			this.divs_content.innerHTML = this.htmlOfModalMessage;	
		}
    }		
}
// JScript File

IYWindowExt = function()
{
	var url;								// url of modal message
	var htmlOfModalMessage;					// html of modal message
	
	var divs_transparentDiv;				// Transparent div covering page content
	var divs_content;						// Modal message div.
	var iframe;								// Iframe used in ie
	var width;								// Width of message box
	var height;								// Height of message box
	
	var existingBodyOverFlowStyle;			// Existing body overflow css
	var dynContentObj;						// Reference to dynamic content object
	var cssClassOfMessageBox;				// Alternative css class of message box - in case you want a different appearance on one of them
	var shadowDivVisible;					// Shadow div visible ? 
	var shadowOffset; 						// X and Y offset of shadow(pixels from content box)
	var MSIE;
		
	this.url = '';							// Default url is blank
	this.htmlOfModalMessage = '';			// Default message is blank
	this.height = 200;						// Default height of modal message
	this.width = 400;						// Default width of modal message
	this.cssClassOfMessageBox = false;		// Default alternative css class for the message box
	this.shadowDivVisible = false;			// Shadow div is visible by default
	this.shadowOffset = 5;					// Default shadow offset.
	this.MSIE = false;
	
	this.cssText_modalDialog_contentDiv='z-index:100;position:absolute;background-color:#FFF;';
	this.cssText_contentDiv_shadow='z-index:90;position:absolute;background-color:#555;filter:alpha(opacity=30);opacity:0.3;';
	this.cssText_modalDialog_transparentDivs='filter:alpha(opacity=60);opacity:0.6;background-color:#AAA;z-index:1;position:absolute;';
	
	if(navigator.userAgent.indexOf('MSIE')>=0) this.MSIE = true;
	
	this.comboBoxOff=false;
	this.argsComboBoxOffed=[];
	

}

IYWindowExt.prototype = {
	setHtmlContent : function(newHtmlContent)
	{
		this.htmlOfModalMessage = newHtmlContent;
		
	}
	,
	setSize : function(width,height)
	{
		if(width)this.width = width;
		if(height)this.height = height;		
	}
	,		
	setShadowOffset : function(newShadowOffset)
	{
		this.shadowOffset = newShadowOffset
					
	}
	,	
	display : function(ComboBoxOff)
	{
	    if (ComboBoxOff!=null){ this.comboBoxOff=ComboBoxOff; }
	    if (this.comboBoxOff==true){
	        var comboxs=document.getElementsByTagName("select");
			var cxs=[];
			for(var j=0;j<comboxs.length;j++){
				if (comboxs[j].style.display!="none"){
				    comboxs[j].style.LastDisplay=comboxs[j].style.display;
					comboxs[j].style.display="none";
					cxs.push(comboxs[j]);
				}
			}
			this.argsComboBoxOffed=cxs;
	    }
	    
	    
		if(!this.divs_transparentDiv){
			this.__createDivs();
		}	
		
		// Redisplaying divs
		this.divs_transparentDiv.style.display='block';
		this.divs_content.style.display='block';
		this.divs_shadow.style.display='block';		
		if(this.MSIE && this.comboBoxOff==false)this.iframe.style.display='block';	
		this.__resizeDivs();
		
		/* Call the __resizeDivs method twice in case the css file has changed. The first execution of this method may not catch these changes */
		window.refToThisModalBoxObj = this;		
		setInterval('window.refToThisModalBoxObj.__resizeDivs()',150);
		
		this.__insertContent();	// Calling method which inserts content into the message div.
	}
	,
	setShadowDivVisible : function(visible)
	{
		this.shadowDivVisible = visible;
	}
	,
	close : function()
	{
		//document.documentElement.style.overflow = '';	// Setting the CSS overflow attribute of the <html> tag back to default.
		
		/* Hiding divs */
		this.divs_transparentDiv.style.display='none';
		this.divs_content.style.display='none';
		this.divs_shadow.style.display='none';
		if(this.MSIE && this.comboBoxOff==false)this.iframe.style.display='none';
		if (this.comboBoxOff==true){
		    if (this.argsComboBoxOffed){
		        for(var j=0;j<this.argsComboBoxOffed.length;j++){
			        this.argsComboBoxOffed[j].style.display=this.argsComboBoxOffed[j].style.LastDisplay;
			        
			    }
			}
		}
		/*Remove divs*/
		this.divs_content.innerHTML="";
		
	}	
	,
	// {{{ __addEvent()
    /**
     *	Add event
     * 	
     *
     * @private	
     */		
	addEvent : function(whichObject,eventType,functionName,suffix)
	{ 
	  if(!suffix)suffix = '';
	  if(whichObject.attachEvent){ 
	    whichObject['e'+eventType+functionName+suffix] = functionName; 
	    whichObject[eventType+functionName+suffix] = function(){whichObject['e'+eventType+functionName+suffix]( window.event );} 
	    whichObject.attachEvent( 'on'+eventType, whichObject[eventType+functionName+suffix] ); 
	  } else 
	    whichObject.addEventListener(eventType,functionName,false); 	    
	} 
	// }}}	
	,
	// {{{ __createDivs()
    /**
     *	Create the divs for the modal dialog box
     * 	
     *
     * @private	
     */		
	__createDivs : function()
	{
		// Creating transparent div
		this.divs_transparentDiv = document.createElement('DIV');
		this.divs_transparentDiv.style.cssText=this.cssText_modalDialog_transparentDivs;
		this.divs_transparentDiv.style.left = '0px';
		this.divs_transparentDiv.style.top = '0px';
		
		document.body.appendChild(this.divs_transparentDiv);
		// Creating content div
		this.divs_content = document.createElement('DIV');
		this.divs_content.id = 'IY_modalBox_contentDiv';
		this.divs_content.style.cssText = this.cssText_modalDialog_contentDiv;
		this.divs_content.style.zIndex = 100000;
		
		if(this.MSIE && this.comboBoxOff==false){
			this.iframe = document.createElement('<IFRAME frameborder="0">');
			this.iframe.style.zIndex = 90000;
			this.iframe.style.position = 'absolute';
			this.iframe.style.left = this.divs_content.style.left;
 			this.iframe.style.top = this.divs_content.style.top;
 			this.iframe.style.width = this.divs_content.style.width;
 			this.iframe.style.height = this.divs_content.style.height;
 			this.iframe.style.cssText+=";filter:alpha(opacity=0);opacity:0;";
		    document.body.insertBefore(this.iframe,null);
		}
			
		// Creating shadow div
		this.divs_shadow = document.createElement('DIV');
		this.divs_shadow.style.cssText = this.cssText_contentDiv_shadow;
		this.divs_shadow.style.zIndex = 95000;
		document.body.insertBefore(this.divs_shadow,null);
		window.refToModMessage = this;
		document.body.appendChild(this.divs_content);
		this.addEvent(window,'scroll',function(e){ window.refToModMessage.__repositionTransparentDiv() });
		this.addEvent(window,'resize',function(e){ window.refToModMessage.__resizeDivs() });
		this.__repositionTransparentDiv();

	}
	// }}}
	,
	// {{{ __getBrowserSize()
    /**
     *	Get browser size
     * 	
     *
     * @private	
     */		
	__getBrowserSize : function()
	{
    	var bodyWidth = document.documentElement.clientWidth;
    	var bodyHeight = document.documentElement.clientHeight;
    	
		var bodyWidth, bodyHeight; 
		if (self.innerHeight){ // all except Explorer 
		 
		   bodyWidth = self.innerWidth; 
		   bodyHeight = self.innerHeight; 
		}  else if (document.documentElement && document.documentElement.clientHeight) {
		   // Explorer 6 Strict Mode 		 
		   bodyWidth = document.documentElement.clientWidth; 
		   bodyHeight = document.documentElement.clientHeight; 
		} else if (document.body) {// other Explorers 		 
		   bodyWidth = document.body.clientWidth; 
		   bodyHeight = document.body.clientHeight; 
		} 
		return [bodyWidth,bodyHeight];		
		
	}
	// }}}	
	,
	// {{{ __resizeDivs()
    /**
     *	Resize the message divs
     * 	
     *
     * @private	
     */	
    __resizeDivs : function()
    {
        var topOffset = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
    	if(!this.divs_transparentDiv)return;
    	
    	// Preserve scroll position
    	var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
    	var sl = Math.max(document.body.scrollLeft,document.documentElement.scrollLeft);
    	
    	window.scrollTo(sl,st);
    	setTimeout('window.scrollTo(' + sl + ',' + st + ');',10);

    	this.__repositionTransparentDiv();
    	

		var brSize = this.__getBrowserSize();
		var bodyWidth = brSize[0];
		var bodyHeight = brSize[1];
    	
    	// Setting width and height of content div
      	this.divs_content.style.width = this.width + 'px';
    	this.divs_content.style.height= this.height + 'px';
    	
    	// Creating temporary width variables since the actual width of the content div could be larger than this.width and this.height(i.e. padding and border)
    	var tmpWidth = this.divs_content.offsetWidth;	
    	var tmpHeight = this.divs_content.offsetHeight;
    	
    	
    	// Setting width and height of left transparent div
       	this.divs_content.style.left = Math.ceil((bodyWidth - tmpWidth) / 2) + 'px';;
    	this.divs_content.style.top = (Math.ceil((bodyHeight - tmpHeight) / 2) +  topOffset) + 'px';
    	
    	this.divs_shadow.style.left = (this.divs_content.style.left.replace('px','')/1 + this.shadowOffset) + 'px';
    	this.divs_shadow.style.top = (this.divs_content.style.top.replace('px','')/1 + this.shadowOffset) + 'px';
    	this.divs_shadow.style.height = tmpHeight + 'px';
    	this.divs_shadow.style.width = tmpWidth + 'px';
    	
    	if(!this.shadowDivVisible)this.divs_shadow.style.display='none';	// Hiding shadow if it has been disabled
    }
    // }}}	
    ,
	// {{{ __insertContent()
    /**
     *	Insert content into the content div
     * 	
     *
     * @private	
     */	    
    __repositionTransparentDiv : function()
    {
    	this.divs_transparentDiv.style.top = Math.max(document.body.scrollTop,document.documentElement.scrollTop) + 'px';
    	this.divs_transparentDiv.style.left = Math.max(document.body.scrollLeft,document.documentElement.scrollLeft) + 'px';
		var brSize = this.__getBrowserSize();
		var bodyWidth = brSize[0];
		var bodyHeight = brSize[1];
    	this.divs_transparentDiv.style.width = bodyWidth + 'px';
    	this.divs_transparentDiv.style.height = bodyHeight + 'px';		
    	
    	if(this.MSIE && this.comboBoxOff==false){
 		  	this.iframe.style.left = this.divs_transparentDiv.style.left;
 			this.iframe.style.top = this.divs_transparentDiv.style.top;
 			this.iframe.style.width = this.divs_transparentDiv.style.width;
 			this.iframe.style.height = this.divs_transparentDiv.style.height;
 		}
		   	
    }
	// }}}	
	,
	// {{{ __insertContent()
    /**
     *	Insert content into the content div
     * 	
     *
     * @private	
     */	
    __insertContent : function()
    {
		if(this.url){	// url specified - load content dynamically
			alert("Это не раелизовано");
		}else{	// no url set, put static content inside the message box
			this.divs_content.innerHTML = this.htmlOfModalMessage;	
		}
    }		
}
// JScript File

function AjaxThread(){
    
    // timeout - максимальный таймаут на запрос, после генериться errorThread(e)
    // asyncstate - признак асинхронной работы
    // applycookies - применение выходных куки запроса браузеру
    this.globals = {
        timeout: 30000,
        isasync: true,
        applycookies: true
    };
    
    
    this._F_xmlHttp=null;
    this._F_getParams=[];
    this._F_postParams=[];
    this._F_header=null;
    this._F_url=null;
    this._F_args=null;
    
    this._F_intervalTimerID=null;
    this._F_timeoutTimerID=null;
    
    this._F_autoRefill=false;
    this._F_refillCount=0;
    
    // Добавление пост параметра, параметр игнорируется в случае, если значение парамерта, либо пустая строка, либо undefined или null
    this.addPostParameter=function(name,value){
        if ((value=="") || (value==null) || (value==undefined)) { return false; }
        this._F_postParams.push(name+"="+value);
    }
    
    this.addPostParameterEx=function(name,value){
        this._F_postParams.push(name+"="+value);
    }
    
    
    this.returnParameters=function(arrayParams){
        var resultString="";
        var tempParameter=null;
        var args_length=arrayParams.length;
        for(var i=0;i<args_length;i++){
            tempParameter=arrayParams[i];
            if (tempParameter){ 
                if (resultString.length>0){ resultString+="&"; }
                resultString+=tempParameter;
            }
        }
        return resultString;
    }
    // Добавление гет параметра, параметр игнорируется в случае, если значение парамерта, либо пустая строка, либо undefined или null
    this.addGetParameter=function(name,value){
        if ((value==null) || (value==undefined)) return;
        var strValue=value.toString();
        if (strValue.length>0){            
            this._F_getParams.push(name+"="+strValue);
        }
    }

    // Запуск запроса
    //  params - { timeout,url,header,isasync,applycookies,args }
    //  url - запрос-страница
    this.startThread=function(params,args){
        var G=this.globals;
        this.setAjaxParams(params);
        this._F_args=args;
        this._F_beginThread();
    }
    
    this._F_beginThread=function(){
        this._F_intervalTimerID=null;
        this._F_timeoutTimerID=null;

        
        var G=this.globals;
        var getparams=this.returnParameters(this._F_getParams);
        var postparams=this.returnParameters(this._F_postParams);
        var query_url=this._F_url;
        var query_post=postparams;
        
        if (getparams.length>0){ query_url+="?"+getparams; }
        if (query_post.length==0){ query_post=""; }
        
        this._F_createXmlObject();
        if ((this._F_xmlHttp==null) ||(this._F_xmlHttp==undefined)){
            this.errorThread("Error creating XMLHTTP object");
        }
  
        this._F_xmlHttp.open("POST", query_url, G.isasync);
        if ((this._F_header) && (this._F_header.length>0)){
            this._F_xmlHttp.setRequestHeader("Content-Type", this._F_header);
        }
        if (this.globals.isasync==true){
            this._F_startCompleteTimer(this,this._F_args);
        }
        var clength=0;
        if (query_post){clength=query_post.length;}
        this._F_xmlHttp.setRequestHeader('Content-length', clength);
        this._F_xmlHttp.send(query_post);
    }
    
    this.endThread=function(text,xml,args){  }
    this._F_receivedResponseUser=function(userinfo){}
    
    
    this.callbackEndThread=function(text,xml,args){
        var now = new Date();
        now.setTime(now.getTime() + 20 * 60 * 1000);
        setCookie("ASPNET_SessionId",this._F_xmlHttp.getResponseHeader("ASPNET_SessionId"),now,"/");
        this._F_receivedResponseUser({UserName:this._F_xmlHttp.getResponseHeader("UserName")});
        var heads=[];
        heads.push({Access:this._F_xmlHttp.getResponseHeader("ACCESS")});
        var retVal=this.endThread(text,xml,args,heads);
        if (retVal==false){
            if (this._F_refillCount>=5) 
            {
                 return;
            }
            this._F_beginThread();
            this._F_refillCount++;
        }
    }
    
    
    this._F_startCompleteTimer=function(ajax_loader,args){
        var timerFunction=function(){
            if (ajax_loader._F_xmlHttp.readyState==4){
                clearInterval(ajax_loader._F_intervalTimerID);
                clearTimeout(ajax_loader._F_timeoutTimerID);                
                ajax_loader.callbackEndThread(ajax_loader._F_xmlHttp.responseText,ajax_loader._F_xmlHttp.responseXML,args);
            }
        }
        var timeoutFunction=function(){
            clearInterval(ajax_loader._F_intervalTimerID);
            clearTimeout(ajax_loader._F_timeoutTimerID);
            if (ajax_loader._F_xmlHttp.readyState==4){
                ajax_loader.callbackEndThread(ajax_loader._F_xmlHttp.responseText,ajax_loader._F_xmlHttp.responseXML,args);
            }else{
                if (ajax_loader.errorThread){
                    ajax_loader.errorThread("Don't received data.Timeout experid");  
                }          
            }
        }
        this._F_intervalTimerID = setInterval( timerFunction, 50 );
        this._F_timeoutTimerID=setTimeout( timeoutFunction,this.globals.timeout );
    }
    
    
    
    // Ошибка исполнения запроса
    this.errorThread=function(msg){}
    
    
    //Применение параметров запроса
    this.setAjaxParams=function(params){
        var G=this.globals;
        G.timeout=params.timeout ? params.timeout : G.timeout;
        G.isasync=params.isasync ? params.isasync : G.isasync;
        G.applycookies=params.applycookies ? params.applycookies : G.applycookies;
        this._F_url=params.url;
        this._F_header=params.header ? params.header : this._F_header;
    }
    
    // Принцип работы Sync,Async, по умолчанию синхронный
    this.setAsyncState=function(state){
        this.globals.isasync=state;
    }
    // Применение куки запроса браузеру
    this.setApplyQueryCookies=function(apply){
        this.globals.applycookies=apply;
    }
    this.setRequestHeader=function(header){
        this._F_header=header;
    }
    
    this._F_createXmlObject=function(){
        var httpRequestObj=new (window.XMLHttpRequest||ActiveXObject)("Msxml2.XMLHTTP");
        this._F_xmlHttp=httpRequestObj;
    }
    
}

function AjaxLogin(){
    this.User = {
        UserName:null,
        IsAuthenticated:null
    }
    this._loadLoginForm=function(div){
        AjaxLoginWindow.show();
    }
    this.AuthenticateChanged=function(state){}
}

function AjaxWebForm(){
    this._F_login=new AjaxLogin(); 
    this._container_div=null;
    
    this.getLogin=function(){
        return this._F_login;
    }
    this.setContainer=function(container_div){
        this._container_div=container_div;
    }
    this.getContainer=function(){
        return this._container_div;
    }
    this.LoadLoginForm=function(){
        this.getLogin()._loadLoginForm(this.getContainer());
    }
    
    
    this._F_login.AuthenticateChanged=function(state)
    {
        this.User.IsAuthenticated=state;
        AjaxTools.RefreshAuthenticate();
        AjaxTools.RefillThreads();
    }
    
    this._threads=[];
    
    this.CreateNewThread=function(autorefill){
        var thread=new AjaxThread();
        if (autorefill==true){
            thread._F_autoRefill=autorefill;
            this._threads.push(thread);
        }
        this._initNewThread(thread,this._F_login);
        return thread; 
    }
    
    this._initNewThread=function(thread,loginAjax){
        thread._F_receivedResponseUser=function(userinfo){
                            
        }
    }
   
    this.RefillThreads=function(){
        for(var i=0;i<this._threads.length;i++){
            this._threads[i]._F_beginThread();            
        }  
    }
    
    this.RefreshAuthenticate=function(){
        var IaState=false;
        var PName="";
        this._F_login.User.UserName="";
        this._F_login.User.IsAuthenticated=false;
        if (getCookie("WebCityEstate")){
            var cString=getCookie("WebCityEstate");
            var Ia=GetStringValue(cString,"IA","&","=");
            if (Ia=="True"){
                IaState=true;
                PName=GetStringValue(cString,"U","&","=");
            }
        }
        this.AuthenticateChanged(IaState,PName);
    }

    this.AuthenticateChanged=function(ia,name){}
}

var AjaxTools=new AjaxWebForm();
AjaxTools.RefreshAuthenticate();
AjaxTools.AuthenticateChanged=function(UserState,PName){}


function GetStringValue(sourceString,name,delOuter,delInner){
    var args=sourceString.split(delOuter);
    for(var i=0;i<args.length;i++){
        var nameP=args[i].split(delInner)[0];
        var val=args[i].split(delInner)[1];
        if (nameP==name){
            return val; 
        }
    }
    return null;
}

function getCookie(name) {
        var prefix = name + "=";
        var cookieStartIndex = document.cookie.indexOf(prefix);
        if (cookieStartIndex == -1)
                return null;
        var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length);
        if (cookieEndIndex == -1)
                cookieEndIndex = document.cookie.length;
        return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}

function deleteCookie(name, path, domain) {
        if (getCookie(name)) {
                document.cookie = name + "=" + 
                ((path) ? "; path=" + path : "") +
                ((domain) ? "; domain=" + domain : "") +
                "; expires=Thu, 01-Jan-70 00:00:01 GMT";
        }
}

function setCookie(name, value, expires, path, domain, secure) {
	var curCookie = name + "=" + escape(value) +
		((expires) ? "; expires=" + expires.toGMTString() : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");
	document.cookie = curCookie;
}

// Динамическая загрузка CSS стилей
function importCSSToDoc(doc, cssFileName) {
    var styleSheet = doc.createElement("link");
    styleSheet.setAttribute("href", cssFileName);
    styleSheet.setAttribute("rel", "stylesheet");
    styleSheet.setAttribute("type", "text/css");
    var head = doc.getElementsByTagName("head");
    head[0].appendChild(styleSheet);
}

function GetQueryStringParameter(name){
    var params=document.location.search.replace("?","&");
    params=params.split("&");
    for(var i=0;i<params.length;i++){
        if (params[i].split("=").length==2){
            if (params[i].split("=")[0]==name){
                return params[i].split("=")[1];
            }
        }
    }
    return "";
}

//Функция добавляет/изменяет значение параметра (paramName) в строке запроса query и 
//возвращает измененный запрос. Если указано значение paramValue = "", то параметр удаляется
function SetQueryParam(query, paramName, paramValue)
{
    if (query == undefined || query == null || paramName == undefined || paramName == null) return query;
    var path = query;
    var startIndex = path.indexOf(paramName);      
    var newParam;
    paramValue == undefined || paramValue == null || paramValue.length == 0 ? newParam = "" : newParam = paramName + "=" + paramValue;
    var pref;
    path.indexOf("?") == -1 ? pref = "?" : pref = "&";  
    if (startIndex == -1)
    {
        if (newParam.length == 0) return query;
        path += (pref + newParam);        
    }
    else
    {
        if (newParam.length > 0) newParam = pref + newParam;        
        var endIndex = path.indexOf("&", startIndex);        
        if (endIndex == -1) endIndex = path.length;
        var oldParam = pref + path.substring(startIndex, endIndex);
        path = path.replace(oldParam, newParam);
    }    
    return path;
}

function TrimString(sInString){
    return sInString.replace(/(^\s+)|(\s+$)/g, "");
}


function IsNumeric(obj){
    obj.value=obj.value.replace(/(^\D*)/g,"");
}

function IsMaxLength(obj){
    var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : "";
    if (obj.getAttribute && obj.value.length>mlength) {
    obj.value=obj.value.substring(0,mlength); }
}

function IsGUID(value){
    if (!value) return false;
    return /[0-9a-fA-F]{8}(-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}/.test(value);
}

function ImageLoader(img,html_text_load){
    var div_load=document.createElement("DIV");
    div_load.innerHTML=html_text_load;
    div_load.style.backgroundColor="white";
    img.style.display="none";
    img.parentNode.appendChild(div_load);
    
    if (img.getIntervalId==null){
        function ImageLoaded(image,div_loader){
            function asyncImageLoaded(){
                if ((image.width!=0) && (image.height!=0)){
                    image.style.display="";
                    clearInterval(image.getIntevalId);
                    image.getIntevalId=null;
                    div_loader.parentNode.removeChild(div_loader);
                }
            }
            image.getIntevalId=setInterval(asyncImageLoaded,500);     
        }
        ImageLoaded(img,div_load);
    }
    
    return img;
}




function AjaxUserMenu(){
    this.ParentAutoRefill=true;
    this._RefillMenu=function(){
        if (!(this.ParentAutoRefill)){
            this.LoadMenu();
        }
    }
    
    this.LoadMenu=function(autorefill){
        
        if (autorefill!=null){this.ParentAutoRefill=autorefill;}      
        var MenuThread=AjaxTools.CreateNewThread();
        MenuThread.addGetParameter("source","usermenu");
        MenuThread.addGetParameter("op","GetMenu");
        MenuThread.startThread({url:"/industry/request.php",header:"application/x-www-form-urlencoded"});
        MenuThread.endThread=function(text,xml,args){
            try{
                var divMenu=document.getElementById("UserMenu");
                if (xml.getElementsByTagName("UL")[0].getAttribute("xsi:nil")=="true" || xml.getElementsByTagName("UL")[0].getAttribute("nil")=="true"){
                    divMenu.style.display="none";
                  
                    return true;
                }else{
                    divMenu.style.display="block";
                    divMenu.innerHTML=text;
                    divMenu.getElementsByTagName("UL")[0].id="menu"; 
                    var nodes = document.getElementById("menu").getElementsByTagName("LI");
	                for (var i = 0; i < nodes.length; i++) {
		                nodes[i].onmouseover = function() { this.className += "over"; }
		                nodes[i].onmouseout =  function() { this.className = this.className.replace(new RegExp("over\\b"), ""); }
	                }
                 }
            }
            catch(ex){
                return false;
            }
        }    
    
    }
}
var UserMenu=new AjaxUserMenu();



function LoginWindow(){
    
this.hide=function(){
this.close();
}

    this.show=function(){
        this._F_Init();
        var logWindow = this;
        var lm=new AjaxThread();
        lm.addGetParameter("key","85b1753d-25f4-4cce-aa08-ba66a6761413");
        lm.addGetParameter("source","user");
        lm.addGetParameter("go","[[[go]]]");
        lm.startThread({url:"/industry/request.php",header:"application/x-www-form-urlencoded"},{container:this});
        lm.endThread=function(text,xml,args){
            if (text.length<10){return false;}
            logWindow.setHtmlContent(text);
            logWindow.display();
        }
        lm.errorThread=function(e){
        
        }
    }    
    
    this.Authenticate=function(fid,login,password){
        var logWindow = this;
        var lt=new AjaxThread();
        lt.addPostParameter("fs","in");
        lt.addPostParameter("login",escape(login));
        lt.addPostParameter("pass",escape(password));
        lt.addPostParameter("fid",fid);
        logWindow.setHtmlContent("<table style='width:100%;height:100%;text-align:center;'><tr style='height:99%'><td><img src='http://industry-soft.ru/WebCityEstate/Images/loader.GIF' /></td></tr><tr><td style='font-family:verdana;color:white;font-weight:bold;font-size:10px'>&nbsp;</td></tr></table>");
        logWindow.display();
        lt.startThread({url:"/industry/request.php?source=login",header:"application/x-www-form-urlencoded"},{user:AjaxTools.getLogin().User,login:AjaxTools.getLogin()});
        lt.endThread=function(text,xml,args,heads){
            if (heads){
                if (heads[0].Access){
                    text=heads[0].Access;
                }else{ return false; }
            }else{ return false; }
            if (TrimString(text)=='USER_ACCESS_YES'){
                logWindow.setHtmlContent("<table style='width:100%;height:250px;text-align:center'><tr><td style='color:red;font-family:arial'><b>Вы успешно авторизовались!</b><br>Сверху появилось меню пользовательских действий<br><input type='button' onclick='AjaxLoginWindow.close();' value='Закрыть'/></td></tr></table>");
                logWindow.display();
	window.location.reload(); 
            }
            if (TrimString(text)=='USER_ACCESS_PASS'){
                alert("Неверный логин или пароль!");
            }
            args.user.UserName=text.split(";")[1];  
            args.user.IsAuthenticated=true;  
            UserMenu._RefillMenu();
            args.login.AuthenticateChanged(true); 
             
        }
        lt.errorThread=function(e){
            
        }
    }
   
    this.SignOut=function(){
        var logWindow = this;
        var lt=new AjaxThread();
        lt.addPostParameter("fs","out");
        logWindow.setHtmlContent("<table style='width:100%;height:100%;text-align:center;'><tr style='height:99%'><td><img src='http://industry-soft.ru/WebCityEstate/Images/loader.GIF' /></td></tr><tr><td style='font-family:verdana;color:white;font-weight:bold;font-size:10px'>&nbsp;</td></tr></table>");
        logWindow.display();
        lt.startThread({url:"/industry/request.php?source=login",header:"application/x-www-form-urlencoded"},{user:AjaxTools.getLogin().User,login:AjaxTools.getLogin()});
        lt.endThread=function(text,xml,args,heads){
            if (heads){
                if (heads[0].Access){
                    text=heads[0].Access;
                }else{ return false; }
            }else{ return false; }
            if (TrimString(text)=='USER_ACCESS_NO'){
                logWindow.setHtmlContent("<table style='width:100%;height:250px;text-align:center'><tr><td style='color:red;font-family:arial'><b>Вы успешно покинули систему!</b><br><input type='button' onclick='AjaxLoginWindow.close();' value='Закрыть'/></td></tr></table>");
                logWindow.display();
            }
            args.user.UserName="";  
            UserMenu._RefillMenu();
            args.login.AuthenticateChanged(false); 
            window.location.reload();    
        }
        lt.errorThread=function(e){
            
        }
    }
}
LoginWindow.prototype = new IYWindowExt();

LoginWindow.prototype._F_Init = function() {    
    this.setHtmlContent("<table style='width:100%;height:100%;text-align:center;'><tr style='height:99%'><td><img src='http://industry-soft.ru/WebCityEstate/Images/loader.GIF' /></td></tr><tr><td style='font-family:verdana;color:white;font-weight:bold;font-size:10px'>&nbsp;</td></tr></table>");
    this.setSize(500,300);
    this.display();
}
var AjaxLoginWindow=new LoginWindow();


function parseBoolean(arg){
    if (arg){
        if (arg=="true"){return true;}
        if (arg=="false"){return false;}
        if (arg=="1"){return true;}
        if (arg=="0"){return false;}
        if (arg==1){return true;}
        if (arg==0){return false;}
    }else{return null;}
}

(function(){ var ua = navigator.userAgent, av = navigator.appVersion, v, i;$is={};$is.Opera = !!(window.opera && opera.buildNumber);$is.WebKit = /WebKit/.test(ua);$is.OldWebKit = $is.WebKit && !window.getSelection().getRangeAt;$is.IE = !$is.WebKit && !$is.Opera && (/MSIE/gi).test(ua) && (/Explorer/gi).test(navigator.appName);$is.IE6 = $is.IE && /MSIE [56]/.test(ua);$is.IE5 = $is.IE && /MSIE [5]/.test(ua);$is.Gecko = !$is.WebKit && /Gecko/.test(ua);$is.Mac = ua.indexOf('Mac') != -1;for (i in $is) if (!$is[i]) $is[i]=NaN;switch (true) {    case ($is.WebKit): $is.WebKit =v= (ua.indexOf('Mac') != -1) ? av.substr(av.indexOf("Version/")+8, 4) : 2; break;    case ($is.Opera): $is.Opera =v= av.substr(0,4)-0; break;    case ($is.Gecko): $is.Gecko =v= (ua.indexOf("; rv:1.9") != -1) ? 1.9 : 1.8;break;    case ($is.IE): $is.IE =v= window.XMLHttpRequest ? 7 : (/MSIE [5]/.test(av)) ? 5 : 6;    };$is.verb = v;})();


// JScript File

function SubmitOrder(go){
    if (go==6) { PersonalTools.CreatePersonal(6001); return;}
    if (go==40) { PersonalTools.CreatePersonal(4); return;}
    PersonalTools.CreatePersonal(go);
}

// JScript File


var styleDemandPath="http://industry-soft.ru/WebCityEstate/Firm337/demand/css/design.css";



function AjaxDemandSend()
{
    this.Globals={
        current_demandwindow:null,
        style_loaded:false,
        go:null
    }
    this.CreateDemand=function(go){
        var G=this.Globals;
        if (!(G.style_loaded)){
            importCSSToDoc(document,styleDemandPath);
        }
        G.current_demandwindow=new DemandWindow("demand_container");
        G.current_demandwindow.show(go);
        G.style_loaded=true;
        G.go=go;
    }
    this.Hide=function(){
        var G=this.Globals;
        G.current_demandwindow.HideWindow();
    }
    this.Send=function(controls,alert_fields){
        var G=this.Globals;
        var vals=[];
        var Valid=true; 
        for(var i=0;i<alert_fields.length;i++){
            var e=document.getElementById(alert_fields[i]);
            if (e){ if (TrimString(e.value).length==0){ Valid=false; } }
        }
        if (Valid){
            for(i=0;i<controls.length;i++){
                var e=document.getElementById(controls[i]);
                if (e){
                    vals.push(TrimString(e.value));continue;
                }
                vals.push(null);
            }
            DemandTools.Globals.current_demandwindow.send(controls,vals,G.go);     
        } else {
            DemandTools.Globals.current_demandwindow.errorFields();
        }
    }

}
var DemandTools =new AjaxDemandSend(); 

var loadForm="<table style='width:100%;height:100%;text-align:center;'><tr style='height:99%'><td style='font-size:20px;color:#0C438E;'><img src='http://industry-soft.ru/WebCityEstate/Images/loader.GIF' /><br/>Идет загрузка...</td></tr><tr><td style='font-family:verdana;color:white;font-weight:bold;font-size:10px'>&nbsp;</td></tr></table>";


function DemandWindow(container_div_name){
    this.lastInnerHTML=null;
    this.windowEx=null;
  
    this.createWindow=function(){
        this.windowEx=new IYWindowExt();
        var div_win=document.createElement("div");
        div_win.id=container_div_name;
        div_win.innerHTML=loadForm;
        var outer_div=document.createElement("div");
        outer_div.appendChild(div_win);
        return outer_div;
    }
    
    this.HideWindow=function(){
        this.windowEx.close();
    }
    
    this.showWindowEx=function(){
        var DivWin=this.createWindow();
        var innerWinHTML;
        innerWinHTML=DivWin.innerHTML;
        this.windowEx.setHtmlContent(innerWinHTML);
        this.windowEx.setSize(500,400);
        this.windowEx.display();
    }
    
    this.show=function(go){
        //DemandWindow.prototype.show(document.body,this.createWindow(),"Оставить заявку","500px");
        this.showWindowEx();
         
        var MainThread=AjaxTools.CreateNewThread();
        MainThread.addGetParameter("key","85b1753d-25f4-4cce-aa08-ba66a6761413");
        MainThread.addGetParameter("go",go);
        MainThread.addGetParameter("source","demand");
        MainThread.startThread({url:"/industry/request.php",header:"application/x-www-form-urlencoded"});
        MainThread.endThread=function(text,xml,args){
            if (text.length<10){ return false; }
            document.getElementById(container_div_name).style.height="";
            document.getElementById(container_div_name).innerHTML=text; 
        }
        MainThread.errorThread=function(e){
            alert(e);
        }
    }
    this.errorFields=function(){
        this.lastInnerHTML=document.getElementById(container_div_name).innerHTML;  
        document.getElementById(container_div_name).innerHTML="<table style='width:100%;height:250px;text-align:center'><tr><td style='color:red;font-family:arial'>Пожалуйста, заполните все поля отмеченные (*)</td></tr></table>"; 
        setTimeout("DemandTools.Globals.current_demandwindow.revertErrorFields();",2000);
    }
    this.revertErrorFields=function(){
        document.getElementById(container_div_name).innerHTML=this.lastInnerHTML;   
    }
    this.printSendWindow=function(){
        this.lastInnerHTML=document.getElementById(container_div_name).innerHTML;  
        document.getElementById(container_div_name).innerHTML="<table style='width:100%;height:250px;text-align:center'><tr><td style='color:red;font-family:arial'>Спасибо за обращение в агентство «Александр Недвижимость»!<br/>В самое ближайщее время с вами свяжутся наши специалисты</td></tr></table>"; 
        setTimeout("DemandTools.Hide();",5000);
    }
    
    this.send=function(args,vars,go){	   var MainThread=AjaxTools.CreateNewThread();
        MainThread.addGetParameter("key","85b1753d-25f4-4cce-aa08-ba66a6761413");
        for(var i=0;i<args.length;i++){
            MainThread.addPostParameter(args[i],vars[i]);
        }
        MainThread.addGetParameter("go",go);
        MainThread.addGetParameter("send","1");
        MainThread.addGetParameter("source","demand");
        MainThread.startThread({url:"/industry/request.php",header:"application/x-www-form-urlencoded"});
       /* MainThread.endThread=function(text,xml,args){
                    document.getElementById(container_div_name).style.height="250px";
                    document.getElementById(container_div_name).innerHTML=text; 
        }
        MainThread.errorThread=function(e){
            alert(e);
        }*/
        this.printSendWindow();
    }

}
//DemandWindow.prototype = new iyWindow(true,true);






/* Personal Manager */



function AjaxPersonalSend()
{
    this.Globals={
        current_Personalwindow:null,
        style_loaded:false,
        go:null
    }
    this.CreatePersonal=function(go,getform){
        var G=this.Globals;
        G.current_Personalwindow=new PersonalWindow("Personal_container");
 	G.getform=getform;
        G.current_Personalwindow.show(go);
        G.style_loaded=true;
        G.go=go;
    }
    this.Hide=function(){
        var G=this.Globals;
        G.current_Personalwindow.HideWindow();
    }
    this.Send = function(controls, alert_fields) {				var G = this.Globals;
    	var vals = [];
    	var Valid = true;
    	for (var i = 0; i < controls.length; i++) {
    		var curControl = document.getElementById(controls[i]);
    		if (curControl && Valid) {
    			Valid = (curControl.getAttribute('required') && (TrimString(curControl.value).length == 0)) ? false : true;
    		}
    	}
    	if (Valid) {
    		for (i = 0; i < controls.length; i++) {
    			var e = document.getElementById(controls[i]);
    			if (e) {
    				vals.push(TrimString(e.value)); continue;
    			}
    			vals.push(null);
    		}			alexsend(controls);
    		//PersonalTools.Globals.current_Personalwindow.send(controls, vals, G.go);			
    	} else {
    		PersonalTools.Globals.current_Personalwindow.errorFields();
    	}
    }

}

var industry_path_personal="/industry/request.php";
function PersonalWindow(container_div_name){
    
    this.createWindow=function(){
        this.windowEx=new IYWindowExt();
        var div_win=document.createElement("div");
        div_win.id=container_div_name;
        div_win.innerHTML=loadForm;
        var outer_div=document.createElement("div");
        outer_div.appendChild(div_win);
        return outer_div;
    }
    
    this.showWindowEx=function(){
        var DivWin=this.createWindow();
        var innerWinHTML;
        innerWinHTML=DivWin.innerHTML;
        this.windowEx.setHtmlContent(innerWinHTML);
        this.windowEx.setSize(550,570);
        this.windowEx.display();
    }
    
    this.HideWindow=function(){
        this.windowEx.close();
    }
    
    this.show=function(go){
        var ace=PersonalTools;
        var gl=ace.Globals;
        gl.current_Personalwindow.showWindowEx();
        var MainThread=AjaxTools.CreateNewThread();
        MainThread.addGetParameter("key","85b1753d-25f4-4cce-aa08-ba66a6761413");
        MainThread.addGetParameter("go",go);
        MainThread.addGetParameter("getform",gl.getform);
        MainThread.addGetParameter("source","personal");
        MainThread.startThread({url:industry_path_personal,header:"application/x-www-form-urlencoded"});
        MainThread.endThread=function(text,xml,args){
            if (text.length<10){ return false; }
            document.getElementById(container_div_name).style.height="";
            document.getElementById(container_div_name).innerHTML=text; 
        }
        MainThread.errorThread=function(e){
            alert(e);
        }
    }
    this.errorFields=function(){
        this.lastInnerHTML=document.getElementById(container_div_name).innerHTML;  
  	document.getElementById(container_div_name).innerHTML="<table style='width:500px;height:250px;text-align:center'><tr><td style='color:red;font-family:arial'>Пожалуйста, заполните все поля отмеченные (*)</td></tr></table>";       
 setTimeout("PersonalTools.Globals.current_Personalwindow.revertErrorFields();",2000);
    }
    this.revertErrorFields=function(){
        document.getElementById(container_div_name).innerHTML=this.lastInnerHTML;   
    }
    this.printSendWindow=function(){
        this.lastInnerHTML=document.getElementById(container_div_name).innerHTML;  

   document.getElementById(container_div_name).innerHTML="<table style='width:500px;height:250px;text-align:center'><tr><td style='color:red;font-family:arial'>Спасибо за обращение в агентство «Александр Недвижимость»!<br/>В самое ближайщее время с вами свяжутся наши специалисты</td></tr></table>"; 
       
        setTimeout("PersonalTools.Hide();",5000);
    }
    
    this.send=function(args,vars,go){
        var MainThread=AjaxTools.CreateNewThread();
        MainThread.addGetParameter("key","85b1753d-25f4-4cce-aa08-ba66a6761413");
        for(var i=0;i<args.length;i++){
            MainThread.addPostParameter(escape(args[i]), escape(vars[i]));
        }
        MainThread.addGetParameter("go",go);
        MainThread.addGetParameter("send","1");
        MainThread.addGetParameter("source","personal");

        MainThread.startThread({url:industry_path_personal,header:"application/x-www-form-urlencoded"});
       /* MainThread.endThread=function(text,xml,args){
                    document.getElementById(container_div_name).style.height="250px";
                    document.getElementById(container_div_name).innerHTML=text; 
        }
        MainThread.errorThread=function(e){
            alert(e);
        }*/
        this.printSendWindow();
    }

}




var PersonalTools =new AjaxPersonalSend(); function alexsend(controls){	var par = new Object();//sem	for (i = 0; i < controls.length; i++) 	{		var e = document.getElementById(controls[i]);		var Id=controls[i];		if (e) 		{								par[Id] =e.value;		}    }		jQuery.ajax({	  type: "POST",	  dataType: 'json',	  url: '/js/industry/request3.php',	  data: par,	  // Если все ОК	  success: function(response) {	  	  },	  // Ошибка, например, timeout	  error: function(response) {		alert('error - '+response.error);	  }	});}
