$(document).ready(function() {
	
$('#main nav ul li.toplevel').mouseenter(
	function(){
		$('#main nav ul li').removeClass('on');
		$(this).addClass('on');
		$('#main nav ul li ul').css("display", "none");
		$(this).find('ul').css("display", "block");
	});
$('#main nav ul li.toplevel').mouseleave(
	function(){//mouse out
		
		$('#main nav ul li').removeClass('on');
		$(this).find('ul').css("display", "none");
	}
);
$('#smlft').css('display', 'none');
$('.popit').hover(function(){
	$('#smlft').toggle();
});


$('.innerfade').innerfade({
	speed: 600,
	timeout: 4000,
	type: 'sequence',
	containerheight: '220px'
});
$('#rightside ul').innerfade({
	speed: 600,
	timeout: 4000,
	type: 'sequence',
	containerheight: '220px'
});
$('#promo3 ul').innerfade({
	speed: 400,
	timeout: 4000,
	type: 'sequence',
	containerheight: '125px'
});
$('#connecter input').toggleVal();

$(initmenuinfo);
function initmenuinfo() {
     onz = $('#prodlists').find('li.onz').attr("rel");
	 divall = '.prodinfo' + onz;
	$(divall).css("display","block");
}
$('.menuitem li').hover(function(){
	
 var divyo = '.prodinfo' + onz;
	$('.onz').removeClass('onz');
	$(this).addClass('onz');
	$('#prodinfocontainer section').css("display", "none");
	$(initmenuinfo);
});
$('.arrowprev').click(function(){
	var thisonzrel =$('.menuitem').find('li.onz').attr("rel");
	
	if( thisonzrel == 1 )
		{
		//This is the Active Link

		} else {
		//This isn't
	var thisonz = $('.menuitem').find('li.onz');
	$(thisonz).prevAll("li.menuli:first").addClass('onz');
	$(thisonz).removeClass('onz');
	
 onz2 = $('#prodlists').find('li.onz').attr("rel");
	     thisonzrel = '.prodinfo' + thisonzrel;
 divyo2 = '.prodinfo' + onz2;
	$('#prodinfocontainer section').css("display", "none");
	$(divyo2).css("display","block");
	}
});
$('.arrownext').click(function(){
	var thisonzrel =$('.menuitem').find('li.onz').attr("rel");
	var thisonz = $('.menuitem').find('li.onz');
	var lizsize = $('.menuitem').parent().find('li').size();
	if( thisonzrel == lizsize ){
	}
	else{
	$(thisonz).nextAll("li.menuli:first").addClass('onz');
	$(thisonz).removeClass('onz');
 onz2 = $('#prodlists').find('li.onz').attr("rel");
	     thisonzrel = '.prodinfo' + thisonzrel;
 divyo2 = '.prodinfo' + onz2;
	$('#prodinfocontainer section').css("display", "none");
	$(divyo2).css("display","block");
	}
});


$('.lox #onecoltoplinks li a').click(function(){
	$('#onecoltoplinks li.onz').removeClass('onz');
	$(this).parent().addClass('onz');
	var onzdivz = "#"+ $(this).attr("rel");
	$('#locs_list div').hide();
	$(onzdivz).show();
	$('.onecolpic').hide();
	var tehrel = "." + $(this).attr("rel");
	$(tehrel).show();
	return false;
});

$('#map_a').hover(function(){
	$(this).find('.poppar').toggleClass('yes');
});
$('#map_b').hover(function(){
	$(this).find('.poppar').toggleClass('yes');
});
$('#map_c').hover(function(){
	$(this).find('.poppar').toggleClass('yes');
});
$('#map_d').hover(function(){
	$(this).find('.poppar').toggleClass('yes');
});
$('#map_e').hover(function(){
	$(this).find('.poppar').toggleClass('yes');
});
$('#map_f').hover(function(){
	$(this).find('.poppar').toggleClass('yes');
});
$('#map_g').hover(function(){
	$(this).find('.poppar').toggleClass('yes');
});
$('#map_h').hover(function(){
	$(this).find('.poppar').toggleClass('yes');
});
$('#map_i').hover(function(){
	$(this).find('.poppar').toggleClass('yes');
});
$('#map_j').hover(function(){
	$(this).find('.poppar').toggleClass('yes');
});
$('#map_k').hover(function(){
	$(this).find('.poppar').toggleClass('yes');
});
$('.decorations_header h3').next().slideUp();
$('.decorations_header.selc h3').next().slideDown();
$('.decorations_header h3').click(function(){
	$(this).next().slideToggle();
	$(this).toggleClass('opent');
});



$('.decorations_header ul a').click(function(){
 var add = $(this).attr('rel');
	var url = "img/decorations_" + (add) + ".jpg";
	$('#decorations_right_top img').attr("src", url);
	$('.highlight').removeClass('highlight');
	$(this).addClass('highlight');
	return false;
});


                $(function() {   
                
                        var theWindow        = $(window),
                            $bg              = $("#backgrounder"),
                            aspectRatio      = $bg.width() / $bg.height();
                                                                
                        function resizeBg() {
                                
                                if ( (theWindow.width() / theWindow.height()) < aspectRatio ) {
                                    $bg
                                        .removeClass()
                                        .addClass('bgheight');
                                } else {
                                    $bg
                                        .removeClass()
                                        .addClass('bgwidth');
                                }
                                                        
                        }
                                                                
                        theWindow.resize(function() {
                                resizeBg();
                        }).trigger("resize");
                
                });


});//Document Ready end
