// JavaScript Document
jQuery(document).ready(function($) {
	//Search Box
	$('#s').focusin(function(){
		var sv = $('#s').attr('value'); 
		if( sv == 'Search' ){ 
			$(this).attr('value', '');
		}
	});
	$('#s').focusout(function(){
		var sv = $('#s').attr('value'); 
		if( !sv ){ 
			$(this).attr('value', 'Search');
		}
	});
	$('nav li li a').hover(function(){
			$(this).parent().parent().parent().addClass('hover');
		}, function(){
			$(this).parent().parent().parent().removeClass('hover');
	});
	
	$(".no-borderradius nav>ul>li>a").wrapInner('<span />');
	
	if( $('#Content').height() - $('#Features').height() > 40 ){
		$('#Features').css( 'height', $('#Content').height()-6+'px' );
	
	}
	if( $('#Sidebar').height() < $('#Content').height() ){
		$('#Sidebar').css( 'height', $('#Content').height()-6+'px' );
	}
	if( $('#Content').height() < $('#Sidebar').height() ){
		$('#Content').css( 'height', $('#Sidebar').height()+6+'px' );
	}
	
	
	$('table tr:even').addClass('alt');
	
	
	$('#Content a').each(function(){
		var href = $(this).attr('href');
		if( href == null ){
			$(this).parent().before('<a href="#top" class="go2top">Back to top</a>');
		}
	});
	$('#Content a').not('.go2top').click(function(){
		var href = $(this).attr('href');
		var isID = href.charAt(0);
		var aName = href.substr(1);
		if(  isID == '#' ){
			var offset = $('a[name='+aName+']').offset();
			$('html,body').animate({scrollTop: offset.top},'1000');
			return false;
		}				   
	});
	
	$('#Content a.go2top').click(function(){
			$('html, body').animate({scrollTop:0}, '1000');
			return false;	 
	});
	
	$('#Features h2').prepend('<span class="cl"></span><span class="cr"></span>');
	
	$('.photo-frame').cycle();
});
