// JavaScript Document


  // Read a page's GET URL variables and return them as an associative array.
   function getUrlVars()
      {

      var vars = [], hash;
      var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
      for(var i = 0; i < hashes.length; i++)
      {
      hash = hashes[i].split('=');
      vars.push(hash[0]);

      vars[hash[0]] = hash[1];
       }
      return vars[0];
      }
	  
$(document).ready(function()
{

var hash = getUrlVars();
	// alert(isset(hash['lounge']));
   if(hash=="lounge"){
			$('#casestudies').animate({ left: '0px' }, 500, 'swing')
			$('#thearmydescription').animate({ left: '0px' }, 700, 'swing')
			$('#bottomcontent').animate({ height: '1px' }, 700, 'swing')
			$('#services').animate({ height: '340px' }, 700, 'swing')
			$('#lounge').animate({ height: '810px' }, 700, 'swing')
			$('#maincontent').animate({ height: '810px' }, 700, 'swing')

			document.body.style.backgroundImage='url(_images/background_expanded2.jpg)';
			$('#topcontent').animate({ top: '-1370px' }, 700, 'swing')				
   }
   if(hash=="work"){
			$('#casestudies').animate({ left: '0px' }, 500, 'swing')
			$('#thearmydescription').animate({ left: '0px' }, 700, 'swing')
			$('#bottomcontent').animate({ height: '250px' }, 700, 'swing')
			$('#services').animate({ height: '340px' }, 700, 'swing')
			$('#maincontent').animate({ height: '340px' }, 700, 'swing')
			$('#lounge').animate({ height: '340px' }, 700, 'swing')
			$('#topcontent').animate({ top: '-340px' }, 700, 'swing')				
			$('#bottomcontainer').animate({ top: '-240px' }, 500, 'swing')	
   }
   if(hash=="army"){
			$('#casestudies').animate({ left: '0px' }, 500, 'swing')
			$('#thearmydescription').animate({ left: '0px' }, 700, 'swing')
			$('#bottomcontent').animate({ height: '250px' }, 700, 'swing')
			$('#services').animate({ height: '340px' }, 700, 'swing')
			$('#lounge').animate({ height: '340px' }, 700, 'swing')
			$('#maincontent').animate({ height: '340px' }, 700, 'swing')

			$('#topcontent').animate({ top: '-1020px' }, 700, 'swing')				
			$('#bottomcontainer').animate({ top: '-490px' }, 500, 'swing')					
   }
   if(hash=="services"){
			$('#casestudies').animate({ left: '0px' }, 500, 'swing')
			$('#thearmydescription').animate({ left: '0px' }, 700, 'swing')
			$('#bottomcontent').animate({ height: '1px' }, 700, 'swing')
			$('#services').animate({ height: '580px' }, 700, 'swing')
			$('#lounge').animate({ height: '340px' }, 700, 'swing')
			$('#maincontent').animate({ height: '580px' }, 700, 'swing')

			document.body.style.backgroundImage='url(_images/background_expanded.jpg)';
			$('#topcontent').animate({ top: '-680px' }, 700, 'swing')				
   }

});


jQuery.easing.def = "easeInOutExpo";

var featuredescID=0;

	$(function() {

    var id = setInterval(function() {

			if(featuredescID>=3){
				featuredescID=0;
				moveAmmount=(featuredescID*530)*-1
				moveAmmountDesc=(featuredescID*305)*-1
				$('#descriptionscontainer #container').animate({ left: moveAmmountDesc }, 500, 'swing')
				$('#mycontainer').animate({ left: moveAmmount }, 700, 'swing')
			}else{
				featuredescID++;
				moveAmmount=(featuredescID*530)*-1
				moveAmmountDesc=(featuredescID*305)*-1
				$('#descriptionscontainer #container').animate({ left: moveAmmountDesc }, 500, 'swing')
				$('#mycontainer').animate({ left: moveAmmount }, 700, 'swing')
			}

	}, 10000); 

		$('#featureright').click(function() {
			if(featuredescID>=3){
				featuredescID=0;
				moveAmmount=(featuredescID*530)*-1
				moveAmmountDesc=(featuredescID*305)*-1
				$('#descriptionscontainer #container').animate({ left: moveAmmountDesc }, 500, 'swing')
				$('#mycontainer').animate({ left: moveAmmount }, 700, 'swing')
			}else{
				featuredescID++;
				moveAmmount=(featuredescID*530)*-1
				moveAmmountDesc=(featuredescID*305)*-1
				$('#descriptionscontainer #container').animate({ left: moveAmmountDesc }, 500, 'swing')
				$('#mycontainer').animate({ left: moveAmmount }, 700, 'swing')
			}
			clearInterval(id);
		})
		$('#featureleft').click(function() {
			if(featuredescID<=0){
				featuredescID=3;
				moveAmmount=(featuredescID*530)*-1
				moveAmmountDesc=(featuredescID*305)*-1
				$('#descriptionscontainer #container').animate({ left: moveAmmountDesc }, 500, 'swing')
				$('#mycontainer').animate({ left: moveAmmount }, 700, 'swing')

			}else{
				featuredescID--;
				moveAmmount=(featuredescID*530)*-1
				moveAmmountDesc=(featuredescID*305)*-1
				$('#descriptionscontainer #container').animate({ left: moveAmmountDesc }, 500, 'swing')
				$('#mycontainer').animate({ left: moveAmmount }, 700, 'swing')
			}
			clearInterval(id);
		})

		// NAVIGATE CASE 1 SCREENSHOTS
		$('#portfolio01_01').click(function() {
				screenmoveAmount=(0*540)*-1;
				$('#casestudy01 #left #screenshots').animate({ left: screenmoveAmount }, 500, 'swing')
		})

		$('#portfolio01_02').click(function() {
				screenmoveAmount=(1*558)*-1;
				$('#casestudy01 #left #screenshots').animate({ left: screenmoveAmount }, 500, 'swing')
		})

		$('#portfolio01_03').click(function() {
				screenmoveAmount=(2*558)*-1;
				$('#casestudy01 #left #screenshots').animate({ left: screenmoveAmount }, 500, 'swing')
		})

		$('#portfolio01_04').click(function() {
				screenmoveAmount=(3*558)*-1;
				$('#casestudy01 #left #screenshots').animate({ left: screenmoveAmount }, 500, 'swing')
		})

		// NAVIGATE CASE 2 SCREENSHOTS
		$('#portfolio02_01').click(function() {
				screenmoveAmount=(0*540)*-1;
				$('#screenshots2').animate({ left: screenmoveAmount }, 500, 'swing')
		})

		$('#portfolio02_02').click(function() {
				screenmoveAmount=(1*558)*-1;
				$('#screenshots2').animate({ left: screenmoveAmount }, 500, 'swing')
		})

		$('#portfolio02_03').click(function() {
				screenmoveAmount=(2*558)*-1;
				$('#screenshots2').animate({ left: screenmoveAmount }, 500, 'swing')
		})

		$('#portfolio02_04').click(function() {
				screenmoveAmount=(3*558)*-1;
				$('#screenshots2').animate({ left: screenmoveAmount }, 500, 'swing')
		})

		// NAVIGATE CASE 3 SCREENSHOTS
		$('#portfolio03_01').click(function() {
				screenmoveAmount=(0*540)*-1;
				$('#screenshots3').animate({ left: screenmoveAmount }, 500, 'swing')
		})

		$('#portfolio03_02').click(function() {
				screenmoveAmount=(1*558)*-1;
				$('#screenshots3').animate({ left: screenmoveAmount }, 500, 'swing')
		})

		$('#portfolio03_03').click(function() {
				screenmoveAmount=(2*558)*-1;
				$('#screenshots3').animate({ left: screenmoveAmount }, 500, 'swing')
		})

		$('#portfolio03_04').click(function() {
				screenmoveAmount=(3*558)*-1;
				$('#screenshots3').animate({ left: screenmoveAmount }, 500, 'swing')
		})


		// NAVIGATE CASE 4 SCREENSHOTS
		$('#portfolio04_01').click(function() {
				screenmoveAmount=(0*540)*-1;
				$('#screenshots4').animate({ left: screenmoveAmount }, 500, 'swing')
		})

		$('#portfolio04_02').click(function() {
				screenmoveAmount=(1*558)*-1;
				$('#screenshots4').animate({ left: screenmoveAmount }, 500, 'swing')
		})

		$('#portfolio04_03').click(function() {
				screenmoveAmount=(2*558)*-1;
				$('#screenshots4').animate({ left: screenmoveAmount }, 500, 'swing')
		})

		$('#portfolio04_04').click(function() {
				screenmoveAmount=(3*558)*-1;
				$('#screenshots4').animate({ left: screenmoveAmount }, 500, 'swing')
		})

		// NAVIGATE CASE 5 SCREENSHOTS
		$('#portfolio05_01').click(function() {
				screenmoveAmount=(0*540)*-1;
				$('#screenshots5').animate({ left: screenmoveAmount }, 500, 'swing')
		})

		$('#portfolio05_02').click(function() {
				screenmoveAmount=(1*558)*-1;
				$('#screenshots5').animate({ left: screenmoveAmount }, 500, 'swing')
		})

		$('#portfolio05_03').click(function() {
				screenmoveAmount=(2*558)*-1;
				$('#screenshots5').animate({ left: screenmoveAmount }, 500, 'swing')
		})

		$('#portfolio05_04').click(function() {
				screenmoveAmount=(3*558)*-1;
				$('#screenshots5').animate({ left: screenmoveAmount }, 500, 'swing')
		})

		function RevertBG(){
			document.body.style.backgroundImage='url(_images/background.jpg)';
		}
		// SWITCH TO WORK SECTION
		$('#gotowork').click(function() {
			$('#casestudies').animate({ left: '0px' }, 500, 'swing')
			$('#thearmydescription').animate({ left: '0px' }, 700, 'swing')
			$('#bottomcontent').animate({ height: '250px' }, 700, 'swing')
			$('#services').animate({ height: '340px' }, 700, 'swing')
			$('#maincontent').animate({ height: '340px' }, 700, 'swing')
			$('#lounge').animate({ height: '340px' }, 700, 'swing')
			$('#topcontent').animate({ top: '-340px' }, 700, 'swing')				
			$('#bottomcontainer').animate({ top: '-240px' }, 500, 'swing',RevertBG)

		})

		// SWITCH TO SERVICES SECTION
		$('#gotoservices').click(function() {
			$('#casestudies').animate({ left: '0px' }, 500, 'swing')
			$('#thearmydescription').animate({ left: '0px' }, 700, 'swing')
			$('#bottomcontent').animate({ height: '1px' }, 700, 'swing')
			$('#services').animate({ height: '580px' }, 700, 'swing')
			$('#lounge').animate({ height: '340px' }, 700, 'swing')
			$('#maincontent').animate({ height: '580px' }, 700, 'swing')

			document.body.style.backgroundImage='url(_images/background_expanded.jpg)';
			$('#topcontent').animate({ top: '-680px' }, 700, 'swing')				
		})
		
		// SWITCH TO LOUNGE SECTION
		$('#gotolounge').click(function() {
			$('#casestudies').animate({ left: '0px' }, 500, 'swing')
			$('#thearmydescription').animate({ left: '0px' }, 700, 'swing')
			$('#bottomcontent').animate({ height: '1px' }, 700, 'swing')
			$('#services').animate({ height: '340px' }, 700, 'swing')
			$('#lounge').animate({ height: '810px' }, 700, 'swing')
			$('#maincontent').animate({ height: '810px' }, 700, 'swing')

    		$('#phpoutput_tweets').load('gettwitter_ajax.php?randval='+ Math.random());
     		$('#phpoutput_links').load('getlinks_ajax.php?randval='+ Math.random());
     		$('#phpoutput_photos').load('getphotos_ajax.php?randval='+ Math.random());
	 

		   // called every second to get time from server
		   var refreshId = setInterval(function()
			   {
				 $('#phpoutput_tweets').load('gettwitter_ajax.php?randval='+ Math.random());
				 $('#phpoutput_links').load('getlinks_ajax.php?randval='+ Math.random());
				 $('#phpoutput_photos').load('getphotos_ajax.php?randval='+ Math.random());
			   }, 60000);
   
   
			document.body.style.backgroundImage='url(_images/background_expanded2.jpg)';
			$('#topcontent').animate({ top: '-1370px' }, 700, 'swing')				
		})


		// SWITCH TO LOUNGE SECTION - HOME LINK
		$('#goloungehome').click(function() {
			$('#casestudies').animate({ left: '0px' }, 500, 'swing')
			$('#thearmydescription').animate({ left: '0px' }, 700, 'swing')
			$('#bottomcontent').animate({ height: '1px' }, 700, 'swing')
			$('#services').animate({ height: '340px' }, 700, 'swing')
			$('#lounge').animate({ height: '810px' }, 700, 'swing')
			$('#maincontent').animate({ height: '810px' }, 700, 'swing')

			document.body.style.backgroundImage='url(_images/background_expanded2.jpg)';
			$('#topcontent').animate({ top: '-1370px' }, 700, 'swing')				
		})
		
		// SWITCH TO SERVICES SECTION - LEARN LINK
		$('#learnservices').click(function() {
			$('#casestudies').animate({ left: '0px' }, 500, 'swing')
			$('#thearmydescription').animate({ left: '0px' }, 700, 'swing')
			$('#bottomcontent').animate({ height: '1px' }, 700, 'swing')
			$('#services').animate({ height: '580px' }, 700, 'swing')
			$('#lounge').animate({ height: '340px' }, 700, 'swing')
			$('#maincontent').animate({ height: '580px' }, 700, 'swing')

			document.body.style.backgroundImage='url(_images/background_expanded.jpg)';
			$('#topcontent').animate({ top: '-680px' }, 700, 'swing')				
		})

		// SWITCH TO THE ARMY SECTION
		$('#gotoarmy').click(function() {
		
			$('#casestudies').animate({ left: '0px' }, 500, 'swing')
			$('#thearmydescription').animate({ left: '0px' }, 700, 'swing')
			$('#bottomcontent').animate({ height: '250px' }, 700, 'swing')
			$('#services').animate({ height: '340px' }, 700, 'swing')
			$('#lounge').animate({ height: '340px' }, 700, 'swing')
			$('#maincontent').animate({ height: '340px' }, 700, 'swing')

			$('#topcontent').animate({ top: '-1020px' }, 700, 'swing')				
			$('#bottomcontainer').animate({ top: '-490px' }, 500, 'swing',RevertBG)	
			

			
		})

		// SWITCH TO HOME SECTION
		$('#gotohome').click(function() {
			$('#casestudies').animate({ left: '0px' }, 500, 'swing')
			$('#thearmydescription').animate({ left: '0px' }, 700, 'swing')
			$('#bottomcontent').animate({ height: '250px' }, 700, 'swing')
			$('#services').animate({ height: '340px' }, 700, 'swing')
			$('#lounge').animate({ height: '340px' }, 700, 'swing')
			$('#maincontent').animate({ height: '340px' }, 700, 'swing')

			$('#topcontent').animate({ top: '0px' }, 700, 'swing')				
			$('#bottomcontainer').animate({ top: '0px' }, 500, 'swing',RevertBG)			
		})



		// SWITCH TO MEMBER 1

		$('#armymember1').click(function() {
			$('#thearmydescription').animate({ left: '-890px' }, 700, 'swing')
		})
		$('#armymember2').click(function() {
			// $('#thearmydescription').animate({ left: '-1740px' }, 700, 'swing')
		})
		$('#armymember3').click(function() {
			//$('#thearmydescription').animate({ left: '-2600px' }, 700, 'swing')
		})
		$('#armymember4').click(function() {
			//$('#thearmydescription').animate({ left: '-3460px' }, 700, 'swing')
			$('#thearmydescription').animate({ left: '-1740px' }, 700, 'swing')
			
		})
		$('#armymember5').click(function() {
			//$('#thearmydescription').animate({ left: '-4310px' }, 700, 'swing')
			$('#thearmydescription').animate({ left: '-2600px' }, 700, 'swing')
		})

		// NAVIGATE TOP CASE STUDIES - PROJECTS
		$('#case1').click(function() {
				$('#casestudies').animate({ left: '0px' }, 500, 'swing')				
		})

		$('#case2').click(function() {
				$('#casestudies').animate({ left: '-880px' }, 500, 'swing')				
		})
		$('#case3').click(function() {
				$('#casestudies').animate({ left: '-1760px' }, 500, 'swing')				
		})
		$('#case4').click(function() {
				$('#casestudies').animate({ left: '-2640px' }, 500, 'swing')				
		})
		$('#case5').click(function() {
				$('#casestudies').animate({ left: '-3520px' }, 500, 'swing')				
		})

		$('#serviceslink').click(function() {

			$('#bottomcontent').animate({ height: '1px' }, 700, 'swing')
			$('#services').animate({ height: '580px' }, 700, 'swing')
			$('#maincontent').animate({ height: '580px' }, 700, 'swing')

			document.body.style.backgroundImage='url(_images/background_expanded.jpg)';
		})
		$('#armymember1').animate({ opacity: 0 }, 0)
		$('#armymember2').animate({ opacity: 0 }, 0)
		$('#armymember3').animate({ opacity: 0 }, 0)
		$('#armymember4').animate({ opacity: 0 }, 0)
		$('#armymember5').animate({ opacity: 0 }, 0)

		$('#armymember1').animate({ opacity: 0.5 }, 500)
		$('#armymember2').animate({ opacity: 0.5 }, 1000)
		$('#armymember3').animate({ opacity: 0.5 }, 1500)
		$('#armymember4').animate({ opacity: 0.5 }, 2000)
		$('#armymember5').animate({ opacity: 0.5 }, 2500)

  	});
	
function RollOverBorder(spanID){

	elementID=document.getElementById(spanID);
	elementID.style.borderBottom='2px solid red';

}
function RollOutBorder(spanID){

	elementID=document.getElementById(spanID);
	elementID.style.borderBottom='2px none';

}

function OpacityMember(memberID,opacityvalue){
	ResetOpacity()
	$('#'+memberID).animate({ opacity: opacityvalue }, 300)
}
function OpacityPhotos(memberID,opacityvalue){
	ResetOpacityPhotos()
	$('#'+memberID).animate({ opacity: opacityvalue }, 300)
}

function ResetOpacity(){
		$('#armymember1').animate({ opacity: 0.5 }, 0)
		$('#armymember2').animate({ opacity: 0.5 }, 0)
		$('#armymember3').animate({ opacity: 0.5 }, 0)
		$('#armymember4').animate({ opacity: 0.5 }, 0)
		$('#armymember5').animate({ opacity: 0.5 }, 0)
}
function ResetOpacityPhotos(){
		$('#swarmphoto1').animate({ opacity: 0.5 }, 0)
		$('#swarmphoto2').animate({ opacity: 0.5 }, 0)
		$('#swarmphoto3').animate({ opacity: 0.5 }, 0)
		$('#swarmphoto4').animate({ opacity: 0.5 }, 0)
		$('#swarmphoto5').animate({ opacity: 0.5 }, 0)
}
