

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

								 

	$('.linkicon').css('margin-top', '-55px');

	$('.linkicon').css('padding-bottom', '55px');

								 

	$('.linkicon').hover(

	  function () {

		$(this).stop().animate({marginTop: 0, paddingBottom: 0}, 333);

	  },

	  function () {

		$(this).stop().animate({marginTop: -55, paddingBottom: 55}, 333);

	  }

	);

	

	



$('.entry img').each(function() {



	if ( $(this).attr('offsetWidth') > 560 ) {

		$maxWidth = 560;

		$imgRatio =   $(this).attr('offsetHeight') / $(this).attr('offsetWidth');

		$newHeight = Math.round($maxWidth * $imgRatio);

		

		$(this).animate({width: 560}, 1);

		$(this).animate({height: $newHeight}, 1);

	}

});



$('.entry_small img').each(function() {



	if ( $(this).attr('offsetWidth') > 270 ) {

		$maxWidth = 270;

		$imgRatio =   $(this).attr('offsetHeight') / $(this).attr('offsetWidth');

		$newHeight = Math.round($maxWidth * $imgRatio);

		

		$(this).animate({width: 270}, 1);

		$(this).animate({height: $newHeight}, 1);

	}

});



								 

$("menu li").hover(function(){ //Main menu - Drop-Down List functionality



if(($(this).parent().attr('nodeName') != "MENU") && (jQuery.support.opacity)) { //disable for IE - IE shouldn't exist. At all.





$imgURL = $('.hidden-img-url').css('background-image'); // get absolute img loc

// set with-child icon to highlighted

$(this).parent().parent().find('a:first').find('.with-child').css('backgroundImage', $imgURL );



}

//if not the top level of the menu (pre-drop down) and not IE

if(($(this).parent().attr('nodeName') != "MENU") && (jQuery.support.opacity)) {

//HL text



}



if($(this).parent().attr('nodeName') == "MENU") { //(top lvl menu)

//find first drop down ul, make visible, set left position



$(this).find('ul:first').css({visibility: "visible",display: "none"}).stop(true, true).show(1).css({left: $(this).last('li').attr('offsetLeft') + 'px'});

//IF IE6 or 7 or IE8 in IE7 mode

if((!jQuery.support.boxModel) || (document.documentMode && document.documentMode == 7)) {

//account for weird offset in some IE versions

$(this).find('ul:first').css({visibility: "visible",display: "none"}).stop(true, true).show(1).css({left: $(this).last('li').attr('offsetLeft') + 0 + 'px'});

}



}else {



//for all other lvls of menu

$(this).find('ul:first').css({visibility: "visible",display: "none"}).stop(true, true).show(1).css({left: $(this).last('ul').attr('clientWidth') + 'px'});



}



//// grab the width of the widest link in the next ul of the menu

var childCount = 0;

var wideChild = 0;



while (childCount < $(this).find('ul:first').children().length){

$childrenArray = ($(this).find('ul:first').attr('children'));

$childWidth = $($childrenArray[childCount]).find('a:first').attr('clientWidth');



if($childWidth > wideChild){

wideChild = $childWidth;

}



childCount++;

}



//// adjust all links to be as wide as the widest



childCount = 0;

while (childCount < $(this).find('ul:first').children().length){



$childrenArray = ($(this).find('ul:first').attr('children'));

$($childrenArray[childCount]).find('a:first').css('width', wideChild + 'px');



childCount++;

}





},function(){

///// on roll-out - set everything back to normal



$(this).find('ul:first').hide(1);

$(this).parent().parent().css('background-color', '');

$(this).parent().parent().find('span:first').css('color', '');

$(this).parent().parent().find('a:first').find('.with-child').css('backgroundImage', '' );

}

); //END drop-down menu







$('menu li a').attr('title', ''); //Remove Titles - causes problems in some browsers, mouse-over pop-up title closes menu



$('menu li').animate({right: 0}, 1, function () { //SET menu ul props on load

var childCount = 0;



while (childCount < $(this).find('ul:first').children().length){

$childrenArray = ($(this).find('ul:first').attr('children'));



if( $($childrenArray[childCount]).children().length > 1 ){ //disabled/skipped in IE

$spanhtml = '<span class="spanpad">' + $($childrenArray[childCount]).find('a:first').html() + '<span class="with-child"></span></span>';

$($childrenArray[childCount]).find('a:first').html($spanhtml);

}else {

$spanhtml = '<span class="spanpad">' + $($childrenArray[childCount]).find('a:first').html() + '</span>';

$($childrenArray[childCount]).find('a:first').html($spanhtml);

}



childCount++;

}

}

);









$imgURL = $('.hidden-current-url').css('backgroundImage') + ' bottom repeat';

//alert($imgURL);

$("menu li.current_page_item").find('a:first').css('color', '#333333');

$("menu li.current_page_parent").find('a:first').css('color', '#333333');

$("menu li.current_page_ancestor").find('a:first').css('color', '#333333');

$("menu li.current_page_item").find('a:first').css('background','#FFFFFF');

$("menu li.current_page_parent").find('a:first').css('background', '#FFFFFF');

$("menu li.current_page_ancestor").find('a:first').css('background', '#FFFFFF');

/*
$("menu li.current_page_item").find('a:first').css('color', '#00a1b1');

$("menu li.current_page_parent").find('a:first').css('color', '#00a1b1');

$("menu li.current_page_ancestor").find('a:first').css('color', '#00a1b1');

$("menu li.current_page_item").find('a:first').css('background','#FFFFFF');

$("menu li.current_page_parent").find('a:first').css('background', '#FFFFFF');

$("menu li.current_page_ancestor").find('a:first').css('background', '#FFFFFF');
*/





$("a").click(function(ev){

				$("menu li").find('ul').fadeOut(500);

				return true;

});







								

								

});





function workTheMagic() {

	  $('#navigation ul:first').replaceWith('<menu>' +  $('#navigation ul:first').html() + '</menu>');

}
