// JavaScript Document

function mainmenu(){
$(" #nav ul ").css({display: "none"}); // Opera Fix
$(" #nav li").hover(function(){
		$(this).find('ul:first').css({visibility: "visible",display: "none"}).show(400);
		},function(){
		$(this).find('ul:first').css({visibility: "hidden"});
		});
}

$(document).ready(function(){
						   
	mainmenu();
	
	loadFeed('wordpress_content','wordpress');	
	loadFeed('twitter_content','twitter');	
	loadFeed('bird_content','travel');	
		
	var topopen = false;
	var navopen = false;
						   
	$("#nav_button").click(function(){
									
		if(navopen==false){
			$("#leader_logo").toggleClass('leader_logo_border') ;
			$("#nav").show();
			$("#nav_mask").show();
			$("#navlist").stop().animate(
										 {height:'160px'},
										 {	queue:false, 
										 	duration:600, 
											easing: 'easeOutBounce',
											complete:function(){ 
									 			$("#nav_button").toggleClass('nav_close') ;
												navopen = true;
												$("#navlist").toggleClass('navlistof') ;
												$("#nav_mask").hide();
											}
										})
			
			navopen = true;
		
		}else{
			
			$("#navlist").toggleClass('navlistof') ;
        	$("#navlist").stop().animate(
									 {height:'0px'},
									 {	queue:false, duration:600, 
									 	easing: 'easeOutBounce', 
										complete:function(){ 
									 		$("#nav_button").toggleClass('nav_close') ;
											$("#leader_logo").toggleClass('leader_logo_border') ;
											navopen = false;
											$("#nav").hide();
										}
									 }
									)
			
		}
		
    });		
	
	$("#nav_close").click(function(){
		//$("#navlist").css("overflow","hidden") ;
		$("#navlist").toggleClass('navlistof') ;
        $("#navlist").stop().animate(
									 {height:'0px'},
									 {	queue:false, duration:600, 
									 	easing: 'easeOutBounce', 
										complete:function(){ 
									 		$("#nav_open").show();
										}
									 }
									)
		
    });		
	
	
	
	function toggleTopBar(bhome){
		if(topopen == false){
			
			$('#contactus_button').css('z-index','99');
			
			$("#topbar").stop().animate({top:'0px'},{queue:false, duration:600, easing: 'easeOutBounce',
											complete:function(){ 
												if(bhome==true){
													
													$('#topbutton_home').css('background-image','url(images/top_button_close.png)');
													$('#topbutton_home').css('margin-bottom','12px');
													$('#topbutton_close_home').show();
												}else{
													$('#topbutton').css('background-image','url(images/top_button_close.png)');
													$('#topbutton').css('margin-bottom','12px');
													$('#topbutton_close').show();
												}
												
												
											}
										});
			topopen = true;
		}else{
			if(bhome==true){
				$('#topbutton_close_home').hide();
				$("#topbar").stop().animate({top:'-520px'},{queue:false, duration:600, easing: 'easeOutBounce',
												complete:function(){ 
													$('#topbutton_home').css('background-image','url(images/top_button_anim.gif)');
													$('#topbutton_home').css('margin-bottom','0px');	
													$('#contactus_button').css('z-index','101');
												}
											});
				
			}else{
					$('#topbutton_close').hide();
				$("#topbar").stop().animate({top:'-500px'},{queue:false, duration:600, easing: 'easeOutBounce',
												complete:function(){ 
													$('#topbutton').css('background-image','url(images/top_button_anim.gif)');
													$('#topbutton').css('margin-bottom','0px');	
													
												}
											});
			}
			
			topopen = false;
		}	
	}
	
	$("#contact_nav").click(function(){
		toggleTopBar(false)
	});
	
	$("#topbutton").click(function(){
		toggleTopBar(false)
	});
	
	$("#topbutton_close").click(function(){
		toggleTopBar(false)
	});
	
	$("#topbutton_close_home").click(function(){
		toggleTopBar(true)
	});
	
	$("#topbutton_home").click(function(){
		toggleTopBar(true)
	});
	
	$("#contactus_button").click(function(){
		toggleTopBar()
	});
	
	$("#pr_link").mouseover(function(){
				$("#pr_bubble").show();
				$("#pr").attr("src","images/pr_hover.png") ;
								});
	$("#pr_bubble").mouseover(function(){
				$("#pr_bubble").show();
				$("#pr").attr("src","images/pr_hover.png") ;
								});
	$("#pr_link").mouseout(function(){
				$("#pr_bubble").hide();
				$("#pr").attr("src","images/pr.png") ;
								});
	$("#pr_bubble").mouseout(function(){
				$("#pr_bubble").hide();
				$("#pr").attr("src","images/pr.png") ;
								});
	
	$("#vm_link").mouseover(function(){
				$("#vm_bubble").show();
				$("#vm").attr("src","images/vm_hover.png") ;
								});
	$("#vm_bubble").mouseover(function(){
				$("#vm_bubble").show();
				$("#vm").attr("src","images/vm_hover.png") ;
								});
	$("#vm_link").mouseout(function(){
				$("#vm_bubble").hide();
				$("#vm").attr("src","images/vm.png") ;
								});
	$("#vm_bubble").mouseout(function(){
				$("#vm_bubble").hide();
				$("#vm").attr("src","images/vm.png") ;
								});

    //When mouse rolls over
    //$("li.subitem").mouseover(function(){
    //    $(this).stop().animate({height:'150px'},{queue:false, duration:600, easing: 'easeOutBounce'})
   // });

    //When mouse is removed
    //$("li.subitem").mouseout(function(){
    //    $(this).stop().animate({height:'50px'},{queue:false, duration:600, easing: 'easeOutBounce'})
   // });
	
	if(openpanel==true){
		toggleTopBar(false)		
	}

});

	function showNavCopy(copyid){	
			$newcopy = $('#'+copyid) ;	
			$("#copy_holder").html($newcopy.html() );
			Cufon.replace('h1');
		}
		
	function showTitle(title, pagetype){
		$("#navlist_sectiontitle").html(title);
		if(pagetype=='pr'){	
			$("div#navlist_center").css("background-image","url(images/fusion_pr_hover.png)") ;
		}else{
			$("div#navlist_center").css("background-image","url(images/vm_logo_hover.png)") ;	
		}
	}
	
	function showCopy(copyid){	
			$newcopy = $('#'+copyid) ;	
			$("#copy_holder").html($newcopy.html() );	
			Cufon.replace('h1');
		}
	
	function hideTitle(pagetype){
		
		$("#navlist_sectiontitle").html('');	
		
		if(pagetype=='pr'){	
			$("div#navlist_center").css("background-image","url(images/fusion_pr.png)") ;
		}else{
			$("div#navlist_center").css("background-image","url(images/vm_logo.png)") ;	
		}
	}
