var swfu;var VideoModule={initChannel:function()
{var clickHandle=function(){VideoModule.channelPlayVideo($(this).parent().parent());return false;}
$('.video_list > li .video a').click(clickHandle);$('.video_list > li h3 a').click(clickHandle);var video=$('.video_list > li:first');this.channelPlayVideo(video)},channelPlayerLoaded:false,channelPlayVideo:function(video)
{if(!video.length)return;$('.video_list > li').removeClass('playing');video.addClass('playing');var poster=video.children('.video').children('a').children('img').attr('src').replace('_w','');var path=video.children('.video').attr('rel');if(!this.channelPlayerLoaded)
{var options={poster:poster,skin:'/static/frontend/flash/video3-1202.txt',width:520,height:388}
Video.play('video_player',path,options);this.channelPlayerLoaded=true;}
else
{uppodSend('video_player','file:'+path);}
$('html, body').animate({scrollTop:$('#video_player').position().top},1000);},pageChannelList:function(page)
{$.get('/video&channel='+channelId+'&page='+page+'&listonly=true',function(r){$('#list_content').html(r);VideoModule.initChannel();});return false;}}
function video_overlay(id,dir)
{var img=$('#video_'+id);var ani=new Image();var old=img.attr('src');var src=dir+'/'+id+'_t.gif';setTimeout(function(){$(ani).attr('src',src);},0);img.hover(function(){$(this).attr('src',src);},function(){$(this).attr('src',old);});};function load_default_player(title,target_id,path,playlist,player_url,poster,redirect_url)
{var flashvars={"comment":'',"st":"/static/frontend/flash/video3-1036.txt","file":path,"autostart":1};if(playlist!='')
{flashvars={"comment":'',"st":"/static/frontend/flash/video3-1036.txt","pl":playlist,"file":path,"poster":poster,"autostart":'true'};}
var params={bgcolor:"#ffffff",allowFullScreen:"true",allowScriptAccess:"always",wmode:'opaque',autostart:'true'};new swfobject.embedSWF(player_url,target_id,"740","416","9.0.0",false,flashvars,params);};function load_connect_player(target_id,host,video_id,buff)
{swfobject.embedSWF(host+'/static/common/swf/video/player.swf',target_id,'400px','350px','8',false,{skinURL:host+'/static/common/swf/video/connect.swf',playlistURL:host+'/playlist='+video_id,advURL:host+'/get_adv',buffSize:buff||2,vs_mode:2,vs_level:5,width:'400px',height:'350px'},{allowfullscreen:'true',wmode:'opaque'},{style:'position:relative;z-index:1;'});};var star_off=new Image(26,26);var star_on=new Image(26,26);star_off.src='/static/frontend/images/ranking/star_small.gif';star_on.src='/static/frontend/images/ranking/full_star_small.gif';function copyFrom(textContainer)
{textContainer.select();r=textContainer.createTextRange();r.select();r.execCommand('copy');};function deleteVideoComment(id,video_id,group_id,event_id)
{group_id=group_id||0;event_id=event_id||0;if(confirm('Вы уверены, что хотите удалить коментарий?'))
{$.post('/delete_comment',{id:id,video_id:video_id,group_id:group_id,event_id:event_id},function(response)
{$('#comment_box_'+id).fadeOut(250);},'json');}
return false;};function initOverlays()
{$('.overlayed').each(function()
{var img=$(this);var id=img.attr('id').substr(6);var ani=new Image();var old=img.attr('src');var dir=img.attr('rel');if(typeof(dir)=='undefined')return;var src=dir+'/'+id+'_t.gif';setTimeout(function(){$(ani).attr('src',src);},0);img.hover(function(){$(this).attr('src',src);},function(){$(this).attr('src',old);});});};function actionVideoView(videoId)
{var vote_imgs=$('img.votestar').get();for(var i in vote_imgs)
{$(vote_imgs[i]).bind('mouseover',function(){for(var j=1;j<=parseInt(this.id);j++)
{$('#'+j+'_star').attr('src',star_on.src);}}).bind('mouseout',function(){for(var j=1;j<=parseInt(this.id);j++)
{$('#'+j+'_star').attr('src',star_off.src);}});if(context.user_id)
{$(vote_imgs[i]).bind('click',function(){var star=parseInt(this.id);$.post('/vote',{video_id:videoId,star:star},function(data,status)
{if(data.ok)
{$('#video_voting').html(data.ok);$('#video_rating').attr('class','video_stars st'+data.star);}},'json');App.track('Rate','Video rate');});}
if(typeof(videoChannel)!='undefined')App.track('View video','Channel',videoChannel);App.track('View video','Category',videoCategory);}
$('#video_add').bind('click',function()
{addToPlaylist(videoId);$('#video_add').fadeOut(500);});$('.autoselect').bind('click',function()
{if(this.value==this.defaultValue)
{this.select();return false;}});};function actionVideoUpload(session_id)
{var settings={flash_url:"/static/frontend/flash/swfupload.swf",upload_url:"/upload&PHPSESSID="+session_id,post_params:{},file_post_name:"Filedata",file_size_limit:"300 MB",file_types:"*.avi;*.mpg;*.mp4;*.flv;*.iflv;*.wmv;*.3gp;*.mov",file_types_description:"Файлы видео",file_upload_limit:1,file_queue_limit:1,custom_settings:{progressTarget:"fsUploadProgress"},debug:false,button_image_url:"/static/frontend/images/buttons/upload.png",button_width:"300",button_height:"20",button_placeholder_id:"upload_button",file_queued_handler:videoQueued,file_queue_error_handler:videoQueueError,file_dialog_complete_handler:videoDialogComplete,upload_start_handler:uploadVideoStart,upload_progress_handler:uploadVideoProgress,upload_error_handler:uploadVideoError,upload_success_handler:uploadVideoSuccess,upload_complete_handler:uploadVideoComplete,queue_complete_handler:queueVideoComplete};swfu=new SWFUpload(settings);};function uploadVideoByUrl()
{if($('#video_url_name').val()=='')
{alert('Введите название видеоролика');return false;}
if($('#url_file').val()=='')
{alert('Введите ссылку на видеоролик');return false;}
$('#upload_url_form').submit();$('#upload_url_form').hide();$('#upload_url_status').show();};function uploadVideo()
{if($('#video_file_name').val()=='')
{alert('Введите название видеоролика');return false;}
if($('#video_file').val()=='')
{alert('Выберите видеоролик');return false;}
App.track('Upload','Upload video file');$('#upload_file_params').hide();$('.upload_progress').fadeIn(150);setTimeout(function(){mediaApi.fetchProgress(xUploadId);},500);return true;}
function approveVideo(id)
{$.post('/video&switch_state',{'id':id,'approve':1});return true;}
function deleteVideo(id)
{$('#delete_video_dialog_video_id').val(id);$('#delete_video_dialog').dialog({width:390,height:310});$('#delete_video_dialog').dialog('open');return false;}
function check_delete_video_form()
{if($('#reason_id').val()=='0'&&$('#reason_my').val()=='')
{$('#reason_id').css('border','1px solid red');$('#reason_my').css('border','1px solid red');return false}
return true}
function addToPlaylist(id)
{$.post('/add2mine',{video_id:id,add:1},function(data,status){$('#add_video_'+id).hide();},'json');}
function removeFromPlaylist(id)
{$.post('/add2mine',{video_id:id,remove:1},function(data,status){$('#remove_video_'+id).hide();},'json');}
function video_poster_init()
{if(!$('#video_poster').height())return;poster_position=$('#video_poster').position();poster_size={'width':$('#video_poster').width(),'height':$('#video_poster').height()};$('.play_button').css('left',(poster_position.left+(poster_size.width/2-35))).css('top',(poster_position.top+(poster_size.height/2-35))).fadeIn(1000);}
$(document).ready(function(){if($.browser.msie){$('.box ul h4').css({'margin-top':'-40px'});}
$('.box h3').bind('click',function(){$(this).parents('div:first').toggleClass("close");});$('.personal').hover(function(){$('.personal strong').toggleClass("open");$(this).parents('div:first').find('.my').toggle();},function(){$('.personal strong').toggleClass("open");$(this).parents('div:first').find('.my').toggle();});initOverlays();$('#create_channel_form').submit(function(){if($('#groupname').val()==''){$('label[for=name]').css('color','red');return false;}});if($('#video_poster').length){$('#video_poster').load(function(){video_poster_init();}).attr('src',$('#video_poster').attr('src'));}});;$(document).ready(function()
{$('#comment_text').bind('blur',function()
{if($(this).val()=='')
{$(this).val(l_commentHintText);$(this).css({color:'silver'});}});$('#comment_text').bind('focus',function()
{if($(this).val()==l_commentHintText)
{$(this).val('');}
$(this).css({color:'black'});});$('#comment_text').blur();});function addComment(type,data)
{var commentBody=jQuery.trim($('#comment_text').val());if((commentBody=='')||(commentBody==l_commentHintText))
{return false;}
$('#comment_wait_panel').show();$('#comment_text').attr('disabled',true);$('#comment_text').css('backgroundColor','#f0f0f0');$('#add_comment_button').attr('disabled',true);data.body=commentBody;data.type=type;$.post('/comments?add',data,function(data)
{$('#comment_wait_panel').hide();$('#comment_text').attr('disabled',false);$('#comment_text').css('backgroundColor','#fff');$('#add_comment_button').attr('disabled',false);$('#comments_title').show();$('#comment_text').val('');if(data)
{$('#comments_container').append(data);return;}
loadPagedCommentsList();$('#comment_text').blur();document.location='#comments_bottom';},'plain');return false;};function deleteComment(commentId,type)
{if(confirm(l_delete_confirm))
{$.post('/comments?delete',{id:commentId,type:type},function(data)
{$('#comment_item_'+commentId).fadeOut(150);},'json');}};function replyOnComment(authorId,id)
{var replyMessage=$('#comment_item_'+id+' .body').textChildren({stringDelimiter:'',trim:true,tagMode:'include',tags:['BR']});$('#comment_text').val('<q author="'+authorId+'">'+replyMessage+'</q>'+"\n");document.location='#add_comment_title';$('#comment_text').focus();};var currentType=null;var currentQuery=null;function initCommentsList(type,query,page)
{currentType=type;currentQuery=query;pagerCurrentPage=page;};function loadCommentsList(type,query,page)
{initCommentsList(type,query,page);$('.comments_loading').show();$.post('/comments?list&type='+type+'&'+query+(typeof page!='undefined'?'&page='+page:''),{},function(response)
{$('#comments_container').html(response);$('.comments_loading').hide();});if($('#pager_left').length==1)
{keyBind.add(37,function(){eval($('#pager_left').attr('rel'))});}
if($('#pager_right').length==1)
{keyBind.add(39,function(){eval($('#pager_right').attr('rel'))});}
return false;};function loadPagedCommentsList(page)
{if(typeof page!='undefined')
{loadCommentsList(currentType,currentQuery,page);}
else
{loadCommentsList(currentType,currentQuery);}
return false;};;var Video={playerUrl:'/static/frontend/flash/uppod.swf',defaultOptions:{skin:"/static/frontend/flash/video3-1036.txt",comment:'',width:740,height:416,flashVersion:'9.0.0',poster:''},play:function(containerId,videoPath,options)
{if(swfobject.getFlashPlayerVersion().major==0)
{$('#'+containerId).html('<div style="text-align:center; padding-top:30px;">Для просмотра видео Вам необходимо установить <a href="http://www.macromedia.com/go/getflashplayer">Adobe Flash Player</a>.</div>')
return;}
if(!options)options={};for(var i in Video.defaultOptions)
{if(!options[i])options[i]=Video.defaultOptions[i];}
var flashvars={"comment":options.comment,"st":options.skin,"file":videoPath,"poster":options.poster,"uid":containerId};var params={bgcolor:"#ffffff",allowFullScreen:"true",allowScriptAccess:"always",wmode:'opaque'};new swfobject.embedSWF(Video.playerUrl,containerId,options.width,options.height,options.flashVersion,false,flashvars,params);}};var uppod_instances=new Array();var uppod_instances_id=new Array();var uppod_play_next=0;function uppodStartsReport(playerID){uppodStartsReportVideo(playerID);}
function uppodErrorReport(playerID){}
function uppodTheEnd(playerID){if(uppod_play_next==1){if(uppod_instances_id[playerID]<uppod_instances.length-1){document.getElementById(uppod_instances[uppod_instances_id[playerID]+1]).sendToUppod('play');}
else{document.getElementById(uppod_instances[0]).sendToUppod('play');}}}
function uppodOnEnd(playerID){}
function uppodOnLoad(playerID){}
function uppodOnDownload(playerID){}
function uppodOnQuality(playerID){}
function uppodOnSeek(playerID){}
function uppodStopAll(playerID){for(var i=0;i<uppod_instances.length;i++){try{if(uppod_instances[i]!=playerID){document.getElementById(uppod_instances[i]).sendToUppod("stop");}}
catch(errorObject){}}}
function uppodSend(playerID,com,callback){document.getElementById(playerID).sendToUppod(com,(callback?callback:''));}
function uppodGet(playerID,com,callback){return document.getElementById(playerID).getUppod(com,(callback?callback:''));}
function uppodGetNpl(n,playerID){}
function uppodGetVolume(n,playerID){}
function uppodGetTime(n,playerID){}
function uppodGetTimeDuration(n,playerID){}
function uppodGetStatus(n,playerID){}
function uppodGetBytesTotal(n,playerID){}
function uppodGetBytesLoaded(n,playerID){}
function uppodGetProcent(n,playerID){}
function uppodGetFullScreen(n,playerID){}
function testCallback(n){}
function uppodPlayers(){var objectID;var objectTags=document.getElementsByTagName("object");for(var i=0;i<objectTags.length;i++){objectID=objectTags[i].id;if(objectID.indexOf("player")>-1&uppod_instances.indexOf(objectID)==-1){uppod_instances[i]=objectID;uppod_instances_id[objectID]=i;}}}
function uppodPL(playerID){}
function uppodPreloader(playerID){document.getElementById(playerID+"Preloader")?document.getElementById(playerID+"Preloader").style.display="none":'';document.getElementById(playerID+"Box")?document.getElementById(playerID+"Box").style.position="static":'';}
if(!Array.indexOf){Array.prototype.indexOf=function(obj){for(var i=0;i<this.length;i++){if(this[i]==obj){return i;}}
return-1;}}
var ap_uppodID=setInterval(uppodPlayers,1000);;function NewOdnaknopka2(){this.domain=location.href+'/';this.domain=this.domain.substr(this.domain.indexOf('://')+3);this.domain=this.domain.substr(0,this.domain.indexOf('/'));this.title=document.title;this.placeholder_selector='';this.add_url=location.href;this.location=false;this.selection=function(){var sel;if(window.getSelection)sel=window.getSelection();else if(document.selection)sel=document.selection.createRange();else sel='';if(sel.text)sel=sel.text;return encodeURIComponent(sel);}
this.redirect=function(){if(this.location)location.href=this.location;this.location=false;}
this.go=function(i){this.location=this.url(i);setTimeout('odnaknopka2.redirect()',2000);var scr=document.createElement('script');scr.type='text/javascript';scr.src='http://odnaknopka.ru/save2/?domain='+this.domain+'&system='+i;document.body.appendChild(scr);return false;}
this.url=function(system){var title=encodeURIComponent(this.title);var url=encodeURIComponent(this.add_url);switch(system){case 1:return'http://memori.ru/link/?sm=1&u_data[url]='+url+'&u_data[name]='+title;case 2:return'http://bobrdobr.ru/addext.html?url='+url+'&title='+title;case 3:return'http://www.google.com/bookmarks/mark?op=add&bkmk='+url+'&title='+title;case 4:return'http://zakladki.yandex.ru/userarea/links/addfromfav.asp?bAddLink_x=1&lurl='+url+'&lname='+title;case 5:return'http://twitter.com/home?status='+title+' '+url;case 6:return'http://del.icio.us/post?v=4&noui&jump=close&url='+url+'&title='+title;case 7:return'http://text20.ru/add/?source='+url+'&title='+title+'&text='+this.selection();case 8:return'http://news2.ru/add_story.php?url='+url;case 9:return'http://www.mister-wong.ru/index.php?action=addurl&bm_url='+url+'&bm_description='+title;case 10:return'http://moemesto.ru/post.php?url='+url+'&title='+title;case 11:return'http://smi2.ru/add/?url='+url+'&precaption='+title;case 12:return'http://www.vaau.ru/submit/?action=step2&url='+url;case 13:return'http://myscoop.ru/add/?URL='+url+'&title='+title;case 14:return'http://www.linkstore.ru/servlet/LinkStore?a=add&url='+url+'&title='+title;case 15:return'http://www.ruspace.ru/index.php?link=bookmark&action=bookmarkNew&bm=1&url='+url+'&title='+title;case 16:return'http://www.100zakladok.ru/save/?bmurl='+url+'&bmtitle='+title;}}
this.hide=function(){if(this.timeout)clearTimeout(this.timeout);document.getElementById('odnaknopka').style.visibility='hidden';}
this.show=function(element){if(this.timeout)clearTimeout(this.timeout);var left=0,top=0;var style=document.getElementById('odnaknopka').style;while(element){left+=element.offsetLeft;top+=element.offsetTop;element=element.offsetParent;}
style.left=left+'px';style.top=top+'px';style.visibility='visible';}
this.init=function(){var titles=new Array('Memori','&#1041;&#1086;&#1073;&#1088;&#1044;&#1086;&#1073;&#1088;','&#1047;&#1072;&#1082;&#1083;&#1072;&#1076;&#1082;&#1080; Google','&#1071;&#1085;&#1076;&#1077;&#1082;&#1089;.&#1047;&#1072;&#1082;&#1083;&#1072;&#1076;&#1082;&#1080;','Twitter','del.icio.us','&#1058;&#1077;&#1082;&#1089;&#1090; 2.0','News2','&#1052;&#1080;&#1089;&#1090;&#1077;&#1088; &#1042;&#1086;&#1085;&#1075;','&#1052;&#1086;&#1105;&#1052;&#1077;&#1089;&#1090;&#1086;','&#1057;&#1052;&#1048; 2','&#1042;&#1072;&#1072;&#1091;!','AddScoop','LinkStore','RuSpace','&#1057;&#1090;&#1086; &#1047;&#1072;&#1082;&#1083;&#1072;&#1076;&#1086;&#1082;');if(!document.getElementById('odnaknopka')){var div=document.createElement('div');div.id='odnaknopka';div.style.position='absolute';div.style.visibility='hidden';div.style.width='264px';div.style.height='182px';div.style.backgroundColor='transparent';div.style.backgroundImage='url(/static/frontend/images/onebutton_panel.png)';div.style.border='0';div.style.margin='0';div.style.padding='0 1px 4px 1px';div.style.overflow='hidden';div.style.zIndex='1000';div.style.font='normal 12px arial';div.style.lineHeight='20px';div.style.color='#666';html='<a href="http://odnaknopka.ru" onclick="window.open(\'http://odnaknopka.ru/add/?url=\'+encodeURIComponent(location.href)+\'&title=\'+encodeURIComponent(this.title),\'odnaknopka\',\'scrollbars=yes,menubar=no,width=600,height=500,left='+(document.body.clientWidth/2-300)+',top='+(document.body.clientHeight/2-250)+',resizable=yes,toolbar=no,location=no,status=no\');return false;" style="display:block;float:left;width:258px;height:20px;overflow:hidden;margin:1px 0;padding:0;background-color:transparent;font:bold 11px arial;color:#666;text-decoration:none"></a>';for(var i=0;i<16;i++){html+='<a href="'+this.url(i+1)+'" style="display:block;float:left;width:108px;height:16px;overflow:hidden;margin:1px 0;padding:0 0 0 24px;background-color:transparent;background:url(/static/frontend/images/onebutton_panel.png) no-repeat -266px '+(-i*16)+'px;font:normal 12px arial;color:#666;text-decoration:none;text-align:left" onmouseover="this.style.textDecoration=\'underline\'" onmouseout="this.style.textDecoration=\'none\'" onclick="return odnaknopka2.go('+(i+1)+');">'+titles[i]+'</a>';}
html+='<a href="http://odnaknopka.ru" style="display:block;float:left;width:258px;height:16px;overflow:hidden;margin:1px 0;padding:0;background-color:transparent;font:bold 11px arial;color:#666;text-decoration:none;text-align:right">&copy;&nbsp;&#1054;&#1076;&#1085;&#1072;&#1050;&#1085;&#1086;&#1087;&#1082;&#1072;.&#1088;&#1091;</a>';div.innerHTML=html;div.onmouseover=function(){if(odnaknopka2.timeout)clearTimeout(odnaknopka2.timeout)}
div.onmouseout=function(){odnaknopka2.timeout=setTimeout('odnaknopka2.hide()',500)};document.body.insertBefore(div,document.body.firstChild);}
if(!this.placeholder_selector){document.write('<a href="http://odnaknopka.ru/add/" onclick="window.open(\'http://odnaknopka.ru/add/?url=\'+encodeURIComponent(location.href)+\'&title=\'+encodeURIComponent(this.title),\'odnaknopka\',\'scrollbars=yes,menubar=no,width=600,height=500,left='+(document.body.clientWidth/2-300)+',top='+(document.body.clientHeight/2-250)+',resizable=yes,toolbar=no,location=no,status=no\');return false;"><img src="/static/frontend/images/onebutton_button.gif" width="136" height="16" alt="&#1054;&#1076;&#1085;&#1072;&#1050;&#1085;&#1086;&#1087;&#1082;&#1072;" title="&#1054;&#1076;&#1085;&#1072;&#1050;&#1085;&#1086;&#1087;&#1082;&#1072;" style="border:0;margin:0;padding:0" onmouseover="odnaknopka2.show(this);" onmouseout="odnaknopka2.timeout=setTimeout(\'odnaknopka2.hide()\',500);"></a>');}
else{$(this.placeholder_selector).html('<a href="http://odnaknopka.ru/add/" onclick="window.open(\'http://odnaknopka.ru/add/?url=\'+encodeURIComponent(location.href)+\'&title=\'+encodeURIComponent(this.title),\'odnaknopka\',\'scrollbars=yes,menubar=no,width=600,height=500,left='+(document.body.clientWidth/2-300)+',top='+(document.body.clientHeight/2-250)+',resizable=yes,toolbar=no,location=no,status=no\');return false;"><img src="/static/frontend/images/onebutton_button.gif" width="136" height="16" alt="&#1054;&#1076;&#1085;&#1072;&#1050;&#1085;&#1086;&#1087;&#1082;&#1072;" title="&#1054;&#1076;&#1085;&#1072;&#1050;&#1085;&#1086;&#1087;&#1082;&#1072;" style="border:0;margin:0;padding:0" onmouseover="odnaknopka2.show(this);" onmouseout="odnaknopka2.timeout=setTimeout(\'odnaknopka2.hide()\',500);"></a>');}}};(function($){var RETURN=13;var TAB=9;var ESC=27;var ARRLEFT=37;var ARRUP=38;var ARRRIGHT=39;var ARRDOWN=40;var BACKSPACE=8;var DELETE=46;function debug(s){$('#info').append(htmlspecialchars(s)+'<br>');}
function getCaretPosition(obj){var start=-1;var end=-1;if(typeof obj.selectionStart!="undefined"){start=obj.selectionStart;end=obj.selectionEnd;}
else if(document.selection&&document.selection.createRange){var M=document.selection.createRange();var Lp;try{Lp=M.duplicate();Lp.moveToElementText(obj);}catch(e){Lp=obj.createTextRange();}
Lp.setEndPoint("EndToStart",M);start=Lp.text.length;if(start>obj.value.length)
start=-1;Lp.setEndPoint("EndToStart",M);end=Lp.text.length;if(end>obj.value.length)
end=-1;}
return{'start':start,'end':end};}
function setCaret(obj,l){obj.focus();if(obj.setSelectionRange){obj.setSelectionRange(l,l);}
else if(obj.createTextRange){m=obj.createTextRange();m.moveStart('character',l);m.collapse();m.select();}}
function prepareArray(jsondata){var new_arr=[];for(var i=0;i<jsondata.length;i++){if(jsondata[i].id!=undefined&&jsondata[i].value!=undefined){jsondata[i].id=jsondata[i].id+"";jsondata[i].value=jsondata[i].value+"";if(jsondata[i].info!=undefined)
jsondata[i].info=jsondata[i].info+"";new_arr.push(jsondata[i]);}}
return new_arr;}
function escapearg(s){if(s==undefined||!s)return'';return s.replace('\\','\\\\').replace('*','\\*').replace('.','\\.').replace('/','\\/');}
function htmlspecialchars(s){if(s==undefined||!s)return'';return s.replace('&','&amp;').replace('<','&lt;').replace('>','&gt;');}
function ltrim(s){if(s==undefined||!s)return'';return s.replace(/^\s+/g,'');}
$.fn.jqac=function(options){return this.each(function(){var me=$(this);var me_this=$(this).get(0);if(!me.is('input:text,input:password,textarea'))
return;if(!options&&(!$.isFunction(options.get)||!options.ajax_get)){return;}
if(me.attr('jqac')=='on')return;me.attr('jqac','on');me.attr('autocomplete','off');options=$.extend({delay:200,timeout:5000,minchars:3,multi:false,cache:true,height:150,autowidth:false,noresults:'-',default_list:0},options);if(options.default_list){me.focus(function(ev){if((getUserInput()=='')&&!suggestions_menu)getSuggestions(getUserInput());});}
me.keydown(function(ev){switch(ev.which){case RETURN:if(!suggestions_menu)return true;else setHighlightedValue();return false;case ESC:clearSuggestions();return false;}
return true;});me.keypress(function(ev){switch(ev.keyCode){case RETURN:case ESC:return false;case ARRUP:changeHighlight(ev.keyCode);return false;case ARRDOWN:if(!suggestions_menu)getSuggestions(getUserInput());else changeHighlight(ev.keyCode);return false;}
return true;});me.keyup(function(ev){switch(ev.which){case RETURN:case ESC:case ARRLEFT:case ARRRIGHT:case ARRUP:case ARRDOWN:return false;default:getSuggestions(getUserInput());}
return true;});var user_input="";var input_chars_size=0;var suggestions=[];var current_highlight=0;var suggestions_menu=false;var suggestions_list=false;var loading_indicator=false;var clearSuggestionsTimer=false;var getSuggestionsTimer=false;var showLoadingTimer=false;var zIndex=me.css('z-index');function getUserInput(){var val=me.val();if(options.multi){var pos=getCaretPosition(me_this);var start=pos.start;for(;start>0&&val.charAt(start-1)!=',';start--){}
var end=pos.start;for(;end<val.length&&val.charAt(end)!=',';end++){}
var val=val.substr(start,end-start);}
return ltrim(val);}
function setSuggestion(val){user_input=val;if(options.multi){var orig=me.val();var pos=getCaretPosition(me_this);var start=pos.start;for(;start>0&&orig.charAt(start-1)!=',';start--){}
var end=pos.start;for(;end<orig.length&&orig.charAt(end)!=',';end++){}
var new_val=orig.substr(0,start)+(start>0?' ':'')+val+orig.substr(end);me.val(new_val);setCaret(me_this,start+val.length+(start>0?1:0));}
else{me_this.focus();me.val(val);}}
function getSuggestions(val){if(options.default_list&&(val.length==0)){suggestions=prepareArray(options.get_default());createList(suggestions);return false;}
if(val.length<options.minchars){clearSuggestions();return false;}
if(options.cache&&val.length>input_chars_size&&suggestions.length){var arr=[];for(var i=0;i<suggestions.length;i++){var re=new RegExp("("+escapearg(val)+")",'ig');if(re.exec(suggestions[i].value))
arr.push(suggestions[i]);}
user_input=val;input_chars_size=val.length;suggestions=arr;createList(suggestions);return false;}
else{clearTimeout(getSuggestionsTimer);user_input=val;input_chars_size=val.length;getSuggestionsTimer=setTimeout(function(){suggestions=[];if($.isFunction(options.pre_callback))
options.pre_callback();if($.isFunction(options.get)){suggestions=prepareArray(options.get(val));createList(suggestions);}
else if($.isFunction(options.ajax_get)){clearSuggestions();showLoadingTimer=setTimeout(show_loading,options.delay);options.ajax_get(val,ajax_continuation);}},options.delay);}
return false;};function ajax_continuation(jsondata){hide_loading();suggestions=prepareArray(jsondata);createList(suggestions);}
function show_loading(){if(!loading_indicator){loading_indicator=$('<div class="jqac-menu"><div class="jqac-loading">Loading</div></div>').get(0);$(loading_indicator).css('position','absolute');var pos=me.offset();$(loading_indicator).css('left',pos.left+"px");$(loading_indicator).css('top',(pos.top+me.height()+2)+"px");if(!options.autowidth)
$(loading_indicator).width(me.width());$('body').append(loading_indicator);}
$(loading_indicator).show();setTimeout(hide_loading,10000);}
function hide_loading(){if(loading_indicator)
$(loading_indicator).hide();clearTimeout(showLoadingTimer);}
function createList(arr){if(suggestions_menu)
$(suggestions_menu).remove();hide_loading();killTimeout();suggestions_menu=$('<div class="jqac-menu"></div>').get(0);$(suggestions_menu).css({'position':'absolute','z-index':1000000,'max-height':options.height+'px','overflow-y':'auto'});suggestions_list=$('<ul></ul>').get(0);$(suggestions_list).css('list-style','none').css('margin','0px').css('padding','0px').css('overflow','hidden');var re=new RegExp("("+escapearg(htmlspecialchars(user_input))+")",'ig');for(var i=0;i<arr.length;i++){var val=new String(arr[i].value);var output=htmlspecialchars(val).replace(re,'<em>$1</em>');var span=$('<span class="jqac-link">'+output+'</span>').get(0);if(arr[i].info!=undefined&&arr[i].info!=""){$(span).append($('<div class="jqac-info">'+arr[i].info+'</div>'));}
$(span).attr('name',i+1);$(span).click(function(){setHighlightedValue();});$(span).mouseover(function(){setHighlight($(this).attr('name'),true);});var li=$('<li></li>').get(0);$(li).append(span);$(suggestions_list).append(li);}
if(arr.length==0){$(suggestions_list).append('<li class="jqac-warning">'+options.noresults+'</li>');}
$(suggestions_menu).append(suggestions_list);var pos=me.offset();$(suggestions_menu).css('left',pos.left+"px");$(suggestions_menu).css('top',(pos.top+me.height()+2)+"px");if(!options.autowidth)
$(suggestions_menu).width(me.width());$(suggestions_menu).mouseover(function(){killTimeout()});$(suggestions_menu).mouseout(function(){resetTimeout()});$('body').append(suggestions_menu);if($.fn.bgiframe)
$(suggestions_menu).bgiframe({height:suggestions_menu.scrollHeight});if(suggestions_menu.scrollHeight>options.height){$(suggestions_menu).height(options.height);$(suggestions_menu).width($(suggestions_menu).width()+20);}
current_highlight=0;clearSuggestionsTimer=setTimeout(function(){clearSuggestions()},options.timeout);};function setHighlightedValue(){if(current_highlight&&suggestions[current_highlight-1]){var sugg=suggestions[current_highlight-1];if(sugg.affected_value!=undefined&&sugg.affected_value!='')
setSuggestion(sugg.affected_value);else
setSuggestion(sugg.value);if($.isFunction(options.callback))
options.callback(suggestions[current_highlight-1]);clearSuggestions();}};function changeHighlight(key){if(!suggestions_list||suggestions.length==0)return false;var n;if(key==ARRDOWN)
n=current_highlight+1;else if(key==ARRUP)
n=current_highlight-1;if(n>$(suggestions_list).children().size())
n=1;if(n<1)
n=$(suggestions_list).children().size();setHighlight(n);};function setHighlight(n,mouse_mode){if(!suggestions_list)return false;if(current_highlight>0)clearHighlight();current_highlight=Number(n);var li=$(suggestions_list).children().get(current_highlight-1);li.className='jqac-highlight';if(!mouse_mode)adjustScroll(li);killTimeout();};function clearHighlight(){if(!suggestions_list)return false;if(current_highlight>0){$(suggestions_list).children().get(current_highlight-1).className='';current_highlight=0;}};function clearSuggestions(){killTimeout();if(suggestions_menu){$(suggestions_menu).remove();suggestions_menu=false;suggestions_list=false;current_highlight=0;}};function adjustScroll(el){if(!suggestions_menu)return false;var viewportHeight=suggestions_menu.clientHeight;var wholeHeight=suggestions_menu.scrollHeight;var scrolled=suggestions_menu.scrollTop;var elTop=el.offsetTop;var elBottom=elTop+el.offsetHeight;if(elBottom>scrolled+viewportHeight){suggestions_menu.scrollTop=elBottom-viewportHeight;}
else if(elTop<scrolled){suggestions_menu.scrollTop=elTop;}
return true;}
function killTimeout(){clearTimeout(clearSuggestionsTimer);};function resetTimeout(){clearTimeout(clearSuggestionsTimer);clearSuggestionsTimer=setTimeout(function(){clearSuggestions()},500);};})};})($);;;jQuery.ui||(function($){var _remove=$.fn.remove,isFF2=$.browser.mozilla&&(parseFloat($.browser.version)<1.9);$.ui={version:"1.7.1",plugin:{add:function(module,option,set){var proto=$.ui[module].prototype;for(var i in set){proto.plugins[i]=proto.plugins[i]||[];proto.plugins[i].push([option,set[i]]);}},call:function(instance,name,args){var set=instance.plugins[name];if(!set||!instance.element[0].parentNode){return;}
for(var i=0;i<set.length;i++){if(instance.options[set[i][0]]){set[i][1].apply(instance.element,args);}}}},contains:function(a,b){return document.compareDocumentPosition?a.compareDocumentPosition(b)&16:a!==b&&a.contains(b);},hasScroll:function(el,a){if($(el).css('overflow')=='hidden'){return false;}
var scroll=(a&&a=='left')?'scrollLeft':'scrollTop',has=false;if(el[scroll]>0){return true;}
el[scroll]=1;has=(el[scroll]>0);el[scroll]=0;return has;},isOverAxis:function(x,reference,size){return(x>reference)&&(x<(reference+size));},isOver:function(y,x,top,left,height,width){return $.ui.isOverAxis(y,top,height)&&$.ui.isOverAxis(x,left,width);},keyCode:{BACKSPACE:8,CAPS_LOCK:20,COMMA:188,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38}};if(isFF2){var attr=$.attr,removeAttr=$.fn.removeAttr,ariaNS="http://www.w3.org/2005/07/aaa",ariaState=/^aria-/,ariaRole=/^wairole:/;$.attr=function(elem,name,value){var set=value!==undefined;return(name=='role'?(set?attr.call(this,elem,name,"wairole:"+value):(attr.apply(this,arguments)||"").replace(ariaRole,"")):(ariaState.test(name)?(set?elem.setAttributeNS(ariaNS,name.replace(ariaState,"aaa:"),value):attr.call(this,elem,name.replace(ariaState,"aaa:"))):attr.apply(this,arguments)));};$.fn.removeAttr=function(name){return(ariaState.test(name)?this.each(function(){this.removeAttributeNS(ariaNS,name.replace(ariaState,""));}):removeAttr.call(this,name));};}
$.fn.extend({remove:function(){$("*",this).add(this).each(function(){$(this).triggerHandler("remove");});return _remove.apply(this,arguments);},enableSelection:function(){return this.attr('unselectable','off').css('MozUserSelect','').unbind('selectstart.ui');},disableSelection:function(){return this.attr('unselectable','on').css('MozUserSelect','none').bind('selectstart.ui',function(){return false;});},scrollParent:function(){var scrollParent;if(($.browser.msie&&(/(static|relative)/).test(this.css('position')))||(/absolute/).test(this.css('position'))){scrollParent=this.parents().filter(function(){return(/(relative|absolute|fixed)/).test($.curCSS(this,'position',1))&&(/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));}).eq(0);}else{scrollParent=this.parents().filter(function(){return(/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));}).eq(0);}
return(/fixed/).test(this.css('position'))||!scrollParent.length?$(document):scrollParent;}});$.extend($.expr[':'],{data:function(elem,i,match){return!!$.data(elem,match[3]);},focusable:function(element){var nodeName=element.nodeName.toLowerCase(),tabIndex=$.attr(element,'tabindex');return(/input|select|textarea|button|object/.test(nodeName)?!element.disabled:'a'==nodeName||'area'==nodeName?element.href||!isNaN(tabIndex):!isNaN(tabIndex))&&!$(element)['area'==nodeName?'parents':'closest'](':hidden').length;},tabbable:function(element){var tabIndex=$.attr(element,'tabindex');return(isNaN(tabIndex)||tabIndex>=0)&&$(element).is(':focusable');}});function getter(namespace,plugin,method,args){function getMethods(type){var methods=$[namespace][plugin][type]||[];return(typeof methods=='string'?methods.split(/,?\s+/):methods);}
var methods=getMethods('getter');if(args.length==1&&typeof args[0]=='string'){methods=methods.concat(getMethods('getterSetter'));}
return($.inArray(method,methods)!=-1);}
$.widget=function(name,prototype){var namespace=name.split(".")[0];name=name.split(".")[1];$.fn[name]=function(options){var isMethodCall=(typeof options=='string'),args=Array.prototype.slice.call(arguments,1);if(isMethodCall&&options.substring(0,1)=='_'){return this;}
if(isMethodCall&&getter(namespace,name,options,args)){var instance=$.data(this[0],name);return(instance?instance[options].apply(instance,args):undefined);}
return this.each(function(){var instance=$.data(this,name);(!instance&&!isMethodCall&&$.data(this,name,new $[namespace][name](this,options))._init());(instance&&isMethodCall&&$.isFunction(instance[options])&&instance[options].apply(instance,args));});};$[namespace]=$[namespace]||{};$[namespace][name]=function(element,options){var self=this;this.namespace=namespace;this.widgetName=name;this.widgetEventPrefix=$[namespace][name].eventPrefix||name;this.widgetBaseClass=namespace+'-'+name;this.options=$.extend({},$.widget.defaults,$[namespace][name].defaults,$.metadata&&$.metadata.get(element)[name],options);this.element=$(element).bind('setData.'+name,function(event,key,value){if(event.target==element){return self._setData(key,value);}}).bind('getData.'+name,function(event,key){if(event.target==element){return self._getData(key);}}).bind('remove',function(){return self.destroy();});};$[namespace][name].prototype=$.extend({},$.widget.prototype,prototype);$[namespace][name].getterSetter='option';};$.widget.prototype={_init:function(){},destroy:function(){this.element.removeData(this.widgetName).removeClass(this.widgetBaseClass+'-disabled'+' '+this.namespace+'-state-disabled').removeAttr('aria-disabled');},option:function(key,value){var options=key,self=this;if(typeof key=="string"){if(value===undefined){return this._getData(key);}
options={};options[key]=value;}
$.each(options,function(key,value){self._setData(key,value);});},_getData:function(key){return this.options[key];},_setData:function(key,value){this.options[key]=value;if(key=='disabled'){this.element
[value?'addClass':'removeClass'](this.widgetBaseClass+'-disabled'+' '+
this.namespace+'-state-disabled').attr("aria-disabled",value);}},enable:function(){this._setData('disabled',false);},disable:function(){this._setData('disabled',true);},_trigger:function(type,event,data){var callback=this.options[type],eventName=(type==this.widgetEventPrefix?type:this.widgetEventPrefix+type);event=$.Event(event);event.type=eventName;if(event.originalEvent){for(var i=$.event.props.length,prop;i;){prop=$.event.props[--i];event[prop]=event.originalEvent[prop];}}
this.element.trigger(event,data);return!($.isFunction(callback)&&callback.call(this.element[0],event,data)===false||event.isDefaultPrevented());}};$.widget.defaults={disabled:false};$.ui.mouse={_mouseInit:function(){var self=this;this.element.bind('mousedown.'+this.widgetName,function(event){return self._mouseDown(event);}).bind('click.'+this.widgetName,function(event){if(self._preventClickEvent){self._preventClickEvent=false;event.stopImmediatePropagation();return false;}});if($.browser.msie){this._mouseUnselectable=this.element.attr('unselectable');this.element.attr('unselectable','on');}
this.started=false;},_mouseDestroy:function(){this.element.unbind('.'+this.widgetName);($.browser.msie&&this.element.attr('unselectable',this._mouseUnselectable));},_mouseDown:function(event){event.originalEvent=event.originalEvent||{};if(event.originalEvent.mouseHandled){return;}
(this._mouseStarted&&this._mouseUp(event));this._mouseDownEvent=event;var self=this,btnIsLeft=(event.which==1),elIsCancel=(typeof this.options.cancel=="string"?$(event.target).parents().add(event.target).filter(this.options.cancel).length:false);if(!btnIsLeft||elIsCancel||!this._mouseCapture(event)){return true;}
this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet){this._mouseDelayTimer=setTimeout(function(){self.mouseDelayMet=true;},this.options.delay);}
if(this._mouseDistanceMet(event)&&this._mouseDelayMet(event)){this._mouseStarted=(this._mouseStart(event)!==false);if(!this._mouseStarted){event.preventDefault();return true;}}
this._mouseMoveDelegate=function(event){return self._mouseMove(event);};this._mouseUpDelegate=function(event){return self._mouseUp(event);};$(document).bind('mousemove.'+this.widgetName,this._mouseMoveDelegate).bind('mouseup.'+this.widgetName,this._mouseUpDelegate);($.browser.safari||event.preventDefault());event.originalEvent.mouseHandled=true;return true;},_mouseMove:function(event){if($.browser.msie&&!event.button){return this._mouseUp(event);}
if(this._mouseStarted){this._mouseDrag(event);return event.preventDefault();}
if(this._mouseDistanceMet(event)&&this._mouseDelayMet(event)){this._mouseStarted=(this._mouseStart(this._mouseDownEvent,event)!==false);(this._mouseStarted?this._mouseDrag(event):this._mouseUp(event));}
return!this._mouseStarted;},_mouseUp:function(event){$(document).unbind('mousemove.'+this.widgetName,this._mouseMoveDelegate).unbind('mouseup.'+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=false;this._preventClickEvent=(event.target==this._mouseDownEvent.target);this._mouseStop(event);}
return false;},_mouseDistanceMet:function(event){return(Math.max(Math.abs(this._mouseDownEvent.pageX-event.pageX),Math.abs(this._mouseDownEvent.pageY-event.pageY))>=this.options.distance);},_mouseDelayMet:function(event){return this.mouseDelayMet;},_mouseStart:function(event){},_mouseDrag:function(event){},_mouseStop:function(event){},_mouseCapture:function(event){return true;}};$.ui.mouse.defaults={cancel:null,distance:1,delay:0};})(jQuery);;(function($){var setDataSwitch={dragStart:"start.draggable",drag:"drag.draggable",dragStop:"stop.draggable",maxHeight:"maxHeight.resizable",minHeight:"minHeight.resizable",maxWidth:"maxWidth.resizable",minWidth:"minWidth.resizable",resizeStart:"start.resizable",resize:"drag.resizable",resizeStop:"stop.resizable"},uiDialogClasses='ui-dialog '+'ui-widget '+'ui-widget-content '+'ui-corner-all ';$.widget("ui.dialog",{_init:function(){this.originalTitle=this.element.attr('title');var self=this,options=this.options,title=options.title||this.originalTitle||'&nbsp;',titleId=$.ui.dialog.getTitleId(this.element),uiDialog=(this.uiDialog=$('<div/>')).appendTo(document.body).hide().addClass(uiDialogClasses+options.dialogClass).css({position:'absolute',overflow:'hidden',zIndex:options.zIndex}).attr('tabIndex',-1).css('outline',0).keydown(function(event){(options.closeOnEscape&&event.keyCode&&event.keyCode==$.ui.keyCode.ESCAPE&&self.close(event));}).attr({role:'dialog','aria-labelledby':titleId}).mousedown(function(event){self.moveToTop(false,event);}),uiDialogContent=this.element.show().removeAttr('title').addClass('ui-dialog-content '+'ui-widget-content').appendTo(uiDialog),uiDialogTitlebar=(this.uiDialogTitlebar=$('<div></div>')).addClass('ui-dialog-titlebar '+'ui-widget-header '+'ui-corner-all '+'ui-helper-clearfix').prependTo(uiDialog),uiDialogTitlebarClose=$('<a href="#"/>').addClass('ui-dialog-titlebar-close '+'ui-corner-all').attr('role','button').hover(function(){uiDialogTitlebarClose.addClass('ui-state-hover');},function(){uiDialogTitlebarClose.removeClass('ui-state-hover');}).focus(function(){uiDialogTitlebarClose.addClass('ui-state-focus');}).blur(function(){uiDialogTitlebarClose.removeClass('ui-state-focus');}).mousedown(function(ev){ev.stopPropagation();}).click(function(event){self.close(event);return false;}).appendTo(uiDialogTitlebar),uiDialogTitlebarCloseText=(this.uiDialogTitlebarCloseText=$('<span/>')).addClass('ui-icon '+'ui-icon-closethick').text(options.closeText).appendTo(uiDialogTitlebarClose),uiDialogTitle=$('<span/>').addClass('ui-dialog-title').attr('id',titleId).html(title).prependTo(uiDialogTitlebar);uiDialogTitlebar.find("*").add(uiDialogTitlebar).disableSelection();(options.draggable&&$.fn.draggable&&this._makeDraggable());(options.resizable&&$.fn.resizable&&this._makeResizable());this._createButtons(options.buttons);this._isOpen=false;(options.bgiframe&&$.fn.bgiframe&&uiDialog.bgiframe());(options.autoOpen&&this.open());},destroy:function(){(this.overlay&&this.overlay.destroy());this.uiDialog.hide();this.element.unbind('.dialog').removeData('dialog').removeClass('ui-dialog-content ui-widget-content').hide().appendTo('body');this.uiDialog.remove();(this.originalTitle&&this.element.attr('title',this.originalTitle));},close:function(event){var self=this;if(false===self._trigger('beforeclose',event)){return;}
(self.overlay&&self.overlay.destroy());self.uiDialog.unbind('keypress.ui-dialog');(self.options.hide?self.uiDialog.hide(self.options.hide,function(){self._trigger('close',event);}):self.uiDialog.hide()&&self._trigger('close',event));$.ui.dialog.overlay.resize();self._isOpen=false;},isOpen:function(){return this._isOpen;},moveToTop:function(force,event){if((this.options.modal&&!force)||(!this.options.stack&&!this.options.modal)){return this._trigger('focus',event);}
if(this.options.zIndex>$.ui.dialog.maxZ){$.ui.dialog.maxZ=this.options.zIndex;}
(this.overlay&&this.overlay.$el.css('z-index',$.ui.dialog.overlay.maxZ=++$.ui.dialog.maxZ));var saveScroll={scrollTop:this.element.attr('scrollTop'),scrollLeft:this.element.attr('scrollLeft')};this.uiDialog.css('z-index',++$.ui.dialog.maxZ);this.element.attr(saveScroll);this._trigger('focus',event);},open:function(){if(this._isOpen){return;}
var options=this.options,uiDialog=this.uiDialog;this.overlay=options.modal?new $.ui.dialog.overlay(this):null;(uiDialog.next().length&&uiDialog.appendTo('body'));this._size();this._position(options.position);uiDialog.show(options.show);this.moveToTop(true);(options.modal&&uiDialog.bind('keypress.ui-dialog',function(event){if(event.keyCode!=$.ui.keyCode.TAB){return;}
var tabbables=$(':tabbable',this),first=tabbables.filter(':first')[0],last=tabbables.filter(':last')[0];if(event.target==last&&!event.shiftKey){setTimeout(function(){first.focus();},1);}else if(event.target==first&&event.shiftKey){setTimeout(function(){last.focus();},1);}}));$([]).add(uiDialog.find('.ui-dialog-content :tabbable:first')).add(uiDialog.find('.ui-dialog-buttonpane :tabbable:first')).add(uiDialog).filter(':first').focus();this._trigger('open');this._isOpen=true;},_createButtons:function(buttons){var self=this,hasButtons=false,uiDialogButtonPane=$('<div></div>').addClass('ui-dialog-buttonpane '+'ui-widget-content '+'ui-helper-clearfix');this.uiDialog.find('.ui-dialog-buttonpane').remove();(typeof buttons=='object'&&buttons!==null&&$.each(buttons,function(){return!(hasButtons=true);}));if(hasButtons){$.each(buttons,function(name,fn){$('<button type="button"></button>').addClass('ui-state-default '+'ui-corner-all').text(name).click(function(){fn.apply(self.element[0],arguments);}).hover(function(){$(this).addClass('ui-state-hover');},function(){$(this).removeClass('ui-state-hover');}).focus(function(){$(this).addClass('ui-state-focus');}).blur(function(){$(this).removeClass('ui-state-focus');}).appendTo(uiDialogButtonPane);});uiDialogButtonPane.appendTo(this.uiDialog);}},_makeDraggable:function(){var self=this,options=this.options,heightBeforeDrag;this.uiDialog.draggable({cancel:'.ui-dialog-content',handle:'.ui-dialog-titlebar',containment:'document',start:function(){heightBeforeDrag=options.height;$(this).height($(this).height()).addClass("ui-dialog-dragging");(options.dragStart&&options.dragStart.apply(self.element[0],arguments));},drag:function(){(options.drag&&options.drag.apply(self.element[0],arguments));},stop:function(){$(this).removeClass("ui-dialog-dragging").height(heightBeforeDrag);(options.dragStop&&options.dragStop.apply(self.element[0],arguments));$.ui.dialog.overlay.resize();}});},_makeResizable:function(handles){handles=(handles===undefined?this.options.resizable:handles);var self=this,options=this.options,resizeHandles=typeof handles=='string'?handles:'n,e,s,w,se,sw,ne,nw';this.uiDialog.resizable({cancel:'.ui-dialog-content',alsoResize:this.element,maxWidth:options.maxWidth,maxHeight:options.maxHeight,minWidth:options.minWidth,minHeight:options.minHeight,start:function(){$(this).addClass("ui-dialog-resizing");(options.resizeStart&&options.resizeStart.apply(self.element[0],arguments));},resize:function(){(options.resize&&options.resize.apply(self.element[0],arguments));},handles:resizeHandles,stop:function(){$(this).removeClass("ui-dialog-resizing");options.height=$(this).height();options.width=$(this).width();(options.resizeStop&&options.resizeStop.apply(self.element[0],arguments));$.ui.dialog.overlay.resize();}}).find('.ui-resizable-se').addClass('ui-icon ui-icon-grip-diagonal-se');},_position:function(pos){var wnd=$(window),doc=$(document),pTop=doc.scrollTop(),pLeft=doc.scrollLeft(),minTop=pTop;if($.inArray(pos,['center','top','right','bottom','left'])>=0){pos=[pos=='right'||pos=='left'?pos:'center',pos=='top'||pos=='bottom'?pos:'middle'];}
if(pos.constructor!=Array){pos=['center','middle'];}
if(pos[0].constructor==Number){pLeft+=pos[0];}else{switch(pos[0]){case'left':pLeft+=0;break;case'right':pLeft+=wnd.width()-this.uiDialog.outerWidth();break;default:case'center':pLeft+=(wnd.width()-this.uiDialog.outerWidth())/2;}}
if(pos[1].constructor==Number){pTop+=pos[1];}else{switch(pos[1]){case'top':pTop+=0;break;case'bottom':pTop+=wnd.height()-this.uiDialog.outerHeight();break;default:case'middle':pTop+=(wnd.height()-this.uiDialog.outerHeight())/2;}}
pTop=Math.max(pTop,minTop);this.uiDialog.css({top:pTop,left:pLeft});},_setData:function(key,value){(setDataSwitch[key]&&this.uiDialog.data(setDataSwitch[key],value));switch(key){case"buttons":this._createButtons(value);break;case"closeText":this.uiDialogTitlebarCloseText.text(value);break;case"dialogClass":this.uiDialog.removeClass(this.options.dialogClass).addClass(uiDialogClasses+value);break;case"draggable":(value?this._makeDraggable():this.uiDialog.draggable('destroy'));break;case"height":this.uiDialog.height(value);break;case"position":this._position(value);break;case"resizable":var uiDialog=this.uiDialog,isResizable=this.uiDialog.is(':data(resizable)');(isResizable&&!value&&uiDialog.resizable('destroy'));(isResizable&&typeof value=='string'&&uiDialog.resizable('option','handles',value));(isResizable||this._makeResizable(value));break;case"title":$(".ui-dialog-title",this.uiDialogTitlebar).html(value||'&nbsp;');break;case"width":this.uiDialog.width(value);break;}
$.widget.prototype._setData.apply(this,arguments);},_size:function(){var options=this.options;this.element.css({height:0,minHeight:0,width:'auto'});var nonContentHeight=this.uiDialog.css({height:'auto',width:options.width}).height();this.element.css({minHeight:Math.max(options.minHeight-nonContentHeight,0),height:options.height=='auto'?'auto':Math.max(options.height-nonContentHeight,0)});}});$.extend($.ui.dialog,{version:"1.7.1",defaults:{autoOpen:true,bgiframe:false,buttons:{},closeOnEscape:true,closeText:'close',dialogClass:'',draggable:true,hide:null,height:'auto',maxHeight:false,maxWidth:false,minHeight:150,minWidth:150,modal:false,position:'center',resizable:true,show:null,stack:true,title:'',width:300,zIndex:1000},getter:'isOpen',uuid:0,maxZ:0,getTitleId:function($el){return'ui-dialog-title-'+($el.attr('id')||++this.uuid);},overlay:function(dialog){this.$el=$.ui.dialog.overlay.create(dialog);}});$.extend($.ui.dialog.overlay,{instances:[],maxZ:0,events:$.map('focus,mousedown,mouseup,keydown,keypress,click'.split(','),function(event){return event+'.dialog-overlay';}).join(' '),create:function(dialog){if(this.instances.length===0){setTimeout(function(){$(document).bind($.ui.dialog.overlay.events,function(event){var dialogZ=$(event.target).parents('.ui-dialog').css('zIndex')||0;return(dialogZ>$.ui.dialog.overlay.maxZ);});},1);$(document).bind('keydown.dialog-overlay',function(event){(dialog.options.closeOnEscape&&event.keyCode&&event.keyCode==$.ui.keyCode.ESCAPE&&dialog.close(event));});$(window).bind('resize.dialog-overlay',$.ui.dialog.overlay.resize);}
var $el=$('<div></div>').appendTo(document.body).addClass('ui-widget-overlay').css({width:this.width(),height:this.height()});(dialog.options.bgiframe&&$.fn.bgiframe&&$el.bgiframe());this.instances.push($el);return $el;},destroy:function($el){this.instances.splice($.inArray(this.instances,$el),1);if(this.instances.length===0){$([document,window]).unbind('.dialog-overlay');}
$el.remove();},height:function(){if($.browser.msie&&$.browser.version<7){var scrollHeight=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight);var offsetHeight=Math.max(document.documentElement.offsetHeight,document.body.offsetHeight);if(scrollHeight<offsetHeight){return $(window).height()+'px';}else{return scrollHeight+'px';}}else{return $(document).height()+'px';}},width:function(){if($.browser.msie&&$.browser.version<7){var scrollWidth=Math.max(document.documentElement.scrollWidth,document.body.scrollWidth);var offsetWidth=Math.max(document.documentElement.offsetWidth,document.body.offsetWidth);if(scrollWidth<offsetWidth){return $(window).width()+'px';}else{return scrollWidth+'px';}}else{return $(document).width()+'px';}},resize:function(){var $overlays=$([]);$.each($.ui.dialog.overlay.instances,function(){$overlays=$overlays.add(this);});$overlays.css({width:0,height:0}).css({width:$.ui.dialog.overlay.width(),height:$.ui.dialog.overlay.height()});}});$.extend($.ui.dialog.overlay.prototype,{destroy:function(){$.ui.dialog.overlay.destroy(this.$el);}});})(jQuery);