/**
*	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) {
        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();
        var fullnavurl = navurl.replace("CO=1", "full=1");

        $('body').append("<div id='ak_modal_div' style='clear: both; padding-top:0px; border:1px solid black; background-color:#FFF;position: absolute;z-index:1000;display:none; width: " + box_width + "px; height:" + (box_height + 32) + "px;' ><div style='background-color:#295F8C; color:white; display:block; padding-top:0px; margin-top:0px; font-family:Arial; position:relative; clear:both; text-align:center; float: left; border-bottom: solid 1px black; width: " + box_width + "px;'> <b>" + title + "</b><a href='" + fullnavurl + "' style='font-size: 10px; color: #c0c0c0; display: block; padding-left: 5px;'> Click to View in Full Screen </a><img src='/images/cross.png' id='closemodal' title='Click to Close' class='modalclose' /></div><iframe width='" + box_width + "' height='" + box_height + "'  frameborder=0 marginwidth='0' marginheight='0' scroll='auto' name='frmTest' id='frmTest' src='" + navurl + "'>Please Wait a Moment While the Page Loads...</iframe></div>");

        $('#ak_modal_div').css({ left: (((win_width / 2 - box_width / 2)) + scrollToLeft) + 'px', top: (((win_height / 2 - box_height / 2)) + scrollToBottom) + 'px' });
        
                  
        $('#closemodal').click(function() {
            //
            try { modalCloseEvent(); } catch (e) {
            }
            $('#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;
        X_top = offset.top - $(window).scrollTop();

        $('#closemodal').css({ right: -15, top: 0 });

    },

    akModalRemove: function() {
        $('#closemodal').click()
        //        $('#ak_modal_div').fadeOut(500);
        //        $('#ak_modal_div').remove();
        //        $.dimScreenStop();
        //        try { modalCloseEvent(); } catch (e) { }
    },

    akModalHideAndRedirect: function(redirect_url) {
        $('#ak_modal_div').fadeOut(500);
        $.dimScreenStop();
        window.location = redirect_url;
    }
});
