//Preload Images
(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery)
jQuery.preLoadImages("/images/rotator/bg_img_default.jpg", "/images/rotator/bg_img_1.jpg", "/images/rotator/bg_img_2.jpg", "/images/rotator/bg_img_3.jpg", "/images/rotator/bg_img_4.jpg", "/images/rotator/bg_img_5.jpg", "/images/rotator/bg_img_6.jpg", "/images/rotator/bg_img_7.jpg");

$(document).ready(function(){
	//Rotate container background image	
	var mixImagesNum = 7; 
	var rndMixImagesNum = Math.floor(Math.random() * mixImagesNum); 
	if(rndMixImagesNum != 0)
		$('#container_image').css('background-image', 'url(/images/rotator/bg_img_' + rndMixImagesNum + '.jpg)');
	
	//Nav Listing
	$('#nav_list_business').hover(function(){
		 $(".navListing").addClass('navListing_hover');
	},
	function(){
		$(".navListing").removeClass('navListing_hover');
	});
			
	$('#nav_list_business').click(function(){
		window.location = '/join/';
	});
			
	//Nav Got Talent
	$('#nav_got_talent').hover(function(){
		 $(".navTalent").addClass('navTalent_hover');
	},
	function(){
		$(".navTalent").removeClass('navTalent_hover');
	});
			
	$('#nav_got_talent').click(function(){
		window.location = '/community/';
	});
			
	//Nav Photo
	$('#nav_submit_photo').hover(function(){
		 $(".navPhoto").addClass('navPhoto_hover');
	},
	function(){
		$(".navPhoto").removeClass('navPhoto_hover');
	});
			
	$('#nav_submit_photo').click(function(){
		window.open('http://facebook.com/NEPAConnect', '_blank');
	});
			
	//Nav Feedback
	$('#nav_feedback').hover(function(){
		 $(".navFeedback").addClass('navFeedback_hover');
	},
	function(){
		$(".navFeedback").removeClass('navFeedback_hover');
	});
			
	$('#nav_feedback').click(function(){
		window.location = '/jobs/';
	});
			
	$("#signup_btn").colorbox({
		width: 410,
		height: 370,
		href:"/inc/mailchimp_form.php?e="+escape($('#signup_txt').val())
	});
			
	$('#signup_btn').click(function() {	
		if($('#signup_txt').val() == $('#signup_txt')[0].title || $('#signup_txt').val() == ''){
			alert('Please enter your email address.');
			$('#signup_txt').focus();
			return false;
		}
		else {
			$("#signup_btn").colorbox({
				width: 410,
				height: 390,
				href:"/inc/mailchimp_form.php?e="+escape($('#signup_txt').val()),
				onOpen: function(){
					window.scroll(0,0);
				}
			});
		}
	});
	
	$("#main_video").colorbox({
		width: 535,
		height: 375,
		html: '<iframe width="482" height="271" src="http://www.youtube.com/embed/mzSW2jiFPAo?rel=0&autoplay=1" frameborder="0" allowfullscreen></iframe>',
		onOpen: function(){
			window.scroll(0,0);
		}
	});
});	

