$(
    function()
    {    
        $.ajaxSetup({cache:false});
		$('ul.jd_menu').jdMenu({	onShow: loadMenu,
									onHideCheck: onHideCheckMenu,
									onHide: unloadMenu, 
									onClick: onClickMenu, 
									onAnimate: onAnimate
									});
    
        // Get the hash 
        var hash = window.location.hash.substr(1);
        
        // Make sure we're on index, otherwise force it.
        /*
        var path = window.location.pathname;
        var page = path.substring(path.lastIndexOf('/') + 1);
        if(page != 'index.php' && page != '')
        {
            window.location = 'index.php#' + page.substr(0, page.length - 4);
            return;
        }
        
        // Get the page to load if selected
        var href = $('#nav li a').each(function()
        {  
            var href = $(this).attr('href');
            if(href != undefined)
            {
                if(hash == href.substr(0,href.length-4))
                { 
                    var toLoad = hash + '.php #content';  
                    $('#content').load(toLoad, '', function(){refreshContent();});
                }
            }   
        });
        
        $('#nav a').click(function()
        {  
            if($(this).attr('href') == undefined)
            {
                return false;
            }
            var toLoad = $(this).attr('href') + ' #content';  
            $('#content').hide(100,loadContent);  
            $('#load').fadeIn(100);  
            var hash = $(this).attr('href').substr(0,$(this).attr('href').length - 4);
            if(hash == "index")
            {
                window.location.hash = "#";
            }
            else
            {
                window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length - 4)
            }
            function loadContent() {  
                $('#content').load(toLoad,'',function(){hideLoader();})  
            }  
            function showNewContent() {  
                $('#content').fadeIn(500); 
                refreshContent(); 
            }  
            function hideLoader() {  
                $('#load').fadeOut('normal', function(){showNewContent();});  
            }  
            return false;  
        }); */
	});

function onAnimate(show) {
	//$(this).fadeIn('slow').show();
	if (show) {
		$(this)
			.css('visibility', 'hidden').show()
		    .css('width', $(this).innerWidth())
			.hide().css('visibility', 'visible')
		    .fadeIn(500);
	} else {
		$(this).fadeOut(250);
	}
}
function loadMenu() 
{
}
function unloadMenu() 
{
}

// We're passed a UL
function onHideCheckMenu() {
	return !$(this).parent().is('.LOCKED');
}

// We're passed a LI
function onClickMenu() {
	$(this).toggleClass('LOCKED');
	return true;
}


/*----------------------------------------------------------*/
// Refresh new content bindings
/*----------------------------------------------------------*/
function refreshContent()
{
    $('.hoverme').hover(function()
    {
        $(this).parent().children('.hovershow').fadeIn(250);
        //$(this).parent.child
    },
    function()
    {
        $(this).parent().children('.hovershow').fadeOut(250);   
    });

    $('#resumebutton').click(function()
    {
        if($('#resumeform').is(':visible') == true)
        {
            $('#resumeform').slideUp(1500);
        }
        else
        {
            $('#resumeform').load('resumeform.html #content','',function(){showResumeForm();})     
        }
        return false;
    });
    
    $('form').submit(function()
    {
        $(".temp").remove();
        $(this).children('.processing').fadeIn(150);
        //$(this).ajaxForm(function(data){submitResumeForm(data));
        $.post($(this).attr('action'), $(this).serialize(), function(data){submitResumeForm(data);});
        return false;
    });
    
    
    $('.thbutton').click(function()
    {
        if($(this).parent().parent().children('div .details').is(':visible'))
        {
            $(this).parent().next().children('.details').slideUp(1500);
        }
        else
        {
            $(this).parent().parent().children('div .details').slideDown(1500);
            //refreshContent();
        }
    }); 
    
    tb_init('a.thickbox, area.thickbox, input.thickbox');//pass where to apply thickbox
    imgLoader = new Image();// preload image
    imgLoader.src = tb_pathToImage;
    
    
    //alert('fire');
    setTimeout("$('#slider').s3Slider({timeOut: 4000});", 1000);
}

function showResumeForm(){$('#resumeform').slideDown(1500);refreshContent();}
function submitResumeForm(data)
{
    if(data == "Done")
    {
        $('#thanks').slideDown(1500);
        $('form').slideUp(500);
        $('#resumeform').slideUp(500);
    }
    else
    {
        $("[name='" + data + "']").after(' <span class="temp req">Must be filled out</span>');
    }
}


$('.round_this').hover(
    function() 
    {
        $('.round_this').corner();
        alert("hi");
    },
    function (){}
);

$(document).ready(function()
{
    refreshContent(); 
});