﻿//Header profile
$(function() {
	$('a.button_sys_open').click(function() {
		 if ($.browser.msie) {$('.hSys_pop').css("display","block")} else {$('.hSys_pop').fadeIn(500)}
		 return false;
	});
	$('.hSys_pop_close').click(function() {
		 if ($.browser.msie) {$(this).parents('.hSys_pop').css("display","none")} else {$(this).parents('.hSys_pop').fadeOut(500)}
	});
});

//Paginator
$(function() {
	var paginators = $('#pagesBlock1');
	paginators.append('<div class="hr_line"></div>');
	paginators.prepend('<div class="hr_line"></div>');
});

//pagesBlockuz2
$(function() {
	var paginators = $('.pagesBlockuz2');
	paginators.append('<div class="hr_line"></div>');
	paginators.prepend('<div class="hr_line"></div>');
});

//Block vote
$(function() {
	var block_vote = $('.pollButton input.pollBut').clone();
	$('.bVote_bottom').append(block_vote);
	$('.bVote_bottom input').attr('value', ' ');
});

//Rating
$(function() {
	$('.u-current-rating').append('<b class="u_curr_rat_in"></b>');

	$(".u-current-rating").each(function() {
		var rat_full = $(this).width();
		if (rat_full>99) {
			$(this).find('b').remove();
		};
	}); 
	
	$("u-star-rating a").click(function() {
		var rat_full = $(this).find(".u-current-rating").width();
		if (rat_full>99) {
			$(this).find('.u-current-rating b').remove();
		};
	});


		if ($.browser.msie) {
		var ref_loop = setInterval(function() {
			$(".u-current-rating").each(function() {
				var rat_full = $(this).width();
				if (rat_full>99) {
					$(this).find('b').remove();
				};
			}); 
		}, 100);	
		ref_loop();
	};
});




//Login ucoz
sendFrm549009=function(){
 var o=$('#frmLg549009')[0],pos=_uGetOffset(o),o2=$('#blk549009')[0];
 document.body.insertBefore(o2,document.body.firstChild);
 $(o2).css({top:(pos['top'])+'px',left:(pos['left'])+'px',width:o.offsetWidth+'px',height:o.offsetHeight+'px',display:''}).html('<div align="left" style="padding:5px;"><div class="myWinLoad"></div></div>');
 _uPostForm('frmLg549009',{type:'POST',url:'/index/sub/',error:function() {
 $('#blk549009').html('<div align="left" style="padding:10px;"><div class="myWinLoadSF" title="Невозможно выполнить запрос, попробуйте позже"></div></div>');
 _uWnd.alert('<div class="myWinError">Невозможно выполнить запрос, попробуйте позже</div>','',{w:250,h:90,tm:3000,pad:'15px'});
 setTimeout("$('#blk549009').css('display','none');",'1500');
 }
 });
};


/* BLOCK_CATEGORY */
$(function() {
	$(".catsTable td a").prepend("<b></b>");
	$(".catsTable td").each(function() {
	var linkText = $(this).find("span").html();
	$(this).find("b").show().html(linkText); 
	}); 
});



//Forum
$(document).ready(function() {
	$(".gDivLeft").before('<div class="forum_top"><div class="forum_top_in"></div></div>');

	$("div.gDivRight").append('<div class="forum_lb_bg"><div class="forum_rb_bg"></div></div>');
	
	
});


$(function() {
	$(".forum_top").next().each(function() {
	var linkText = $(this).find("td.gTableTop").html();
	$(this).prev().show().find('.forum_top_in').html(linkText); 
	}); 
	$(".gTableTop").remove();
});




//Plugin cookie
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') {
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString();
        }
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};


//AddPost_options_hide
$(document).ready(function(){
	var lights = 0;
	var myCookie = $.cookie('light_ys');
	var lights = myCookie;
	
	if(lights != 1) {
		$('.fPost_option:hidden').slideDown(500);
		$('.fPost_option').addClass('current');
		$('.fPost_opt_hide').attr('value','Спрятать настройки');
	} else {
		$('.fPost_option:visible').hide();
		$('.fPost_option').removeClass('current');
		$('.fPost_opt_hide').attr('value','Показать настройки');
	};
	
	$('.fPost_opt_hide').click(function(){
			var myCookie = $.cookie('light_ys');
			var lights = myCookie;
			
			if(lights == 1) {
				$('.fPost_option').stop(true, true);
				$('.fPost_option:hidden').slideDown(500);
				$(this).addClass('current');
				$('.fPost_opt_hide').attr('value','Спрятать настройки');
				
				$.cookie('light_ys', 0);
				lights = $.cookie('light_ys');
				
			} else {
				$('.fPost_option').stop(true, true);
				$('.fPost_option:visible').slideUp(500);
				$(this).removeClass('current');
				$('.fPost_opt_hide').attr('value','Показать настройки');
				
				$.cookie('light_ys', 1);
				lights = $.cookie('light_ys');
				
			};
			return false;
			
		});
});






// complaint for admin
function complaint(admin) {
	new _uWnd('u_complaint', 'Жалоба на материал', 300, 100, {
		align: 0,
		shadow: 0,
		close: 1,
		autosize: 1,
		maxh: 500,
		minh: 100,
		resize: 0,
		oncontent: function () {
			$('.theme').change(function () {
				if ($('.theme option:selected').attr('value') == 'Битая ссылка') {
					$('#upComlaint').html('<fieldset><legend>Рабочая ссылка:</legend><input id="actLink" type="text" style="width:80%"><br><span style="font-size:9px;">Если у вас есть рабочая ссылка на файл, то укажите её.</span></fieldset></fieldset><fieldset><legend>Сообщение:</legend><textarea id="badM" style="width:80%;height:45px">Просьба исправить ссылку в материале, либо удалить его</textarea></fieldset>')
				}
				else if ($('.theme option:selected').attr('value') == 'Нарушение авторских прав') {
					$('#upComlaint').html('<fieldset><legend>Исходный файл:</legend><input id="actIst" type="text" style="width:80%"><br><span style="font-size:9px;">Файл доказывающий авторство(<b>.psd</b>,<b>.js</b> и т.п)</span></fieldset><fieldset><legend>Настоящий автор [<b>Имя</b>]:</legend><input id="actIstA" type="text" style="width:80%"></fieldset><fieldset><legend>Ссылка на сайт автора:</legend><input id="actIstL" type="text" style="width:80%"></fieldset><fieldset><legend>Ваше сообщение:</legend><textarea id="actIstM" style="width:80%;height:30px;"></textarea></fieldset>');
					$('#rP').val('Ссылка на файл: [url=' + location.href + ']' + location.href + '[/url]\nИсходный файл: [b]' + $('#actIst').val() + '[/b]\nИмя автора:[b] ' + $('#actIstA').val() + '[/b]\nСайт автора:[b] ' + $('#actIstL').val() + '[/b]\nСообщение:[b] ' + $('#actIstM').val() + '[/b]');
				}
				else if ($('.theme option:selected').attr('value') == 'Жалоба на материал') {
					$('#upComlaint').html('<fieldset><legend>Причина жалобы:</legend><textarea id="otherM" style="width:80%;height:100px"></textarea></fieldset>');
					$('#rP').val('Ссылка на файл: [url=' + location.href + ']' + location.href + '[/url]\nСообщение: [b]' + $('#otherM').val() + '[/b]\nИмя автора:[b] ' + $('#actIstA').val() + '[/b]\nСайт автора:[b] ' + $('#actIstL').val() + '[/b]\nСообщение:[b] ' + $('#actIstM').val() + '[/b]');
				}
				_uWnd.getbyname('u_complaint').checksize()
			});
			$('.nButton').click(function () {
				if ($('.theme option:selected').attr('value') == 'Битая ссылка') {
					if ($('#badM').val().length == '0') {
						_uWnd.alert('<center><font color="red">Не заполнено поле <b>Сообщение</b></font></center>', 'Ошибка', {
							w: 300,
							h: 70
						});
						$('#upReload').html('<img src="/.s/img/icon/er.png">')
					} else {
						$('.strClick').click();
						$('#rP').val('Ссылка на файл: [url=' + location.href + ']' + location.href + '[/url]\nРабочая ссылка: [b]' + $('#actLink').val() + '[/b]\nСообщение: [b]' + $('#badM').val() + '[/b]');
					}
				}
				if ($('.theme option:selected').attr('value') == 'Жалоба на материал') {
					if ($('#otherM').val().length < '5') {
						_uWnd.alert('<center><font color="red">Причина должна содержать более <b>5-и</b> символов</font></center>', 'Ошибка', {
							w: 300,
							h: 70
						});
						$('#upReload').html('<img src="/.s/img/icon/er.png">')
					} else {
						$('.strClick').click();
						$('#rP').val('Ссылка на файл: [url=' + location.href + ']' + location.href + '[/url]\nСообщение: [b]' + $('#otherM').val() + '[/b]');
					}
				}
				if ($('.theme option:selected').attr('value') == 'Нарушение авторских прав') {
					if ($('#actIst').val().length == '0') {
						_uWnd.alert('<center><font color="red">Не заполнено поле <b>Исходный файл</b></font></center>', 'Ошибка', {
							w: 300,
							h: 70
						});
						$('#upReload').html('<img src="/.s/img/icon/er.png">');
						return;
					}
					if ($('#actIstL').val().length == '0') {
						_uWnd.alert('<center><font color="red">Не заполнено поле <b>Ссылка на сайт автора</b></font></center>', 'Ошибка', {
							w: 300,
							h: 70
						});
						$('#upReload').html('<img src="/.s/img/icon/er.png">');
						return;
					}
					if ($('#actIstA').val().length == '0') {
						_uWnd.alert('<center><font color="red">Не заполнено поле <b>Настоящий автор [Имя]</b></font></center>', 'Ошибка', {
							w: 300,
							h: 70
						});
						$('#upReload').html('<img src="/.s/img/icon/er.png">');
						return;
					}
					else {
						$('.strClick').click();
						$('#rP').val('Ссылка на файл: [url=' + location.href + ']' + location.href + '[/url]\nИсходный файл: [b]' + $('#actIst').val() + '[/b]\nИмя автора:[b] ' + $('#actIstA').val() + '[/b]\nСайт автора:[b] ' + $('#actIstL').val() + '[/b]\nСообщение:[b] ' + $('#actIstM').val() + '[/b]')
					}
				}
			});
			$.get('/index/14-0-0-1/', function (data) {
				$('.caphaIMG').html('<img src=' + $('#secuImg', data).attr('src') + ' style="cursor:pointer;" class="reloaded" align="absmiddle" title="Обновить код безопасности">');
				$('.seCap').val($('input[name="seckey"]', data).val())
				reloaded = $('#secuImg', data).attr('onclick');
				$('.reloaded').click(reloaded)
				if ($('#secuImg', data).attr('src') == undefined) {
					$('#CF').hide()
				}
			});
			$('.strClick').click(function () {
				$('#upReload').html('<img src="/designs_123/loader.gif">')
				$.get('/index/14-0-0-1/', function (data) {
					var ssid = $('input[name="ssid"]', data).val();
					$.post('/index/', {
						a: '18',
						s: admin,
						subject: $('.theme option:selected').attr('value'),
						message: $('#rP').val(),
						seckey: $('.seCap').val(),
						code: $('.onCode').val(),
						ssid: ssid
					},
					function (s) {
						response = $(s).text();
						if (response.indexOf('успешно') != -1) {
							$('#upReload').html('<img src="/.s/img/icon/ok.png">');
							_uWnd.alert('<center><font color="blue">Жалоба отправлена на рассмотрение</font></center>', 'Успешно', {
								w: 300,
								h: 70
							});
							$('.reloaded').click();
							_uWnd.close('u_complaint')
						}
						else if (response.indexOf('безопасности') != -1) {
							$('#upReload').html('<img src="/.s/img/icon/er.png">');
							_uWnd.alert('<center><font color="red">Неверно введён <b>Код безопасности</b></font></center>', 'Ошибка', {
								w: 300,
								h: 70
							});
							$('.reloaded').click()
						}
						else if (response.indexOf('самому') != -1) {
							$('#upReload').html('<img src="/.s/img/icon/er.png">');
							_uWnd.alert('<center><font color="red">Отправлять сообщение самому себе - <b>бред</b></font></center>', 'Капитан Очевидность', {
								w: 300,
								h: 70
							});
							$('.reloaded').click()
						}
						else if (response.indexOf('запретил') != -1) {
							$('#upReload').html('<img src="/.s/img/icon/er.png">');
							_uWnd.alert('<center><font color="red">Админ запретил отправлять себе сообщения</font></center>', 'Ошибка', {
								w: 300,
								h: 70
							});
							$('.reloaded').click()
						}
						else if (response.indexOf('запрещён') != -1) {
							$('#upReload').html('<img src="/.s/img/icon/er.png">');
							_uWnd.alert('<center><font color="red">Доступ заперещён</font></center>', 'Ошибка', {
								w: 300,
								h: 70
							});
							$('.reloaded').click()
						}
					});
				});
			});

		}
	},
	'<div class="strClick"></div><fieldset><legend>Причина жалобы:</legend><select class="theme"><option value="Битая ссылка">Битая ссылка</option><option value="Нарушение авторских прав">Нарушение авторских прав</option><option value="Жалоба на материал">Другая причина</option></select></fieldset><div id="upComlaint"><fieldset><legend>Рабочая ссылка:</legend><input id="actLink" type="text" style="width:80%"><br><span style="font-size:9px;">Если у вас есть рабочая ссылка на файл, то укажите её.</span></fieldset><fieldset><legend>Сообщение:</legend><textarea id="badM" style="width:80%;height:45px">Просьба исправить ссылку в материале, либо удалить его</textarea></fieldset></div><fieldset id="CF"><legend>Код безопасности:</legend><input class="onCode" type="text" autocomplete="off" name="code" style="font-size:20px;padding:4px;width:60px;margin-right:3px;" size="5" maxlength="5"><span class="caphaIMG"></span></fieldset><fieldset><table width="100%"><tr><td align="left" valign="top"><table border="0" cellpadding="0" cellspacing="0" onmousedown="this.className=\'downBtn\'" onmouseover="this.className=\'overBtn\'" onmouseout="this.className=\'outBtn\'"><tr><td class="myBtnLeft"><img alt="" border="0" src="http://s1.ucoz.net/img/1px.gif"/></td><td class="myBtnCenter"><div class="myBtnCont x-unselectable" unselectable="on"><a href="javascript://" class="nButton" id="cButton">Оповестить</a> </div> </td><td class="myBtnRight"><img alt="" border="0" src="http://s1.ucoz.net/img/1px.gif"/></td></tr></table></td><td width="35%" align="right" valign="top"><span id="upReload"></span></td></tr></table></fieldset><input type="hidden" id="rP"><input type="hidden" class="seCap">')
};

//----------Tooltip-----------
$(function() {
$('a').tooltip({
track: true,
delay: 0,
showURL: false,
fade: 200
});
});
;(function($){var helper={},current,title,tID,IE=$.browser.msie&&/MSIE\s(5\.5|6\.)/.test(navigator.userAgent),track=false;$.tooltip={blocked:false,defaults:{delay:200,fade:false,showURL:true,extraClass:"",top:15,left:15,id:"tooltip"},block:function(){$.tooltip.blocked=!$.tooltip.blocked;}};$.fn.extend({tooltip:function(settings){settings=$.extend({},$.tooltip.defaults,settings);createHelper(settings);return this.each(function(){$.data(this,"tooltip",settings);this.tOpacity=helper.parent.css("opacity");this.tooltipText=this.title;$(this).removeAttr("title");this.alt="";}).mouseover(save).mouseout(hide).click(hide);},fixPNG:IE?function(){return this.each(function(){var image=$(this).css('backgroundImage');if(image.match(/^url\(["']?(.*\.png)["']?\)$/i)){image=RegExp.$1;$(this).css({'backgroundImage':'none','filter':"progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='"+image+"')"}).each(function(){var position=$(this).css('position');if(position!='absolute'&&position!='relative')$(this).css('position','relative');});}});}:function(){return this;},unfixPNG:IE?function(){return this.each(function(){$(this).css({'filter':'',backgroundImage:''});});}:function(){return this;},hideWhenEmpty:function(){return this.each(function(){$(this)[$(this).html()?"show":"hide"]();});},url:function(){return this.attr('href')||this.attr('src');}});function createHelper(settings){if(helper.parent)return;helper.parent=$('<div id="'+settings.id+'"><h3></h3><div class="body"></div><div class="url"></div></div>').appendTo(document.body).hide();if($.fn.bgiframe)helper.parent.bgiframe();helper.title=$('h3',helper.parent);helper.body=$('div.body',helper.parent);helper.url=$('div.url',helper.parent);}function settings(element){return $.data(element,"tooltip");}function handle(event){if(settings(this).delay)tID=setTimeout(show,settings(this).delay);else
show();track=!!settings(this).track;$(document.body).bind('mousemove',update);update(event);}function save(){if($.tooltip.blocked||this==current||(!this.tooltipText&&!settings(this).bodyHandler))return;current=this;title=this.tooltipText;if(settings(this).bodyHandler){helper.title.hide();var bodyContent=settings(this).bodyHandler.call(this);if(bodyContent.nodeType||bodyContent.jquery){helper.body.empty().append(bodyContent)}else{helper.body.html(bodyContent);}helper.body.show();}else if(settings(this).showBody){var parts=title.split(settings(this).showBody);helper.title.html(parts.shift()).show();helper.body.empty();for(var i=0,part;(part=parts[i]);i++){if(i>0)helper.body.append("<br/>");helper.body.append(part);}helper.body.hideWhenEmpty();}else{helper.title.html(title).show();helper.body.hide();}if(settings(this).showURL&&$(this).url())helper.url.html($(this).url().replace('http://','')).show();else
helper.url.hide();helper.parent.addClass(settings(this).extraClass);if(settings(this).fixPNG)helper.parent.fixPNG();handle.apply(this,arguments);}function show(){tID=null;if((!IE||!$.fn.bgiframe)&&settings(current).fade){if(helper.parent.is(":animated"))helper.parent.stop().show().fadeTo(settings(current).fade,current.tOpacity);else
helper.parent.is(':visible')?helper.parent.fadeTo(settings(current).fade,current.tOpacity):helper.parent.fadeIn(settings(current).fade);}else{helper.parent.show();}update();}function update(event){if($.tooltip.blocked)return;if(event&&event.target.tagName=="OPTION"){return;}if(!track&&helper.parent.is(":visible")){$(document.body).unbind('mousemove',update)}if(current==null){$(document.body).unbind('mousemove',update);return;}helper.parent.removeClass("viewport-right").removeClass("viewport-bottom");var left=helper.parent[0].offsetLeft;var top=helper.parent[0].offsetTop;if(event){left=event.pageX+settings(current).left;top=event.pageY+settings(current).top;var right='auto';if(settings(current).positionLeft){right=$(window).width()-left;left='auto';}helper.parent.css({left:left,right:right,top:top});}var v=viewport(),h=helper.parent[0];if(v.x+v.cx<h.offsetLeft+h.offsetWidth){left-=h.offsetWidth+20+settings(current).left;helper.parent.css({left:left+'px'}).addClass("viewport-right");}if(v.y+v.cy<h.offsetTop+h.offsetHeight){top-=h.offsetHeight+20+settings(current).top;helper.parent.css({top:top+'px'}).addClass("viewport-bottom");}}function viewport(){return{x:$(window).scrollLeft(),y:$(window).scrollTop(),cx:$(window).width(),cy:$(window).height()};}function hide(event){if($.tooltip.blocked)return;if(tID)clearTimeout(tID);current=null;var tsettings=settings(this);function complete(){helper.parent.removeClass(tsettings.extraClass).hide().css("opacity","");}if((!IE||!$.fn.bgiframe)&&tsettings.fade){if(helper.parent.is(':animated'))helper.parent.stop().fadeTo(tsettings.fade,0,complete);else
helper.parent.stop().fadeOut(tsettings.fade,complete);}else
complete();if(settings(this).fixPNG)helper.parent.unfixPNG();}})(jQuery);
