$(document).ready(function () {	
/* Main navigation script */
if ( $('#sub_nav.home')[0] ) {
	$('#sub_nav.home').delay(500).animate({bottom: "0px"}, 500 );
}else{
	$('#sub_nav').css({bottom: "0px"});
}
	$('li.top_li').has('ul').addClass('expand');
	$('li.expand').hover(
		function () {
			//show its submenu
			if ( $('#dept_title')[0] ) { 
			$('#dept_title').stop(true, true).delay(500).hide(300);
			$('ul', this).stop(true, true).delay(800).slideDown(300);
			$('ul.sub_nav_b').stop(true, true).hide();
			} else if ( $('#port_menu')[0] ){
			$('#port_menu').stop(true, true).delay(500).fadeOut(300);
			$('ul', this).stop(true, true).delay(800).slideDown(300);
			$('ul.sub_nav_b').stop(true, true).hide();
			}else{
			$('ul', this).stop(true, true).delay(500).slideDown(300);
			$('ul.sub_nav_b').stop(true, true).hide();
			}
		}, 
		function () {
			//hide its submenu
			if ( $('#dept_title')[0] ) { 
			$('ul', this).stop(true, true).delay(500).slideUp(200);
			$('#dept_title').stop(true, true).delay(800).show(300);
			} else if ( $('#port_menu')[0] ){
			$('ul', this).stop(true, true).delay(500).slideUp(200);
			$('#port_menu').stop(true, true).delay(800).fadeIn(300);
			}else{
			$('ul', this).stop(true, true).delay(500).slideUp(200);	
			}
		}
);

$('li.top_sub').has('ul').addClass('drop_dwn');
	$('li.drop_dwn').hover(
		function () {
			//show its submenu
			$('ul', this).stop(true, true).slideDown(200);	
		}, 
		function () {
			//hide its submenu
			$('ul', this).stop(true, true).delay(200).slideUp(200);	
		}
);


/* lower navigation front page script */
$('.btn_img').click(function() {
	if ($(this).next().hasClass('up')){
		$('.up').slideUp(300).removeClass('up').addClass('down');
		$(this).children('img').removeClass('show').addClass('fade');
		$(this).next().slideUp(300);
		$(this).next().removeClass('up').addClass('down')		
	}else{
		$('.up').slideUp(300).removeClass('up').addClass('down');
		$('img.show').removeClass('show').addClass('fade hide').css("display", "none");
		$(this).next().slideDown(300);
		$(this).next().addClass('up').removeClass('down')
		$("img",this).removeClass('fade').addClass('show');
	}
});
$('.btn_title').click(function() {
	if ($(this).prev().hasClass('up')){
		$('.up').slideUp(300).removeClass('up').addClass('down');
		$('img.show').removeClass('show').addClass('fade hide');
		$(this).prev().slideUp(300);
		$(this).prev().removeClass('up').addClass('down')
	}else{
		$('.up').slideUp(300).removeClass('up').addClass('down');
		$('img.show').removeClass('show').addClass('fade hide').css("display", "none");
		$(this).prev().slideDown(300);
		$(this).prev().addClass('up').removeClass('down')
		$(this).parent('.button').children('.btn_img').children('img').removeClass('fade').addClass('show').css("display", "inline");;
	}
	$('.btn_title').click(function(){ return false; });
});

$(".button").hover(
  function () {
    $("img.fade", this).stop(true, true).fadeIn(200);
  },
  function () {
    $("img.fade", this).stop(true, true).fadeOut(200);
  }
);

/* facebook pop up script */	
$(".tooltip_trigger").tooltip({ position: "top center", relative: true});
/*form script */
/*$('#info_tag').click(function() {
	if ($('#open_form').hasClass('closed')){
		$('#dim').stop(true, true).show();
		$('#open_form').stop(true, true).slideDown(300).removeClass('closed').addClass('opened');
		$('#fly_out').stop(true, true).delay(300).animate({left: '-300', width: '290'}, 300);
		return false;		
	}else{
		$('#fly_out').stop(true, true).animate({left: '0', width: '0'}, 300);
		$('#open_form').stop(true, true).delay(300).slideUp(300).removeClass('opened').addClass('closed');
		$('#dim').stop(true, true).delay(600).hide();
		return false;
	}
});
$('#dim').click(function() {
	$('#fly_out').stop(true, true).animate({left: '0', width: '0'}, 300);
	$('#open_form').stop(true, true).delay(300).slideUp(300).removeClass('opened').addClass('closed');
	$('#dim').stop(true, true).hide();
});
*/	
});
