function addInput(){$("#addPhoto").prepend('<input type="file" name="photo" />');bindFileCursor();$("#addNewPhoto").unbind("click");$("#addNewPhoto").click(function(){if($("#addPhoto input").length==1&&$("#addPhoto input").val()!=""&&$("#addPhoto input").val()!=undefined){var a=new Date();$("body").append('<iframe src="#" id="iframe" name="iframe" style="display: none;"></iframe>');var b="";if($("input[name=id]").val()!=undefined){b='<input type="hidden" name="contentid" value="'+parseInt($("input[name=id]").val())+'" />'}$("body").append('<form id="form" enctype="multipart/form-data" method="post" action="/doaddphoto/" target="iframe">'+b+"</form>");$("#form").append($("#addPhoto input"));$("#form").submit();$("*").css("cursor","progress");$("#iframe").load(function(){$("*").css("cursor","");var c=$(document.getElementById("iframe").contentWindow.document.body);var d=c.text();var e=d.split("|");if(e[4]==""){if(e[0]==1){if(e[1]!=0){$(".caddform").append('<input type="hidden" name="id" value="'+parseInt(e[1])+'" />')}else{alert("‚îçíèêëè îøèáêè ïðè ïðåäâàðèòåëüíîì ñîõðàíåíèè êîíòåíòà. Žáðàòèòåñü â ñëóæáó ïîääåðæêè!")}}if(e[2]!=0){showNewPhoto(e[2],e[3])}else{alert("‚îçíèêëè îøèáêè ïðè çàãðóçêå ôîòî. Žáðàòèòåñü â ñëóæáó ïîääåðæêè!")}}else{alert(e[4])}removeIframe();removeForm();addInput()})}else{alert("„ëß äîáàâëåíèß ôîòî íåîáõîäèìî åãî âûáðàòü!")}return false})}function showNewPhoto(a,b){$("#photos").prepend('<img class="adedPhoto" id="'+b+'_photo" src="'+a+'" alt="" />');bindDeletePhoto()}function bindDeletePhoto(){$("#photos img.adedPhoto").unbind("click");$("#photos img.adedPhoto").click(function(){var a=parseInt($(this).attr("id"));if(confirm("“äàëèòü ôîòî?")){$("*").css("cursor","progress");$.get("/adminarea/content/deletephoto/",{id:a},function(b){$("*").css("cursor","");if(b!=""){alert("‚îçíèêëè îøèáêè ïðè óäàëåíèè ôîòî. Žáðàòèòåñü â ñëóæáó ïîääåðæêè!")}else{$("#"+a+"_photo").remove()}})}})}function removeIframe(){$("#iframe").remove()}function removeForm(){$("#form").remove()}function bindFileCursor(){$("#addPhoto input").hover(function(){$("*").css("cursor","pointer")},function(){$("*").css("cursor","")})}function ratingContent(c,a,b){$.getJSON("/system/ratingContent.html",{ContentId:c,UserId:a,Rating:b},onratingContent)}function onratingContent(a){if(a.status==1){$(".rateContent span.plus").text(a.rating_plus);$(".rateContent span.minus").text(a.rating_minus)}}function commentContent(c,a,b){$.getJSON("/system/ratingComment.html",{CommentId:c,UserId:a,Rating:b},onratingComment)}function onratingComment(a){if(a.status==1){$(".rateComment"+a.CommentId+" span.plus").text(a.rating_plus);$(".rateComment"+a.CommentId+" span.minus").text(a.rating_minus)}}$(document).ready(function(){});
