// Javascript Library used by This website.
/*
 * This function show a text in the INPUT box and remove it when click on it
 * source http://remysharp.com/wp-content/uploads/2007/01/input_hint.html
 */
jQuery.fn.hint = function() {
	return this.each(function(){
		var t = $(this); // get jQuery version of 'this'
		var title = t.attr('title'); // get it once since it won't change
		if (title) { // only apply logic if the element has the attribute
			// on focus, set value to blank if current value matches title attr
			t.focus(function(){
				if (t.val() == title) { t.val(''); t.removeClass('blur'); }
			})
			// on blur, set value to title attr if text is blank
			t.blur(function(){
				if (t.val() == '') { t.val(title); t.addClass('blur'); }
			})
			// now change all inputs to title
			t.blur();
		}
	})				
}
			
/*
 * this function toggle an image plus.png and minus.png
 */ 
jQuery.toggleImg = function(imgObj){
	var	src= $("img#"+imgObj).attr("src");
	if (src == '/images/icons/plus.png') return '/images/icons/minus.png';
	else return '/images/icons/plus.png';
}


var fonctionLoad = function(service,fonction) {
// alert ('LOADING function, service = '+service+'/fonction = '+fonction);
loadXMLForm('formSelect','fonction','service/'+service,fonction) 
 
}

var regionLoad = function(pays,region) {
// alert ('LOADING function, service = '+service+'/fonction = '+fonction);
loadXMLForm('formSelect','region','country/'+pays,region) 
 
}
var departementLoad = function(region,departement) {

loadXMLForm('formSelect','departement','region/'+region,departement) 
 
}

var adsInfoTop = function() {
 $("#ads").load("http://telemaque.salaireonline.com/nav.php/adsinfo/zone/top");
 setTimeout(adsInfoTop,25 * 1000);
}
var adsInfoRight = function() {
 $("#adsInfoRight").load("http://telemaque.salaireonline.com/nav.php/adsinfo/zone/top");
 setTimeout(adsInfoRight,40 * 1000);
}

$(document).ready(function(){
$('#fonction').load(function(){
// alert ('LOADING function');

})
 $('#service').change(function(){loadXMLForm('formSelect','fonction','service/'+$(this).val(),'')});
$('#pays').change(function(){loadXMLForm('formSelect','region','country/'+$(this).val(),'')});
$('#region').change(function(){loadXMLForm('formSelect','departement','region/'+$(this).val(),'')});



	/* togle + - images for menus */
	$('#profil1').bind('click',function() {$("#profil").toggle();$("img#imgToggle1").attr("src",$.toggleImg("imgToggle1"));})
	$('#profil2').bind('click',function() {$("#rapport").toggle();$("img#imgToggle2").attr("src",$.toggleImg("imgToggle2"));})
	
//	$(function(){	$('.date-pick').datePicker({clickInput:true});});
//	$('label').Tooltip({track: true, delay: 0}); // display tooltip with LABEL tags

$(function(){ $('input:text').hint();	});
// $('#protected').change(updatePage);
// updatePage();

	
	/* display a div based on the select field value */
//	 	
   
 	
 	 	
	}
	);
	
	
