/**
*	akModal-  simplest alternative to thickbox
*	author: Amit Kumar Singh 
* 	project url : http://amiworks.co.in/talk/akmodal-simplest-alternative-to-thickbox/
 * 	inspired from early versions of thickbox
 *	
**/
/**
  * Version 2.0.0
  *  @param String  navurl             url to dispaly in the ifame
  *  @param String  title      title of the pop up box
  *  @param  Numeric  box_width	width of the box in pixels
  *  @param  Numeric  box_height	height of the box in pixels
  *   
 **/

jQuery.extend({
	
	showAkModal:function(navurl,title,box_width,box_height,url)
	{
	    var offset={};
	    var options ={
	    margin:1,
	    border:1,
	    padding:1,
	    scroll:0
	    };
		
	    var win_width =$(window).width();
	    var scrollToLeft=$(window).scrollLeft();
	    var win_height =$(window).height();
	    var scrollToBottom=$(window).scrollTop();

	    //$('body').append("<div class='lightBoxHeading' id='lightBox' style='top:0px; position:absolute; z-index:2000; display:none; width:"+box_width+"px;'><div style='display:block; padding:2px 6px 2px 6px; margin-top:0px;'><div style='float:left; font-size:117%'>"+title+"</div><div align='right'><span id='close' style='cursor:pointer;'><img src='http://gsweb/wumclient/wum_mortgagev2/wum_mortgage/resources/images/btn_close.png' width='24' height='24' /></span></div></div><div id='loader' align='center' style='z-index:1800; display:block; background-color:#FFFFFF; padding:4px;'><img src='"+url+"resources/images/ajax-loader2.gif' /></div><iframe style='display:none;' width='"+box_width+"' height='"+box_height+"' frameborder='0' marginwidth='0' marginheight='0' scrolling='NO' name='frmlightBox' id='frmlightBox' src='"+navurl+"'></iframe></div>");
		//$('body').append("<div class='form_heading' id='lightBox' style='top:0px;padding:0px;margin-top:4px;position: absolute;z-index:2000;display:none; width:"+box_width+"px;' ><div style='display:block;padding:2px 6px;margin-top:0px;'><div style='float:left; font-size:117%' >"+title+"</div><div align='right'><span id='close' style=' cursor:pointer;'>Close</span></div></div><div id='loader' align='center' style='z-index:1800;display:block; background-color:#FFFFFF; padding:4px;'><img src='"+url+"resources/images/ajax-loader2.gif' /></div><iframe style='display:none;' width='"+box_width+"' height='"+box_height+"'  frameborder=0 marginwidth='0' marginheight='0' scrolling='NO'  name='frmlightBox' id='frmlightBox' src='"+navurl+"'></iframe></div>");
		$('body').append("<div class='lightBoxHeading' id='lightBox' style='top:0px; padding:0px; position:absolute; z-index:2000; display:none; width:"+box_width+"px;'><div class=\"lightBoxContent\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td width=\"90%\" class=\"lightBoxTitle\">"+title+"</td><td width=\"40\" id=\"close\"><img src=\"http://72.167.134.10/resources/images/btn_close.png\" width=\"24\" height=\"24\" /></td></tr></table></div><div id='loader' align='center' style='z-index:1800; display:block; background-color:#FFFFFF; padding:4px;'><img src='"+url+"resources/images/ajax-loader2.gif' /></div><iframe style='display:none;' width='"+box_width+"' height='"+box_height+"' frameborder='0' marginwidth='0' marginheight='0' scrolling='NO' name='frmlightBox' id='frmlightBox' src='"+navurl+"'></iframe></div>");
	    $('#lightBox').css({left:(((win_width/2-box_width/2))+scrollToLeft)+'px',top:(((win_height/2-box_height/2))+scrollToBottom)+'px'});
	 
	    $('#close').click( function() {
	       $('#lightBox').fadeOut(500);
	       $('#lightBox').remove();
	        $.dimScreenStop();
	    });
	    $.dimScreen(500, 0.7, function() {
		$('#lightBox').fadeIn(500);
		setTimeout(function (){$('#loader').fadeOut(500)},3000);
		setTimeout(function (){$('#frmlightBox').fadeIn(500)},3500);
	    });
	   
		var offset = {}
	    offset=$("#lightBox").offset({ scroll: false })

  	    X_left=offset.left+box_width-16;
	    X_top=offset.top;

	    $('#close').css({left:X_left,top:X_top});
	},
	
	akModalRemove:function()
	{
	   $('#lightBox').fadeOut(500);
	   $.dimScreenStop();
	},
	
	akModalHideAndRedirect:function(redirect_url)
	{
	    $('#lightBox').fadeOut(500);
	    $.dimScreenStop();
	    window.location=redirect_url;
	}
});	
