$(document).ready(function() {
	$('#colors li img').attr('title', '');
	$('#colors_textbox').text('Roll over swatches to preview available colors');
	
	// Image preloads
	if ($('#colors').hasClass('dynamic_image')) {
		$('#colors img').each(function(i){
			var thiscolorfn = $(this).attr('src');
			thiscolorfn = thiscolorfn.replace(/img\/|.jpg|.gif/g, '');
			var house = $('#big_house');
			var housecolor = house.attr("src").replace(/\.jpg|\.gif|-color.*/g, '') + '-' + thiscolorfn.toLowerCase() + '.jpg';
			newimage = $('<img />').attr('src', housecolor);
		});
	}

	$('#colors li').mouseover(function() {
		var thiscolortext = $(this).find('img').attr('alt');
		$('#colors_textbox').text(thiscolortext);

		if ($('#colors').hasClass('dynamic_image')) {
			var thiscolorfn = $(this).find('img').attr('src');
			thiscolorfn = thiscolorfn.replace(/img\/|.jpg|.gif/g, '');
			var house = $('#big_house');
			var housecolor = house.attr("src").replace(/\.jpg|\.gif|-color.*/g, '') + '-' + thiscolorfn.toLowerCase() + '.jpg';
			house.attr("src", housecolor);
		}
	});
});

$(document).ready(function() {
	if ($('#prod_desc').hasClass('dynamic')) {
		$('.prod_text div').hide();
		$('.prod_text div').css('position', 'absolute');

		$('.prod_text').before('<p id="no_selection">Roll over the numbers on the left to explore features of this product.</p>');

		$('#prod_view div').hover(function(){
	//		$('#no_selection').hide();
			$('.prod_text div:eq(' + $('#prod_view div').index(this) + ')').fadeIn('fast');
		},function(){
			$('.prod_text div:eq(' + $('#prod_view div').index(this) + ')').fadeOut('fast', function(){
	//			$('#no_selection').fadeIn('fast');
			});
		});
	}
});

$(document).ready(function() {
	if ($('#content_main').hasClass('colorswatch')) {

		$('.no_js').hide();
		$('.js_only').show();

		$('.swatches img').attr('title', '');

		// Image preloads
		$('.swatches img').each(function(i){
			var thiscolorfn = $(this).attr('src');
			var thiscolorhouse = $(this).attr('class');
			thiscolorfn = thiscolorfn.replace(/img\/|.jpg|.gif/g, '');
			var house = $('#big_house');
			var housecolor = 'img/' + thiscolorhouse + '-' + thiscolorfn.toLowerCase() + '.jpg';
			newimage = $('<img />').attr('src', housecolor);
		});

		$('.swatches img').mouseover(function() {
			var thiscolortext = $(this).attr('alt');
			$('#swatch_textbox').text(thiscolortext);

			var thisclasslist = $(this).parent().attr("class").split(' ');
			
			$('#prod_list li').hide();		
	
			for (i = 0; i < thisclasslist.length; i++) {
				$('#prod_list li').each(function(j){
					if ($(this).hasClass(thisclasslist[i])) {
						$(this).fadeIn('fast');
					}
				});
			}
			
		
			var thiscolorfn = $(this).attr('src');
			var thiscolorhouse = $(this).attr('class');
			thiscolorfn = thiscolorfn.replace(/img\/|.jpg|.gif/g, '');
			var house = $('#big_house');
			var housecolor = 'img/' + thiscolorhouse + '-' + thiscolorfn.toLowerCase() + '.jpg';
			house.attr("src", housecolor);
		});
	}
});

