/*
 * jQuery  Plugin jQPOOOP v 1.0.16
 * http://www.dieroboter.com/jQPOOOP/
 *
 * Copyright (c) 2009 Esteban Martin Gimenez
 *http://www.dieroboter.com
 * Dual licensed under the MIT and GPL licenses.
 *Email:jqpooop@gmail.com
 * Date: 2009-08-12 20:42:16 
 * Revision: 25
 */
 
(function($) {

$.fn.jqpooop = function(){
    this.each( function(){
        alert(this);
    });
}

$.fn.jqpooop.options_default = {
		 Unique:true,
		 Top:0,
		 Left:0,
		 Mensaje:"Ninguno",
		 Position:"absolute",
		 Ajax:" ",
		 Id:"Id_jqpooop",
		 Center:"true",
		 Width:400,
		 Height:250,
		 Headmsg:"Alert message"
},

$.extend({
	'load':function(urlajax){
		$.ajax({
			'url':urlajax,
			'cache': false,
			'dataType': 'html',
			'type':'GET',
			success: function(msg)
			{
				$('<div id="'+ opc.Id +'" class="popup"><div class="button"><button id="botonpop'+ opc.Id +'" title="Fechar" onclick="$(this).parent().parent().remove()"><img src="js/jQPOOOP/close.gif"/></button></div>'+ msg +'</div>').appendTo(document.body);
				$('#'+opc.Id).css("width", opc.Width + "px");
				$('#'+opc.Id).css("height", opc.Height + "px");
				$('#'+opc.Id).css("display","");
				$('#'+opc.Id).css("z-index","1000");
				$('#'+opc.Id).css("position","absolute");
                setTimeout("jqpooop_center('" + opc.Id + "')", 100);
			}
		})
	}
});

$.jqpooop=function(options_user) {
    opc = $.extend( $.fn.jqpooop.options_default,options_user );
    if(opc.Unique==true && $('#'+opc.Id).length) {		
        return false;
    }
				
    if(opc.Ajax!='') {	
        this.load(opc.Ajax);	
        return false;
    }
		
    return false;
},

$.close=function(options_user) {
    opc = $.extend( $.fn.jqpooop.options_default,options_user );
    $('#'+opc.Id).remove();
}
})(jQuery);

function jqpooop_center(id) {
    var w = (($(window).width() - $('#' + id).outerWidth(true)) / 2) + $(window).scrollLeft(); 
    var h = (($(window).height() - $('#' + id).outerHeight(true)) / 2) + $(window).scrollTop();
    $('#' + id).css("top", h + "px");
    $('#' + id).css("left", w + "px");
}
