// JavaScript Document v1.5


/// ######## slideshow
// USER ADJUST
   <!-- put first image in jqs_slideshow DIV with width and height values -->
   var jqs_predelay=0; // delay in milliseconds before show starts
   var jqs_interval=2000; // interval in milliseconds between slides
   // program vars
   var cache = []; // top level array holding img elements  
   var jqsIndex=1; // index of next photo
   
     function jqs_slideshow() {
   // PROGRAM CODE
   // setup html
   if ( $('#jqs_slideshow_container img').length ) {
   var jsqsCont=$("#jqs_slideshow_container"); // main container
   $("#jqs_slideshow_container").css("width",jqs_width).css("height",jqs_height);
   var jqs=$("#jqs_slideshow"); $(jqs).css("position","relative");
   var jqsImg=$(jqs).html(); $(jqs).html('<div id="jqs_back">'+jqsImg+'</div><div id="jqs_front">'+jqsImg+'</div>');
    $("#jqs_back,#jqs_front").css("position",'absolute');
   $("#jqs_slideshow,#jqs_slideshow img,#jqs_back,#jqs_front").css("width",jqs_width).css("height",jqs_height).css("margin",0).css("padding",0).css("top",0).css("left",0);
   $("#jqs_back").css("z-index",'100'); $("#jqs_front").css("z-index",'102');
   johnnycache(); // start caching images running ahead of slideshow interval
   var walk=setTimeout("walktheline()",jqs_predelay); // do the slideshow
   }
   }   
   function walktheline() {
		$("#jqs_front img").css("display","none");
		$("#jqs_front img").attr("src",jqs_dir+jqs_data[jqsIndex]);
		$("#jqs_front img").fadeIn(jqs_interval, function() {
			$("#jqs_back").html($("#jqs_front").html());
			jqsIndex=(jqsIndex<jqs_data.length-1)? jqsIndex+1 : 0;
			var jqsNext=setTimeout("walktheline()",jqs_interval); // do the slideshow
		});
   }

   function johnnycache() { 
   		var cache_delay=Math.floor(jqs_interval*.65);
   		if(cache.length<jqs_data.length-1) {
   		var cacheImage = document.createElement('img'); 
   		cacheImage.src = jqs_dir+jqs_data[cache.length+1]; 
		cache.push(cacheImage);
		var goCache=setTimeout("johnnycache()",cache_delay);
	  	}
	}   




function inputText() {
	
	$('#keyword,#salary_min,#salary_max').css('color','#444');
	$('#keyword,#salary_min,#salary_max').focus(function() {
	var tx=$(this).val()
  	if( tx=='KEYWORD' || tx.substr(-3)=='MIN' || tx.substr(-3)=='MAX' ) {
	$(this).css('color','#000'); $(this).val('');}
	});
}

$(document).ready(function() {
						   
      	inputText();
		jqs_slideshow();
	
	/// ######## widget
	$('#goSearch').click(function() { document.ablysearch.submit(); });
	$("#zones").change(function() { updateCountries(); });
	$("#countries").change(function() { updateCities('RoW');  });
	if(setCountry!='0') { updateCountries(); }

function updateCountries(thisCountry,thisCity) {
var zoneID=$("#zones").val();
	if(zoneID>0) {
	$("#countries_container").css('display','block');
		var op=co[zoneID].split(","); var opts='';
		for(var c=0;c<op.length;c++) { 
			var e=op[c].split("|"); var sx='';
			if(setCountry!='0' && e[0]==setCountry) { sx=' selected="selected" '; delete setCountry; }
			if(e[0].length>0) { opts+='<option value="'+e[0]+'" '+sx+'>'+e[1]+'</option>'; }
		}
	$("#countries_container select").html('<option value="0">&#8212;&nbsp;Countries</option>'+opts);
	updateCities();
	} else {
	$("#countries_container").css('display','none');
	$("#cities_container").css('display','none');
	}
}


function updateCities(cmd) {
 	countryCode=$("#countries").val();
	if(countryCode!=0) {
			for(var i=0;i<cc.length;i++) { if(cc[i]==countryCode) {
			// get match
				if(ci[i].length>0) {
				$("#cities_container").css('display','block');
						var op=ci[i].split(","); var opts='';
					for(var c=0;c<op.length;c++) { 
						var e=op[c].split("|"); var sx='';
						if(setCity!='0' && e[0]==setCity) { sx=' selected="selected" '; delete setCity; }
						if(e[0].length>0) { opts+='<option value="'+e[0]+'"'+sx+'>'+e[1]+'</option>'; }
					}
				$("#cities_container select").html('<option value="0">&#8212;&nbsp;Cities</option>'+opts);
				} else  {
				$("#cities_container").css('display','none');
				}
			// end get match	
				} }
	 } else {
	 	$("#cities_container").css('display','none');
	 }
}


$(".jobitem .jobtitle a").click(function() {
					$(".jobitem").css("display","none");	
					$(".resulttable").css("display","none");
					$(".resultreturn").css("display","block");
					$(this).parent().parent().parent().parent().css("display","block");
					$(".jobextra").css("display","block");

});

$(".resultreturn a").click(function() {
					$(".jobextra,.resulttable,.resultreturn,.buttonresponse").css("display","none");
					$(".jobitem").css("display","block");	
					$(".resulttable").css("display","block").css("width","100%");
					$(".pager").css("width","50%");
					$(".resulttable td").width('215px'); // workaround for td collapse
});

$(".apply_now").click(function() {
		$(".buttonresponse").fadeIn();
		$(this).parent().css("display","none");
	});







$(".mab").click(function() { var p='ma'; var t='to'; var i='il';
var str=$(this).attr("href").substr(29);str=str.replace("/", "@");	 
window.location.href= p+i+t+':'+str; return false;
});



/// end doc ready
 });

