//========================================================
var gZoneHeight = 0;
var gScrollMaxHeight = 0;
var gScrollPos = 0;
var gScrollOffset = 18;
var gScrollTimer = null;
var gScrollSens = false;
//===========================
(function(jQuery) {

	jQuery.extend(jQuery.fn, {
		PaneScroll : function(opts) {
			var config = jQuery.extend({}, jQuery.fn.PaneScroll.defaults, opts || {});
			this.bind('mousedown', config, handleMouseDown);
			if (jQuery.fn.mousewheel) {
				this.mousewheel(function(e, delta) {
					this.scrollTop -= delta * config.mousewheelSpeed;
					e.preventDefault();
				});
			}
			if (!config.accesible) {
				this.css({ overflow: 'hidden' });
			}
			return this;
		}
	
	});
  
	function handleMouseDown(e) {
		jQuery(document).data('PaneScroll', {
			element: this,
			scroll: this.scrollTop,
			y : e.clientY,
			config : e.data
		}).bind('mousemove.PaneScroll', handleMouseMove).bind('mouseup.PaneScroll', handleMouseUp);
		e.preventDefault();
	}
  
	function handleMouseMove(e) {
		var data = jQuery(this).data('PaneScroll');
		data.element.scrollTop = data.scroll + (data.y - e.clientY) * data.config.speed;
	}
  
	function handleMouseUp(e) {
		jQuery(this).removeData('PaneScroll').unbind('.PaneScroll');    
	}
  
	jQuery.fn.PaneScroll.defaults = {
		accesible: true,
		speed: 1.5,
		mousewheelSpeed : 25 
	};
  

})(jQuery);
//===========================
jQuery(document).ready(function(){
	 gZoneHeight = jQuery.iUtil.getSize(jQuery('.OFR_TblBody').get(0)).hb;
	 gScrollMaxHeight = jQuery.iUtil.getSize(jQuery('.OFR_Table').get(0)).hb;
	 gScrollMaxHeight = gScrollMaxHeight-(13*gScrollOffset);
	 //
	 jQuery('.OFR_TblBody').PaneScroll({accesible: false});
	 //
});
//===========================
function f_SelectCriteres(pSearch){
	if(pSearch == 1){
		jQuery('#OFFER_Search').val('SEARCH_Sector');
		jQuery('#LOFR_Criteres').submit();
	}else if(pSearch == 2){
		jQuery('#OFFER_Search').val('SEARCH_Keywords');
		jQuery('#LOFR_Criteres').submit();
	}
}
//===========================
function f_SearchButtons(pValue) {
  jQuery('#OFFER_Search').val('SEARCH_Position');
  jQuery('#LOFR_From').val(pValue);
  jQuery('#LOFR_Criteres').submit();
}
//===========================
var gObjClose = null;
function f_OffreDisplay(pOffreId, pObject, pLang) {
	//
	if(gObjClose){
		if(gObjClose.className=="BTN_ShowActif"){
			gObjClose.className="BTN_ShowInactif";
		}
	}
	jQuery("#OFF_AjaxView").hide();
	jQuery("#OFF_AjaxView").html('');
	jQuery.get("../includes/entreprises-offres/offre-display.php", { OFR_ID: pOffreId, OFR_LANG: pLang },
	function(pRecord){
	  //
	  if(jQuery.browser.msie){
		 /* jQuery('#OFF_AjaxView').append(pRecord); */
		 var __ElDiv = document.getElementById("OFF_AjaxView");
		 __ElDiv.innerHTML = pRecord;
	  }else{
		 jQuery("#OFF_AjaxView").html(pRecord);
	  }	 
	  jQuery("#OFF_AjaxView").fadeIn(100, function(){
			  gObjClose = pObject;
			  gObjClose.className="BTN_ShowActif";		
		});
	});

}
//===========================
function f_CoseAjaxView (){
	
	jQuery("#OFF_AjaxView").hide();
	 jQuery("#OFF_AjaxView").html('<img src="'+gOFR_ImgBackground+'" alt="" />');
	 jQuery("#OFF_AjaxView").fadeIn(100);
	 gObjClose.className="BTN_ShowInactif";
	 jQuery.post(gDirAppl+"functions/oma-funct-offres.php",{ OFFER_DeselectRcd: "yes" });
}
//===========================