﻿
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);
}

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();

	    if (href == url) {
	        if (id == "A1") {
	            if (id.length > 2) {
	                $(this).parent('li').parent('ul').parent('li').addClass("selected-m1");
	            }
	            else {
	                $(this).parent("li").addClass("selected-m1");
	            }
	        }
	        else if (id == "A2" || id.indexOf("A2") > -1) {
	            
                if (id.length > 2) {
	                
	                $(this).parent('li').parent('ul').parent('li').addClass("selected-m2");
	            }
	            else {
	                $(this).parent("li").addClass("selected-m2");
	            }
	        }
	        else if (id == "A3" || id.indexOf("A3") > -1) {
	            if (id.length > 2) {
	                $(this).parent('li').parent('ul').parent('li').addClass("selected-m3");
	            }
	            else {
	                $(this).parent("li").addClass("selected-m3");
	            }
	        }
	        else if (id == "A4" || id.indexOf("A4") > -1) {
	            if (id.length > 2) {
	                $(this).parent('li').parent('ul').parent('li').addClass("selected-m4");
	            }
	            else {
	                $(this).parent("li").addClass("selected-m4");
	            }
	        }
	        else if (id == "A5" || id.indexOf("A5") > -1) {
	            if (id.length > 2) {
	                $(this).parent('li').parent('ul').parent('li').addClass("selected-m5");
	            }
	            else {
	                $(this).parent("li").addClass("selected-m5");
	            }
	        }
	    }
	});
}

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;
}


function setFontSize(fsize) {
    createCookie("page_size", fsize, 180);
    changeFontSize(fsize);
}

function getFontStyle() {
    var fsize = readCookie("page_size");
    if (fsize != null) {
        changeFontSize(fsize);
    } else {
        changeFontSize("small");
    }
}

function changeFontSize(fontID) {
    var fsize;
    if (fontID == "small") {
        fsize = "100%";
    } else if (fontID == "medium") {
        fsize = "105%";
    } else if (fontID == "large") {
        fsize = "120%";
    }

    $(".bodycontent").css({
        "font-size": fsize
    });    
}


