﻿// Full site functionality

$(document).ready(function() {
    // Slider Menu 
	$('.kwicks').kwicks({
	                max : 205, //245  
					spacing : -3, // This is negative to remove spaces on lower menu items (bug in control)
					isVertical : true,
					sticky: true
	});
	
	// Show the back to menu item when Navagation class is available
	if ($('#slideshowHolder').hasClass('hasNavagation'))
	{
	    $('#btnBack').show();
	} else
	{
	    $('#btnBack').hide();
	}
	
    // Background image swaper
    $('#slideshowHolder').jqFancyTransitions({ 
                        effect: '', // wave, zipper, curtain
                        width: 920, // width of panel
                        height: 387, // height of panel
                        strips: 0, // number of strips
                        delay: 3000, // delay between images in ms
                        stripDelay: 35, // delay between strips in ms
                        titleOpacity: 0.7, // opacity of title
                        titleSpeed: 1000, // speed of title appereance in ms
                        position: 'alternate', // top, bottom, alternate, curtain
                        direction: 'random', // left, right, alternate, random, fountain, fountainAlternate
                        navigation: $('#slideshowHolder').hasClass('hasNavagation'), // prev and next navigation buttons  
                        links: false // show images as links
    });
    
    // Change the verbiage on the image rotator
    $('#ft-prev-slideshowHolder').text(" <-- Back");
    $('#ft-next-slideshowHolder').text(" Next -->");
    
});

// Remove the moto image
$(document).click(function() {
  $("#moto").fadeOut('slow', function() {
    // Animation complete.
  });
  
});

function ShowMessage(path, top, left, width, height, returnpath)
{
       
    // Setup path to slider content
    path = "./slide_menu_content/" + path 
    
    // fade out the image    
    $("#box").fadeOut(200, function() {
    });

    // Load the content into the div    
    $("#box").hide().load(path + " #guts", function() {

        // Add the close button and return link (if applicable)
        // Unfortunately, had to put the CSS information in this section
        // I'm guessing its because the object anchor is not available when rendering???
        if (returnpath.length > 0)
            $("#box").prepend('<a href="#" style="margin-left: 400px; padding-top: 5px; color: #0033ff; text-decoration: none; margin-right: 20px" id="btnReturn" onmouseover="UnderlineIt(this)" onmouseout="NoTextDecoration(this)" onclick="ShowMessage(\'' + returnpath + '\', 40, 300, 600, 100,\'\')">Return to Previous Page</a><img style="padding-top: 5px;" onclick="CloseMessage();" id="btnClose" src="./image/common/close.png" />');
        else
            $("#box").prepend('<img style="margin-left: 580px; padding-top: 5px" onclick="CloseMessage();" id="btnClose" src="./image/common/close.png" />');
     });
  
    // Animate the div to display the content
    $("#box").animate({
        opacity: 0.83,
        top: top + ' px',
        left: left + ' px',
        height: 'toggle',
        width: width + ' px'
    }, 1000, function() {
        // Animation complete.
    });   
}

// Close button fire this function which hide the window
function CloseMessage()
{
    $('#box').fadeOut('fast');
}

// Puts an underline on the hyperlink (doesn't do it in IE6 if no href is given)
function UnderlineIt(control)
{
    $(control).css('text-decoration', 'underline');
}

// Clears text decoration on the hyperlink 
function NoTextDecoration(control)
{
    $(control).css('text-decoration', 'none');
}



