// JavaScript Document
window.onload = function()
{
	$("ul#topmenu li a img").mouseover(function() {
												
		var testo = ($(this).attr("src")).indexOf("_o.jpg");
		if (testo == -1) {
			$(this).attr("src",($(this).attr("src")).replace(".jpg", "_o.jpg"));	
		}
	});
	
	$("ul#topmenu li a img").mouseout(function() {
												
		var testo = ($(this).attr("src")).indexOf("_o.jpg");
		if (testo != -1) {
			$(this).attr("src",($(this).attr("src")).replace("_o.jpg", ".jpg"));	
		}
	});
	
	$("area#maphome").mouseover(function() {
			$("img#mapbutton").attr("src","/Content/images/4btntop_h.jpg");				 
	});
	
	$("area#maplocat").mouseover(function() {
			$("img#mapbutton").attr("src","/Content/images/4btntop_l.jpg");				 
	});
	
	$("area#mapfaq").mouseover(function() {
			$("img#mapbutton").attr("src","/Content/images/4btntop_f.jpg");				 
	});
	
	$("area#mapabout").mouseover(function() {
			$("img#mapbutton").attr("src","/Content/images/4btntop_a.jpg");				 
	});
	
	$("area#maphome").mouseout(function() {
			$("img#mapbutton").attr("src","/Content/images/4btntop.jpg");				 
	});
	
	$("area#maplocat").mouseout(function() {
			$("img#mapbutton").attr("src","/Content/images/4btntop.jpg");				 
	});
	
	$("area#mapfaq").mouseout(function() {
			$("img#mapbutton").attr("src","/Content/images/4btntop.jpg");				 
	});
	
	$("area#mapabout").mouseout(function() {
			$("img#mapbutton").attr("src","/Content/images/4btntop.jpg");				 
	});

}
// font resize
$(function () {
    initFontSize();
    $('a.changeFont').click(function () {
        var isSetCookie = true;
        var fSize = getFontSizeCSS();

        if (this.id == 'increase') {
            if (fSize < 30) fSize *= 1.2;
        }
        else if (this.id == 'decrease') {
            if (fSize > 8) fSize /= 1.2;
        }
        else {
            // reset: read size f/ style sheet
            fSize = $('html').css('font-size');
            isSetCookie = false;
        }

        var iSize = parseInt(fSize);
        setFontSize(iSize);

        if (isSetCookie) { setCookie(iSize); }
        else { removeCookie(); }
    });
});

// initializes the font sizing based on cookie value
function initFontSize() {
    var iSize = $.cookie("SC_FontSize");
    if (iSize != null) setFontSize(iSize);
};

// gets the current font size based on css value
function getFontSizeCSS() {
    var target = $('#main');
    var origSize = target.css('font-size');
    var fSize = parseFloat(origSize, 10);
    return fSize;
};

// performs the actual font size setting for the main div & persists cookie
function setFontSize(iSize) {
    $('#main').animate({ fontSize: iSize }, 500);
};

function setCookie(iSize) {
    $.cookie("SC_FontSize", iSize, { expires: 30, path: '/' });
};

function removeCookie() {
    $.cookie("SC_FontSize", null, { path: '/' });
};

