/*
*
*	Hooah Interactive Communications
*	Department: IT Department
*	Developer: William Diaz
*
*/
	
	$(document).ready(function () {
	

			if($.browser.msie && parseInt($.browser.version, 10) == 7) {
			
				$("#social-networks").hide();

			}
			
			$.localScroll.defaults.axis = 'xy';
			
			/* OnPage load function */
							
			// Scroll initially if there's a hash (#something) in the url 
			$.localScroll.hash({
				target: '#container', // Could be a selector or a jQuery object too.
				duration:500,
				queue:true

			});
			

			$('#explorer-wrapper-menu').click(function() {
			
						$("#dynamic-close").animate({ right: 'toggle', opacity: 'hide' }, 10);
				
						  $("#main-site").animate({marginTop: "0px"}, {duration: 1000, 
							  complete: function() {
							  $('.nav').animate({ right: 'toggle', opacity: 'show' }, 700);
							  $("body").css("overflow-y", "hidden");
							  
							}
						  });
  
				
			});
					
					
			$.localScroll({
				queue:false,
				hash:true,
				onBefore:function( e, anchor, $target ){
				
					// The 'this' is the settings object, can be modified
					if ((anchor.id =="box1") || (anchor.id =="box2") || (anchor.id =="box3") || (anchor.id =="box4") || (anchor.id =="box5") || (anchor.id =="box6"))
					{
					
						$('.bulb-1').hide();
						$('.bulb-2').hide();
						$('.bulb-3').hide();
						$('.bulb-4').hide();
						$('.bulb-5').hide();
						$('.bulb-6').hide();

						RemoveClasses();
					}
					
				},
				onAfter:function( anchor, settings ){
				
					// The 'this' contains the scrolled element (#container)				
					leftImageHandling(anchor.id);
					
				}
			});
							
			
			/*
			*
			*		 CONTENT WINDOW
			*
			*/
			

		
			
			function leftImageHandling(e)
			{

				switch (e)
				{
					case "box1":
					
						if ($('.bulb-1').is(":hidden")) {
							$('.bulb-1').animate({ right: 'toggle', opacity: 'show' }, 1500);
						}
						
						//Check if the user has the content window open and close it.
						 checkOpenWindows();
					break;
					
					case "box2":
						
						if ($('.bulb-2').is(":hidden")) {
							$('.bulb-2').animate({ right: 'toggle', opacity: 'show' }, 1500);
						}
						
						//Check if the user has the content window open and close it.
						 checkOpenWindows();
						 
					break;
					
					case "box3":
					
						if ($('.bulb-3').is(":hidden")) {
							$('.bulb-3').animate({ right: 'toggle', opacity: 'show' }, 1500);
						}
					
						//Check if the user has the content window open and close it.
						 checkOpenWindows();
						
					break;
					
					case "box4":
					
						if ($('.bulb-4').is(":hidden")) {
							$('.bulb-4').animate({ right: 'toggle', opacity: 'show' }, 1500);
						}
					
						//Check if the user has the content window open and close it.
						 checkOpenWindows();
						
					break;
					
					case "box5":
					
						if ($('.bulb-5').is(":hidden")) {
							$('.bulb-5').animate({ right: 'toggle', opacity: 'show' }, 1500);
						}
						
						//Check if the user has the content window open and close it.
						 checkOpenWindows();
						
					break;
					
					case "box6":
					
						if ($('.bulb-6').is(":hidden")) {
							$('.bulb-6').animate({ right: 'toggle', opacity: 'show' }, 1500);
						}
						
						//Check if the user has the content window open and close it.
						 checkOpenWindows();
						
					break;


				}


			}
			
			
			function checkOpenWindows(){
			
				if ($("#bottom-navigation-window").is(":visible")) {
					$('#bottom-navigation-window').slideUp('slow', function() {});
				}

				if ($("#popup1").is(":visible")) {
					$('#popup1').fadeOut("slow");
				}
				if ($("#popup2").is(":visible")) {
					$('#popup2').fadeOut("slow");
				}
				if ($("#popup3").is(":visible")) {
					$('#popup3').fadeOut("slow");
				}
				
				if ($("#popup4").is(":visible")) {
					$('#popup4').fadeOut("slow");
				}
				
				if ($("#popup5").is(":visible")) {
					$('#popup5').fadeOut("slow");
				}
				
				if ($("#popup6").is(":visible")) {
					$('#popup6').fadeOut("slow");
				}
				

			}
			
			/*
			*
			*	   BOTTOM NAVIGATION MENU
			*
			*/
			
			 $(".close-nav").click(function() {
			 
				$('#bottom-navigation-window').slideUp('slow', function() {});
				
				//Check if the user has the content window open and close it.
				 checkOpenWindows()
			 })
			
			$(".nav-explorer").click(function(){
			

				
				if ($("#bottom-navigation-window").is(":visible")) {
				
					if ($("#static-explorer-content").is(":visible")) {
						$('#bottom-navigation-window').slideUp('slow', function() {});
						$(".nav-explorer").removeClass("nav-explorer-over");
						
					}
					else
					{
						
						$(".nav-explorer").addClass("nav-explorer-over");
						$(".nav-social").removeClass("nav-social-over");
						$(".nav-contact").removeClass("nav-contact-over");
						$("#static-explorer-content").animate({ right: 'toggle', opacity: 'show' }, 1000);
						$("#static-explorer-content").show();
					}
					
					
					$("#dynamic-contact-content").hide();
					$("#dynamic-social-content").hide();
				

					
				} 
				else
				{
				
					$(".nav-explorer").addClass("nav-explorer-over");
				
					$("#static-explorer-content").show();
					$("#dynamic-social-content").hide();
					$("#dynamic-contact-content").hide();
	
					$("#bottom-navigation-window").slideDown();	
					$("#dynamic-content").animate({ right: 'toggle', opacity: 'show' }, 4000);
				}
				
			
				
			})

			
			$(".nav-social").click(function(){
				
				if($.browser.msie && parseInt($.browser.version, 10) == 7) {
						window.open('content/social-content-ie7.html','_blank');
						return false;
				}
				else
				{

				  $("#main-site").animate({marginTop: "-1616px"}, {duration: 1000, complete: function() {
					  $("body").css("overflow-y", "auto");
					  $("#social-networks").css("margin-top", "-5px");
					}
				  });

	 
					 $.ajax({
					  url: "content/social-content.php",
					  cache: false,
					  context: document.body,
					  success: function(data) {
					  
						$('.nav').animate({ right: 'toggle', opacity: 'hide' }, 700);
					  	$('.bulb-1').animate({ right: 'toggle', opacity: 'hide' }, 700);
						$('.bulb-2').animate({ right: 'toggle', opacity: 'hide' }, 700);
						$('.bulb-3').animate({ right: 'toggle', opacity: 'hide' }, 700);
						$('.bulb-4').animate({ right: 'toggle', opacity: 'hide' }, 700);
						$('.bulb-5').animate({ right: 'toggle', opacity: 'hide' }, 700);
						$('.bulb-6').animate({ right: 'toggle', opacity: 'hide' }, 700);
						
						$('.dynamic-content').html(data);
						
						$("#dynamic-close").animate({ right: 'toggle', opacity: 'show' }, 1000);
					  
					  },
						statusCode: {404: function() {alert('The page "content/social-content.html" not found');}}
					});
				

				}
	


			})
			
			
			$(".nav-contact").click(function(){
			
				
				if($.browser.msie && parseInt($.browser.version, 10) == 7) {
						window.open('content/contact-content-ie7.html','_newtab');
						return false;
				}
				else
				{
				
					$("#main-site").animate({marginTop: "-1616px"}, {duration: 1000, 
					  complete: function() {
					  $("body").css("overflow-y", "auto");
					  $("#social-networks").css("margin-top", "-5px");
					}
					});

	 
					 $.ajax({
					  url: "content/contact-content.html",
					  cache: false,
					  context: document.body,
					  success: function(data) {
					  
						$('.nav').animate({ right: 'toggle', opacity: 'hide' }, 700);
					  	$('.bulb-1').animate({ right: 'toggle', opacity: 'hide' }, 700);
						$('.bulb-2').animate({ right: 'toggle', opacity: 'hide' }, 700);
						$('.bulb-3').animate({ right: 'toggle', opacity: 'hide' }, 700);
						$('.bulb-4').animate({ right: 'toggle', opacity: 'hide' }, 700);
						$('.bulb-5').animate({ right: 'toggle', opacity: 'hide' }, 700);
						$('.bulb-6').animate({ right: 'toggle', opacity: 'hide' }, 700);
						
						$('.dynamic-content').html(data);
						$("#dynamic-close").animate({ right: 'toggle', opacity: 'show' }, 1000);
					  
					  },
						statusCode: {404: function() {alert('The page "content/contact-content.html" not found');}}
					});

				}
			})

			$("#explorer-arrow").mouseenter(function(){
					
					if ($("#explorer-bottom").is(":visible")) {
						$(".explorer-wrapper").animate({marginTop: "0px"}, 500 );
						$('#explorer-bottom').hide(); 
						
					}

				$("#explorer-wrapper-menu").mouseleave(function(){
			
					if ($("#explorer-bottom").is(":hidden")) {
						$(".explorer-wrapper").animate({marginTop: "-116px"}, 500 );
						$('#explorer-bottom').show(); 
					}

				});
				
			});



			
			$("#bottom-navigation-window").click(function(){	
			
				//Remove the classes from the bottom navigation bar
				RemoveClasses();
				$('#bottom-navigation-window').slideUp('slow', function() {});
			})
			
			
			//Remove the classes from the bottom navigation bar
			function RemoveClasses()

			{	$(".nav-explorer").removeClass("nav-explorer-over");
				$(".nav-social").removeClass("nav-social-over");
				$(".nav-contact").removeClass("nav-contact-over");	
			}
			
				
				//select all the a tag with name equal to modal
				$('a[name=mod]').click(function(e) {

					//Cancel the link behavior
					e.preventDefault();

					//Get the A tag
					var id = $(this).attr('href');

					//Get the screen height and width
					var bgHeight = document.documentElement.clientHeight;  
					var bgWidth = document.documentElement.clientWidth;  

					//Set height and width to mask to fill up the whole screen
					//$('#transBG').css({'width':bgWidth,'height':bgHeight});

			
					//Get the window height and width
					var winH = (document.documentElement.clientHeight) - (144);  
					var winW = document.documentElement.clientWidth;  

					//Remove the classes from the bottom navigation bar
					RemoveClasses();

					
					//Get the page tag
					var mypage = $(this).attr('action');
	
					
							 $.ajax({
							  url: mypage,
							  cache: false,
							  context: document.body,
							  success: function(data) {
							  
								e.preventDefault();
							  
								//grab the html data
								$(id).html(data);

			
								//transition effect			
								$(id).slideDown();	
															
							  },
							 statusCode: {404: function() {
								alert('The page "' + mypage + '" is not found');
								}
							}

					});
			
			});
		
	
	
			

		});

		
		
