var prev,next,current,c;
var fadein_delay=400
var fadeout_delay=0
$(document).ready(function(){
	if($('#fquery').length){
		$('#fquery').sSelect();
	}
	if($('#fcountry').length){
		$('#fcountry').sSelect();
	}

	if($(".listing").length){
		$(".job_block").hide();
		$(".listing .link" ).each(
			function( intIndex ){
				$( this ).bind (
				"click",
				function(){
					if($("#"+$(this).attr('id')+"_data").is(':hidden')){
						$(".listing .job_block").hide();
						$(".listing a.link").removeClass('open');
						$("#"+$(this).attr('id')+"_data").show();
						$(this).addClass('open');
					}else{
						$("#"+$(this).attr('id')+"_data").hide();
						$(this).removeClass('open');
					}
					return false;
				});
			});
	}
	if($('#slide .entry').length){
		$("#slide .entry").hide();
		$("#slide .entry:first").fadeIn(fadein_delay,function(){
			$(".homes").css("background","url(images/bgr-masthome1.jpg) no-repeat center top");
			$(".homes_out").css("background","url(images/bgr-strip1.jpg) repeat-x");
		});
		c=$("#slide .entry").size();
		current=parseInt($("#slide .entry:visible").attr('id').slice(5));

		$("#slide .prev").click(function(){
			prev=current-1;
			if(prev<1) prev=c;
			$("#slide .entry:visible").hide(fadeout_delay,function(){
				$("#slide #entry"+prev).fadeIn(fadein_delay,function(){
					$(".homes_out").css("background","url(images/bgr-strip"+prev+".jpg) repeat-x");
					$(".homes").css("background","url(images/bgr-masthome"+prev+".jpg) no-repeat center top");
				});
			});
			current=prev
			return false;
		});
		$("#slide .next").click(function(){
			next=current+1;
			if(next>c) next=1;
			$("#slide .entry:visible").hide(fadeout_delay,function(){

				$("#slide #entry"+next).fadeIn(fadein_delay,function(){
					$(".homes_out").css("background","url(images/bgr-strip"+next+".jpg) repeat-x");
					$(".homes").css("background","url(images/bgr-masthome"+next+".png) no-repeat center top");
				});
			});
			current=next
			return false;
		});
	}
});
