﻿

function NDSInstallationUIMng() {            
    	
    var suspendWaitScreenInterval = null;
	this.hide = function() {
	    document.documentElement.style.overflow = '';
			    
	    if (typeof(this.suspendWaitScreenInterval) != 'undefined' && this.suspendWaitScreenInterval != null)
        {
            clearInterval(this.suspendWaitScreenInterval);
            this.suspendWaitScreenInterval = null;
        }
        	 		   
	    document.getElementsByName('quiteInstallation_container')[0].style.display = 'none';		    	    	    
	    
	    tvinciHelper.toggleFlash('visible');
	    var bg = document.getElementById('quiteInstallation_background');
	    if (bg != null)
	        bg.style.display = 'none';	    	 	    	    
	}

	this.showBackground = function() {
	    var bg = document.getElementById('quiteInstallation_background');

	    document.documentElement.style.overflow = 'hidden';

	    if (bg.style.display == 'block') {
	        return;
	    }

	    //if (tvinciHelper.ie && !tvinciHelper.ie7) {	this.toggleSelects('hide');	}
	    tvinciHelper.toggleFlash('hide');

	    var pageSize = this.getPageSize();
	    bg.style.height = pageSize[1] + "px";
	    bg.style.display = 'block';
	}
    
    this.ensureCloseButtonExists = function()
    {
        if (typeof(this.suspendWaitScreenInterval) != 'undefined' && this.suspendWaitScreenInterval != null)
        {
            clearInterval(this.suspendWaitScreenInterval);
            this.suspendWaitScreenInterval = null;
        }
        
        if (document.getElementsByName('quiteInstallation_wait_screen')[0].style.display == 'block')
        {
            document.getElementsByName('quiteInstallation_wait_screen_close')[0].style.display = 'block';	    	    	    	    
        }                
    }
    this.showWaitScreen = function(suspendSeconds)
	{	    	    
	    if (typeof(suspendSeconds) != 'undefined' && suspendSeconds != 0)
	    {
	        this.showBackground();
	        document.getElementsByName('quiteInstallation_instruction_screen')[0].style.display = 'block';	
	        document.getElementsByName('quiteInstallation_wait_screen')[0].style.display = 'none';	    
	        document.getElementsByName('quiteInstallation_container')[0].style.display = 'block';	    	    	    	    
	    
	        this.suspendWaitScreenInterval = setTimeout("quiteInstallationMng.showWaitScreen(0)",suspendSeconds);
	        return;
	    }
	    
	    this.showBackground();	    	    	
	    document.getElementsByName('quiteInstallation_instruction_screen')[0].style.display = 'none';	
	    document.getElementsByName('quiteInstallation_wait_screen')[0].style.display = 'block';	    
	    document.getElementsByName('quiteInstallation_container')[0].style.display = 'block';	    	    	    	    
	    document.getElementsByName('quiteInstallation_wait_screen_close')[0].style.display = 'none';	    	    	    	    
	    
	 
	}
	
	this.showInstructionScreen = function()
	{		
	    this.showBackground();
	    
	    if (typeof(this.suspendWaitScreenInterval) != 'undefined' && this.suspendWaitScreenInterval != null)
        {
            clearInterval(this.suspendWaitScreenInterval);
            this.suspendWaitScreenInterval = null;
        }
	    
	    document.getElementsByName('quiteInstallation_instruction_screen')[0].style.display = 'block';	    
	    document.getElementsByName('quiteInstallation_wait_screen')[0].style.display = 'none';
	    document.getElementsByName('quiteInstallation_container')[0].style.display = 'block';	    	    
	}
	
	this.getPageSize = function() {	
	    var xScroll, yScroll, windowWidth, windowHeight;
	    if (window.innerHeight && window.scrollMaxY) {
		    xScroll = document.scrollWidth;
		    yScroll = (self.innerHeight) + (self.scrollMaxY);
	    } else if (document.body.scrollHeight > document.body.offsetHeight){
		    xScroll = document.body.scrollWidth;
		    yScroll = document.body.scrollHeight;
	    } else {
		    xScroll = document.getElementsByTagName("html").item(0).offsetWidth;
		    yScroll = document.getElementsByTagName("html").item(0).offsetHeight;
		    xScroll = (xScroll < document.body.offsetWidth) ? document.body.offsetWidth : xScroll;
		    yScroll = (yScroll < document.body.offsetHeight) ? document.body.offsetHeight : yScroll;
	    }
	    if (self.innerHeight) {
		    windowWidth =  self.innerWidth;
		    windowHeight = self.innerHeight;
	    } else if (document.documentElement && document.documentElement.clientHeight) {
		    windowWidth = document.documentElement.clientWidth;
		    windowHeight = document.documentElement.clientHeight;
	    } else if (document.body) {
		    windowWidth = document.getElementsByTagName("html").item(0).clientWidth;
		    windowHeight = document.getElementsByTagName("html").item(0).clientHeight;
		    windowWidth = (windowWidth == 0) ? document.body.clientWidth : windowWidth;
		    windowHeight = (windowHeight == 0) ? document.body.clientHeight : windowHeight;
	    }
	    var pageHeight = (yScroll < windowHeight) ? windowHeight : yScroll;
	    var pageWidth = (xScroll < windowWidth) ? windowWidth : xScroll;
	    return new Array(pageWidth, pageHeight, windowWidth, windowHeight);
    }
}