// JavaScript Document
$(function(){
  $('.moveMenu')
	  .css( {backgroundPosition: "0 0"} )
	  .mouseover(function(){
		 // $(this).css({color:"#FFF"});
		  $(this).stop().animate({backgroundPosition:"(150px 0)"}, {duration:500})
		  $(this).children('img').attr('src','images/h.png');
		 $(this).children('span').css({color:'#FFFFFF'});
		  
	  })
	  .mouseout(function(){
		  $(this).stop().animate({backgroundPosition:"(0 0)"}, {duration:500, complete:function(){
			// $(this).css({color:"#666"}); 
			 $(this).css({backgroundPosition: "0 0"})
			 
		  }});
		  $(this).children('img').attr('src','images/h1.png');
		  //alert($(this).css('color'));
		  $(this).children('span').css({color:'#e60e0f'});
	  })
});
function basename(path) {
	return path.replace(/\\/g,'/').replace( /.*\//, '' );
}
function dirname(path) {
	return path.replace(/\\/g,'/').replace(/\/[^\/]*$/, '');;
}
function pageName(path)
{
	var p=basename(path);
	p=p.split('.');
	if(p[0]=='') return('index');
	else return(p[0]); 
}
$(window).load(function() {
  //code to run after the others
  var href = jQuery(location).attr('href');
	var page = pageName(href);
	$('#'+page).css({background:"#e60f0f", color:"#FFF"});
	$('#'+page).children('img').attr('src','images/h.png');
	
	$('#'+page).unbind('mouseover');
	$('#'+page).unbind('mouseout');
	$('#'+page).removeClass('moveMenu');
	
	/*var pTitle=$('#'+page+' img').attr('title');
	if(page=='index') pTitle='';

	document.title = document.title+' | '+pTitle;*/

	
$(".sign").css({opacity:0});
	$("#ap1").animate({opacity:1, left: "0"},1000); 
	$("#ap2").animate({opacity:1, top: "0"},1000, function(){
		$(".sign").animate({opacity:1, top: "0"},1000);
		});	
		
$.ajax({
	  url: 'availablejobs.php',
	  success: function(data) {
		 if(data==0) {}
		 else {
			 var span='<span> ('+data+')</span>';
			 $("#careers").append(span);
			 $("#careers span").fadeIn(2000);	
			 $('#'+page).children('span').css({'color':'#FFFFFF'});	 
		 }
	  }
	});
});
$(document).ready(function(){
jQuery.event.add(window, "load", resizeFrame);
jQuery.event.add(window, "resize", resizeFrame);

function resizeFrame() 
{
    var h = $(window).height();
    //var w = $(window).width();//alert(h);
    $("#r").animate().css({'min-height':h-60});
}

	$(".tt").easyTooltip();
	
$(".tt").click(function(){
	$('#tInfo').animate({height:"495px"}, {duration:500});
	var p=$(this).attr('rel');//alert(p);
	$.post("profile.php",{who:p}, function(data){
			$('#tInfo').html(data);
	//		$('#inData').stop().fadeIn('slow');
			});
//	$('#tInfo').html('info info info info');
return false;	});
	
	$('.getIn').click(function(){
	$('#inData').slideUp('slow');
			var m=$(this).attr('id');
			//alert(m);
			$.post("inDiv.php",{what:m}, function(data){
			$('#inData').html(data);
			$('#inData').stop(true,true).slideDown('slow');
			});
			//alert($(this).children().html());
			$('.getIn').children().removeClass('lightMini')

			$(this).children().addClass('lightMini');
			//$.scrollTo($('#stage'), {duration: 500});
			return false;
			
			});	
$('.section').click(function(){
	var s=$(this).attr('id');
			 $.each($('.section'), function(i,item){
			   $(item).parent().stop().children('.inData').slideUp().html('');
			   $(item).parent().stop().children('.mini').slideUp().html('');
			 });
	$.ajax({
	  url: 'subsection.php?section='+s,
	  success: function(data) {
		 $('#mini'+s).slideDown('slow');
		$('#mini'+s).html(data);
	  }
	});

	return false;
});	
 
$('.showmap').click(function(){
	//var map='';
	//$.post("map.php", function(data){	
	//	map=data;
	//	});
	$.ajax({
	  url: "map.php",
	  success: function(data) {
		$('#showmap').animate({
    opacity: 0.25,
    top: '-130'
  }, 1000, function() {
	$('#showmap').animate({
		opacity: 1,
     height: '500px',
	 width:'500px'
  },1000).css({'background':'none'});
		$('#showmap').html(data);
	$('#showmap').unbind("click")
  });
	  }
	});
return false;
});	

$('.getPort').click(function(){

	$.post("gal.php", function(data){
		$('#inData').html(data);
	});
return false;
});	
$('.showFrm').click(function(){
	var id=$(this).attr("id");
	$("#send"+id).fadeIn('slow');
return false;
});	


$('.portMenu li').click(function(){
	$('.portMenu li').removeClass('selected');
	$('.portMenu li').removeClass('colored');
	$('.portSub').stop(true,true).fadeOut('slow');
	$(this).addClass('selected');
	$(this).addClass('colored');
	var portSub=$(this).attr('id');
	$.ajax({
	  url: 'subsection.php?section='+portSub,
	  success: function(data) {
		 //$('#mini'+s).slideDown('slow');
		 $('.portSub').stop(true,true).fadeIn('slow');
		$('.portSub').html(data);
		//$('.portItem').stop(true,true).fadeOut('slow');
		$('.portItem').html('');
	  }
	});

	return false;

	//$(".portSub").html(portSub);
});
	/*$('a').live('mousedown', function(e) {
		e.target.blur();
		e.target.hideFocus = true;
		e.target.style.outline = 'none'
	}).live('mouseout', function(e) {
		e.target.blur();
		e.target.hideFocus = false;
		e.target.style.outline = null;
	});*/
	/*$('.fblink').hover(function(){
		$(this).parent().animate({'width':100})
		},function(){
			$(this).parent().animate({'width':50})
			})
	*/
});
