jQuery.extend({
	
	modal:function(navurl,title,box_width,box_height, couleur, produit)
	{
	    var offset={};
	    var options =
	    {
	    margin:0,
	    border:0,
	    padding:0,
	    scroll:0
	    };
	    //alert(navurl);
	    var win_width =$(window).width();
	    var scrollToLeft=$(window).scrollLeft();
	    var win_height =$(window).height();
	    var scrollToBottom=$(window).scrollTop();
	    var wleft =((win_width/2 )-(box_width/2))+15;
	    var wtop  =((win_height/2)-(box_height/2))+15;
	    w2=box_width-30;		// largeur du DIV qui contient la frame
	    h2=box_height-30;		// hauteur du DIV qui contient la frame
	    
	    toph=0;			// top du header
	    lefth=0;			// left du header
	    widthh=w2;			// largeur du header
	    heighth=25;			// hauteur du hauteur
	    
	    topf=wtop+10;		// a priori, ne sert à rien ....
	    leftf= wleft+10; 		// a priori, ne sert à rien ....
	    wf= (w2-20);		// largeur de la iFRAME
	    hf= (h2-20-heighth);	// hauteur de la iFRAME
	    
	    limg=(widthh+lefth-25);
	    timg=toph;
	    wimg=24;
	    himg=24;
	    if (produit ==0)
	    {
	    param="<div id='ak_modal_div' style='background-color: #FFFFFF; z-index:120;'>";
	    param+="<div name='header_modal' style='background-color: white; left:"+lefth+"px; top:"+toph+"px; width:"+widthh+"px; height:"+heighth+"px;  overflow: visible'>";
	    //param+=title+"<div style='position: absolute; left:"+limg+"; top:"+timg+"; height:"+himg+"; width"+wimg+"; border: solid red 1px;'>";
	    //param+="<img src='include/navigate_cross.png' width='24' height='24' border='0' title='Cliquez pour fermer la fenetre' id='close' style='pointer:hand; z-Index:120;'></div></div>";
	    param+="<table border='0' width='100%'><tr><td>"+title+"</td><td align='right'><img src='include/navigate_cross.png' width='24' height='24' border='0' title='Cliquez pour fermer la fenetre' id='close' style='pointer:hand; z-Index:120;'></td></tr></table>";
	    param+="</div><iframe width='"+wf+"' height='"+hf+"'  frameborder='0' marginwidth='10' marginheight='0' scrolling='auto'  id='frmTest' name='frmTest' src='"+navurl+"'></iframe>";
	    param+="</div>";	    
	    $('body').append(param);
	    $('#ak_modal_div').css({
				   	position: 'absolute',
				   	top: wtop,
					left: wleft,
					width: w2+'px',
					height: h2+'px',
					border: 'solid yellow 1px'
					
					
	   			   });
	    }
	    if (produit ==1)
	    {
	    param="<div id='ak_modal_div2' style='background-color: #FFFFFF; z-index:120; position:absolute; top:0; left:0; padding:10'>";
	    param+="<div name='header_modal' style='background-color: white; left:"+(lefth+100)+"px; top:"+toph+"px; width:"+(widthh+100)+"px; height:"+heighth+"px;  overflow: visible'>";
	    param+="<table border='0' width='100%'><tr><td align='right'>Cliquez sur la croix pour fermer la fen&ecirc;tre&nbsp;&nbsp;</td><td align='right'><img src='../include/navigate_cross.png' width='24' height='24' border='0' title='Cliquez pour fermer la fenetre' id='close2' style='pointer:hand; z-Index:120;'></td></tr></table>";
	    param+="</div><iframe width='"+(wf+100)+"' height='"+(hf+100)+"'  frameborder='1' style='border-left: solid lightgreen 2px; border-top: solid lightgreen 2px;' marginwidth='0' marginheight='0' scrolling='auto'  id='frmTest' name='frmTest' src='"+navurl+"'></iframe>";
	    param+="</div>";	
	    $('body').append(param);
	    $('#ak_modal_div2').css({
				   	position: 'absolute',
				   	top: 0,
					left: 0,
					width: (w2+20)+'px',
					height: h2+'px'
	   			   });
	   
	    }
	    
	    
	    
	  
	    $('#close').click( function() 
	    {
	       // 
	       $('#ak_modal_div').fadeOut(500);
	       $('#ak_modal_div').remove();
	       $('#__dimScreenfond').fadeOut(500);
	       $('#__dimScreenfond').remove();
	        $.dimScreenStop();
	    });
	    
	    $('#close2').click( function() 
	    {
	       // 
	       $('#ak_modal_div2').fadeOut(500);
	       $('#ak_modal_div2').remove();
	       /*$('#__dimScreenfond').fadeOut(500);
	       $('#__dimScreenfond').remove();*/
	        $.dimScreenStop();
	    });
	    // appel de la fonction qui dessine le fond ...
	    if (produit == 0)
	    {
	    	$.dimScreen2(500, 0.7, function() {$('#ak_modal_div').fadeIn(500);},box_width, box_height, couleur,produit);
	    }
	    if (produit == 1)
	    {
		 $.dimScreen2(500, 0.7, function() {$('#ak_modal_div2').fadeIn(500);},1000, 1000, couleur,produit);	 
	    }
	    var offset = {}
	    offset=$("#ak_modal_div").offset({ scroll: false })
	
  	    X_left=offset.left+box_width-16;
	    X_top=offset.top;

	    $('#close').css({left:X_left,top:X_top});
	    


	},
	
	akModalRemove:function()
	{
	   $('#ak_modal_div').fadeOut(3500);
	   $('#ak_modal_div2').fadeOut(1500);
	   $.dimScreenStop();
	},
	
	akModalHideAndRedirect:function(redirect_url)
	{
	    $('#ak_modal_div').fadeOut(3500);
	     $('#ak_modal_div2').fadeOut(3500);
	    $.dimScreenStop();
	    window.location=redirect_url;
	}
});	