$(document).ready(function() {
	launch.init();
}); //end document.ready()

var launch = {
	
	init:function() {
		launch.getTwitterFeed();
		launch.ieFix();
	}, //end init
	
	getTwitterFeed:function() {
		$.ajax({
			beforeSend:function() {
			}, //end beforeSend
			url:'twitter-php/launch_agency.php',  
			complete:function(data) {
				$('#social_media_container').append(data.responseText);
			} //end complete
		}); //end ajax
	}, //end getTwitterFeed
	
	showTweets:function() {
		if ($('#tweet_container').css("height").replace("px", "") == 0) {
			$('#tweet_container').css("padding", "10px");
			$('#tweet_container').animate({
				top:'-450px',
				height:'420px',
				width:'200px',
				left:'-40px'
			}, {
				duration:500,
				easing:"easeOutCubic"
			});
		} else {
			$('#tweet_container').css("padding", "0px");
			$('#tweet_container').animate({
				top:'0px',
				height:'0px',
				width:'0px',
				left:'130px'
			}, {
				duration:500,
				easing:"easeOutCubic"
			});

		} //end if
	}, //showTweets
	
	ieFix:function() {
		if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) { //test for MSIE x.x;
			document.getElementById("header").style.fontSize = "13px";
			var ieversion = new Number(RegExp.$1); // capture x.x portion and store as a number
			if (ieversion <= 7) {
				document.getElementById("nav").style.left = "135px";
				$('li span').css("line-height", "140px");
				$('li').css("margin-right", "20px");
			} //end else if
		} //end if
	}, //end testFont
	
	showPersonInfo:function(elm) {
		//find the current person_info div to display
		var person_info_children = $(elm).children();
		var currentPerson = "";
		for (i = 0; i < person_info_children.length; i++) {
			if ($(person_info_children[i]).attr("class") == "person_info") {
				currentPerson = $(person_info_children[i]);
			} //end if
		} //end for
		
		if ($(currentPerson).css("display") == "block") {
			$(currentPerson).css("display", "none");
			return;
		} else {
			//resets all person_infos to opacity:0 and display:none
			var all_person_info = $('.person_info');
			for (i = 0; i < all_person_info.length; i++) {
			  $(all_person_info[i]).animate({
				  opacity:'0'
			  }, {
				  duration:100
			  }); //end animate
			  $(all_person_info[i]).css("display", "none");
			} //end for
		} //end if
				
		//show the current person_info
		$(currentPerson).css("display", "block");
		$(currentPerson).animate({
			opacity:1
		}, {
			duration:100
		}); //end animate
	}, //end showPersonInfo
	
	tabs:function(id) {
		var el =document.getElementById(id);
		if ($(el).css("display") == "block")
			return;
		
		var allEls = document.getElementsByTagName("*");
		var openedTab = "";
		
		//change the tabs
		for (i = 0; i < allEls.length; i++) {
			if (allEls[i].className != "" && allEls[i].className != null && allEls[i].className.indexOf("tab") >= 0) {
				if (allEls[i].className.indexOf("green_tab") >= 0) {
					$(allEls[i]).attr("class", "tab white_tab");
				} //end if
				if ($(allEls[i]).attr("id").replace("tab_", "") == id) {
					$(allEls[i]).attr("class", "tab green_tab") 
				} //end if
			} //end if
		} //end for
		
		//show the section
		for (i = 0; i < allEls.length; i++) {
			if (allEls[i].className != "" && allEls[i].className != null && allEls[i].className.indexOf("section_container") >= 0) {
				if ($(allEls[i]).css("display") == "block") {
					openedTab = allEls[i];
					$(allEls[i]).animate({
						opacity:'0'
					}, {
						duration:200,
						complete:function() {
							$(openedTab).css("display", "none");
						} //end complete
					}); //end animate
				} else if ($(allEls[i]).attr("id") == id) {
					$(allEls[i]).css("display", "block");
					$(allEls[i]).animate({
						opacity:'1'
					}, {
						duration:700
					}); //end animate
				} //end if
			} //end if
		} //end for
	}, //end tabs
	
	changeRocket:function() {
		var obj = $('#rocket');
		if (obj.attr("src").indexOf("png") >= 0)
			obj.attr("src", "images/rocket.gif");
		else
			obj.attr("src", "images/rocket.png");
	} //end changeRocket
	
} //end launch














