$(document).ready(function(){
	$('#header .mainMenu ul.menu li:has(ul)').each(function(){
		var $t=$(this);
		$t.lnk=$t.find('a:first');
		$t.subMenu=$t.find('ul:first');
		$t.lnk.hover(function(){
			$t.addClass('active');
			$t.lnk.append('<span class="arr"><!----></span>');
		},function(){
			$('#header .mainMenu li.active').removeClass('active');
			$('#header .mainMenu span.arr').remove();
		});
		$t.subMenu.hover(function(){
			$t.addClass('active');
			$t.lnk.append('<span class="arr"><!----></span>');
		},function(){
			$('#header .mainMenu li.active').removeClass('active');
			$('#header .mainMenu span.arr').remove();
		});
	});
	$('#header ul.mainMenu li.active > a').append('<span class="arr"><!----></span>');
	
	$('#header div.citySelect li:not(:last), #content div.citySelect li:not(:last)').each(function(){
		$(this).append('<span class="saparator"><!----></span>');
	});
	
	$('#header a.btnFav').click(function(e){
		e.preventDefault();
		var url=location.protocol+'//'+location.host;
		window.external.AddFavorite(url,'Ukrmisto');
	});
	
	$('#leftSidebar ul.expandable li:has(ul) > a').each(function(){
		var $t=$(this);
		$t.prnt=$t.parent();
		$t.subMenu=$t.next('ul');
		$t.prepend('<span class="arr"><!----></span>').click(function(e){
			e.preventDefault();
			if($t.prnt.hasClass('closed')){
				$t.prnt.removeClass('closed');
				$t.subMenu.slideDown(500);
			}else{
				$t.subMenu.slideUp(500,function(){
					$t.prnt.addClass('closed');
				});
			}
		});
	});
	
	$('ul.bloglist > li:last,#bottomMenu > li:last,ul.alphabet > li:last').addClass('last');
	$('#bottomMenu > li:first,ul.alphabet > li:first').addClass('first');
	
	$('#leftSidebar div.leftLinks a, #mainContent ul.sorting a.down, #mainContent ul.sorting a.up').prepend('<span><!----></span>');
	
	$('ul.contList > li:even, ul.commentsList > li:even').addClass('even');
	
	if($('#carouselAlbumUl > li').length){
		if($('#carouselAlbumUl > li').length>7){
			$('#carouselAlbum').jCarouselLite({
				auto:0,
				visible:7,
				speed:1000,
				scroll:1,
				btnPrev:$('#carouselPrev'),
				btnNext:$('#carouselNext')
			});
			$('#carouselPrev').show();
			$('#carouselNext').show();
		}
	}
	
	$('ul.twoLinks a').each(function(){
		$(this).after('<span>'+$(this).text()+'</span>');
	});
	
	$(window).scroll(function(){
		if(parseInt(window.pageYOffset)>300){
			if(!$('#upLink').length){
				$('body').prepend('<input type="text" name="#" id="toTop" /><a href="#" id="upLink"></a>');
				$('#upLink').click(function(e){
					e.preventDefault()
					$('#toTop').show().focus().hide();
				});
			}
			$('#upLink').show();
		}else{
			$('#upLink').hide();
		}
	});
	
	$('.views-exposed-form input:radio').bind('click',function(e){$('#edit-submit-catalogue').click();});
});



