


window.popup = function(url,width,height)
{
  width = width || 750;
  height = height || 650;
  var w = document.all ? screen.width  : window.outerWidth;
  var h = document.all ? screen.height : window.outerHeight;
  var left = (w - width) / 2;
  var top  = (h - height) / 2;
  var params = ',width=' + width + ',height=' + height + ',top=' + top + ',left=' + left;
  var popup = window.open(url,'popup','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1' + params);
  popup.focus();
}


 //**********************************************
function TabsObject()
{
    //**Tab ids and names are registered when the page loads.  they are defined in the web config.
    this.tabArray = arrTabIds; 
    this.tabArrayNames = arrTabNames;
    
    
    this.setTabNames();
    this.mapArea = document.getElementById("divRouteMap");
    this.galleryArea = document.getElementById("divGallery");
    this.tabCurrentName = this.tabArrayNames[0];
    this.galleryVisible = false;
    this.tabArea = document.getElementById("tab_area");
    this.tabArea.style.visibility = 'visible';
}


TabsObject.prototype.setTabNames = function ()
{
    for(i=0; i < this.tabArrayNames.length;i++)
    {
        var href = "<a  href=\"javascript:void(0);\" onclick=\"Tabs.selectTab("+ i.toString() +");\">";
        href += this.tabArrayNames[i];
        href += "</a>";
        
        var tabName = "tab" + i.toString() + "_M";
        document.getElementById(tabName).innerHTML = href;
    }
}

TabsObject.prototype.selectTab = function (tabNumber)
{
    var intTab = parseInt(tabNumber);
    for(i=0; i < this.tabArray.length;i++)
    {
        var ctl = document.getElementById(this.tabArray[i]);
        ctl.style.display = "none";
    }
    
    var ctlSelected  = document.getElementById(this.tabArray[intTab]);
	ctlSelected.style.display = "block";
	
    this.changeTabClass(intTab);
    
    this.tabCurrentName = this.tabArrayNames[tabNumber];
    this.galleryVisible =  this.tabCurrentName != "Gallery" ? false : true;

    this.toggleMapGallery();
}

TabsObject.prototype.changeTabClass = function (intTab)
{
    var strPreClassName = "";
    var strClassName = "";
    for(i=0; i < this.tabArray.length;i++)
    {
        if( i == intTab)
        {
            strPreClassName = "tab_s";
        }
        else
        {
            strPreClassName = "tab";
        }
    	var tabi_L = document.getElementById("tab" + i.toString() + "_L");
    	var tabi_M = document.getElementById("tab" + i.toString() + "_M");
    	var tabi_R = document.getElementById("tab" + i.toString() + "_R");
	    	  
	    tabi_L.className = strPreClassName + '_left';
    	tabi_M.className = strPreClassName + '_mid';
    	tabi_R.className = strPreClassName + '_right';  
    	
    }
}
TabsObject.prototype.toggleMapGallery = function ()
{
        if(!this.galleryVisible)
        {
            this.mapArea.style.display = '';
            this.galleryArea.style.display = 'none';
        }
        else
        {
            this.mapArea.style.display = 'none';
            this.galleryArea.style.display = '';
        }
}

function showdiv(divname) {    document.getElementById(divname).style.display = "block"; }  
function hidediv(divname) {    document.getElementById(divname).style.display = "none"; } 


