(function( $ ){
	$(document).ready(function(){

		// :hover dekoracijos
		$('.recentcomments, #Recent li, #recent-posts li, .cat-item, , #archives li').mouseover(function(){
			$(this).addClass("suFonu");
		});
		$('.recentcomments, #Recent li, #recent-posts li, .cat-item, , #archives li').mouseout(function(){
			$(this).removeClass("suFonu");
		});

		// pirmasis H2 šoninėje kolonėlėje
// 		$('#inner h2:first, #outer h2:first').css({"margin-top":"0"});

		// KOMENTARAI: paskutinis komentaras
		$('#commentblock li:last').css({"border-bottom":"0 none"});

		// MENIU (viršutinis): aktyvaus punkto stilius
		$('.current_page_item > a, .current_page_ancestor > a').css({
			"background-color":"#C5F939"
		});

		// KOMENTARAI: padedam kursorių į komentavimo laukelį
		var adresas = window.location.toString();
		if (adresas.match(/\#comment$/) || adresas.match(/\#respond$/)) $('#comment').focus();

		// NUORODOS: klasės priskyrimas išorinėms nuorodoms
		$('a:not(:has(img))').filter(function(){
			return this.hostname && this.hostname !== location.hostname;
		}).addClass("external");
		$('.widget_deliciousplus a').removeClass("external");

		// NUORODOS: klasės priskyrimas priklausomai nuo failo tipo
		var fc = "linkToFile";
		$('a:not(:has(".external"))').each(function(){
			if ($(this).is('a[href$=".avi"]')) $(this).addClass(fc + " avi");
			else if ($(this).is('a[href$=".mpg"]')) $(this).addClass(fc + " mpg");
			else if ($(this).is('a[href$=".mpeg"]')) $(this).addClass(fc + " mpeg");
			else if ($(this).is('a[href$=".wmv"]')) $(this).addClass(fc + " wmv");
			else if ($(this).is('a[href$=".doc"]')) $(this).addClass(fc + " doc");
			else if ($(this).is('a[href$=".docx"]')) $(this).addClass(fc + " docx");
			else if ($(this).is('a[href$=".exe"]')) $(this).addClass(fc + " exe");
			else if ($(this).is('a[href$=".gz"]')) $(this).addClass(fc + " gz");
			else if ($(this).is('a[href$=".gzip"]')) $(this).addClass(fc + " gzip");
			else if ($(this).is('a[href$=".ods"]')) $(this).addClass(fc + " ods");
			else if ($(this).is('a[href$=".sxc"]')) $(this).addClass(fc + " sxc");
			else if ($(this).is('a[href$=".odt"]')) $(this).addClass(fc + " odt");
			else if ($(this).is('a[href$=".sxw"]')) $(this).addClass(fc + " sxw");
			else if ($(this).is('a[href$=".pdf"]')) $(this).addClass(fc + " pdf");
			else if ($(this).is('a[href$=".ppt"]')) $(this).addClass(fc + " ppt");
			else if ($(this).is('a[href$=".rar"]')) $(this).addClass(fc + " rar");
			else if ($(this).is('a[href$=".tar"]')) $(this).addClass(fc + " tar");
			else if ($(this).is('a[href$=".txt"]')) $(this).addClass(fc + " txt");
			else if ($(this).is('a[href$=".xls"]')) $(this).addClass(fc + " xls");
			else if ($(this).is('a[href$=".zip"]')) $(this).addClass(fc + " zip");
		});

		// ILIUSTRACIJOS: klasės iliustracijų atitraukimams
		$('img[align="left"]').addClass("aLeft");
		$('img[align="right"]').addClass("aRight");

		// ILIUSTRACIJOS: pavadinimas po iliustracija iš „title“ teksto
		$('img.suPav').each(function(){
			var pavadinimas = this.title;
			if ( this.title.replace(/\s*/i, '') != "") { // jei „title“ atributas netuščias
				$(this).wrap('<div class="img"></div>').after('<p class="caption">' + pavadinimas + '</p>');
				if ($(this).hasClass("aLeft")) {
					$(this).parent().addClass("fl aLeft").width($(this).width());
					$(this).removeClass("aLeft");
				}
				if ($(this).hasClass("aRight")) {
					$(this).parent().addClass("fr aRight").width($(this).width());
					$(this).removeClass("aRight");
				}
			}
		});
		
		// CYCLE:
		$('.cycle').cycle();


	});
})( jQuery );
