(function($){$.fn.extend({dragonDrop:function(settings){settings=$.extend({nextZ:2000,placeholder:null,width:null,top:null,left:null,centerOnScreen:true,centerTopEdge:false,curtain:false,draggable:true,movebtn:false,type:'box',enableClose:true,enableCloseEsc:false,enableMinMax:false,content:null,title:null,displayClass:'dragonWhite',autoScroll:true,dragOpacity:false,curtainOpacity:'0.5',horizontalSelector:false,verticalSelector:false,callbackMouseDown:null,callbackMouseMove:null,callbackMouseUp:null,callbackMin:null,callbackMax:null,callbackClose:null,confirmClose:false,curtainColor:'#000'},settings);if(settings.curtain)settings.autoScroll=false;$(this).each(function(){var dragObj=$(this);dragObj.addClass('dragon');dragObj.addClass(settings.displayClass);dragObj.css({zIndex:settings.nextZ});settings.nextZ++;if(settings.title){var titleObj=dragObj.find('.title');if(titleObj.length<1&&settings.type=='window'){var titleBar=$('<div />').addClass('titleBar').prependTo(dragObj);titleObj=$('<span />').addClass('title').prependTo(titleBar)}titleObj.html(settings.title)}var controlChildren=dragObj.children('.dragonControl');if(controlChildren.length>0){var control=controlChildren}else if(dragObj.hasClass('dragonControl')){var control=dragObj}else{var titleBar=dragObj.find('.titleBar');if(titleBar.length>0){titleBar.addClass('dragonControl');var control=titleBar}else{dragObj.addClass('dragonControl');var control=dragObj}}var hasActionBtn=true;if(settings.draggable&&settings.movebtn){move=$('<div><div>&nbsp;</div></div>').addClass('movebtn').prependTo(control)}if(settings.enableMinMax&&hasActionBtn){var min=dragObj.find('.min');if(min.length<1){min=$('<div><div>&nbsp;</div></div>').addClass('btn').addClass('min').prependTo(control)}min.children('div').click(function(e){window.dragon=$(this).parents('.dragon');window.dragon.addClass('dragonMinimized').children('.dragonContent').slideUp('fast',function(){settings.callbackMin?settings.callbackMin(e):null}).addClass('dragonContentMinimized').end().children('.dragonControl').addClass('dragonControlMinimized').children('.max').show().end().end().end().parent().hide()});var max=dragObj.find('.max');if(max.length<1){max=$('<div><div>&nbsp;</div></div>').addClass('btn').addClass('max').addClass('hide').prependTo(control)}max.click(function(e){window.dragon=$(this).parents('.dragon');window.dragon.removeClass('dragonMinimized').children('.dragonContent').slideDown('fast',function(){settings.callbackMax?settings.callbackMax(e):null}).removeClass('dragonContentMinimized').end().children('.dragonControl').removeClass('dragonControlMinimized').children('.min').show().end().end()})}if(settings.enableClose&&hasActionBtn){var close=dragObj.find('.close');if(close.length<1){close=$('<div><div>&nbsp;</div></div>').addClass('btn').addClass('close').prependTo(control)}close.click(function(e){window.dragon=$(this).parents('.dragon');if(settings.confirmClose&&!confirm(settings.confirmClose)){return false}window.dragon.slayDragon(settings.callbackClose,settings.curtain)})}if(settings.enableCloseEsc){$(document).keyup(function(e){if(e.keyCode==27){window.dragon=dragObj;if(settings.confirmClose&&!confirm(settings.confirmClose)){return false}dragObj.slayDragon(settings.callbackClose)}})}if(settings.content||settings.type=='window'){var content=dragObj.find('.dragonContent');if(content.length<1){content=$('<div />').addClass('dragonContent').appendTo(dragObj)}var contentType=typeof(settings.content);if(contentType=='object'){content.append(settings.content)}else{content.html(settings.content)}}dragObj.refreshDragProperties();if(settings.width)dragObj.css('width',settings.width+'px');if(settings.centerOnScreen&&settings.centerTopEdge)dragObj.centerTopEdge();else if(settings.centerOnScreen)dragObj.centerOnScreen();if(settings.top)dragObj.css('top',settings.top);if(settings.left)dragObj.css('left',settings.left);if(!settings.draggable)control.css('cursor','default');if(settings.draggable){control.bind('mousedown.DragonDrop',function(e){if(($(e.target).parent('a').length>0||$(e.target).is('a'))&&!$(e.target).is('.dragonControl')){return}if(e.which!=1){return}if(window.dragonMouseDown){$(document).triggerHandler('mouseup')}if($(e.target).parents('.close').length>0||$(e.target).parents('.min').length>0||$(e.target).parents('.max').length>0){$(e.target).click();return false}$(document).bind('mousedown.DragonDrop',function(e){return false});this.ondrag=function(){return false};window.dragonMouseDown=true;$('body').css('cursor','move');var innerWidth=$(window).width();var innerHeight=$(window).height();var dragon=null;var targetParents=$(e.target).parents('.dragon');if($(e.target).hasClass('dragon')){dragon=$(e.target)}else if(targetParents.length>0){dragon=$(targetParents.get(0))}if(dragon){dragon.container=dragon.parent();dragon.startZ=dragon.css('z-index');dragon.lastParent=$(dragon.parent());dragon.refreshDragProperties();if(settings.dragOpacity!==false){dragon.css({opacity:settings.dragOpacity})}dragon.mouse_relativeX=e.pageX-dragon.l;dragon.mouse_relativeY=e.pageY-dragon.t;var bodyMarginLeft=$.getBodyMarginLeft();var clientWidth=$(window).width();var clientHeight=$(window).height();var offsetX=document.documentElement.scrollLeft||document.body.scrollLeft;var offsetY=document.documentElement.scrollTop||document.body.scrollTop;dragon.moveX=!dragon.is(settings.verticalSelector);dragon.moveY=!dragon.is(settings.horizontalSelector);window.dragon=dragon;settings.callbackMouseDown?settings.callbackMouseDown(e):null;if(!dragon.container.is('body')){if($.browser.msie&&$.browser.version<7){var dragonCheckBox=dragon.find(':checkbox');if(dragonCheckBox.length>0){dragonCheckBox.filter(':checked').addClass('tmpDragonChecked')}dragon.css({position:'absolute',left:dragon.l,top:dragon.t,zIndex:settings.nextZ}).addClass('activeDragon').appendTo('body');if(dragonCheckBox.length>0){dragonCheckBox.each(function(){if($(this).hasClass('tmpDragonChecked')){this.checked=true}else{this.checked=false}})}}else{dragon.css({position:'absolute',left:dragon.l,top:dragon.t,zIndex:settings.nextZ}).addClass('activeDragon').appendTo('body')}}var mouse_x;var mouse_y;var newX;var newY;$(document).bind('mousemove.DragonDrop',function(e){dragon.moveX?mouse_x=e.pageX:null;dragon.moveY?mouse_y=e.pageY:null;newX=mouse_x-dragon.mouse_relativeX;newY=mouse_y-dragon.mouse_relativeY;if(settings.curtain){if(newX<-1*(bodyMarginLeft+offsetX))var newX=-1*(bodyMarginLeft+offsetX);if(newX+dragon.w+bodyMarginLeft>clientWidth+offsetX-5)var newX=clientWidth+offsetX-dragon.w-bodyMarginLeft-5;if(newY<offsetY)var newY=offsetY;if(newY+dragon.h>=clientHeight+offsetY)var newY=clientHeight+offsetY-dragon.h}dragon.moveX?dragon.css('left',newX):null;dragon.moveY?dragon.css('top',newY):null;if(settings.autoScroll){$.dragonScroll(e,'x',innerWidth,50,20);$.dragonScroll(e,'y',innerHeight,50,20)}settings.callbackMouseMove?settings.callbackMouseMove(e):null});$(document).bind('mouseup.DragonDrop',function(e){e.cancelBubble=true;e.stopPropagation();$('body').css('cursor','');clearInterval(window.dragonScrollInterval);$(document).unbind('mousemove.DragonDrop');$(document).unbind('mousedown.DragonDrop');$(document).unbind('mouseup.DragonDrop');if(settings.dragOpacity!==false){dragon.css({opacity:1})}settings.callbackMouseUp?settings.callbackMouseUp(e):null;$('.activeDragon').removeClass('activeDragon');window.dragonMouseDown=false})}})}});if(settings.curtain)$.dragonCurtain(settings);return this},slayDragon:function(callback,removeCurtain){this.fadeOut('fast',function(){$(this).remove();callback?callback():null});if(typeof removeCurtain!=undefined&&removeCurtain==true){$.dragonCurtainRemove()}},dragonRemove:function(){this.slayDragon()},unDragon:function(){this.unbind('mousemove.DragonDrop').unbind('mousedown.DragonDrop').unbind('mouseup.DragonDrop').css('z-index','').removeClass('dragon');return this},refreshDragProperties:function(){var offset=this.offset();this.w=this.width();this.h=this.height();this.t=offset.top;this.l=offset.left-$.getBodyMarginLeft();this.r=this.l+this.w;this.b=this.t+this.h;this.centerX=this.l+(this.w/2);this.centerY=this.t+(this.h/2);return this},centerOnScreen:function(animate){var w=$(window).width();var h=$(window).height();var offsetX=document.documentElement.scrollLeft||document.body.scrollLeft;var offsetY=document.documentElement.scrollTop||document.body.scrollTop;var bodyMarginLeft=$.getBodyMarginLeft();this.css('position','absolute');var leftEdge=(w/2)-(this.width()/2)+offsetX-bodyMarginLeft;var topEdge=(h/2)-(this.height()/2)+offsetY;if(topEdge<10){topEdge=10}if(animate){this.animate({left:leftEdge,top:topEdge})}else{this.css({left:leftEdge,top:topEdge})}return this},centerTopEdge:function(animate){var w=$(window).width();var h=$(window).height();var offsetX=document.documentElement.scrollLeft||document.body.scrollLeft;var offsetY=document.documentElement.scrollTop||document.body.scrollTop;var bodyMarginLeft=$.getBodyMarginLeft();this.css('position','absolute');var leftEdge=(w/2)-(this.width()/2)+offsetX-bodyMarginLeft;var topEdge=offsetY;if(animate){this.animate({left:leftEdge,top:topEdge})}else{this.css({left:leftEdge,top:topEdge})}return this},hoverTip:function(content){IMAGE_URL.charAt(-1)!='/'?IMAGE_URL2=IMAGE_URL+'/':IMAGE_URL2=IMAGE_URL;var ext=($.browser.msie&&$.browser.version<7)?'gif':'png';$(this).hover(function(e){$('#DragonDrop-hoverTip').remove();var hoverTipHTML='<img class="tl" src="'+IMAGE_URL2+'images/DragonDrop/hoverTip-tl.'+ext+'" /><div class="tm" style="background-image:url('+IMAGE_URL2+'images/DragonDrop/hoverTip-tm.'+ext+');"></div><img class="tr" src="'+IMAGE_URL2+'images/DragonDrop/hoverTip-tr.'+ext+'" />';hoverTipHTML+='<div class="mr" style="background-image:url('+IMAGE_URL2+'images/DragonDrop/hoverTip-mr.'+ext+');"><div class="ml" style="background-image:url('+IMAGE_URL2+'images/DragonDrop/hoverTip-ml.'+ext+');"></div></div>';hoverTipHTML+='<img class="bl" src="'+IMAGE_URL2+'images/DragonDrop/hoverTip-bl.'+ext+'" /><div class="bm" style="background-image:url('+IMAGE_URL2+'images/DragonDrop/hoverTip-bm.'+ext+');"></div><img class="br" src="'+IMAGE_URL2+'images/DragonDrop/hoverTip-br.'+ext+'" />';hoverTipHTML+='<img class="ba" src="'+IMAGE_URL2+'images/DragonDrop/hoverTip-arrow.'+ext+'" />';hoverTipObj=$('<div id="DragonDrop-hoverTip" />').appendTo('body').html(hoverTipHTML);hoverTipObj.find('.ml').append(content);hoverTipObjWidth=hoverTipObj.width();hoverTipObj.find('.tm').css('width',(hoverTipObjWidth-14)+'px');hoverTipObj.find('.ml').css('width',(hoverTipObjWidth-7)+'px');hoverTipObj.find('.bm').css('width',(hoverTipObjWidth-14)+'px');hoverTipObj.find('.mr').css('background-position',(hoverTipObjWidth-7)+'px 0');hoverTipObj.css({top:e.pageY-hoverTipObj.height()-5,left:e.pageX-19-$.getBodyMarginLeft(),zIndex:2000});if($.browser.msie){if($.browser.version<7){hoverTipObj.find('.ml').css('margin-left','-6px')}else{hoverTipObj.find('.ml').width(hoverTipObj.find('.ml').width()+6)}}},function(e){$('#DragonDrop-hoverTip').remove()});$(this).bind('mousemove.hoverTip',function(e){$('#DragonDrop-hoverTip').css({top:e.pageY-hoverTipObj.height()-5,left:e.pageX-19-$.getBodyMarginLeft()})})}});$.extend({dragonAlert:function(msg,settings){settings=$.extend({title:'myYearbook',enableClose:true,enableCloseEsc:true,enableMinMax:false,curtain:true,type:'window',width:300,centerOnScreen:true,centerTopEdge:false,displayClass:'dragonWhite',okImg:'btn_ok.gif',okCallback:null},settings);var alertDiv=$('<div />').text(msg).addClass('dragonDialog');IMAGE_URL.charAt(-1)!='/'?IMAGE_URL2=IMAGE_URL+'/':IMAGE_URL2=IMAGE_URL;$('<br /><img src="'+IMAGE_URL2+settings.okImg+'" />').click(function(){$(this).parents('.dragon').find('.dragonControl .close').trigger('click');if($.isFunction(settings.okCallback)){settings.okCallback()}}).appendTo(alertDiv);settings.content=alertDiv;var alertWindow=$('<div />').appendTo('body').hide().dragonDrop(settings).show('fast',function(){$(this).css('width','300px')});return alertWindow},dragonAlertHTML:function(msg,settings){settings=$.extend({title:'myYearbook',enableClose:true,enableCloseEsc:true,enableMinMax:false,curtain:true,type:'window',width:300,centerOnScreen:true,displayClass:'dragonWhite',okImg:'btn_ok.gif',okCallback:null},settings);var alertDiv=$('<div />').html(msg).addClass('dragonDialog');IMAGE_URL.charAt(-1)!='/'?IMAGE_URL2=IMAGE_URL+'/':IMAGE_URL2=IMAGE_URL;$('<br /><img src="'+IMAGE_URL2+settings.okImg+'" />').click(function(){$(this).parents('.dragon').find('.dragonControl .close').trigger('click');if($.isFunction(settings.okCallback)){settings.okCallback()}}).appendTo(alertDiv);settings.content=alertDiv;var alertWindow=$('<div />').appendTo('body').hide().dragonDrop(settings).show('fast',function(){$(this).css('width','300px')});return alertWindow},dragonConfirm:function(msg,settings){settings=jQuery.extend({title:'myYearbook',curtain:true,cancelImg:'images/buttons/cancel.gif',confirmImg:'images/buttons/ok.gif',width:300,confirmCallback:null,cancelCallback:null,displayClass:'dragonWhite'},settings);var popupDiv=$('<div />').html(msg).addClass('dragonDialog');var buttons=$('<div class="dragonButtons" />').appendTo(popupDiv);IMAGE_URL.charAt(-1)!='/'?IMAGE_URL2=IMAGE_URL+'/':IMAGE_URL2=IMAGE_URL;$('<img src="'+IMAGE_URL2+settings.confirmImg+'" />').click(function(){$(this).parents('.dragon').find('.dragonControl .close').trigger('click');if($.isFunction(settings.confirmCallback)){settings.confirmCallback()}}).appendTo(buttons);$('<img src="'+IMAGE_URL2+settings.cancelImg+'" border="0" alt="Cancel" />').click(function(){$(this).parents('.dragon').find('.dragonControl .close').trigger('click');if($.isFunction(settings.cancelCallback)){settings.cancelCallback()}}).appendTo(buttons);var confirmWindow=$('<div />').appendTo('body').hide().dragonDrop({title:settings.title,content:popupDiv,enableCloseEsc:true,enableMinMax:false,curtain:settings.curtain,type:'window',width:settings.width,centerOnScreen:true,displayClass:settings.displayClass}).show('fast',function(){$(this).css('width',settings.width)});return confirmWindow},dragonCurtainInterval:0,dragonCurtain:function(settings){if($('#dragonCurtain').length<1){settings=$.extend({window_scroll:true,zIndex:999,curtainColor:'#000',curtainOpacity:.5},settings);var offsetX=document.documentElement.scrollLeft||document.body.scrollLeft;var offsetY=document.documentElement.scrollTop||document.body.scrollTop;var bodyMarginLeft=$.getBodyMarginLeft();var curW=$(window).width();var curH=$('body').height();var curTop=0;var curLeft=offsetX-bodyMarginLeft;var winH=$(window).height();if(winH>curH){curH=winH;curTop=offsetY}var cur=$('<div />').attr('id','dragonCurtain').css({backgroundColor:settings.curtainColor,opacity:settings.curtainOpacity,MozOpacity:settings.curtainOpacity,filters:'alpha('+(settings.curtainOpacity*100)+')',position:'absolute',top:curTop,left:curLeft,width:curW,height:curH,zIndex:settings.zIndex}).appendTo('body').fadeIn('fast');var selector='iframe:not(#gameFrame)';$(selector).hide();if($.browser.msie&&$.browser.version<7){$('select:visible').addClass('curtainHide').hide()}if(!($.browser.msie)){$(window).bind('resize.DragonDrop',function(){$.dragonCurtain(settings)})}if(settings.window_scroll){window.scroll(offsetX,offsetY)}}},dragonCurtainRemove:function(){$(window).unbind('resize.DragonDrop');$('#dragonCurtain').fadeOut('fast').remove();$('iframe').show();if($.browser.msie&&$.browser.version<7){$('select.curtainHide').show()}clearInterval($.dragonCurtainInterval)},getBodyMarginLeft:function(){var pos=$('body').css('position');if(pos=='absolute'||pos=='relative'||pos=='fixed'){var innerWidth=$(window).width();var innerHeight=$(window).height();var bodyWidth=$('body').width();var marginLeft=(innerWidth-bodyWidth)/2}else{var marginLeft=0}marginLeft<0?marginLeft=0:null;return marginLeft},dragonScroll:function(event,axis,axisSize,scrollBufferSize,rate){if($('#dragonCurtain').length>0){return}if(!rate)rate=20;var absCoord;var scrollFunc;if(axis=='x'){absCoord=event.pageX-$(window).scrollLeft();scrollFunc='scrollLeft'}else if(axis=='y'){absCoord=event.pageY-$(window).scrollTop();scrollFunc='scrollTop'}if(absCoord>axisSize-scrollBufferSize){eval('clearInterval( window.dragonScrollInterval ); window.dragonScrollInterval = setInterval("$(window).'+scrollFunc+'( $(window).'+scrollFunc+'() + '+rate+' )", 50);')}else if(absCoord<scrollBufferSize){eval('clearInterval( window.dragonScrollInterval ); window.dragonScrollInterval = setInterval("$(window).'+scrollFunc+'( $(window).'+scrollFunc+'() - '+rate+' )", 50);')}},evalWithStatus:function(callback,customMsg,paramObj){!customMsg?customMsg='Please Wait...':null;IMAGE_URL.charAt(-1)!='/'?IMAGE_URL2=IMAGE_URL+'/':IMAGE_URL2=IMAGE_URL;$.dragonCurtain();window.evalWithStatusDiv=$('<div>'+customMsg+'<br /><img src="'+IMAGE_URL2+'images/ajax/circ_blue_small.gif" /></div>').appendTo('body').css({width:200,height:40,backgroundColor:'#FFF',border:'1px solid #CCC',position:'absolute',zIndex:1000,fontWeight:'bold',fontSize:'10pt'}).centerOnScreen();setTimeout(function(){callback(paramObj)},500)},evalWithStatusComplete:function(keepCurtain){if(!keepCurtain){$.dragonCurtainRemove()}window.evalWithStatusDiv.remove()},bindKeys_k:{},bindKeys:function(keys,callback){$.bindKeys_k[keys]=0;$(document).bind('keyup.'+keys,keys,function(e){var k=e.data;var v=$.bindKeys_k[k];var p=String.fromCharCode(e.keyCode);k.charAt(v)==p?$.bindKeys_k[k]++:$.bindKeys_k[k]=0;if($.bindKeys_k[k]>=k.length){$.sayHey(k);callback();$.bindKeys_k[k]=0}})},sayHey:function(msg){return $('<div class="sayHey">'+msg+'</div>').appendTo('body').css({fontWeight:'bold',fontSize:'28px',width:$('body').width()+'px',textAlign:'center',overflow:'hidden'}).centerOnScreen().animate({opacity:0,top:'-=30px'},'slow','linear',function(){$(this).remove()})},toolTip:function(html,width,x,y){var close=$('<a href="#" class="close">X</a>').click(function(){$(this).parent().remove();return false});return $('<div class="toolTip" />').css({width:width,top:y,left:x-$.getBodyMarginLeft()}).html(html).prepend(close).appendTo('body').show()}})})($);window.documentReady=false;$(document).ready(function(e){window.documentReady=true});