﻿$(document).ready(function() {
	resizeSite();

	/*Navigation*/
	var currentSection = $('#ctl00_hfCurrentPageLocation').attr('value');
	navCloudLocation(currentSection);
	$('div#main_nav ul li').mouseover(function(){
		navCloudLocation(this.title);
	}).mouseout(function(){
		navCloudLocation(currentSection);
	});

	/*Fancy boxes*/
	superFancyContactBox(); 
	superFancyLoginBox();  
	superFancySignUpBox(); 

	commentBox();   	
});
function superFancyContactBox()
{
    $("a#contactInfo").fancybox({ 'hideOnContentClick': false, 'frameWidth' :370, 'frameHeight':178 });   
}
function superFancyLoginBox()
{
    $("a#login").fancybox({ 'hideOnContentClick': false,'frameWidth' :393, 'frameHeight':200  });    
    $("a#login1").fancybox({ 'hideOnContentClick': false,'frameWidth' :393, 'frameHeight':200  });
	$("a#loginHeader").fancybox({ 'hideOnContentClick': false,'frameWidth' :393, 'frameHeight':200  });    
}
function superFancySignUpBox()
{	
    $("a#createaccount").fancybox({ 'hideOnContentClick': false,'frameWidth' :445, 'frameHeight':375  }); 
    $("a#createaccount1").fancybox({ 'hideOnContentClick': false,'frameWidth' :445, 'frameHeight':375  });  
	$("a#createaccountHeader").fancybox({ 'hideOnContentClick': false,'frameWidth' :445, 'frameHeight':375  }); 
}
function commentBox()
{
    $("a#postcomment").fancybox({ 'hideOnContentClick': false, 'frameWidth': 456, 'frameHeight': 375 }); 
}
Cufon.replace('#footer_utility', {
    color: '#ffffff'
});
Cufon.replace('#credits p span.cufon_yellow', {
    color: '#e1d444'
});
Cufon.replace('#credits p span.cufon_orange', {
    color: '#f7aa43'
});
Cufon.replace('#credits p span.cufon_green', {
    color: '#00ea98'
});

$(window).resize(function() {
    resizeSite();
});

function navCloudLocation(isGoingTo)
{
	switch (isGoingTo)
	{
	case 'home':
		$('#navCloud').stop();
		$('#navCloud').animate({'left': '65px'}, 'normal');
		break;
	case 'mission':
		$('#navCloud').stop();
		$('#navCloud').animate({'left': '136px'}, 'normal');
		break;
	case 'history':
		$('#navCloud').stop();
		$('#navCloud').animate({'left': '212px'}, 'normal');
		break;
	case 'tour':
		$('#navCloud').stop();
		$('#navCloud').animate({'left': '281px'}, 'normal');
		break;
	case 'volunteer':
		$('#navCloud').stop();
		$('#navCloud').animate({'left': '355px'}, 'normal');
		break;
	case 'merch':
		$('#navCloud').stop();
		$('#navCloud').animate({'left': '434px'}, 'normal');
		break;
	case 'blog':
		$('#navCloud').stop();
		$('#navCloud').animate({'left': '493px'}, 'normal');
		break;
	case 'video':
		$('#navCloud').stop();
		$('#navCloud').animate({'left': '552px'}, 'normal');
		break;
	case 'faq':
		$('#navCloud').stop();
		$('#navCloud').animate({'left': '607px'}, 'normal');
		break;  
	default:
		$('#navCloud').stop();
		$('#navCloud').animate({'left': '65px'}, 'normal');
	}
}

function resizeSite() 
{
    $('.siteWidthResizer').width($(window).width());
    var headerHeight = $('#header').height();
    var contentHeight = $('#content').height();
    var footerHeight = $('#footer').height();
    var trueContentHeight = $(window).height() - (headerHeight + footerHeight/*padding in the #content div*/);
    //alert(trueContentHeight);
    if (trueContentHeight < contentHeight) 
    {
        $('#content').css('height', '100%');
    }
    else 
    {   
        $('.siteHeightResizer').height(trueContentHeight);
    }
}
function launchLogin() 
{
    var login = document.getElementById("loginHeader");
    login.href = "/ajax/userlogin.aspx";
    $('#loginHeader').trigger('click');
}
function launchSignup() 
{
    var signup = document.getElementById("createaccountHeader");
    signup.href = "/ajax/createaccount.aspx";
    $('#createaccountHeader').trigger('click');
}