$(document).ready(function() {
             //get url file
             var currentfile = jQuery.url.attr("file");
             //highlight selected link
             $(".mainnavigation li a").each(function (i) {
                if ($(this).attr('href') == "../"+currentfile) {
                    $(this).addClass('selectedlink');
                }
				if (!currentfile) {
                    $(".mainnavigation li:first").children("a").addClass('selectedlink');
                } 
              });

             

//add hover for the logo
if ($.browser.msie && $.browser.version.substr(0,1)<7 ) {
    
}else{
    $(".logo").hover(function(){
        $(this).attr("src","../images/farmstead-first-logo_over_1.png"); 
    },function(){
        $(this).attr("src","../images/farmstead-first-logo_1.png"); 
    }); 
}

    //header slideshow
    $('#slideshow').cycle({ 
        fx:      'scrollLeft', 
        speed:    500, 
        timeout:  6000,
        pause: 1 
    });
});

function URLDecode(url) //function decode URL
    {
    // Replace + with ' '
    // Replace %xx with equivalent character
    // Put [ERROR] in output if %xx is invalid.
    var HEXCHARS = "0123456789ABCDEFabcdef";
    var encoded = url;
    var plaintext = "";
    var i = 0;
    while (i < encoded.length) {
    var ch = encoded.charAt(i);
    if (ch == "+") {
    plaintext += " ";
    i++;
    } else if (ch == "%") {
    if (i < (encoded.length-2)
    && HEXCHARS.indexOf(encoded.charAt(i+1)) != -1
    && HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) {
    plaintext += unescape( encoded.substr(i,3) );
    i += 3;
    } else {
    alert( 'Bad escape combination near ...' + encoded.substr(i) );
    plaintext += "%[ERROR]";
    i++;
    }
    } else {
    plaintext += ch;
    i++;
    }
    } // while
    
    return plaintext;
    }