/* jQpopup - jQuery Popup Box v0.1
 *  jQpopup is distributed under the terms of the MIT license
 *  For more information visit http://jqframework.com/jqpopup
 *  Copyright (C) 2009  jqframework.com
 * Do not remove this copyright message
 */

$.jQpopup={mousepos:{},objectsize:{},minHeight:100,minWidth:200,imagePath:"images/",popupwrapper:null,box:function(b){var a='<div id="'+b+'_p" class="jqpopup">';
a+='<div id="'+b+'_px" class="jqpopup_cross"></div>';
a+='<div class="jqpopup_header" id="'+b+'_ph"></div>';
a+='<div id="'+b+'_pm" class="jqpopup_message"></div>';
a+='<div id="'+b+'_pc" class="jqpopup_content"></div>';
a+='<div id="'+b+'_pf" class="jqpopup_footer"></div>';
a+='<div id="'+b+'_ps" class="jqpopup_resize"></div>';
a+='<div id="'+b+'_pl" class="jqpopup_center"></div>';
a+="</div>";
return a
},toTop:function(c){var b=(this.id).substr(0,this.id.length-1);
var a=0;
$(".jqpopup").each(function(e){if($(this).css("zIndex")>a){a=$(this).css("zIndex")
}});
var d=parseInt(a)+1;
$("#"+b).css("zIndex",d)
},toCenter:function(g){var c=g+"_p";
var f=$("#"+c).offset();
var e=parseInt($("#"+c).width());
var d=parseInt($("#"+c).height());
var b=parseInt($(window).width())/2-e/2;
var a=parseInt($(window).height())/2-d/2;
$("#"+c).css({left:b,top:a})
},open:function(b,f){var e=$.jQpopup.box(f);
if($("#"+f).html()!=""){$("body").append(e);
$("#"+f+"_p").bgiframe();
$("#"+f+"_p").jqDrag(".jqpopup_header").jqResize(".jqpopup_resize");
$("#"+f+"_px").bind("click",function(){$("#"+f).jqpopup_close()
});
$("#"+f+"_pl").bind("click",function(){$("#"+f).jqpopup_toCenter(this.id)
});
var h=$("#"+b).offset();
var d=parseInt(h.left)+(parseInt($("#"+b).width()/2));
var c=parseInt(h.top)+parseInt($("#"+b).height());
$("#"+f+"_p").css({left:d,top:c});
var a=$("#"+f).clone(true);
var g=$("#"+f).attr("title");
$("#"+f+"_ph").html(g);
$("#"+f+"_pc").html(a.show());
$("#"+f+"_p").show();
$("#"+f+"_ph").mousedown($.jQpopup.toTop);
$("#"+f).html("");
if($("#"+f+"_p").height()<$.jQpopup.minHeight){$("#"+f+"_p").css("height",$.jQpopup.minHeight)
}if($("#"+f+"_p").width()<$.jQpopup.minWidth){$("#"+f+"_p").css("width",$.jQpopup.minWidth)
}}},close:function(b){if($("#"+b+"_pc").html()!=""&&$("#"+b+"_pc").html()!=null){var a=$("#"+b+"_pc").clone(true);
$("#"+b).html(a.show());
$("#"+b+"_pc").html("");
$("#"+b+"_p").hide();
$("#"+b+"_ps").unbind("mousemove",$.jQpopup.resizeMove);
$("#"+b+"_ps").unbind("mouseup",$.jQpopup.resizeUp);
$("#"+b+"_ps").unbind("mouseout",$.jQpopup.resizeMove);
$("#"+b+"_ph").unbind("mousemove",$.jQpopup.mouseMove);
$("#"+b+"_ph").unbind("mouseup",$.jQpopup.mouseUp);
$("#"+b+"_ph").unbind("mouseout",$.jQpopup.mouseMove)
}}};
$.fn.extend({jqpopup_close:function(){return this.each(function(){$.jQpopup.close(this.id)
})
},jqpopup_open:function(a){return this.each(function(){$.jQpopup.open(a,this.id)
})
},jqpopup_toCenter:function(){return this.each(function(){$.jQpopup.toCenter(this.id)
})
}});