﻿$(function(){
    initFlashBorders();
    initClearInputs();
    
    // Email Signup Helper
    $("#menu .news .txt").keydown(function(e){
            if (e.which || e.keyCode){
                if ((e.which == 13) || (e.keyCode == 13)){
                    $("#menu .news .btn").trigger("click");
                    return false;
                }
            }
            
            return true;
        });
    
    // Sliding Doors Menu
    $("#menu li.selected:last").parents("ul").show();
    $("#menu li:has(ul)").each(function(){
            $(this).children("a").click(function(){
                    var li = $(this).parent();
                    var ul = $(li).children("ul:first")
                    if ($(ul).css("display") == "none"){
                        $(ul).show();
                    }
                    else {
                        $(ul).hide();
                    }
                    return false;
                });
        });
});

/* Flash Border Removal
===================================================================================== */
function initFlashBorders(){
    if ($.browser.msie){
        $("object[@type='application/x-shockwave-flash']").each(function(){
                var h = this.outerHTML ;
				var params = '' ;
				var j = this.childNodes.length - 1 ;
				do {
					var p = this.childNodes[j] ;
					if (p.tagName == "PARAM") params += p.outerHTML ;
				} while (j--) ;
				var tag = h.split(">")[0] + ">" ;
				this.outerHTML = tag + params + this.innerHTML + " </object>" ;
            });
    }
}

/* Form Element Methods
===================================================================================== */
function initClearInputs(){
    $("input.autoClear").each(function(){
            $(this).attr("default",$(this).val());
            $(this).focus(function(){if($(this).val() == $(this).attr("default")) $(this).val("");});
            $(this).blur(function(){if ($(this).val() == "") $(this).val($(this).attr("default"));});
        });
}

/* Bookmark Functions
===================================================================================== */
function setBookmark(url,str){
    if(str=='')str=url;
    if (document.all)window.external.AddFavorite(url,str);
    else alert('Press CTRL and D to add a bookmark to:\n"'+url+'".');
} 
