﻿/*==========================================================*/

function showPopup(popupNum){	
    setOverlayHeight();
	var overlay=document.getElementById('overlay');	
    var popup=document.getElementById('popup');
	var innerDivs = [];
	
	innerDivs = getElementsByClassName(popup, 'div', 'inner');
	for(var p=0; p<innerDivs.length; p++){
		if(p == popupNum){
			innerDivs[p].style.display = "block";
		}else{
			innerDivs[p].style.display = "none";
		}
	}
	
	overlay.style.display = "block";
    popup.style.display = "block";
	attachEventListener(overlay, "mousedown", hidePopup, false);
	DropDowns('');
	window.scrollTo(0, 0);

}

function scrollToTop() {
    window.scrollTo(0, 0);
}

function hidePopup(){
    DropDowns(1);
    var overlay = document.getElementById('overlay');
    var popup=document.getElementById('popup');
    overlay.style.display='';
    popup.style.display='';
}

function DropDowns(visibility){    
    var ddl=document.getElementsByTagName('select');
    for (var i=0; i<ddl.length; i++){
        if(visibility==''){
            ddl[i].style.visibility='hidden';
        }else{
            ddl[i].style.visibility='';
        }
    }

    var popup = document.getElementById('popup');
	ddl=popup.getElementsByTagName('select');
	for (i=0; i<ddl.length; i++){
		ddl[i].style.visibility='';
	}
}

function setOverlayHeight(){
    var scrHeight=getScreenHeight();
    contentHeight= document.getElementById('container').offsetHeight;	
    var overlay=document.getElementById('overlay');
    if(contentHeight>scrHeight){
        overlay.style.height=contentHeight+'px';
    }	
}

function getScreenHeight(){
    scrHeight=0;
    if(typeof( window.innerWidth ) == 'number') {
        scrHeight = window.innerHeight;
    }else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        scrHeight = document.documentElement.clientHeight;
    }else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        scrHeight = document.body.clientHeight;
    }
    return scrHeight;
}