$(document).ready(function()
{		
		
		//sign in box	
		$(".sign_in").click(function(e) {          
				e.preventDefault();
                $("#sign_box").toggle();
				$(".sign_in").toggleClass("sign_in_active");
				$("#login").focus();
            });
			
			
			$("div#sign_box").mouseup(function() {
				return false
			});
			$(document).mouseup(function(e) {
				if($(e.target).parent("a.sign_in").length==0) {
					$(".sign_in").removeClass("sign_in_active");
					$("#sign_box").hide();
				}
			});		
			
			//job sort action dropdown!			
			 $(".action-sort").click(function(e) {          
				e.preventDefault();
				if($(this).children().hasClass('action-sort-active'))
				{
					$(this).children().toggleClass('action-sort-active');
					$(this).siblings().toggle();
				}
				else
				{
					$('.sort').removeClass('action-sort-active');
					$('.action-sort-box').hide();
                	$(this).next('.action-sort-box').toggle();
					$(this).children().toggleClass("action-sort-active");
				}
			});
			
			//Jon summary action dropsown box!	
			$("div.action-sort-box").mouseup(function() {
				return false
			});
			$(document).mouseup(function(e) {
				if($(e.target).parent("a.action-sort, .action-sort-box").length==0) {
					$(".action-sort").children().removeClass("action-sort-active");
					$(".action-sort-box").hide();
				}
			});
			
			
			
			//job action dropdown2			
			 $(".action").click(function(e) {          
				e.preventDefault();
                $(this).siblings('.action-box').toggle();
				$(this).children().toggleClass("action-active");
            });
			
			
			$("div.action-box").mouseup(function() {
				return false
			});
			$(document).mouseup(function(e) {
				if($(e.target).parent("a.action, .action-box").length==0) {
					$(".action").children().removeClass("action-active");
					$(".action-box").hide();
				}
			});	
			
			//Header Navigation Dropdown			
			 $(".action-dropdown").click(function(e) {          
				e.preventDefault();
                $(this).siblings('.action-box-dropdown').toggle();
				$(this).children().toggleClass("action-active-dropdown");
            });
			
			
			$("div.action-box-dropdown").mouseup(function() {
				return false
			});
			$(document).mouseup(function(e) {
				if($(e.target).parent("a.action-dropdown, .action-box-dropdown").length==0) {
					$(".action-dropdown").children().removeClass("action-active-dropdown");
					$(".action-box-dropdown").hide();
				}
			});	
			
			
/*
* input text value display and hide
* need to define a unique ID while including the class in input-text
*/
var active_color = '#000'; // Colour of user provided text
var inactive_color = '#787878'; // Colour of default text
        
        $(document).ready(function() {
          $("input.default-value").css("color", inactive_color);
          var default_values = new Array();
          $("input.default-value").focus(function() {
            if (!default_values[this.id]) {
                default_values[this.id] = this.value;
            }
            if (this.value == default_values[this.id]) {
                 this.value = '';
                 this.style.color = active_color;
            }
			$(this).blur(function() {
              if (this.value == '') {
                this.style.color = inactive_color;
                this.value = default_values[this.id];
              }
            });
          });
        });
			
			
//dropdown menu for left column navigation
  //hide all the .submenu items and show first item when page loads
  //$('.submenu').hide()
  //$('.submenu:first').show();
  $('.left-menu a').click(function(){
	  //if this is expanded then make it collapse
	  $(this).toggleClass('closed_state');
	  $(this).next().toggle();
	  
	  });
	  
//job result table actions - Applicants resume expanded box
/*$('#job_result_table tr').click(function(){
	   var n = $("#job_item_detail_ab").length;
	   //alert(this.id);
	   var id = this.id;
	   if(n>0)
	   { 
		if($(this).next().hasClass('job_item_detail_abc'))
		{
			$(this).next().remove();
			$(this).removeClass('active_tr');
		}
		else
		{
			$('#job_item_detail_ab').remove();
			$('#job_result_table tr').removeClass('active_tr');
			$(this).addClass('active_tr');
		}
	   }
	   else
	   {
		   $(this).addClass('active_tr');
	   }
	});*/

//tabs
  //make first tab active and hide others
  $('.tab-container').hide();
  $('.tab-container:first').show();
  //make first tab active
  $('.tab-pannel li:first a').addClass('selected');
  $('.tab-pannel li a').click(function(event){
	  event.preventDefault();
	  $('.tab-pannel li a').removeClass('selected');
	  $(this).addClass('selected');
	  $('.tab-container').hide();
	  var showBox = '#'+$(this).attr('rel');
	  $(showBox).show();
	  });
  //on switching tabs show tab according to rel

//tooltip script
$(".tt").tooltip({
	
		// place tooltip on the right edge
		position: "center right",
	
		// a little tweaking of the position
		offset: [-2, 10],
	
		// use the built-in fadeIn/fadeOut effect
		effect: "fade",
	
		// custom opacity setting
		opacity: 0.7
	
	});
//hover color for table row
$('#job_result_table tr').hover(
	function()
	{
  		$(this).css('background', '#FFF2DC');	
	},
	function()
	{
		$(this).removeAttr('style');
	}
);

//hover for main menu
$('#nav li').hover(
	function()
	{
  		$(this).children('ul').show();	
	},
	function()
	{
		$(this).children('ul').hide();
	}
);



});

var loginbox_show = function()
{
    $("#sign_box").toggle();
	$(".sign_in").toggleClass("sign_in_active");
	$("#login").focus();
}

