﻿
function createCookie(name, value, days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        var expires = "; expires=" + date.toGMTString();
    }
    else var expires = "";
    document.cookie = name + "=" + value + expires + "; path=/";
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}

function eraseCookie(name) {
    createCookie(name, "", -1);
}

//Navigation Menu
function navTab( hostId ) {
    var linkID = "";
    var url = window.location.href.toLowerCase();

    if (hostId.toLowerCase() == url) {
	    url += "default.aspx";
	}

	$("#nav li a").each(function () {

	    var id = $(this).attr("id");
	    var href = document.getElementById(id).href.toLowerCase();

	    id = id.replace("ctl00_", "").replace("ctl00_", "");

	    if (href == url) {
	        if (id == "A1" || id.indexOf("A1") > -1) {
	            if (id.length > 2) {
	                $(this).parent('li').parent('ul').parent('li').addClass("selected-s");
	            }
	            else {
	                $(this).parent("li").addClass("selected-s");
	            }
	            linkID = id;
	        }
	        else if (id == "A2" || id.indexOf("A2") > -1) {
	            if (id.length > 2) {
	                $(this).parent('li').parent('ul').parent('li').addClass("selected-s");
	            }
	            else {
	                $(this).parent("li").addClass("selected-s");
	            }
	            linkID = id;
	        }
	        else if (id == "A3" || id.indexOf("A3") > -1) {
	            if (id.length > 2) {
	                $(this).parent('li').parent('ul').parent('li').addClass("selected-l");
	            }
	            else {
	                $(this).parent("li").addClass("selected-l");
	            }
	            linkID = id;
	        }
	        else if (id == "A4" || id.indexOf("A4") > -1) {
	            if (id.length > 2) {
	                $(this).parent('li').parent('ul').parent('li').addClass("selected-m");
	            }
	            else {
	                $(this).parent("li").addClass("selected-m");
	            }
	            linkID = id;
	        }
	        else if (id == "A5" || id.indexOf("A5") > -1) {
	            if (id.length > 2) {
	                $(this).parent('li').parent('ul').parent('li').addClass("selected-s");
	            }
	            else {
	                $(this).parent("li").addClass("selected-s");
	            }
	            linkID = id;
	        }
	        else if (id == "A6" || id.indexOf("A6") > -1) {
	            if (id.length > 2) {
	                $(this).parent('li').parent('ul').parent('li').addClass("selected-s");
	            }
	            else {
	                $(this).parent("li").addClass("selected-s");
	            }
	            linkID = id;
	        }
	    }
	});

}

function openWindow(url, width, height) {
    window.open(url, 'Fisher', 'width=' + width + ',height=' + height + ',channelmode=no,directories=no,fullscreen=no,menubar=no,resizable=no,scrollbars=no,satus=no,titlebar=yes,toolbar=no');
    return false;
}

function setFocus() { document.getElementById("q").focus(); }
function SearchSite( hostID ) {
    var searchBox = ltrim(document.getElementById("q").value)
    if (searchBox != "") {
        document.location.href = hostID + "GoogleSearch/GoogleSearchResults.aspx?cx=011925274680028676297:9p_gtaqtere&cof=FORID:10&ie=UTF-8&q=" + URLEncode(document.getElementById("q").value) + "&sa=Search";
        return true;
    }
    else
        document.getElementById("q").focus();
    return false;
}


