if(/^(?:www\.)?nintendoclub\.ru$/.test(location.host)){
for(i in $.browser)
	if($.browser[i]===true) $(document.documentElement).addClass(i);
String.prototype.trim = function(){
	return this.replace(/^\s+/gm, '').replace(/\s+$/mg, '');
};
nintendoclub = {
	restoreDefault	: function(e){e.value=e.value==e.defaultValue?'':e.value},
	removeDefault	: function(e){e.value=e.value==''?e.defaultValue:e.value},
	getRelated		: function(u){
		var o = $('#relatedNews');
		function err(){
			o.remove();
		}
		if(!u) return err();
		$.get(u, function(data){
			var n = data.indexOf('<!--bs-->')+9,
				l = data.lastIndexOf('<!--be-->'),
				c = 0;
			if(n==-1||l==-1) return err();
			data = $('<div>'+data.substring(n,l)+'</div>');
			$('li.loading',o).remove();
			$('div.search-entry:lt(3)',data).each(function(){
				var link = $('a:last',this),
					cat = $('span:first a',this);
				if(location.href.indexOf(link.attr('href'))!=-1) return;
				c++;
				$('ul',o).append('<li><h5><a href="'+link.attr('href')+'">'+link.text()+'</a></h5><span class="info">Категория: <a href="'+cat.attr('href')+'">'+cat.text()+'</a></span></li>');
			});
			if(c==0) err();
		});
	},
	doRate			: function(rate, id, module, cid){
		if(typeof rate == 'undefined' ||
		   typeof id == 'undefined' )
				return; // not enough data
		if(typeof module == 'undefined' || module===false){
			module = location.href.match( new RegExp(location.host+'/'+'(\\w+)','i') );
			if(!module)return;
			module = module[1];
		};
		var callback = function(data){
			rateBar.show().next().remove();
			data = $('cmd:first',data).text();
			var rdata = data.match(/Рейтинг:\s*([0-9.]+)\/(\d+)/i);
			
			if( !rdata ){
				try{
					eval(data);
				} catch(e){};
				return;
			}
			$('#entry-rating_'+id).html( (rdata[1]*2).toFixed(1) );
			$('li.current-rating',rateBar).css('width',parseInt(rdata[1])*12+'px');
			_uWnd.alert( 'Оценка засчитана' );
		};
		var rateBar = $('#rate-bar_'+id).hide().after('<img src="/images1/1-0.gif" alt="Пожалуйста, подождите" />'),url;
		switch(module){
			case 'publ':
			case 0: // publ
				url = '/publ/0-1-'+rate+'-'+id+'-3';
				break;
			case 'board':
			case 1: // board
				url = '/board/0-1-'+rate+'-'+id+'-3';
				break;
			case 'photo':
			case 2:
				url = '/photo/'+cid+'-1-'+id+'-13-'+rate;
				break;
		}
		$.get(url,callback);
	},
	customize		: {
		input: function(elem,attrs,events){
			var t = $(elem||this),i=0,uclassName; /* Get argument or curElement */
			attrs = attrs || {};
			events = $.extend({click:function(){$('input.'+this.rel).click(); return false}},events||{});
			t.filter('input').each(function(){ /* Inputs only! No <button> */
				uclassName = 'customInput_'+parseInt((new Date().getTime()*.001))+i; /* unique class => unique selector */
				if(!$(this).is('[type="button"], [type="submit"], [type="reset"], :visible') ) return; /* No need to work with hidden or non-button inputs */
				var btn = $('<a href="#" class="button" rel="'+uclassName+'"><span class="leftCorner"><img src="http://s6.ucoz.net/img/ma/1px.gif" alt="" /></span><span class="value">'+this.value+'</span><span class="rightCorner"><img src="http://s6.ucoz.net/img/ma/1px.gif" alt="" /></span></a>').attr(attrs);
				for(var eventName in events)
					btn.bind(eventName, events[eventName]);
				$(this).addClass(uclassName).hide().after(btn); // Insert HTML code after input & hide curElement
				i++
			});
		},
		select: function(){
			if( $(this).parent('div.customSelectParent').size()==0 ) /* No need parent? */
				$(this).wrap('<div></div>').parent().addClass('customSelectParent'); /* Let's make them!  */
			var options = $('option',this), /* Get all options */
				values = [], /* Prepare array for options */
				changeFnc = $(this).attr('onchange')?eval($(this).attr('onchange')):function(){}, /* onchange function */
				active = $('option[selected]',this), // curValue 
				width = $(this).width()+10; // Calculate width
			if( active.size() )
				$('option[selected]', this).remove(); // destroy active
			else {
				active = $('option:first', this); // no option[selected] element => first element is current. Remember value
				$('option:first', this).remove(); // And destroy him! ]:-D
			}
			var curVal = active.text(),
				options = options.map(function(){ // Create values array
								values[$(this).text()] = $(this).val(); // Read value
								return {value:$(this).val(), text:$(this).text(), style: this.style.cssText}; // return value, text and css style
							}).get(), // compare array
				parentDiv = $(this).parent(); // get parentDiv
			values[curVal] = active.val(); // Write current Val. There is no curval in array becouse we deleted him from options
			$(this).after('<div>'+curVal.trim()+'</div>').remove(); // In this block we will write current Value
			parentDiv.css('width',width+'px').click(function(){ // Bind onclick function and set width
				if( $('div.activeCustomSelectParent').size() )
					return;
				$(this).addClass('activeCustomSelectParent');
				var offset = $(this).offset(),
					div = $('<div class="selectPopUp"></div>'),
					toAppend='';
				for(i=0; i<options.length; i++)
					if( options[i].text!=$(this).text().replace(/^\s+|\s+$/g,'').replace(/\s{2,}/g,' ') )
						toAppend += '<div style="'+options[i].style+'"' + ($.browser.msie ? ' onmouseover="$(this).addClass(\'hover\')" onmouseout="$(this).removeClass(\'hover\')"' : '') + '>'+options[i].text+'</div>';
				div.append(toAppend).css({width:$(this).width()+6,top:offset.top+$(this).height()-2,left:offset.left+1+2*$.browser.msie}).hide();
				$('div',div).click(function(){
					var d = $('div',parentDiv).text(this.innerHTML.trim());
					changeFnc.apply(d.get(0), [ {value:values[$(this).text()], text:$(this).text()} ]);
					parentDiv.removeClass('activeCustomSelectParent');
				});
				div.appendTo('body').slideDown('fast',function(){	
					$(document).click(function(){
						div.slideUp(100,function(){$(this).remove()});
						parentDiv.removeClass('activeCustomSelectParent');
						$(this).unbind('click').removeAttr('onclick');
					});
				});
				return false
			});
		}
	}
};
$(function(){
	$('#market_buttons li').click(function(){
		var market_wrapper = $('#market_wrapper');
		if($(this).is('.current')) return;
		$('#market_buttons li.current').removeClass('current');
		$(this).addClass('current');
		if( $(this).next('li').size() == 0 )
			market_wrapper.stop().scrollTo( market_wrapper.height(), 800 );
		else
			market_wrapper.stop().scrollTo( 0, 800 );
	});
	if($.browser.msie && $.browser.version<7)
		$('#navigation li').hover(function(){$(this).addClass('hover')}, function(){$(this).removeClass('hover')});
	var footer = $('#footer'), content = $('#content');
	footer.css('width',content.width()-50);
	onresize = function(){footer.css('width',content.width()-50); return arguments.callee}();
	$('a').each(function(){
		if( $(this).is('[rel="external"]') )
			$(this).click(function(){
				open(this.href);
				return false;
			});
		if( $(this).is('.slideButton') )
			$(this).click(function(){
				$(this).next('div.slidePanel').slideToggle();
				return false;
			});
	});
	$('#tabs > div:first > div').click(function(){
		var tabs = $(this).parents('#tabs:first').addClass('active'),tar,contents;
		(contents = $('div.wrapper div.bigBlock div.content',tabs)).hide();
		if((tar = $('div.full-text',tabs)).length==0){
			var bb =$('div.bigBlock:first',this);
			tar = $('<div class="full-text bigBlock"><div class="content"></div><div class="bottom"><div class="left"></div><div class="right"></div></div></div>').appendTo(tabs).css('top',$('div.head:first',bb).height()-bb.height()-parseInt(bb.css('margin-bottom'))+1 );
		}
		tar.show().css('width',tabs.width()-2-($.browser.msie&&parseInt($.browser.version)==6));
		$('div.active-block',tabs).removeClass('active-block');
		$(this).addClass('active-block');
		$('div.content:first',tar).html($('div.hidden:first',this).html()+'<div id="close"></div>');
		$('<a href="#">Закрыть</a>').click(function(){
			tabs.removeClass('active');
			tar.hide();
			contents.show();
			$('div.active-block',tabs).removeClass('active-block');
			return false;
		}).appendTo('#close');
		return false;
	})
	$('select.customSelect').each(nintendoclub.customize.select);
});
$(window).load(function(){
	$('#market_wrapper').css('height',$('#market_new').height());
	$('#market_recomended').show();
});}