$(document).ready(function(){function wid(a,b){if(!b)$(".bg").fadeIn("fast",function(){$("#"+a).show("slow",function(){$(this).children(".pconent").show()})});else $(".pole").children(".pconent").hide(0,function(){$(".pole").hide("slow",function(){$(".bg").fadeOut("fast")})})};$("#auth,#auth_comment").click(function(){wid("form_auth");$(".login").click(function(){$("#form_auth form").submit()})});$(".login").click(function(){$("#form_auth form").submit()});$(".exit").click(function(){wid("",1)});$("#add_work").click(function(){if($("#auth").is("a")){wid("form_auth");$("#form_auth input[name=url]").val("http://konkurs.prizyvnik.info/addwork/")}else window.location.href="/addwork/"});$("#notshow").click(function(){if($(this).is(":checked")){$("#username").removeAttr("readonly");$("#username").select()}else{$("#username").attr("readonly","readonly");$("#username").val($("#username").attr("rev"))}});function cheklen(){if($(this).val().length>300){$(this).val($(this).val().substring(0,300))}};$("#about").change(cheklen).keypress(cheklen);var d=function(){$(this).unbind("click",d);var b='';var c=$(".index_main :input").serializeArray();$.each(c,function(i,a){if(b)return false;else if(a.name!='about'&&a.name!='city'&&a.value=='')b='Необходимо заполнить все поля отмеченные знаком звездочка!';else if(a.name=='text'&&$.trim(a.value.replace(/(\[([^\]]+)\])/g,"").replace(/\s+/g," ")).length<100){b='Текст вашей работы слишком короткий!'}});if(!b&&!$("input[name=agree]").is(":checked"))b='Вам необходимо принять правила конкурса для того что бы отправить нам свою работу!';if(b){alert(b);$(this).bind("click",d)}else{$(".index_main :input[name!=file],.mceLayout,.button").css("opacity","0.5");$.post("/1/4/1/add.phtml",{form:c,isBlank:1},function(a){if(a.success){wid("send_work");$(".exit").click(function(){wid("",1);window.location.href="http://konkurs.prizyvnik.info/"})}else if(a.error)alert(a.error);$(".index_main :input[name!=file],.mceLayout,.button").css("opacity","1");$("#add").bind("click",d)},"json")}};$("#add").bind("click",d);$("#add").ajaxError(function(){alert("По техническим причинам, в данный момент мы не можем принять вашу работы, пожалуйста, попробуйте отправить ее к нам еще раз через несколько минут.");$(".index_main :input[name!=file],.mceLayout,.button").css("opacity","1");$(this).bind("click",d)});$(".getlink").click(function(){wid("getlink");$("#getlink input").click(function(){$(this).select()})});$(".getvoit").click(function(){wid("getvoit");var c=['Ужасно!','Плохо :(','Удовлетворительно.','Хорошо :)','Отлично!'];$("#getvoit .vote").hover(function(){var a=$(this).index();$("#getvoit .horosho").text(c[a]);$("#getvoit .vote").each(function(i){if(i<=a){$(this).attr("src","/images/star_red.png")}})},function(){$("#getvoit .horosho").text('');$("#getvoit .vote").attr("src","/images/star_grey.png")});$("#getvoit .vote").click(function(){var b=$(this).index();$.post(window.location.href,{rate:1,point:b+1,isBlank:1},function(a){if(a.success){$("#getvoit .vote_ramka").html("<br/><br/><br/><span class=\"horosho\" style=\"color:#D20000\">Спасибо, ваш голос принят!</span>");setTimeout(function(){wid("getvoit",1)},3000)}else if(a.error)alert(a.error)},"json")})});$(".date1 .one_work_button").click(function(){var b=$(".date1 textarea").val();var c=$(".date1 input[name=work]").val();if(b==''||b.length<3){alert("Вы не указали свое сообщение или ваше сообщение слишком короткое!")}else if(c>0){$(".date1 textarea").css("opacity","0.5");$.post("/4/6/1/add.phtml",{text:b,work:c,isBlank:1},function(a){if(a.success){alert("Ваше мнение добавлено");window.location.reload(true)}else if(a.error)alert(a.error)},"json")}})});
