function URLEncode(clearString)
{var output='';var x=0;clearString=clearString.toString();var regex=/(^[a-zA-Z0-9_.]*)/;while(x<clearString.length)
{var match=regex.exec(clearString.substr(x));if(match!=null&&match.length>1&&match[1]!='')
{output+=match[1];x+=match[1].length;}
else
{if(clearString[x]==' ')
output+='+';else
{var charCode=clearString.charCodeAt(x);var hexVal=charCode.toString(16);output+='%'+(hexVal.length<2?'0':'')+hexVal.toUpperCase();}
x++;}}
return output;}
function reportNotWorkingVideo(id)
{if(!id)return false;$('#report_not_working_video').text('Wysy\u0142anie...');$.ajax({type:"POST",url:"/reports,index,ajax-not-working-video.html",dataType:"json",timeout:10000,data:"id="+id,success:function(response)
{if(response.status==1)
{$('.response').html('<span style="color: green;">'+response.message+'</span>');$('.report_not_working_video').text('Zg\u0142oś niedziałający film');}
else
{$('.response').html('<span style="color: #c00;">'+response.message+'</span>');$('.report_not_working_video').text('Zg\u0142oś niedziałający film');}
$('.response').show();}});return false;}
function reportNotWorkingEpisode(id)
{if(!id)return false;$('#report_not_working_episode').text('Wysy\u0142anie...');$.ajax({type:"POST",url:"/reports,index,ajax-not-working-episode.html",dataType:"json",timeout:10000,data:"id="+id,success:function(response)
{if(response.status==1)
{$('.response').html('<span style="color: green;">'+response.message+'</span>');$('.report_not_working_episode').text('Zg\u0142oś niedziałający odcinek');}
else
{$('.response').html('<span style="color: #c00;">'+response.message+'</span>');$('.report_not_working_episode').text('Zg\u0142oś niedziałający odcinek');}
$('.response').show();}});return false;}
function sendVideoVote(video,vote)
{if(!video||!vote)return false;$('#rating-stats form input').rating('disable')
$('#text_message').text('Wysy\u0142anie...');$.ajax({type:"POST",url:"/videos,votes,ajax-vote.html",dataType:"json",timeout:10000,data:"video="+video+"&vote="+vote,success:function(response)
{if(response.status==1)
{$('#text_message').html('<span style="color: green;">'+response.message+'</span>');}
else
{$('#text_message').html('<span style="color: #c00;">'+response.message+'</span>');}
$('#text_message').attr('id','')}});return false;}
function importFilmWebData(url)
{$("input#run_import").attr('disabled','disabled');if(url)
{$('div#import_fw_data').fadeIn('slow');$.ajax({type:"POST",url:"/videos,manage,ajax-import-film-web-data.html",dataType:"json",timeout:30000,data:"url="+URLEncode(url),success:function(response)
{if(response.status==1)
{$("form#add_movie input[name='title']").val(response.data.title);$("form#add_movie textarea[name='description']").text(response.data.description);$("form#add_movie select>option").attr('selected','');$(response.data.categories).each(function(item){$("form#add_movie select>option[value='"+response.data.categories[item]+"']").attr('selected','selected');});if(response.data.image)
{$("form#add_movie ul.errors").hide();$("form#add_movie input[type='file']").parent('p').hide();$("form#add_movie input[name='fw_image']").val(response.data.image);$("#import_poster").attr('src',response.data.image);$("#import_poster").show();}
$('div#import_fw_data p#message').html('Dane filmu zosta\u0142y wczytane do formularza!');$('div#import_fw_data p#preloader').hide();$('div#import_fw_container').hide();}
else
{$('div#import_fw_data p#message').html(response.message);$('div#import_fw_data p#preloader').hide();}
$("input#run_import").attr('disabled','');}});}
else
{alert('Musisz poda\u0107 link do filmu!');$("input#run_import").attr('disabled','');}
return false;}
/*$(document).ready(function(){$(function(){$(".latest").jCarouselLite({btnNext:".next_latest",btnPrev:".prev_latest",visible:5,circular:true});});$(function(){$(".recently_viewed").jCarouselLite({btnNext:".next_recently_viewed",btnPrev:".prev_recently_viewed",visible:5,circular:true});});$(function(){$(".recently_commented").jCarouselLite({btnNext:".next_recently_commented",btnPrev:".prev_recently_commented",visible:5,circular:true});});$(function(){$("input#run_import").click(function(){importFilmWebData($('input#import_link').val());return false;});});$(function(){var image=$("form#add_movie input[name='fw_image']").val();if(image)
{$("#import_poster").attr('src',image);$("#import_poster").show();}});$('.prev').hover(function(){$(this).attr('src','/static/theme/main/img/button_left_active.png');});$('.next').hover(function(){$(this).attr('src','/static/theme/main/img/button_right_active.png');});$('.prev').mouseout(function(){$(this).attr('src','/static/theme/main/img/button_left.png');});$('.next').mouseout(function(){$(this).attr('src','/static/theme/main/img/button_right.png');});$('.report_not_working_video a').click(function(){reportNotWorkingVideo($('.report_not_working_video a:first').attr('target'));return false;});$('.report_not_working_episode a').click(function(){reportNotWorkingEpisode($('.report_not_working_episode a:first').attr('target'));return false;});$('.thumbnail_on_site').click(function(){$('.embed').toggle();return false;});$('.response').click(function(){$('.response').hide();});$('.embed. textarea').click(function(){$(this).focus();$(this).select();});var pos=$(".footer").offset();pos=pos.top+100;$(".description").css({"top":pos+"px"});});*/