document.write("<style>#mainmenubar{visibility:hidden;}</style>");

var Talaris = (typeof (Talaris) == "undefined" || !Talaris) ? {} : Talaris;

YAHOO.util.Event.onDOMReady(function() {
    var oMenuBar = new YAHOO.widget.MenuBar("mainmenubar", {
        autosubmenudisplay: true,
        hidedelay: 750,
		submenuhidedelay: 100,
		showdelay: 0,
        lazyload: true
    });
    
    oMenuBar.render();
    oMenuBar.show();
	Talaris.Ed.init();
    Talaris.Worldwide.Main();
    Talaris.Footer.Main();
 
    
});

Talaris.Worldwide = 
{
    Main: function() 
    {
        Talaris.Worldwide.BindEvent();
    },
    BindEvent: function() 
    {
        if (document.getElementById('locationmap')) 
        {
            var mapE = document.getElementById('locationmap').getElementsByTagName("area");
            for (var i = 0; i < mapE.length; i++) 
            {
                mapE[i].href = "javascript:Talaris.Worldwide.GetData('" + mapE[i].href + "')";
            }
            var linkE = document.getElementById('locationLinks').getElementsByTagName("a");
            for (var i = 0; i < linkE.length; i++) 
            {
                linkE[i].href = "javascript:Talaris.Worldwide.GetData('" + linkE[i].href + "')";
            }
        }
    },
    
    GetData: function(href) 
    {
        YAHOO.util.Connect.asyncRequest(
            "GET", 
            "/GetLocationPageHtml.ashx?LocationPageUrl=" + encodeURI(href) + "&" + (new Date().toString()), 
            {
                success: function(o) 
                {
                    var controlpanel = document.getElementById("controlpanel");
                    controlpanel.innerHTML = o.responseText;
                }  
            }
        );
    }
}

Talaris.Footer = {
    Main: function() {
        var footerJson = (!footerJson) ? false : footerJson;
        var footerLink = footerJson.mailto;
        var parentUl = document.getElementById("footer").getElementsByTagName("ul")[0];

        /*remove last class*/
        var childLis = parentUl.getElementsByTagName("li");
        for (var i = 0; i < childLis.length; i++) {
            if (childLis[i].className) childLis[i].className = "";
        }

        /*create mailto link and append to ul*/
        if (footerJson) {
            var emailLink = document.createElement("li");
            emailLink.setAttribute("class", "last");
            emailLink.innerHTML = "<a href='mailto:" + footerLink + "'>Send Email</a>";
            parentUl.appendChild(emailLink);
        }
    }
}

Talaris.ItemList = {
    ItemClick: function(source) {
            Talaris.AjaxLoader.ShowLoader("loader");           
            	        
	        var target = source.getElementsByTagName("a")[0].href;
	        eval(target);
        }
    }  
    
    
Talaris.AjaxLoader = {
    ShowLoader: function(target) {
            var loader = document.getElementById(target);
            if(null != loader) {
                loader.style.display = "block";
            }},
    HideLoader: function(target) {
            var loader = document.getElementById(target);
            if(null != loader) {
                loader.style.display = "none";
            } 
        }           	        
    }    

Talaris.Helper = {
    BookmarkThisPage: function() 
    {
        var url = document.location.toString();
        
        if (window.sidebar) 
        {
            window.sidebar.addPanel(document.title, url, "");
        } 
        else if (window.external) 
        {
            window.external.AddFavorite(url, document.title);
        } 
        else if (window.opera && window.print) 
        {
            return true;
        }
    }      
}

Talaris.Culture = 
{
    ShowAvailbleCulturesPanel: function() 
    {
        document.getElementById("langselect").style.display="block";
    },
    
    HideAvailbleCulturesPanel: function() 
    {
        document.getElementById("langselect").style.display="none";
    }
}

Talaris.Downloads = 
{
    ShowAvailbleDownloadsPanel: function() 
    {
        document.getElementById("downloadselect").style.display="block";
    },
    
    HideAvailbleDownloadsPanel: function() 
    {
        document.getElementById("downloadselect").style.display="none";
    }
}

Talaris.FormPanels = 
{
    ShowEnquiryFormPanel: function() 
    {
        document.getElementById("enquiryform").style.display="block";
    },
    
    HideEnquiryFormPanel: function() 
    {
        document.getElementById("enquiryform").style.display="none";
    },
    
    ShowEmailFormPanel: function() 
    {
        document.getElementById("emailform").style.display="block";
    },
    
    HideEmailFormPanel: function() 
    {
        document.getElementById("emailform").style.display="none";
    }    
}

Talaris.Ed = {
init:function() {
    var formInputs = document.getElementsByTagName('input');
    for (var i = 0; i < formInputs.length; i++) {
        var theInput = formInputs[i];
        
        if (theInput.type == 'text' && theInput.className.match(/\bcleardefault\b/)) {  
            /* Add event handlers */          
            YAHOO.util.Event.addListener(theInput, "focus", this.clearDefaultText, false);
            YAHOO.util.Event.addListener(theInput, "blur", this.replaceDefaultText, false);
            
            /* Save the current value */
            if (theInput.value != '') {
                theInput.defaultText = theInput.value;
            }
        }
    }
},
clearDefaultText:function(e) {
    var target = window.event ? window.event.srcElement : e ? e.target : null;
    if (!target) return;
    
    if (target.value == target.defaultText) {
        target.value = '';
    }
},

replaceDefaultText:function(e) {
    var target = window.event ? window.event.srcElement : e ? e.target : null;
    if (!target) return;
    
    if (target.value == '' && target.defaultText) {
        target.value = target.defaultText;
    }
}
}