/* start document ready */

$(document).ready(function() {

/* begin resize.bg */
sizebg();

/* begin links animate */

$('.genesis a').mouseenter(
  function () {
    $(this).animate({color: '#ffffff' }, 400);
  } 
);

$('.genesis a').mouseleave(
  function () {
  
   if ($(this).hasClass('current') == true){$(this).stop().animate({color: '#d31117' }, 600);} else{
    $(this).stop().animate({color: '#d31117' }, 600);
	}
  } 
);

/* end links animate */






/* begin section nav links animate */

$('#sectionnav a').mouseenter(
  function () {
    $(this).animate({color: '#ffffff' }, 400);
  } 
);

$('#sectionnav a').mouseleave(
  function () {
  
   if ($(this).hasClass('current') == true){$(this).stop().animate({color: '#d31117' }, 400);} else{
    $(this).stop().animate({color: '#0F76B9' }, 400);
	}
  } 
);

/* end section nav animate */



/* begin section nav links animate */

$('#auxnav a').mouseenter(
  function () {
    $(this).animate({color: '#d31117' }, 400);
  } 
);

$('#auxnav a').mouseleave(
  function () {
  
   if ($(this).hasClass('current') == true){$(this).stop().animate({color: '#d31117' }, 400);} else{
    $(this).stop().animate({color: '#ffffff' }, 400);
	}
  } 
);

/* end section nav animate */



function omniclose(){
		$('.omniclose a').delay(800).css({'opacity': 0, 'display': 'block'}).animate({'opacity': 1}, 750);
}


	function omnicenter(){
	var verseheight = $('#omniverse').outerHeight();
	var contentheight = $('#omnicontent').outerHeight();
		
	if (contentheight > verseheight) { omnimargin = 30}else{(omnimargin =(verseheight - contentheight)/2)}	
	$('#omnicontent').css({'margin-top': omnimargin, 'margin-bottom': omnimargin});
	}


/* begin text animate */
$('a:contains("Social Media")').click(
  function () {
    $('body')
		.append('<div id="omniverse"></div>');
		
		    $('body')
		.append('<div id="omnispace"><div id="omnicontent"></div></div>');
		
		omnicenter();
		
		$('#omniverse')
		.css('opacity', 0);
	
		$('#omnispace')
		.css({'opacity': 0, 'overflow':'auto'})
		.delay(800)
		.animate({'opacity': 1}, 800), omniclose();
		
		
		$('#omnicontent')
		.append($('#social').html());
		
		var $omniverse = $('#omniverse');
		$omniverse.animate({'opacity': 0.85}, 1200);
		
		
  } 
);


	$('.omniclose a').click(function() { 
	$('.omniclose a').stop().animate({'opacity': 0}, 750).delay(800).css('display', 'none');
	
	
		$('#omniverse').animate({'opacity': 0}, 500, function(){
		$('#omniverse').delay(200).remove();
		$('#omnispace').delay(200).remove();
		}
		);
	
	});


/* end text animate */




/* begin social.media */

$('#text a').mouseenter(
  function () {
    $(this).animate({color: '#d31117' }, 400);
  } 
);

$('#text a').mouseleave(
  function () {
    $(this).stop().animate({color: '#0F76B9' }, 600);
  } 
);

/* end social.media */






});

/*end document ready */

$(window).resize(function () {
resizebg();	
});

var bg = $('.background');
var geoloc = $('#gps');

function sizebg(){
var wW=$(window).width();
var wH=$(window).height();
bg.css("height",wH);
bg.css("width",wW);
geoloc.css("height",wH);
}



function resizebg(){
var wW=$(window).width();
var wH=$(window).height();
var iW=bg.width();
var iH=bg.height();
var pH = iH / iW;
var pW = iW / iH;
if ((wH / wW) < pH) {
bg.css("width",wW);
bg.css("height",pH*wW);
} else {
bg.css("height",wH);
bg.css("width",pW*wH);
};

geoloc.css("height",wH);
bg.css("margin-left",wW / 2 - bg.width() / 2);
/*bg.css("margin-top",wH / 2 - bg.height() / 2); */
}

/*
$(function() {
$(this).bind("contextmenu", function(e) {
e.preventDefault();
});
}); right.click */




// contact form
             function ajaxValidationCallback(status, form, json, options){
              
                if (status == true) {
					$('#contactform').fadeOut(750,function(){
					$('#contactformbox').delay(850).css({opacity:0}).html('<p>Thank you for contacting the FATE Foundation.<br /><br />We will respond as soon as possible.<br /><br />Sincerely,<br />The FATE Foundation</p>').animate({opacity:1}, 750);
					$('#contactform').hide();
					});
					
                }else if (status == false){
					$('#contactform').fadeOut(750,function(){
					$('#contactformbox').delay(850).css({opacity:0}).html('<p>We were unable to send your email at this time.<br /><br />Kindly refresh this contact page and try again.<br /><br />Sincerely,<br />The FATE Foundation</p>').animate({opacity:1}, 750);
					$('#contactform').hide();
					});
                }
            }


			
			
// execute only when the whole document is ready
$(document).ready(function() {

	// hide all sub heading lists
	$('.faq #text ul li ul').hide();
	
	// add a click handler to the heading links
	$('.faq #text ul li a').click(function(){
		// if the current sub heading list is already open
		$('.faq #text ul li a').removeClass('navcurrent');
		$(this).addClass('navcurrent');
		if($(this).next('ul:visible').length) {
			// close the sub heading list
			$(this).next('ul:visible').slideUp();
		} else {
			// close all open sub heading lists
			$('.faq #text ul li ul:visible').slideUp();
			// slide open the next list
			$(this).next('ul').slideToggle('normal');
		}
	
	// return false to stop link following the href
	return false;
	});
});
