/* Pra.ui Javascript Updated: Thu 3.10.08 @ 10:33 p.m. Author: Chencheng (sorrycc@gmail.com) —————————————————-*/
(function(){var $=window.jQuery?window.jQuery:null;var c=window.Pra={loadScript:function(a,b){var o={random:true};if(b)$.extend(o,b);var f=document.createElement('script');f.type='text/javascript';var d=new Date();if(o.random){if(a.match(/.*\?.*/)){a=a+'&random='+d.getTime()+parseInt(Math.random()*10000)}else{a=a+'?random='+d.getTime()+parseInt(Math.random()*10000)}}f.src=a;$('head')[0].appendChild(f)}};c.pg=$.extend($.fn,{tab:function(b){var o={tab:'.tab',tablet:'.tablet',li:'li',s:'.s',event:'click'};if(b)$.extend(o,b);return $(this).each(function(){var a=$(this).find(o.tab+' '+o.li),tablet=$(this).find(o.tablet+'>'+o.s);a.each(function(i){$(this).find('a').bind(o.event,function(){if(!/\bcurrent\b/.test($(a[i]).attr('class'))){a.filter('.current').removeClass('current');tablet.filter('.current').removeClass('current');$(a[i]).addClass('current');$(tablet[i]).addClass('current')}this.blur();return false})})})},resizeImage:function(a){var o={width:130,height:130};if(a)$.extend(o,a);return $(this).each(function(){var w=this.width;var h=this.height;if(w>h){this.width=o.width;this.height=h/w*o.height}else{this.height=o.height;this.width=w/h*o.width}})}});$.extend(c,{flash:function(a){var o={url:'',w:0,h:0,wmode:'transparent',back:false,name:null};if(a)$.extend(o,a);o.name=o.name==null?'':o.name;var s='';s+='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+o.w+'" height="'+o.h+'" id="'+o.name+'">';s+='	<param name="movie" value="'+o.url+'" />';s+='	<param name="quality" value="high" />';s+='	<param name="allowScriptAccess" value="always" />';s+='	<param name="wmode" value="'+o.wmode+'" />';s+='	<embed wmode="'+o.wmode+'" src="'+o.url+'" quality="high" allowScriptAccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+o.w+'" height="'+o.h+'" name="'+o.name+'"></embed>';s+='</object>';if(o.back)return s;else document.write(s)}})})();(function(){Pra.ui={drag:function(a,o){if(!o)var o={};this.element=a;this.options={};$.extend(this.options,o);$.extend(this.options,{handle:o.handle?($(o.handle,a)[0]?$(o.handle,a):$(a)):$(a),helper:o.helper||'original'});o=this.options;var b=this;this.mousedownfunc=function(e){return b.click.apply(b,[e])};o.handle.bind('mousedown',this.mousedownfunc)},sort:function(a,o){if(!o)var o={};this.element=a;var b=this;this.options={};$.extend(this.options,o);$.extend(this.options,{items:o.items||'> li',_drag:function(h,p,c,t,e){b.drag.apply(t,[b,e])}});o=this.options;var d=$(o.items,a),set=[];d.each(function(){set.push(this)});this.m=set;d.drag(o)},overlay:function(a,b){var o={close:false,zIndex:999,bgColor:'black',opacity:0.6,height:document.documentElement.scrollHeight>=document.documentElement.clientHeight?document.documentElement.scrollHeight:document.documentElement.clientHeight};if(a)$.extend(o,a);if($('#overlay_frame')[0])if($('#overlay_frame').css('display')=='none'&&!o.close)$('#overlay_frame').css('height',o.height).show();else $('#overlay_frame').hide();else{$('<iframe>').attr('id','overlay_frame').css({position:'absolute',left:0,top:0,background:'red',zIndex:998,width:'100%',border:0,opacity:0,height:o.height}).appendTo('body')}if($('#overlay')[0])if($('#overlay').css('display')=='none'&&!o.close)$('#overlay').css('height',o.height).show();else $('#overlay').hide();else{$('<div>').attr('id','overlay').css({position:'absolute',left:0,top:0,background:o.bgColor,zIndex:o.zIndex,opacity:o.opacity,width:'100%',height:document.documentElement.scrollHeight}).appendTo('body')}if(!$('#overlay_frame')[0]&&!$('#overlay')[0]&&b)b();$(window).resize(function(){})},color:function(){var a=['00','33','66','99','CC','FF'],sp=['FF0000','00FF00','0000FF','FFFF00','00FFFF','FF00FF'],s=['<ul>'];for(var i=0;i<2;i++){for(var j=0;j<6;j++){var b=a[j]+a[j]+a[j];s.push('<li style="background:#000000"><a href="" title="#000000"></a></li>');if(i==0)s.push('<li style="background:#'+b+'"><a href="" title="'+b+'"></a></li>');else s.push('<li style="background:#'+sp[j]+'"><a href="" title="'+sp[j]+'"></a></li>');s.push('<li style="background:#000000"><a href="" title="#000000"></a></li>');for(var k=0;k<3;k++){for(var l=0;l<6;l++){var c=a[k+i*3]+a[l]+a[j];s.push('<li style="background:#'+c+'"><a href="" title="#'+c+'"></a></li>')}}}}s.push('</ul>');return s.join('')}};$.extend(Pra.ui.sort.prototype,{init:false,drag:function(a,e){var e=e||window.event,found=null,max_distance=1000000000;for(var i=0;i<a.m.length;i++){var b=a.m[i];if(this.element==b)continue;var c=Math.sqrt(Math.pow(e.clientX-$(b).offset().left,2)+Math.pow(e.clientY+document.documentElement.scrollTop-$(b).offset().top,2));if(c<max_distance){max_distance=c;found=b}}if(found!=null){if(!$(found).next()[0]||found.nextSibling==this.helper){var d=Math.sqrt(Math.pow(e.clientX-($(b).offset().left+b.offsetWidth),2)+Math.pow(e.clientY-$(b).offset().top,2));$(this.helper).insertBefore(found);return}else{$(this.helper).insertBefore(found)}}}});$.extend(Pra.ui.drag.prototype,{init:false,click:function(e){if(e.which!=1)return true;var a=this.element;var b=this;b.opos=[e.clientX,e.clientY];b.rpos=[a.offsetLeft,a.offsetTop];this.mousemove=function(e){return b.drag.apply(b,[e])};this.mouseup=function(e){return b.stop.apply(b,[e])};document.onmousemove=this.mousemove;document.onmouseup=this.mouseup;if($.browser.msie)a.onselectstart=function(){return false}},drag:function(e){var e=e||window.event,o=this.options;this.pos=[e.clientX+(this.rpos[0]-this.opos[0]),e.clientY+(this.rpos[1]-this.opos[1])];$(this.element).css({left:this.pos[0],top:this.pos[1]});if(!this.init)this.start.apply(this,[e]);if(o._drag){o._drag.apply(this.element,[this.helper,this.pos,o.cursorAt,this,e])}},start:function(e){var e=e||window.event;var o=this.options,a=this.element;this.helper=typeof o.helper=='function'?$(o.helper.apply(a,[e,this]))[0]:(o.helper=='clone'?$(a).clone()[0]:a);$(this.helper).insertBefore(a);this.init=true;$(a).css({position:'absolute',zIndex:9999,left:this.rpos[0],top:this.rpos[1]});if(o.opacity){$(a).css('opacity',o.opacity)}$(document.body).css('cursor','move')},stop:function(){var a=this.element,self=this,o=this.options;this.init=false;this.pos=this.opos=this.rpos=null;document.onmousemove=null;document.onmouseup=null;var b=function(){$(document.body).css('cursor','');$(a).css({position:'',zIndex:'',left:'',top:'',opacity:''});if(self.helper&&self.helper!=a){$(a).insertAfter(self.helper);$(self.helper).remove();self.helper=null}if(o.callback){o.callback()}};if(o.animate){$(a).animate({left:this.rpos[0],top:this.rpos[1]},300,b);return false}b();return false}});$.extend(Pra.pg,{drag:function(o){return this.each(function(){new Pra.ui.drag(this,o)})},sort:function(o){return this.each(function(){new Pra.ui.sort(this,o)})},dialog:function(a){var o={};if(a)$.extend(o,a);if(o.overlay)Pra.ui.overlay({bgColor:o.bgColor,opacity:o.opacity});return this.each(function(){if(!$(this).find('iframe')[0]&&!$(this).find('.opacity')[0]){if($.browser.msie)$('<iframe>').css({position:'absolute',left:0,top:0,width:this.clientWidth,height:this.clientHeight,opacity:0}).appendTo(this);$('<div>').addClass('opacity').css({position:'absolute',right:0,bottom:0,width:this.clientWidth-2,height:this.clientHeight-2,background:'black',opacity:0.1}).appendTo(this)}$(this).css('overflow','hidden')})},updateDialog:function(){return this.each(function(){if($.browser.msie)$(this).find('iframe').css('height',this.clientHeight);$(this).find('.opacity').css('height',this.clientHeight-2)})},color:function(b){return this.each(function(){$(this).click(function(e){var e=e||window.event,l=e.pageX||e.clientX+document.documentElement.scrollLeft,t=e.pageY||e.clientX+document.documentElement.scrollTop,target=e.srcElement||e.target;if(!$('#ColorPicker')[0]){$('<div id="ColorPicker">'+Pra.ui.color()+'<iframe></iframe></div>').css({left:l+4,top:t+2}).appendTo('body')}else{$('#ColorPicker').show().css({left:l,top:t})}$('#ColorPicker li a').unbind('click').click(function(){$('#ColorPicker').hide();var a=$(this).attr('title');$(target).css('background',a);if(b)b(a);this.blur();return false});this.blur();return false})})}})})();
