// 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');
		}
	});
	var navItems = $('nav>ul>li').size();
	$('nav>ul>li:first').addClass('first');
	var navItemWidth = (990/navItems)-22;
	$('nav>ul>li>a').wrapInner('<span />');
	$('nav a').css('width', navItemWidth);
	
	//iFrame Height
	var wintall = $(window).height();
	var iframetall = wintall-350;
	if( iframetall > 400 ){
		$('iframe').height(iframetall);
	}
	
	FG_fixfloats();
	
	
	$('nav li').hover(function(){
		$(this).addClass('hover');
		
	}, function(){
		$(this).removeClass('hover');
	});
	
	//Preview Fix
	/*$('a').click(function(){
		var goto = $(this).attr('href');
		var isemail = goto.indexOf("@");
		if( isemail < 0 ){
			window.location=goto+'?preview_theme=gpr2010'; 
			return false;
		}
	});*/
});
//HomeBox Height Fix
	function FG_fixfloats() {
	  lastParent = 0;
	  galleryitems = jQuery(".homebox");
	  galleryitems.each(function(i){
		if(this.parentNode != lastParent) {
		  lastTop = 0;
		  rowHeight = 0;
		  rowStart = i;
		  lastParent = this.parentNode;
		}
		this.style.height = "auto";
		this.style.clear="none";
		if(this.offsetTop != lastTop) {
		  this.style.clear="left";
		  rowHeight = this.offsetTop - lastTop - (this.style.marginTop + this.style.marginBottom);
		  for(j=rowStart;j<i;j++) {
			galleryitems.get(j).style.height = rowHeight+"px";
		  }
		  lastTop = this.offsetTop;
		  rowStart = i;
		} 
	  });
	}
