$(document).ready(function(){

$("a[href$=jpg]").live('click',function(){return hs.expand(this );});
$("a[href$=JPG]").live('click',function(){return hs.expand(this );});
$("a[href$=gif]").live('click',function(){return hs.expand(this );});
$("a[href$=png]").live('click',function(){return hs.expand(this );});
$("a[href$=jpeg]").live('click',function(){return hs.expand(this );});

$('.decore').find('tr td:first').addClass('first');
$('.decore').find('tr:first').addClass('first');

	$('td.scroll').mousemove(function(e){
		var lastLi = $('div#scroll').find('> div:last-child');
		var divWidth = $(this).width();
		var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth();	
		var left = (e.pageX - $(this).offset().left) * (ulWidth-divWidth) / divWidth;
		diva=$('div#scroll');
		diva.scrollLeft(left);
	});

function changesize(){
	var divs = $('div#scroll');
	divs.width(550).width(divs.parent().width());
if($('.top_menu a.selected').is(':visible')){
	$('#lava').stop().animate({left:$('.top_menu a.selected').offset().left,width:$('.top_menu a.selected').width()},0);
}else{
	$('#lava').stop().animate({left:$('.top_menu').offset().left,width:"hide"},0);
}
}

$(window).bind("resize", function(){
    changesize();
});
changesize();

hrefi='.';
function after_ready(){
	$('div.contentWrap .overlay_data').show();
	$('div.contentWrap form').attr('action',hrefi);
	if ($('div.contentWrap .overlay_data h2').is('h2')){
		$('div.contentWrap h1').hide(); 
		$('div.contentWrap .overlay_data h2').show();
	}
	$('div.contentWrap .comment').removeClass('comment');
}

$("a[rel]").overlay({
	effect: 'apple',
	mask: {
		color: '#000',
		loadSpeed: 200,
		opacity: 0.25
	},
	onBeforeLoad:function() {
		var wrap = this.getOverlay().find(".contentWrap");
		wrap.html('');
		hrefi=this.getTrigger().attr("href");
		wrap.load(this.getTrigger().attr("href")+" .overlay_data,.maincontent h1",after_ready);
	}
});

$('body').append('<div id="lava" style="position:absolute;z-index:1; width:10px;top:19px; height:40px;"><img src="/design3/images/tbbg.gif" alt="" style="width:100%;height:40px;" width="100%" height="40" /></div>');

if($('.top_menu a.selected').is(':visible')){
	$('#lava').stop().animate({left:$('.top_menu a.selected').offset().left,width:$('.top_menu a.selected').width()},0);
}else{
	$('#lava').stop().animate({left:$('.top_menu').offset().left,width:"hide"},0);
}

$('.top_menu a').bind('mouseenter',function(){
	$('#lava').stop().animate({left:$(this).offset().left,width:$(this).width()},{ duration: 1000, easing: "easeOutElastic" });
	$('.top_menu a.selected').addClass('nohover');
});
$('.top_menu').bind('mouseleave',function(){
	if($('.top_menu a.selected').is(':visible')){
		$('.top_menu a.selected').removeClass('nohover');
		$('#lava').stop().animate({left:$('.top_menu a.selected').offset().left,width:$('.top_menu a.selected').width()}, { duration: 1000, easing: "easeOutElastic" });
	}else{
		$('#lava').stop().animate({width:"hide",left:"+="+$('#lava').width()/2},"fast");
	}
});

});

