/******************************************************
*
*	Softscroll
*
******************************************************/
$(document).ready(function(){
$('a[href*=#]').click(function() {
	if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
	&& location.hostname == this.hostname) {
		var $target = $(this.hash);
		$target = $target.length && $target
		|| $('[name=' + this.hash.slice(1) +']');
		if ($target.length) {
			var targetOffset = $target.offset().top;
			$('html,body')
			.animate({scrollTop: targetOffset}, 1000);
			return false;
		}
	}
});
});




/******************************************************
*
*	Replacing rel="external" for Strict XHTML using
*
******************************************************/
$(function() {
	$('a[rel*=external]').click( function() {
		window.open(this.href);
		return false;
	});
});




/******************************************************
*
*	Cufon visibility in IE8
*
******************************************************/
$(window).one("load", function(){
	$('#logo,#bottom-logo').css({'display':'inline'});
});




/******************************************************
*
*	Rounded corner on menu and submenu in general
*
******************************************************/
$(function() {
    $('#bio_menu li').hover(
	function() { 
		$(this).addClass('bio_hover');
	},
	function() { 
		$(this).removeClass('bio_hover');
	});
});

$(function() {
    $('#bio_menu ul li:last-child').addClass("last");
});




/******************************************************
*
*	Get current page
*
******************************************************/
$(function() {
    var pathname = window.location.pathname;
    var pagename = pathname.substring(pathname.lastIndexOf('/') + 1);
    if(pagename == "") {
    	pagename = "index.php";
    }
    $('#bio_menu > li').each(function(){
        var href = $(this).find('a:first').attr('href');
        if(href == pagename) {
        	$(this).addClass('current_page_item');
        }
    });
    $('.bio_pages a').each(function(){
        var href = $(this).attr('href');
        if(href == pagename) {
        	$(this).addClass('current-page');
        }
    });
});




/******************************************************
*
*	Effect on search box
*
******************************************************/
$(function() {
    var searchInner = $('#search_box input[type="text"]').hide();
    $('#search_box').css({'background-position':'0 -38px'});
    var searchForm = $('#search_box form').css({'width':'42px'});
    $('#search_box')
        .mouseenter(function(){
			$('#search_box').css({'background-position':'0 0'});
			$('#search_box input[type="submit"]').css({'background-position':'right -38px'});
            searchForm.stop(true,false).animate({'width': '202px'},200, function() {
				searchInner.show();
			});
        })
        .mouseleave(function(){
            searchForm.stop(true,false).animate({'width': '42px'},200, function() {
				$('#search_box').css({'background-position':'0 -38px'});
				$('#search_box input[type="submit"]').css({'background-position':'right 0'});
			});
			searchInner.hide();
        });
});




/******************************************************
*
*	Default value on emailus
*
******************************************************/
$(function() {
    $('input[type=text]').addClass('onBlur');
    $('textarea').addClass('onBlur');
	$('input[type=text]').focus(function() {
		$(this).removeClass('onBlur');
        if (this.value == this.defaultValue){
        	this.value = '';
    	}
        if(this.value != this.defaultValue){
	    	this.select();
        }
    });
    $('input[type=text]').blur(function() {
        if (this.value == ''){
			$(this).addClass('onBlur');
        	this.value = (this.defaultValue ? this.defaultValue : '');
    	}
    });
	$('textarea').focus(function() {
		$(this).removeClass('onBlur');
        if (this.value == this.defaultValue){
        	this.value = '';
    	}
        if(this.value != this.defaultValue){
	    	this.select();
        }
    });
    $('textarea').blur(function() {
        if (this.value == ''){
			$(this).addClass('onBlur');
        	this.value = (this.defaultValue ? this.defaultValue : '');
    	}
    });
});




/******************************************************
*
*	Initialize scrolldown menu
*
******************************************************/
$(function() {
	jQuery('#bio_menu').superfish({
		delay:200, 
		animation:{opacity:'show',height:'show'},
		speed:'fast',
		autoArrows:false,
		dropShadows:false 
	});
});



/******************************************************
*
*	Colorbox
*
*********************************
$(window).one("load", function(){
	$("a[rel='iframe']").colorbox({iframe:true, innerWidth:650, innerHeight:488, rel:'nofollow' });
	$("a#map[rel='iframe']").colorbox({iframe:true, innerWidth:800, innerHeight:600, rel:'nofollow'});
	if($.browser.msie || $.browser.opera) {
		var the_src = $("#hidemap iframe").attr('src');
	}
	else {
		var the_src = $("#hidemap object").attr('data');
	}
	var v = the_src.replace(/\\"/g,'');
	$("a#map[rel='iframe']").attr("href", v);
});
*********************/


$(window).one("load", function(){
	$("#slideshow a[href$='.jpg']").colorbox({maxWidth:"98%", maxHeight:"98%", onOpen: function(){$('#slider').data('nivo:vars').stop = true;}, onClosed: function(){ setTimeout(function(){ $('#slider').data('nivo:vars').stop = false; }, 2000) }});
	$("#slideshow a[href$='.png']").colorbox({maxWidth:"98%", maxHeight:"98%", onOpen: function(){$('#slider').data('nivo:vars').stop = true;}, onClosed: function(){ setTimeout(function(){ $('#slider').data('nivo:vars').stop = false; }, 2000) }});
	$("#slideshow a[href$='.jpg']").colorbox({maxWidth:"98%", maxHeight:"98%", onOpen: function(){$('#slider').data('nivo:vars').stop = true;}, onClosed: function(){ setTimeout(function(){ $('#slider').data('nivo:vars').stop = false; }, 2000) }});
	$("#slideshow a.colorbox").colorbox({maxWidth:"98%", maxHeight:"98%", onOpen: function(){$('#slider').data('nivo:vars').stop = true;}, onClosed: function(){ setTimeout(function(){ $('#slider').data('nivo:vars').stop = false; }, 2000) }});
	$("#slideshow a[href*='vimeo']").colorbox({iframe:true, innerWidth:640, innerHeight:480, onOpen: function(){$('#slider').data('nivo:vars').stop = true;}, onClosed: function(){ setTimeout(function(){ $('#slider').data('nivo:vars').stop = false; }, 2000) }});
	$("#slideshow a[href*='youtube']").colorbox({iframe:true, innerWidth:640, innerHeight:480, onOpen: function(){$('#slider').data('nivo:vars').stop = true;}, onClosed: function(){ setTimeout(function(){ $('#slider').data('nivo:vars').stop = false; }, 2000) }});
	$("a[href$='.jpg']").not('.noColor').colorbox({maxWidth:"98%", maxHeight:"98%"});
	$("a[href$='.png']").not('.noColor').colorbox({maxWidth:"98%", maxHeight:"98%"});
	$("a[href$='.jpg']").not('.noColor').colorbox({maxWidth:"98%", maxHeight:"98%"});
	$("a.colorbox").colorbox({maxWidth:"98%", maxHeight:"98%"});
	$("a[href*='vimeo']").not('.noColor').colorbox({iframe:true, innerWidth:640, innerHeight:480});
	$("a[href*='youtube']").not('.noColor').colorbox({iframe:true, innerWidth:640, innerHeight:480});
});
    



/******************************************************
*
*	Links in bio_caption
*
  ******************************************************/
$(document).ready(function() {
	$('.bio_caption .link').mouseover(function(){
		$(this).css({'text-decoration':'none'});
		$(this).parent().parent().bind("click.myDisable", function() { return false; });
	})
	.mouseout(function(){
		$(this).css({'text-decoration':'underline'});
		$(this).parent().parent().unbind("click.myDisable");
	})
	$('.bio_caption .link').each(function(){
		var href = $(this).text();
		var href2 = href.substring(href.lastIndexOf('|') + 1);
		var href3 = href.substring(href.lastIndexOf('|') - 1);
		$(this).click(function(){
			window.location.href = href2;
		});
		var removeHref = $(this).text().replace(href3,"");
		$(this).text(removeHref);
	});
});



/******************************************************
*
*	Background effect on mouse over
*
  ******************************************************/
$(window).one("load", function(){
	$('.nivo-prevNav')
		.css( {backgroundPosition: "8px 0"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(0 0)"}, {duration:100})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(8px 0)"}, {duration:100, complete:function(){
				$(this).css({backgroundPosition: "8px 0"})
			}})
		})
	$('.nivo-nextNav')
		.css( {backgroundPosition: "-8px 0"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(0 0)"}, {duration:100})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(-8px 0)"}, {duration:100, complete:function(){
				$(this).css({backgroundPosition: "-8px 0"})
			}})
		})
});



/******************************************************
*
*	More button
*
  ******************************************************/
$(document).ready(function(){
	$('.morebutton').wrapInner('<span />');
	$('.morebutton').mousedown(function(){
		$(this).addClass('morebuttonClick');
	});
	$('.morebutton').mouseup(function(){
		$(this).removeClass('morebuttonClick');
	});
	$('.morebutton input').parent().css('padding','0');
});



/******************************************************
*
*	Feature
*
  ******************************************************/
$(document).ready(function(){
	var featMoreBut = 950-($('#feature .morebutton').width());
	var featH = $('#feature').height();
	var featH3 = $('#feature h3').height();
	var featP = $('#feature .quote p').height();
	$('#feature .quote').css({'width':featMoreBut});
	if (featP > 55) {
		var featPlus = (featP - 55)*0.5;
		var featTop = ($('#feature .quote h3').height())+featPlus;
	}
	else {
		var featTop = (featP+featH3)-50;
	}
	$('#feature .morebutton').css({'margin-top':featTop+2});
    
    if($('#slideshow').length == 0) {
        if($.browser.msie && $.browser.version < 8) {
            $('.home #feature').css({'padding':(322-(featH3+featP))*0.5+'px 0'});
        }
        else {
            $('.home #feature').css({'padding':(302-(featH3+featP))*0.5+'px 0'});
        }
        $('.home #feature').addClass('noSlideshow');
        $('.home #top').css({'height':'600px'});
        $('.home .middle:first .wall').css({'background':'none','margin-top':'-150px'});
    }
});



/******************************************************
*
*	Entry img
*
  ******************************************************/
$(document).ready(function(){
	$('.showcase .showcasebox').wrapInner('<div class="paddingimg" />');
	$('.entry, .bio_recent_comments, #author_info, #commentlist').not(':has(.showcasebox)').find('img').not('.noBorder').wrap('<div class="paddingimg" />');
	$('.entry iframe, .entry object').wrap('<div class="paddingimg" />');
	$('.paddingimg').wrap('<div class="borderimg" />');
	$('.entry').not(':has(.showcasebox)').find('.paddingimg').wrapInner('<div class="iconimg" />');
	$('.entry img.alignleft').not('.noBorder').removeClass('alignleft').parent().parent().parent().addClass('alignleft');
	$('.entry img.alignright').not('.noBorder').removeClass('alignright').parent().parent().parent().addClass('alignright');
	$('.entry img.aligncenter').not('.noBorder').removeClass('aligncenter').parent().parent().parent().addClass('aligncenter');
	$('.entry .aligncenter').wrap('<div class="alignleft" style="width:100%" />');
	$('.entry .aligncenter').each(function() {
    	var wrapW = $(this).parent('div').width();
    	var thisW = $(this).width();
        $(this).css('margin-left',((wrapW - (thisW + 2))*0.5) +'px'); 
    });
	$('.entry img.alignnone').not('.noBorder').removeClass('alignnone').parent().parent().parent().addClass('alignnone');
	$('.entry .alignnone').wrap('<div class="alignleft" style="width:100%" />');
	$('.showcasebox img').before('<div class="iconimg" />');
	$('.showcase .iconimg').css('opacity','0.6');
});
$(window).one("load", function(){
	$('.showcase .iconimg').each(function(){
    	var padH = $(this).parent().height();
        $(this).css('height',padH+22+'px');
    });
});



/******************************************************
*
*	Teaser link
*
  ******************************************************/
$(document).ready(function(){
	$('.teasers .teaser img').each(function() {
		$(this).mouseup(function(){
			 $(this).parent().parent().parent().parent().find('a.morebutton').click();
		});
	});
	$('.teasers .teaser img').hover(function(){
		$(this).stop(true,false).animate({'opacity':'0.5'},150);
	},function(){
		$(this).stop(true,false).animate({'opacity':'1'},150);
	});
});



/******************************************************
*
*	Teaserrow
*
  ******************************************************/
(function($){

   $.fn.wrapChildren = function(options) {

    var options = $.extend({
                              childElem : undefined,
                              sets : 1,
                              wrapper : 'div class="teaserrow"'
                            }, options || {});
    if (options.childElem === undefined) return this;

 return this.each(function() {
  var elems = $(this).children(options.childElem);
  var arr = [];

  elems.each(function(i,value) {
    arr.push(value);
    if (((i + 1) % options.sets === 0) || (i === elems.length -1))
   {
     var set = $(arr);
     arr = [];
     set.wrapAll($("<" + options.wrapper + ">"));
   }
  });
    });

  }

})(jQuery);

$(function() {
  $('.teasers').wrapChildren({ childElem : '.teaser' , sets: 3});
  $('.double .teasers').wrapChildren({ childElem : '.teaser' , sets: 2});
  $('.double .teasers .teaser:odd').css({'margin-right':'0'});
  $('.showcase').wrapChildren({ childElem : '.showcasebox' , sets: 3});
});



/******************************************************
*
*	Showcase effect
*
  ******************************************************/
$(function() {
	$('.showcase .showcasebox').hover(function(){
		$(this).find('img').stop(true,false).animate({'opacity':'0'},300);
	},function(){
		$(this).find('img').stop(true,false).animate({'opacity':'1'},300);
	});

	
	$('.showcase .showcasebox').mouseup(function() {
		$(this).find('a').click();
	});
});



/******************************************************
*
*	Hover effect in general
*
  ******************************************************/
(function($) {
	$.fn.customFadeIn = function(speed, callback) {
		$(this).fadeIn(speed, function() {
			if(!$.support.opacity)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
	$.fn.customFadeOut = function(speed, callback) {
		$(this).fadeOut(speed, function() {
			if(!$.support.opacity)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
	$.fn.customFadeTo = function(speed,to,callback) {
		return this.animate({opacity: to}, speed, function() {
			if (to == 1 && jQuery.browser.msie)
				this.style.removeAttribute('filter');
			if (jQuery.isFunction(callback))
				callback();
		});
	};
})(jQuery);

$(function() {
    if($.browser.msie){
       $('a img[src$=.jpg], a img[src$=.gif]').hover(function(){
            $(this).stop(true,false).animate({'opacity':'0.7'},150);
        },function(){
            $(this).stop(true,false).animate({'opacity':'1'},150);
        });
        $('.iconimg img[src$=.jpg], .iconimg img[src$=.gif], .entry a img[src$=.jpg], .entry a img[src$=.gif]').hover(function(){
            $(this).stop(true,false).animate({'opacity':'0.2'},150);
        },function(){
            $(this).stop(true,false).animate({'opacity':'1'},150);
        });
    }
    else {
       $('a img, #logo, #bottom-logo').hover(function(){
            $(this).stop(true,false).animate({'opacity':'0.7'},150);
        },function(){
            $(this).stop(true,false).animate({'opacity':'1'},150);
        });
        $('.iconimg img, .entry a img').hover(function(){
            $(this).stop(true,false).animate({'opacity':'0.2'},150);
        },function(){
            $(this).stop(true,false).animate({'opacity':'1'},150);
        });
    }
});





/******************************************************
*
*	Recent posts
*
******************************************************/
$(document).ready(function() {
	if ($('.post_slider').length != 0) {
		$('.post_slider').cycle({
		fx:'scrollLeft',
		speed:500,
		timeout:7000,
		cleartype:!$.support.opacity,
		cleartypeNoBg:true,
		prev:'.bio_recent_posts .prev', 
		next:'.bio_recent_posts .next'
		});
	}

	if ($('.post_slider2').length != 0) {
		$('.post_slider2').cycle({
		fx:'scrollLeft',
		speed:500,
		timeout:6000,
		cleartype:!$.support.opacity,
		cleartypeNoBg:true,
		prev:'.bio_recent_comments .prev', 
		next:'.bio_recent_comments .next'
		});
	}
});



/******************************************************
*
*	Cut bg
*
  ******************************************************/
$(window).one("load", function(){
	$('.cut').wrapInner('<div class="vertical_cut" />');
	$('.vertical_cut').wrapInner('<div class="vertical_cut-bottom" />');
	$('.vertical_cut-bottom').wrapInner('<div class="vertical_cut-top" />');
	$('.cut').find('.double .post:first').css('margin-top','-20px');
	$('.cut').find('.sidebar .bio_widget:first').css('margin-top','-5px');
	$('.cut').find('.sidebar .bio_widget:last').css('background','none');
});



/******************************************************
*
*	Quicklinks
*
  ******************************************************/
$(function() {
	var sizeSidebar = $('#footer .sidebar').size();
	if (sizeSidebar == 3) {
		$('#quicklinks ul.multilist').makeacolumnlists({cols:2,colWidth:0,equalHeight:false,startN:1});
        var ulMultilist = $('.li_container ul.multilist').size();
        $('ul.multilist').css({'width':300/ulMultilist+'px'});
        $('ul.multilist li').css({'width':(300/ulMultilist)-10+'px'});
	}
	else if (sizeSidebar == 2) {
		$('.footer #quicklinks .multilist li').css({'width':'142px'});
		$('.footer #quicklinks .multilist ul ul').css({'width':'142px'});
		$('.sidebar#quicklinks').css({'width':'650px'});
		$('.sidebar#quicklinks .multilist').css({'width':'650px'});
		$('#quicklinks ul.multilist').makeacolumnlists({cols:4,colWidth:162.5,equalHeight:false,startN:1});
        var ulMultilist = $('.li_container ul.multilist').size();
        $('ul.multilist').css({'width':650/ulMultilist+'px'});
        $('ul.multilist li').css({'width':(650/ulMultilist)-10+'px'});
	}
	else if (sizeSidebar == 1) {
		$('.footer #quicklinks .multilist li').css({'width':'146px'});
		$('.footer #quicklinks .multilist ul ul').css({'width':'146px'});
		$('.sidebar#quicklinks').css({'width':'1000px','margin':'0'});
		$('.sidebar#quicklinks .multilist').css({'width':'1000px','margin':'0'});
		$('#quicklinks ul.multilist').makeacolumnlists({cols:6,colWidth:166.6,equalHeight:false,startN:1});
        var ulMultilist = $('.li_container ul.multilist').size();
        $('ul.multilist').css({'width':1000/ulMultilist+'px'});
        $('ul.multilist li').css({'width':(1000/ulMultilist)-10+'px'});
	}
});



/******************************************************
*
*	Credits vertical align
*
  ******************************************************/
$(window).one("load", function(){
	var lineH = $('#bottom-logo').height();
	if (lineH > 15) {
		$('#credits').css({'line-height':lineH+'px'});
	}
	if (lineH > 28) {
		var marginT = (lineH - 28)*0.5;
		$('#backtotop').css({'margin-top':marginT+'px'});
	}
});



/******************************************************
*
*	Tabs, Accordion & Show/hide
*
******************************************************/
$(function() {
	$('.tabs').tabs({ fx: { opacity: 'toggle', duration: 'fast' } });
});
$(function() {
	$('.accordion').accordion({ autoheight: false });
	$('.accordion a.button').wrapInner('<span class="accordspan" />');
	$('.accordion a.button').before('<span style="display:block; clear:both; height:5px" />'); /* IE8 workaround */
});
$(function() {
	$('.showhide a.button').wrapInner('<span class="accordspan" />');
	$('.showhide a.button').before('<span style="display:block; clear:both; height:5px" />'); /* IE8 workaround */
	$('.showhide a.button').click(function() {
		if ($(this).parent().find('div').is(":hidden")) {
			$(this).parent().find('div').slideDown('slow');
			$(this).removeClass('ui-state-inactive');
			$(this).addClass('ui-state-active');
			return false;
		}
		else {
			$(this).parent().find('div').slideUp('slow');
			$(this).removeClass('ui-state-active');
			$(this).addClass('ui-state-inactive');
		}
	}).parent().find('div').slideUp('slow');
});	




/******************************************************
*
*	Scroll on Portfolio Slideshow page
*
******************************************************/
$(window).one("load", function(){
	if ($('body.home').length == 0 && $('#slideshow').length == 1) {
		var windH = $(window).height();
		var slideH = $('#slideshow').height();
		var slideMarg = (windH - slideH)*0.5;
		var offset = $('#slideshow').offset();
		var slidePos = (offset.top)-(slideMarg-50);
		setTimeout(function(){
			$('html,body').animate({scrollTop: slidePos}, 500);
		}, 800);
	}
});



/******************************************************
*
*	HR totop
*
******************************************************/
$(function() {
	$('hr').wrap('<div class="hr" />');
	$('hr.totop').wrap('<div class="hrtotop" />');
	$('.hrtotop').after('<span class="totop" />');
	$('span.totop').click(function(){
		$('html,body').animate({scrollTop: 0}, 500);
	});
});



/******************************************************
*
*	Dropcap
*
******************************************************/
$(document).ready(function(){
	$('p.dropcap').each(function () {
		  var el = $(this),
				text = el.html(),
				first = text.slice(0, 1),
				rest = text.slice(1);
		  el.html('<span class="firstletter">' + first + '</span>' + rest);
	});
});



/******************************************************
*
*	Widget list
*
******************************************************/
$(document).ready(function(){
    $('.sidebar ul').find('li:last').css('background','none');
    $('.bio_widget li a:not(.current-page)').hover(
	function() { 
		$(this).stop(true,false).animate({'padding-left': '25px'},200, function() {
			$(this).addClass('hover_current');
		});
	},
	function() { 
		$(this).removeClass('hover_current');
		$(this).stop(true,false).animate({'padding-left': '10px'},200);
	});
});


/******************************************************
*
*	Sitemap
*
******************************************************/
$(document).ready(function(){
    $('.sitemap ul').find('li:last').css('background','none');
    $('.sitemap li a').hover(
	function() { 
		$(this).stop(true,false).animate({'padding-left': '25px'},200, function() {
			$(this).addClass('hover_current');
		});
	},
	function() { 
		$(this).removeClass('hover_current');
		$(this).stop(true,false).animate({'padding-left': '10px'},200);
	});
});


/******************************************************
*
*	IE list bug
*
******************************************************/
$(document).ready(function(){
    $('.post ul, .post ol').wrap('<div class="alignleft" style="width:100%; padding:0; background:none" />');
});


/******************************************************
*
*	Calendar td
*
******************************************************/
$(document).ready(function(){
    $('.bio_calendar td, .bio_calendar th').css({'width':100/7+'%'});
    var tdW = ($('.bio_calendar table').width()/7)-4;
    $('.bio_calendar td, .bio_calendar th').css({'height':tdW+'px'});
    $('.bio_calendar a').css({'line-height':tdW+'px'});
});
$(function() {
    $('.bio_calendar td, .bio_calendar th').hover(
	function() { 
		$(this).addClass('hover');
	},
	function() { 
		$(this).removeClass('hover');
	});
    $('.bio_calendar td:has("a")').addClass('ahover');
});


/******************************************************
*
*	Icon classes
*
******************************************************/
$(window).one("load", function(){
    $(".paddingimg").parent().parent("div:has(a[href*='http'])").find('.iconimg').addClass('readMore');
    $(".paddingimg").parent().parent("div:not(:has(a[href*='http']))").find('.iconimg').addClass('readMore');
    $(".paddingimg").parent().parent("div:has(a[href$='.jpg'])").find('.iconimg').addClass('enlargePicture');
    $(".paddingimg").parent().parent("div:has(a[href$='.gif'])").find('.iconimg').addClass('enlargePicture');
    $(".paddingimg").parent().parent("div:has(a[href$='.png'])").find('.iconimg').addClass('enlargePicture');
    $(".paddingimg").parent().parent("div:has(a[href*='vimeo'])").find('.iconimg').addClass('watchVideo');
    $(".paddingimg").parent().parent("div:has(a[href*='youtube'])").find('.iconimg').addClass('watchVideo');

    $("a[href*='http']").find('.iconimg').addClass('readMore');
    $("a[href^='http']").find('.iconimg').addClass('readMore');
    $("a[href$='jpg']").find('.iconimg').addClass('enlargePicture');
    $("a[href$='gif']").find('.iconimg').addClass('enlargePicture');
    $("a[href$='png']").find('.iconimg').addClass('enlargePicture');
    $("a[href*='vimeo']").find('.iconimg').addClass('watchVideo');
    $("a[href*='youtube']").find('.iconimg').addClass('watchVideo');
});


/******************************************************
*
*	Tag cloud & Postshare
*
******************************************************/
$(window).one("load", function(){
	$('.bio_tag_cloud a').each(function(){
    	var fSize = $(this).css("font-size");
        var fSizenoPx = fSize.replace('px', '');
        $(this).css({'line-height':(fSizenoPx*1.5)+'px','height':(fSizenoPx*1.5)+'px'});
        if(fSizenoPx<14) {
            $(this).css({'color':'#c0c0c0'});
        }
        else if(fSizenoPx>=14 && fSizenoPx<16) {
            $(this).css({'color':'#acacac'});
        }
        else if(fSizenoPx>=16 && fSizenoPx<18) {
            $(this).css({'color':'#999'});
        }
        else if(fSizenoPx>=18 && fSizenoPx<20) {
            $(this).css({'color':'#898989'});
        }
        else {
            $(this).css({'color':'#7f7f7f'});
       }
    });
});

$(window).one("load", function(){
	var tagW = $('#innertags').width();
	var shareW = $('#innershare').width();
	var hovertagW = $('#hovertag').width();
	var hovershareW = $('#hovershare').width();
    $('#tags').css({'width':'0'});
    $('#postshare').css({'width':'0'});
    if(tagW > (590-(hovertagW+hovershareW))) {
        $('#innertags').css({'width':tagW-(hovertagW+hovershareW)+'px'});
    }
    else {
        $('#innertags').css({'width':tagW+5+'px'});
    }
	var tagW2 = $('#innertags').width();
	$('a#hovertag, #tags').hover(function(){
		$('#tags').stop(true,false).animate({'width':tagW2+'px'},300);
	},function(){
		$('#tags').stop(true,false).animate({'width':'0','padding-right':0},300);
	});

    $('#postshare').css({'width':'0','padding-right':0});
    if(shareW > (595-(hovertagW+hovershareW))) {
        $('#innershare').css({'width':shareW-(hovertagW+hovershareW)+'px'});
    }
    else {
        $('#innershare').css({'width':shareW+'px'});
    }
	var shareW2 = $('#innershare').width();
	$('a#hovershare, #postshare').hover(function(){
		$('#postshare').stop(true,false).animate({'width':shareW2+'px','padding-right':'5px'},300);
	},function(){
		$('#postshare').stop(true,false).animate({'width':'0','padding-right':0},300);
	});
});


/******************************************************
*
*	Comments
*
******************************************************/
$(document).ready(function() {
	$('#commentlist .moretn').click(function(){
    	if ($('#commentform input[value=""]:visible').length != 0) {
            $('#commentform input[value=""]:first').focus();
        }
    	else {
            $('#commentform #comment').focus();
        }
    });
});
