function pop(texte,type,choix,posTopRef)
{
	$('#dialog').jqmHide();
	$('.jqmWindow').removeClass("poperror popload popvalid").addClass(type);
   
   $('#contenuJqm').html(texte);
   var largeur=$(window).width()/2-parseInt($('#dialog').width()/2);
   var hauteur=$(window).height()/2-parseInt($('#dialog').height()/2);
   $('#dialog').css("left",largeur+"px");
	$('#dialog').css("top",hauteur+"px");
   
   if(choix=="close")
	{
	$('.jqmClose').show();
	$('.jqmChoice').hide();
	if(posTopRef) {
		var pos=$(posTopRef).findPos();
		$('#dialog').css("top",pos.y-parseInt($('#dialog').height()/2));
		}
	}
	
	else if(choix=="choice"){
	$('.jqmClose').hide();
	$('.jqmChoice').show();
	if(posTopRef) {
		var pos=$(posTopRef).findPos();
		$('#dialog').css("top",pos.y-parseInt($('#dialog').height()/2));
		}
	}
	else if(choix=="texte"){
	$('.jqmClose').hide();
	$('.jqmChoice').hide();
	if(posTopRef) {
		var pos=$(posTopRef).findPos();
		$('#dialog').css("top",pos.y-parseInt($('#dialog').height()/2));
		}
	$('#choixClos hr').remove();
	}
   $('#dialog').jqmShow();
   
   
}

function closepop(){
    $('#dialog').jqmHide();
}

jQuery.fn.extend({
   findPos : function() {
       obj = jQuery(this).get(0);
       var curleft = obj.offsetLeft || 0;
       var curtop = obj.offsetTop || 0;
       while (obj = obj.offsetParent) {
                curleft += obj.offsetLeft
                curtop += obj.offsetTop
       }
       return {x:curleft,y:curtop};
   }
});
