jQuery.fn.xWin=function(cfg){cfg=cfg||{};cfg.obj="#"+$(this).attr("id");if(this.attr("xWin")=="done"){if(cfg.title){$(cfg.obj+" .xWin_tit span:first").html(cfg.title);};if(cfg.show){$(cfg.obj).fadeIn();};if(cfg.hide){$(cfg.obj).fadeOut();};if(cfg.destroy){$(cfg.obj).fadeOut().remove();};if(cfg.ret!=null){$(cfg.obj).attr("ret",cfg.ret);};return false;};cfg.width=cfg.width||200;cfg.height=cfg.height||180;cfg.top=cfg.top||50;cfg.left=cfg.left||50;cfg.minW=cfg.minW||50;cfg.minH=cfg.minH||50;cfg.maxW=cfg.maxW||0;cfg.maxH=cfg.maxH||0;cfg.minX=cfg.minX||-1;cfg.minY=cfg.minY||-1;if(cfg.inParent=="tak"){cfg.minX=0;cfg.minY=0;cfg.maxX=parseInt($(this).parent().width());cfg.maxY=parseInt($(this).parent().height());};cfg.title=cfg.title||"InterEuropol";cfg.dragging=false;cfg.resizing=false;tit='<div class="xWin_tit"><span class="xWin_title">'+cfg.title+'</span></div>';this.prepend(tit);this.css("z-index",1000);this.css("display","block");this.attr("xWin","done");cfg.oTit=$(cfg.obj+" .xWin_tit");if(cfg.start=="center"){cfg.left=screen.width/2-parseInt(cfg.width)/2;cfg.top=screen.height/2-parseInt(cfg.height)/2;};paint();$(cfg.obj).hide();if(cfg.show!="nie")$(cfg.obj).fadeIn();cfg.oTit.mousedown(function(e){cfg.dragging=true;cfg.drgOffX=e.clientX-$(cfg.obj).left().split("px")[0];cfg.drgOffY=e.clientY-$(cfg.obj).top().split("px")[0];});cfg.oRes.mousedown(function(e){cfg.resizing=true;cfg.resOffX=parseFloat(cfg.left)+parseFloat(cfg.width)-e.clientX;cfg.resOffY=parseFloat(cfg.top)+parseFloat(cfg.height)-e.clientY;});$(document).mousemove(function(e){if(cfg.inParent=="tak"){cfg.maxX=parseInt($(cfg.obj).parent().width());cfg.maxY=parseInt($(cfg.obj).parent().height());};if(cfg.dragging==true&&cfg.moveable=="tak"){pT=e.clientY-cfg.drgOffY;pL=e.clientX-cfg.drgOffX;aT=pT+$(cfg.obj).height();aL=pL+$(cfg.obj).width();okX=true;okY=true;if(parseFloat(cfg.minX)>=0)if(pL<parseFloat(cfg.minX))okX=false;if(parseFloat(cfg.maxX)>0)if(aL>=parseFloat(cfg.maxX))okX=false;if(parseFloat(cfg.minY)>=0)if(pT<parseFloat(cfg.minY))okY=false;if(parseFloat(cfg.maxY)>0)if(aT>parseFloat(cfg.maxY))okY=false;if(okX==true){cfg.left=pL;};if(okY==true){cfg.top=pT;};if(okX||okY){paint();};};if(cfg.resizing==true){w=e.clientX-parseFloat(cfg.left)+cfg.resOffX;h=e.clientY-parseFloat(cfg.top)+cfg.resOffY;aL=parseInt($(cfg.obj).left())+w+1;aT=parseInt($(cfg.obj).top())+h+1;okW=true;okH=true;if(w<parseFloat(cfg.minW))okW=false;if(parseFloat(cfg.maxW)>0)if(w>parseFloat(cfg.maxW))okW=false;if(aL>parseInt(cfg.maxX))okW=false;if(h<parseFloat(cfg.minH))okH=false;if(parseFloat(cfg.maxW)>0)if(h>parseFloat(cfg.maxH))okH=false;if(aT>parseInt(cfg.maxY))okH=false;if(okW)cfg.width=w;if(okH)cfg.height=h;if(okW||okH)paint();};});$(document).mouseup(function(){cfg.dragging=false;cfg.resizing=false;});this.mousedown(function(){zi=parseInt($(this).css("z-index"));$(".xWin").each(function(){zi++});$(this).css("z-index",zi);});if(cfg.resizable=="tak"){$(cfg.obj+" div.xWin_tit").dblclick(function(){boxize();});$(cfg.obj+" div.xWin_tit span.xWin_title_toScreen").click(function(){boxize();});};$(cfg.obj+" div.xWin_tit span.xWin_title_close").click(function(){$(cfg.obj).fadeOut();});function boxize(){if($(cfg.obj).attr("p")=="all"){$(cfg.obj+" div.xWin_tit span.xWin_title_toScreen").removeClass("xWin_title_toBox");cfg.top=$(cfg.obj).attr("pt");cfg.left=$(cfg.obj).attr("pl");cfg.width=$(cfg.obj).attr("pw");cfg.height=$(cfg.obj).attr("ph");$(cfg.obj).attr("p","");}else{$(cfg.obj+" div.xWin_tit span.xWin_title_toScreen").addClass("xWin_title_toBox");$(cfg.obj).attr("pw",parseInt($(cfg.obj).width()));$(cfg.obj).attr("ph",parseInt($(cfg.obj).height()));$(cfg.obj).attr("pt",parseInt($(cfg.obj).top()));$(cfg.obj).attr("pl",parseInt($(cfg.obj).left()));$(cfg.obj).attr("p","all");if(cfg.minX>=0)cfg.left=cfg.minX;else cfg.left=0;if(cfg.minY>=0)cfg.top=cfg.minY;else cfg.top=0;if(cfg.maxW>0)cfg.width=cfg.maxW;else cfg.width=screen.width;if(cfg.maxH>0)cfg.heigth=cfg.maxH;else cfg.height=screen.height;if(cfg.inParent=="true"){if(cfg.maxX>0)cfg.width=cfg.maxX;if(cfg.maxY>0)cfg.height=cfg.maxY;}else{if(cfg.maxX>0)cfg.width=parseInt(cfg.maxX)-parseInt(cfg.minX)-1;if(cfg.maxY>0)cfg.height=parseInt(cfg.maxY)-parseInt(cfg.minY)-1;};};paint();};function paint(){$(cfg.obj).width(cfg.width+"px");$(cfg.obj).height(cfg.height+"px");$(cfg.obj).top(cfg.top+"px");$(cfg.obj).left(cfg.left+"px");};};
