
var $j = jQuery.noConflict();

$j(document).ready(function() {
  
  $j('select[name=localoffice]').prepend('<option value="" selected="selected">Please Select</option>');
  $j('select[name=localoffice],select[name=office],select[name=specialism]').addClass('required-entry');
  $j('select[name=localoffice]').val('');
  
  
  

	$j('.multiselect:not(.sector)').attr("multiple","multiple");
	if(typeof(locationJSON) !=  "undefined"){
	    $j('#category_select1').append(
	        $j('<option></option>').val("").html("All")
	    );
	    $j('#category_select2').append(
	        $j('<option></option>').val("").html("All")
	    );
	    $j('#category_select3').append(
	        $j('<option></option>').val("").html("All")
	    );
		for (var key in locationJSON){
		    $j('#category_select1').append(
		        $j('<option></option>').val(key).html(locationJSON[key]["name"])
		    );
		}

		$j("#category_select1").change(function(){
			$j('#category_hidden').val($j('#category_select1').val());
			$j('#category_select2').html("");
		    $j('#category_select2').append(
		        $j('<option></option>').val("").html("All")
		    );
			$j('#category_select3').html("");
		    $j('#category_select3').append(
		        $j('<option></option>').val("").html("All")
		    );

			for (var key in locationJSON[$j('#category_select1').val()]["locations"]){
			    $j('#category_select2').append(
			        $j('<option></option>').val(key).html(locationJSON[$j('#category_select1').val()]["locations"][key]["name"])
			    );
			}

			$j("#category_select2").trigger("change");
		});

		$j("#category_select2").change(function(){
			if($j('#category_select2').val()){
				$j('#category_hidden').val($j('#category_select2').val());
			}else{
				$j('#category_hidden').val($j('#category_select1').val());
			}
			$j('#category_select3').html("");
		    $j('#category_select3').append(
		        $j('<option></option>').val("").html("All")
		    );

			for (var key in locationJSON[$j('#category_select1').val()]["locations"][$j('#category_select2').val()]["locations"]){
			    $j('#category_select3').append(
			        $j('<option></option>').val(key).html(locationJSON[$j('#category_select1').val()]["locations"][$j('#category_select2').val()]["locations"][key]["name"])
			    );
			}
		});

    $j("#category_select3").change(function(){
      if($j('#category_select3').val() != ''){
        $j('#category_hidden').val($j('#category_select3').val());
      }else{
        if($j('#category_select2').val() != ''){
          $j('#category_hidden').val($j('#category_select2').val());
        }else{
          $j('#category_hidden').val($j('#category_select1').val());
        }
      }
    });

	}


	/* home tabs */


	$j("#home-tabs > li").click(function(){
			$j("#home-tabs > li").removeClass("active");
			$j("#home-tab-content > div").hide();
			var target = $j(this).find("a").attr("href");
			$j(this).addClass("active");
			$j(target).show();
	});

	$j("#home-tabs > li:eq(0)").trigger('click');

	/* offices */
	$j('.block-offices .block-content > ul > li').each(function(){
		$j(this).attr("subHeight",$j(this).find("ul").height());
	});
	$j('.block-offices .block-content > ul > li > ul').hide();

	$j('.block-offices .block-content > ul > li').mouseenter(
		function(){$j(this).find("ul").stop().animate(
			{height: $j(this).attr("subHeight")}
		)
	});
	$j('.block-offices .block-content > ul > li').mouseleave(
		function(){$j(this).find("ul").stop().animate(
			{height: 0}
		)
	});

	$j(".jCarouselLite").jCarouselLite({
	    auto: 2500,
	    speed: 200,
	    easing: "linear",
	    visible: 3
	});

	$j(".jCarouselLite2").jCarouselLite({
	    auto: 2500,
	    speed: 200,
	    easing: "linear",
	    visible: 1
	});


	/* HOT JOBS */
	if($j('.block-hot li').size() > 1){
		$j('.block-hot li:gt(0)').hide();

		$j('<a href="javascript:void">+ More</a>').appendTo('.block-hot .block-content').click(function(){
			$j('.block-hot li').show();
			$j(this).hide();
		});
	}
});

