/**
*	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
  *   
 **/
 //Local Url
//var path="../../phase2/";

//Online Url for development folder
var path="../../development/";

jQuery.extend({
	
	showAkModal:function(navurl,title,box_width,box_height)
	{
	    var offset={};
	    var options ={
	    margin:1,
	    border:9,
	    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 id='ak_modal_div' style='text-align:center;background-repeat:repeat;background-image:url(signup_popup3_files/popup_shadow.png);width:500px;height:530px;padding-top:0px;border:1px solid black;position: absolute;z-index:1000;display:none;' ><div style='width:461px;color:white;display:block;padding-top:0px;margin-top:20px;margin-left:auto;border:0px solid black;'><IMG height=82 alt='' src='signup_popup3_files/popup_header.gif' width=420 border=0><IMG height=82 alt='' src='signup_popup3_files/popup_x.gif' width=40 border=0 id='close' style='cursor:pointer;'></div><iframe width='"+box_width+"' height='"+box_height+"'  frameborder=0 marginwidth='0' marginheight='0' scrolling='NO'  name='frmTest' src='"+navurl+"'></iframe></div>");
	    //$('body').append("<div id='ak_modal_div' style='background-repeat:no-repeat;text-align:center;width:483px;height:512px;padding-top:0px;position:absolute;z-index:1000;display:none;' ><div style='background-repeat:no-repeat;padding:0px;margin:0px;height:86px;'><img src='images/top_popup.png' width='483' height='86' /></div><div style='background-image:url(images/bottom_popup.png);background-repeat:no-repeat;width:483px;color:white;display:block;padding-top:0px;border:0px solid black;height:426px;'><iframe width='"+box_width+"' height='"+box_height+"'  frameborder=0 marginwidth='0' marginheight='0' scrolling='NO'  name='frmTest' src='"+navurl+"'></iframe></div></div>");
	    //$('body').append("<div id='ak_modal_div' style='background-repeat:no-repeat;text-align:center;width:467px;height:496px;padding-top:0px;position:absolute;z-index:1000;display:none;background-image:url(images/Untitled-1_03.gif)' ><div style='margin-left:auto;margin-right:auto;margin-top:80px;'><iframe width='"+box_width+"' height='"+box_height+"'  frameborder=0 marginwidth='0' marginheight='0' scrolling='NO'  name='frmTest' src='"+navurl+"'></iframe></div></div>");
	    
	    //$('body').append("<div id='ak_modal_div' style='text-align:center;padding-top:0px;width:"+box_width+"px;height:"+box_height+"px;position:absolute;z-index:1000;display:none;' ><iframe width='"+box_width+"' height='"+box_height+"'  frameborder=0 marginwidth='0' marginheight='0' scrolling='NO'  name='frmTest' src='"+navurl+"'></iframe></div>");
	    $('body').append("<div id='ak_modal_div' style='width:476px;text-align:center;padding-top:0px;position:absolute;z-index:1000;display:none;overflow:visible;' ><table cellspacing='0' cellpadding='0' border='0' width='476px' height='100%'><tr><td colspan='3'><img src='"+path+"images/modal_box_top.png' /></td></tr><tr><td style='width:10px;background-repeat:repeat-y;background-image:url("+path+"images/modal_box_left.png)'></td><td width='456px;' height='"+(box_height-60)+"'><iframe frameborder=0 marginwidth='0' marginheight='0' scrolling='NO' width='456' name='frmTest' src='"+navurl+"' height='"+(box_height-60)+"'></iframe></td><td style='background-repeat:repeat-y;width:10px;background-image:url("+path+"images/modal_box_right.png);'></td></tr><tr><td colspan='3' style='height:18px;' align='center'><img src='"+path+"images/modal_box_bottom.png' height='18' width='476px' /></td></tr></table></div>");
	    
	    
	    
	    
	    $('#ak_modal_div').css({left:(((win_width/2-box_width/2))+scrollToLeft)+'px',top:(((win_height/2-box_height/2))+scrollToBottom)+'px'});
	  
	    $('#close').click( function() {
	       // 
	       $('#ak_modal_div').fadeOut(500);
	       $('#ak_modal_div').remove();
	        $.dimScreenStop();
	    });
	    
	    $('img').click( function() {
	  	// 
	       $('#ak_modal_div').fadeOut(500);
	       $('#ak_modal_div').remove();
	        $.dimScreenStop();
	   });
	    $.dimScreen(500, 0.7, function() {
			$('#ak_modal_div').fadeIn(500);
	    });
	    
		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(500);
	   $.dimScreenStop();
	},
	
	akModalHideAndRedirect:function(redirect_url)
	{
	    $('#ak_modal_div').fadeOut(500);
	    $.dimScreenStop();
	    window.location=redirect_url;
	}
});	