// JavaScript Document
jQuery(document).ready(function() {
$.ajaxSetup ({cache: true});
var ajax_load = "<img src='/wp-content/themes/sterland_oliver/js/images/loading.gif' alt='loading...' />";
$(".hide_if_javascript_enabled").css({ display: "none"});

// print button
$(".print").click(function(){
						   window.print();
						   return false;
						   })

$('.menu li ul.sub-menu').addClass('js_enabled').css({display:'none'});
$('.sub-menu').css({position:'absolute'});
$('.menu li, .menu li ul').hover(
	function(){
		$('ul', this).css({display:'block'});
	},
	function(){
		$('ul', this).css({display:'none'});
		//setTimeout('hideTip()', 1000);
	}
);

$('.arrow_down li ul').append('<li class="arrow_down" >&nbsp;</li>');
$('.arrow_up li ul').prepend('<li class="arrow_up" >&nbsp;</li>');


jQuery("#search_wrapper").css({ height: 0 }, 500);
jQuery("#search_btn").toggle(
    function() {
        jQuery("#search_wrapper").animate({ height: 40 }, 500);
    },
    function() {
        jQuery("#search_wrapper").animate({ height: 0 }, 500);
    }
);


jQuery('#scroll_top').click(function(){
	jQuery('html, body').animate({scrollTop:0}, 'slow');
	return false
});

$('#process_methods .title:first').addClass('help').attr({title:'click the titles to see our step by step processes'})
jQuery(".description").hide();
jQuery(".description:first").show()
jQuery(".title:first").addClass('active');
jQuery(".title, .description").click(
    function() {
        jQuery(".description").hide('fast');
		jQuery(".title").removeClass('active');
		jQuery(this).addClass('active').next(".description").show('fast');
    });


var js_title  = $(".js_title").html();
$('input[title*="apply"]').attr({value:js_title})

$('<link/>', {'href':'/wp-content/themes/sterland_oliver/js/colorbox.css','type':'text/css', 'rel':'stylesheet', 'media':'screen'}).appendTo('head');
$.getScript('/wp-content/themes/sterland_oliver/js/jquery.colorbox-min.js', function(){

					$(".apply").colorbox({width:"80%", inline:true, href:".apply_form"});
					$('.iframe_colorbox').colorbox({iframe:true, width:'80%', height:'80%'});

});//getScript

$('.help').mouseenter(function(){
					  var title = $(this).attr('title');
					  $(this).prepend('<span class="tooltip">' + title + '<img src="/wp-content/themes/sterland_oliver/images/trans/trans_triangle_85k_down.png" width="15" height="7" /></span>').css({position:'relative'})
					  $(this).mouseleave( function(){
												   $('span').remove('.tooltip')
												   })
					  })



});
// function hideTip() { $('ul.js_enabled').css({display:'none'});}

// hide/show a current opportunity and news item, on timer
//global vars
$.jobs_config =
{
g_job_counter : 2,
g_news_counter : 2,
g_job_count : $("#jobs_box > div").size(),
g_news_count : $("#news_box > a").size()
}

// initial hide
$("#featured_job_1").show().siblings().hide();
$("#featured_news_1").show().siblings().hide();

window.setInterval(function() {

    $("#featured_job_"+$.jobs_config.g_job_counter).show().siblings().hide();
    if( $.jobs_config.g_job_counter == $.jobs_config.g_job_count ) {
        $.jobs_config.g_job_counter = 1;
    } else {
        $.jobs_config.g_job_counter++;
    }

}, 10000);

window.setInterval(function() {

    $("#featured_news_"+$.jobs_config.g_news_counter).show().siblings().hide();
    if( $.jobs_config.g_news_counter == $.jobs_config.g_news_count ) {
        $.jobs_config.g_news_counter = 1;
    } else {
        $.jobs_config.g_news_counter++;
    }

}, 7000);

