/* jQpopup - jQuery Popup Box v0.2.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
 */
jQuery.jQpopup={minHeight:100,minWidth:200,imagePath:"images/",popupwrapper:null,box:function(object_id){var popupwrapper='<div id="'+object_id+'_p" class="jqpopup">';
popupwrapper+='<div class="jqpopup_header"><div id="'+object_id+'_ph"></div>';
popupwrapper+="<div>";
//popupwrapper+='<div id="'+object_id+'_pl" class="jqpopup_center"></div>';
popupwrapper+='<div id="'+object_id+'_px" class="jqpopup_cross"></div>';
popupwrapper+="</div>";
popupwrapper+="</div>";
popupwrapper+='<div id="'+object_id+'_pm" class="jqpopup_message"></div>';
popupwrapper+='<div id="'+object_id+'_pc" class="jqpopup_content"></div>';
popupwrapper+='<div id="'+object_id+'_pf" class="jqpopup_footer"></div>';
popupwrapper+='<div id="'+object_id+'_ps" class="jqpopup_resize"></div>';
popupwrapper+="</div>";
return popupwrapper
},toTopEvent:function(e){var rid=(this.id).substr(0,this.id.length-1);
var zMax=0;
jQuery(".jqpopup").each(function(index){if(jQuery(this).css("zIndex")>zMax){zMax=jQuery(this).css("zIndex")
}});
var val=parseInt(zMax)+1;
jQuery("#"+rid).css("zIndex",val)
},toTop:function(id){var str=id.substr(id.length-2);
var rid=id;
if(str!="_p"){rid+="_p"
}var zMax=0;
jQuery(".jqpopup").each(function(index){if(jQuery(this).css("zIndex")>zMax){zMax=jQuery(this).css("zIndex")
}});
var val=parseInt(zMax)+1;
jQuery("#"+rid).css("zIndex",val)
},toCenter:function(id){var top=parseInt(jQuery(window).scrollTop());
var left=parseInt(jQuery(window).scrollLeft());
var rid=id+"_p";
var pos=jQuery("#"+rid).offset();
var box_x=parseInt(jQuery("#"+rid).width());
var box_y=parseInt(jQuery("#"+rid).height());
var center_x=parseInt(jQuery(window).width())/2-box_x/2+left;
var center_y=parseInt(jQuery(window).height())/2-box_y/2+top;
jQuery("#"+rid).css({left:center_x,top:center_y})
},open:function(object_id){if(jQuery("#"+object_id).html()!=""){var content=jQuery.jQpopup.box(object_id);
jQuery("body").append(content);
jQuery("#"+object_id+"_p").bgiframe();
jQuery("#"+object_id+"_p").jqDrag(".jqpopup_header").jqResize(".jqpopup_resize");
jQuery("#"+object_id+"_px").unbind("click");
jQuery("#"+object_id+"_px").bind("click",function(){jQuery("#"+object_id).jqpopup_close()
});
jQuery("#"+object_id+"_pl").unbind("click");
jQuery("#"+object_id+"_pl").bind("click",function(){jQuery("#"+object_id).jqpopup_toCenter(this.id)
});
var pos=0;
var popup_x=parseInt(pos.left)+(0);
var popup_y=parseInt(pos.top)+parseInt(0);
jQuery("#"+object_id+"_p").css({left:popup_x,top:popup_y});
var popup_content=jQuery("#"+object_id).clone(true);
var title=jQuery("#"+object_id).attr("title");
jQuery("#"+object_id+"_ph").html(title);
jQuery("#"+object_id+"_pc").html(popup_content.show());
jQuery("#"+object_id+"_p").show();
jQuery("#"+object_id+"_ph").mousedown(jQuery.jQpopup.toTopEvent);
jQuery("#"+object_id).empty();
if(jQuery("#"+object_id+"_p").height()<jQuery.jQpopup.minHeight){jQuery("#"+object_id+"_p").css("height",jQuery.jQpopup.minHeight+14)
}else{jQuery("#"+object_id+"_p").css("height",jQuery("#"+object_id+"_p").height()+14)
}if(jQuery("#"+object_id+"_p").width()<jQuery.jQpopup.minWidth){jQuery("#"+object_id+"_p").css("width",jQuery.jQpopup.minWidth)
}jQuery("#"+object_id+"_p").jqpopup_toTop()
}},close:function(object_id){var content=jQuery("#"+object_id+"_pc").clone(true);
jQuery("#"+object_id).html(content.show());
jQuery("#"+object_id+"_pc").empty();
jQuery("#"+object_id+"_p").hide()
}};
jQuery.fn.extend({jqpopup_close:function(){return this.each(function(){jQuery.jQpopup.close(this.id)
})
},jqpopup_open:function(){return this.each(function(){jQuery.jQpopup.open(this.id)
})
},jqpopup_toCenter:function(){return this.each(function(){jQuery.jQpopup.toCenter(this.id)
})
},jqpopup_toTop:function(){return this.each(function(){jQuery.jQpopup.toTop(this.id)
})
}});
