var menuTimeout  = 100;
var menuTimer    = null;
var menuPrevious = null;

function menuOpen() {
	menuTimerCancel();
	menuElement = $('header_menu_all');
	if (menuElement) {
		menuElement.show();
	}
}
function menuClose() {
	menuTimer = window.setTimeout(menuCloseTimer, menuTimeout);
}
function menuCloseTimer() {
	menuElement = $('header_menu_all');
	if (menuElement) {
		menuElement.hide();
	}
}
function menuTimerCancel() {
	if (menuTimer) {
		window.clearTimeout(menuTimer);
		menuTimer = null;
	}
}

function catOpen(elm) {
	menuTimerCancel();
	menuElement = $(elm);
	if (menuPrevious) menuPrevious.hide();
	if (menuElement) {
		menuPrevious = menuElement;
		menuElement.show();
	}
}
function catClose(elm) {
	menuTimer = window.setTimeout(function(){catCloseTimer(elm);}, menuTimeout);
}
function catCloseTimer(elm) {
	menuElement = $(elm);
	if (menuElement) {
		menuElement.hide();
	}
}

function addBookmark(title, url) {
        url = url || location.href;
        title = title || document.title;
        // firefox
        if (window.sidebar) {
                window.sidebar.addPanel(title, url, "");
        // opera
        } else if(window.opera && window.print) {
                var elem = document.createElement('a');
                elem.setAttribute('href',url);
                elem.setAttribute('title',title);
                elem.setAttribute('rel','sidebar');
                elem.click();
        // ie
        } else if(document.all) {
                window.external.AddFavorite(url, title);
        } else {
                alert("Your browser does not support this function.");
        }
        return false;
}

function sendEmail(url) {
	url = url || location.href;
	mail_str = "mailto:?subject=Check out Hangers Direct - a great resource for all types of clothes hangers.";
	mail_str += "&body=Save to Favorites. With over 300 styles to choose from, this website will have the hangers that you need.  They can add a logo or monogram and even let you customize your hanger if you want something specific.  Click here: "+url;
	location.href = mail_str;
	return false;
}

function openImageWindow(title, image, width, height) {
	var html = '<html>\n<head>\n';
	html += '<title>Hangers Direct - '+title+'</title>\n';
	html += '<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n';
	html += '<style type="text/css">\n';
	html += 'body { margin:0px; padding:0px; }\n';
	html += '</style>\n';
	html += '</HE' + 'AD>\n';
	html += '</BO' + 'DY onunload="self.close();">\n';
	//html += '<div align="center"><img src="'+image+'" width="'+width+'" height="'+height+'" alt="'+title+'" /></div>\n';
	html += '<div align="center"><img src="'+image+'" width="'+width+'" alt="'+title+'" /></div>\n';
	html += '</BO' + 'DY>\n';
	html += '</HT' + 'ML>';
	var windowWidth = width+30;
	var windowHeight = height+30;
	var leftPos = ((screen.availWidth/2)-(windowWidth/2));
	var topPos = ((screen.availHeight/2)-(windowHeight/2));
	var params = "width=" + windowWidth + ",height=" + windowHeight + ",location=no,toolbar=no,menubar=yes,scrollbars=yes,status=no,resizable=yes,left=" + leftPos + ",top=" + topPos + ",screenX=" + leftPos + ",screenY=" + topPos;
	var imageWin = window.open('','imageContent',params);
	if (imageWin) {
		imageWin.document.open();
		imageWin.document.write(html);
		imageWin.document.close();
	} else {
		alert("You have popups disabled. Please enable this function and try again.");
	}
}

function openEFWindow(url, prod) {
    var windowWidth = 400;
    var windowHeight = 400;
    var leftPos = ((screen.availWidth/2)-(windowWidth/2));
    var topPos = ((screen.availHeight/2)-(windowHeight/2));
    var params = "width=" + windowWidth + ",height=" + windowHeight + ",location=no,toolbar=no,menubar=yes,scrollbars=yes,status=no,resizable=yes,left=" + leftPos + ",top=" + topPos + ",screenX=" + leftPos + ",screenY=" + topPos;
    var printWin = window.open(url+'/emailfriend.php?url='+escape(prod),'emailFriend',params);
    if (printWin) {
        printWin.focus();
    } else {
        alert("You have popups disabled. Please enable this function and try again.");
    }
}
function addBookmark(title, url){
    // firefox
    if (window.sidebar) {
        window.sidebar.addPanel(title, url, "");
    // opera
    } else if(window.opera && window.print) {
        var elem = document.createElement('a');
        elem.setAttribute('href',url);
        elem.setAttribute('title',title);
        elem.setAttribute('rel','sidebar');
        elem.click();
    // ie
    } else if(document.all) {
        window.external.AddFavorite(url, title);
    } else {
        alert("Your browser does not support this function.");
    }
}
function sendEmailBH() {
    mail_str = "mailto:?subject=Check out the " + document.title;
    mail_str += "&body=I thought you might be interested in the " + document.title + ".";
    mail_str += "You can view it at " + location.href;
    location.href = mail_str;
}
function openSelectLink(string) {
    if (string !== "#") {
        location.href = string;
    }
}



