/*
vPack JS
generated 2012.01.26 10:45:15
*/

/* js/EDI_VIDEO/admin.js */

$(document).ready(function(){if($('div.adminHomeAction').length)
{$('div.adminHomeAction a.jsDelete').click(function(){var indicator=$(this).parents('div.videoItem').find('div.jsIndicator');var actions=$(this).parent('div');var id=$(this).attr('name');if(confirm(lang['deleteVideo']))
{actions.hide();indicator.show();$.ajax({type:'POST',url:'/ajax/admin/videoDelete',data:'videoID='+id,dataType:'json',success:function(msg){if(msg)
{actions.parent('div').fadeOut('slow',function(){$(this).remove();});}
else
{actions.show();indicator.hide();alert(lang['deleteVideoError']);}}});}
return false;});var apiVideo=$('div.jsVideoItemEdit').overlay({api:true,expose:{color:'#000000',opacity:0.6,closeOnClick:false,closeOnEsc:true},closeOnClick:false,closeOnEsc:true});var videoEditID;var videoElement;var videoName;$(window).bind('ajaxSuccess',function(event,data){if($('div#vFormvFormvideoFormOK:visible').length){$('body > img:visible').animate({height:'150px'},500);}});$(window).bind('ajaxSend',function(event,XMLHttpRequest,ajaxOptions){if(ajaxOptions.formID=="vFormvideoForm")
{videoName=$('input#vFormInputvideoForm_title').val();}});$(apiVideo).bind('onBeforeClose',function(event,p){videoElement.find('p.title a').text(videoName);});$(apiVideo).bind('onBeforeLoad',function(event,p){var wrap=this.getContent().find('div.wrap');wrap.html('');$.ajax({type:'POST',url:'/empty/admin/videoGet',data:'videoID='+videoEditID,dataType:'html',success:function(msg){wrap.html(msg);vForm.init();$('body > img:visible').height($('form#vFormvideoForm').height()+100);}});});$('div.adminHomeAction a.jsEdit').click(function(){videoEditID=$(this).attr('name');videoElement=$(this).parents('div.videoItem');videoName=videoElement.find('p.title a').text();apiVideo.load();return false;});}});

/* js/EDI_VIDEO/video.js */

$(document).ready(function(){$('a.permalink').click(function(){var a=$(this);var respond=$('#responds');respond.show().html('<div class="boxInfo"><strong>'+lang['sendURL']+':</strong> <input type="text" class="permalink" readonly="readonly" value="'+a.attr('href')+'" /></div>');$('input[type=text].permalink',respond).focus(function(){$(this).select();});return false;});$('.jsNewFavourite').click(function(){var a=$(this);var respond=$('#responds');respond.show().html('<div class="indicator"></div>'+lang['wait']);$('div.indicator',respond).show();$.ajax({type:'POST',url:'/empty/addVideoFavourite',data:'videoID='+$(a).attr('name'),dataType:'html',success:function(data){respond.html(data);}});return false;});if($('div.similarVideo').length)
{$('div.similarVideo div.scrollable').scrollable({api:true,size:1,next:'#nextScroll',prev:'#prevScroll'});$('div.similarVideo p.buttons a.first').click(function(){$('div.similarVideo div.scrollable').scrollable().begin();});$('div.similarVideo p.buttons a.last').click(function(){$('div.similarVideo div.scrollable').scrollable().end();});var scrollableHeight=$('div.similarVideo div.scrollable div.items').outerHeight();$('div.similarVideo div.scrollable').height(scrollableHeight+'px');if($('div.similarVideo div.scrollable div.items div').length<7)
{$('div.similarVideo p.buttons').remove();}
else
{var div=$('div.similarVideo p.'+$('div#player').attr('class')).parent('div');var index=jQuery.makeArray($('div.similarVideo div.scrollable div.items div')).indexOf(div.get(0));$('div.similarVideo div.scrollable').scrollable().seekTo(index);}}
if($('div.channelVideos').length)
{$('div.channelVideos div.scrollable').scrollable({api:true,size:1,next:'#nextScrollChannel',prev:'#prevScrollChannel'});$('div.channelVideos p.buttons a.first').click(function(){$('div.channelVideos div.scrollable').scrollable().begin();});$('div.channelVideos p.buttons a.last').click(function(){$('div.channelVideos div.scrollable').scrollable().end();});var scrollableHeight=$('div.channelVideos div.scrollable div.items').outerHeight();$('div.channelVideos div.scrollable').height(scrollableHeight+'px');if($('div.channelVideos div.scrollable div.items div').length<7)
{$('div.channelVideos p.buttons').remove();}
else
{var div=$('div.channelVideos p.'+$('div#player').attr('class')).parent('div');var index=jQuery.makeArray($('div.channelVideos div.scrollable div.items div')).indexOf(div.get(0));$('div.channelVideos div.scrollable').scrollable().seekTo(index);}}
$('.interestingBox a.voteInteresting').click(function(){var a=$(this);var respond=$(a).parents('.respondBox').find('.respond');respond.show().html('<div class="smallLeftIndicator"></div>'+lang['wait']);$('div.smallLeftIndicator',respond).show();$.ajax({type:'POST',url:'/empty/addVideoVote',data:'videoID='+$(a).attr('name'),dataType:'html',success:function(data){respond.html(data);if(data.search('Głos zapisany')>0)
{var i=a.parents('div.respondBox').find('div.interesting2 span');i.html(parseInt(i.html())+1);}}});return false;});$("form.search input.query").focus(function(){if($(this).val()==lang['searchInputText']){$(this).val('');}});$("form.search input.query").blur(function(){if($(this).val()==''){$(this).val(lang['searchInputText']);}});$('a.jsMoreCategories').click(function(){$(this).toggleClass('up');$('div.jsCategoriesHidden').toggle();return false;});});

/* js/EDI_VIDEO/contest.js */

$(document).ready(function(){if($('#addToContestPanel').length)
{var addedVideoCount=parseInt($('#addToContestPanel').attr('title'));var uploadedVideoCount=parseInt($('#addToContestPanel').attr('name'));var maxVideoPerUser=parseInt($('#addToContestPanel').attr('alt'));var contestID=parseInt($('#addToContestPanel').attr('ref'));if(maxVideoPerUser>1)
{$('#contestStat').html('('+parseInt(uploadedVideoCount+addedVideoCount)+'/max '+maxVideoPerUser+')');}
if(addedVideoCount>0){$('a#addToContestLink').show();}else{$('a#addToContestLink').hide();}
var addToContestF=function(){if(uploadedVideoCount+addedVideoCount>=maxVideoPerUser||$(this).hasClass('fadeOut')){return false;}
addedVideoCount++;if(maxVideoPerUser>1)
{$('#contestStat').html('('+parseInt(uploadedVideoCount+addedVideoCount)+'/max '+maxVideoPerUser+')');}
var videoImg=$(this).parents('div.videoItem').find('img');var videoID=videoImg.attr('id').split('_');$.cookie('CONTEST_VIDEOS_'+contestID,($.cookie('CONTEST_VIDEOS_'+contestID)?$.cookie('CONTEST_VIDEOS_'+contestID)+'_':'')+videoID[1]);$('a#addToContestLink').attr({href:$('a#addToContestLink').attr('alt')+'?upload='+$.cookie('CONTEST_VIDEOS_'+contestID)});var el=$('<div class="imgEl"><span></span><img id="thumb_'+videoID[1]+'" class="addedPhoto" src="'+videoImg.attr('name')+'" alt="'+videoImg.attr('alt')+'" /></div>');$('div#addToContestPanel').append(el);el.hide().fadeIn('slow');if(addedVideoCount>0){$('a#addToContestLink').show();}else{$('a#addToContestLink').hide();}
$(this).unbind('click').hide();$(this).parents('div.videoItem').addClass('fadeOut');return false;};var delFromContestF=function(){var a=$(this).next('img');var id=a.attr('id').split('_');var idPhoto='#video_'+id[1];addedVideoCount--;$.cookie('CONTEST_VIDEOS_'+contestID,$.cookie('CONTEST_VIDEOS_'+contestID).replace('_'+id[1],'').replace(id[1],''));$('a#addToContestLink').attr({href:$('a#addToContestLink').attr('alt')+'?upload='+$.cookie('CONTEST_VIDEOS_'+contestID)});if(maxVideoPerUser>1)
{$('#contestStat').html('('+parseInt(uploadedVideoCount+addedVideoCount)+'/max '+maxVideoPerUser+')');}
if(addedVideoCount>0){$('a#addToContestLink').show();}else{$('a#addToContestLink').hide();}
$(idPhoto).parents('div.videoItem').find('div.actions a').show();$(idPhoto).parents('div.videoItem').find('div.actions a').bind('click',addToContestF);$(idPhoto).parents('div.videoItem').removeClass('fadeOut');a.parent('div.imgEl').remove();};$('div#addToContestPanel div.imgEl span').live('click',delFromContestF);$('div#addToContestPanel div.imgEl span').click(delFromContestF);$('a#addToContestLink').click(function(){$.cookie('CONTEST_VIDEOS_'+contestID,null);});$('div.videoItem div.actions a').click(addToContestF);}});
