var __search;

function InitializeRequest(){
    var str = location.search;
    __search = { };
    if (str){
        str = str.substr(1).split("&");
        for (var i=0; i<str.length; i++){
            var field = str[i].substr(0,str[i].indexOf("="));
            var value = str[i].substr(str[i].indexOf("=")+1);
            if (field){
                __search[field] = value;
            }
        }
    }
}

function Request(field){
    if (!__search){
        InitializeRequest();
    }
    return __search[field];
}

function GenerateMenu(menu){
    if (Prototype.Browser.IE) {
        nav = $(menu).select("li");
        for (var i = 0; i < nav.length; i++) {
            nav[i].onmouseover = function(){
                $(this).addClassName("over");
            }
            nav[i].onmouseout = function(){
                $(this).removeClassName("over");
            }
        }
    }
}

function GenerateTooltip(elm){
	var childs = $(elm).childElements();
	for (var i = 0; i < childs.length; i++) {
		if (childs[i].title) {
			childs[i].tooltip = childs[i].title;
			childs[i].title = "";
			childs[i].onmouseover = function(event){
				event = event || window.event;
				var ypos = this.cumulativeOffset().top + this.getHeight();
				show_tooltip(this.tooltip, event.clientX, ypos);
				return false;
			}
			childs[i].onmouseout = function(){
				hide_tooltip();
				return false;
			}
		}
	}
}

function show_tooltip(text, xpos, ypos){
    $("tooltip").isHover = true;
    $("tooltip").hide();
    $("tooltip").update(text);
    $("tooltip").setStyle({
        left: xpos + "px",
        top: ypos + "px"
    });
    new Effect.Appear("tooltip", {
        duration: 0.25,
        to: 0.8
    });
    $("tooltip").isHover = false;
}

function hide_tooltip(){
    if ($("tooltip").isHover) {
        return;
    }
    $("tooltip").isHover = false;
    $("tooltip").hide();
}

