/* <![CDATA[ */
function css_browser_selector(u){var ua = u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1;},g='gecko',w='webkit',s='safari',o='opera',h=document.getElementsByTagName('html')[0],b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3.5')?g+' ff3 ff3_5':is('firefox/3')?g+' ff3':is('gecko/')?g:is('opera')?o+(/version\/(\d+)/.test(ua)?' '+o+RegExp.$1:(/opera(\s|\/)(\d+)/.test(ua)?' '+o+RegExp.$2:'')):is('konqueror')?'konqueror':is('chrome')?w+' chrome':is('iron')?w+' iron':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?'mobile':is('iphone')?'iphone':is('ipod')?'ipod':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win':is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; css_browser_selector(navigator.userAgent);

$(function(){
	
	$('#menu>li').each(function(){
		if($(this).find('ul').size()>0){$(this).find('>a:first').append('<span class="barr"><!-- --></span>');}
	});
	if($.browser.msie && parseInt($.browser.version) == 6){
		$('#menu>li').hover(function(){$(this).addClass('hovered').find('ul').show()},function(){$(this).removeClass('hovered').find('ul').hide()});
	}
	
	
	$('div.comment-meta').each(function(){
		var el = $(this).find('>a:first');
		var txt = 'on '+el.text();
		el.addClass('dt').text(txt);
	});
	$('#searchsubmit').val('');
	$('input#author').val('Name');
	$('input#email').val('Email');
	$('input#url').val('WebSite');
	$('textarea#comment').val('Your comment…');
	
	$('input#author,input#email,input#url,textarea#comment').each(function(){
		$(this).attr('def', $(this).attr('value'));
	}).focus(function(){
		if($(this).val() == $(this).attr('def')) {
			$(this).val('');
		}
	}).blur(function(){
		if($(this).val() == '') {
			$(this).val($(this).attr('def'));
		}
	});

	function emailvalid(el){
		var value = el;
		var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if(!filter.test(value)){return false}else{return true}
	}

	$('a.[rel=generator]').attr('target','_blank');
	$(':text,:password').addClass('tx');
	if($('div.pagebar:last').size()>0 && $('div.pagebar:last').next().is('navigation') && $.browser.msie && parseInt($.browser.version)==6){
		$('div.pagebar:last').next().hide();
	}
	$('#commentform').submit(function(){
		$(this).find('span.error,span.txarerror').remove();
		isValid = true;
		if($('input#author').size()>0){
			isValid = true;
			$('#author,#comment').each(function(){
				if($(this).val()==$(this).attr('def') || !$(this).val()){
					isValid = false;
					if($(this).is('textarea')){
						$('<span class="txarerror">Please fill the field</span>').insertBefore($(this));
					}
					else{
						$('<span class="error">Please fill the field</span>').insertAfter($(this));
					}
					
				}				
			});
			if(!emailvalid($('#email').val())){
				isValid = false;
				$('<span class="error">Please fill this field correctly</span>').insertAfter($('#email'));
			}
			$('#author,#comment,#email').keyup(function(){
					$('#commentform .error,#commentform .txarerror').remove();
			});
		}
		if(!isValid){
			return false
		}
		else{
			if($('#url').val() == $('#url').attr('def')){$('#url').val('')}
			return true
		}
	});

	$('li.widget_tag_cloud').find('h2').addClass('h2hide').insertAfter($('li.widget_categories h2:first'));
	$('li.widget_tag_cloud').find('div:first').addClass('hide').insertAfter($('li.widget_categories ul:first'));
	$('li.widget_categories').addClass('grouped').find('h2:first').addClass('active').end().find('>ul').addClass('visible');

	$('li.widget_recent_comments').find('h2').addClass('h2hide').insertAfter($('li.widget_recent_entries h2:first'));
	$('li.widget_recent_comments').find('ul:first').addClass('hide').insertAfter($('li.widget_recent_entries ul:first'));
	$('li.widget_recent_entries').addClass('grouped').find('h2:first').addClass('active').end().find('>ul:first').addClass('visible');

	$('ul.months').prev().addClass('h2hide').insertBefore($('ul.years'));
	$('ul.months').addClass('hide').insertAfter($('ul.years'));
	$('ul.years').addClass('visible').parent().addClass('grouped').find('h2:first').addClass('active');

	$('ul.children').parent().addClass('thisparent');
	$('li.widget_recent_comments,li.widget_tag_cloud,#sidebar .pagebar').remove();
	
	$('li.grouped>h2').click(function(){
		if($(this).hasClass('h2hide')){
			$(this).parent().find('h2.active').removeClass('active').addClass('h2hide');
			$(this).removeClass('h2hide').addClass('active');

			var el = $(this).parent().find('.hide');
			var el2 = $(this).parent().find('.visible');
			el.removeClass('hide').addClass('visible');
			el2.removeClass('visible').addClass('hide');	
		}
	});
	if($('html.ff2').size()>0){
		$('<style type="text/css">.commentlist .fn,.comment-author,.comment-meta,#sidebar .grouped h2{display:-moz-inline-stack;</style>').appendTo('head');
	}
	
	if($('.single .pagebar').size()>0){
		var el = $('.single .pagebar');
		var chl = el.children().clone();
		el.find('a,span').remove();
		var txt = parseInt($('.entry .pagebar').text());
		el.text('').append(chl);
		if(el.children(':eq('+txt+')').size()>0){
			$('<span class="this-page">'+txt+'</span>').insertBefore(el.children(':eq('+txt+')'));
		}
		else{
			$('<span class="this-page">'+txt+'</span>').appendTo(el);
		}
	}
	
	$('<input type="text" id="s" name="s" value="" class="tx" maxlength="32" />').insertBefore('#s').next().remove();

});
/* ]]> */
