
$(function(){
	var sub_nav_timer;
	var timer_speed = 700;
	$("#top_nav_products").mouseenter(function(){
		$("#top_nav img").attr({"src": "images/nav_products_on.jpg"});
		$("#top_nav ul:not(#drop_down_nav_products)").hide();
		clearTimeout(sub_nav_timer);
		$("#top_nav ul#drop_down_nav_products").fadeIn("fast");
		
	}).mouseleave(function(){
		$("#top_nav img").attr({"src": "images/nav_off.jpg"});
		sub_nav_timer = setTimeout(function() { $('#top_nav ul#drop_down_nav_products').fadeOut("fast"); }, timer_speed);
	});
	
	$("#top_nav_services").mouseenter(function(){
		$("#top_nav img").attr({"src": "images/nav_services_on.jpg"});
		$("#top_nav ul:not(#drop_down_nav_services)").hide();
		clearTimeout(sub_nav_timer);
		$("#top_nav ul#drop_down_nav_services").fadeIn("fast");
		
	}).mouseleave(function(){
		$("#top_nav img").attr({"src": "images/nav_off.jpg"});
		sub_nav_timer = setTimeout(function() { $('#top_nav ul#drop_down_nav_services').fadeOut("fast"); }, timer_speed);
	});
	
	$("#top_nav_learn").mouseenter(function(){
		$("#top_nav img").attr({"src": "images/nav_learn_on.jpg"});
		$("#top_nav ul:not(#drop_down_nav_learn)").hide();
		clearTimeout(sub_nav_timer);
		$("#top_nav ul#drop_down_nav_learn").fadeIn("fast");
		
	}).mouseleave(function(){
		$("#top_nav img").attr({"src": "images/nav_off.jpg"});
		sub_nav_timer = setTimeout(function() { $('#top_nav ul#drop_down_nav_learn').fadeOut("fast"); }, timer_speed);
	});
	
	$("#top_nav_about").mouseenter(function(){
		$("#top_nav img").attr({"src": "images/nav_about_on.jpg"});
		$("#top_nav ul:not(#drop_down_nav_about)").hide();
		clearTimeout(sub_nav_timer);
		$("#top_nav ul#drop_down_nav_about").fadeIn("fast");
		
	}).mouseleave(function(){
		$("#top_nav img").attr({"src": "images/nav_off.jpg"});
		sub_nav_timer = setTimeout(function() { $('#top_nav ul#drop_down_nav_about').fadeOut("fast"); }, timer_speed);
	});
	
	
	
	$("#top_nav ul#drop_down_nav_products").mouseenter( function(){
		$("#top_nav img").attr({"src": "images/nav_products_on.jpg"});
		clearTimeout(sub_nav_timer);
		$(this).fadeIn("fast");
		
	}).mouseleave( function(){
		sub_nav_timer = setTimeout(function() { $("#top_nav ul").fadeOut("fast"); $("#top_nav img").attr({"src": "images/nav_off.jpg"});}, timer_speed);
		
	});
	
	$("#top_nav ul#drop_down_nav_services").mouseenter( function(){
		$("#top_nav img").attr({"src": "images/nav_services_on.jpg"});
		clearTimeout(sub_nav_timer);
		$(this).fadeIn("fast");
		
	}).mouseleave( function(){
		sub_nav_timer = setTimeout(function() { $("#top_nav ul").fadeOut("fast");$("#top_nav img").attr({"src": "images/nav_off.jpg"}); }, timer_speed);
		
	});
	
	$("#top_nav ul#drop_down_nav_learn").mouseenter( function(){
		$("#top_nav img").attr({"src": "images/nav_learn_on.jpg"});
		clearTimeout(sub_nav_timer);
		$(this).fadeIn("fast");
		
	}).mouseleave( function(){
		sub_nav_timer = setTimeout(function() { $("#top_nav ul").fadeOut("fast");$("#top_nav img").attr({"src": "images/nav_off.jpg"}); }, timer_speed);
		
	});
	
	$("#top_nav ul#drop_down_nav_about").mouseenter( function(){
		$("#top_nav img").attr({"src": "images/nav_about_on.jpg"});
		clearTimeout(sub_nav_timer);
		$(this).fadeIn("fast");
		
	}).mouseleave( function(){
		sub_nav_timer = setTimeout(function() { $("#top_nav ul").fadeOut("fast");$("#top_nav img").attr({"src": "images/nav_off.jpg"}); }, timer_speed);
	});
	
	$("#dealer_zip").focus( function(){
		$(this).val('').css('color', '#000000');
	}).keydown( function(e){
		
		var key =  e.keyCode;
		//alert(key);
		if (key == 13)
		{
			e.preventDefault();
			location.href = 'dealerlookup.aspx?zip=' + $(this).val() + ''
		}
	});
	
	$('a.lightbox').lightBox();
	$('a.colorbox').colorbox({iframe:true, height:219, width:435});
	$(document).pngFix();
	$("#slider").easySlider({
		prevText: '',
		nextText: ''
	});
	
	
	
	/*****************************************************************/
    /*** SLIDESHOW GALLERY THUMB ANIMATIONS **************************/
    /*****************************************************************/
   // var theStart = parseInt($("#gallery_wrapper").find("ul").css("left"));
	var theStart = 0;
    //var theWidth = $("#gallery_wrapper").find("ul").width();
	var totalImages = 0;
	$("#gallery_wrapper li").each(function(){
		totalImages++;
	});
	var theWidth = totalImages*105;
	//alert(theWidth);
    var tempRemainingLeft = 0;
    var tempRemainingRight = theWidth - 420;
    var animationWidth = 210;
    var animationTime = 400;

    /*** ANIMATE LEFT ************************************************/
    $("#gallery_right").click(function()
    {
        //alert("THE TOP: " + theStart + "\nTHE HEIGHT: " + theHeight + "\ntempRemainingLeft: " + tempRemainingLeft + "\ntempRemainingRight: " + tempRemainingRight);
        if (tempRemainingRight >= animationWidth)
        {
            $("#gallery").animate({ marginLeft: theStart - animationWidth }, animationTime);
            theStart = theStart - animationWidth;
            tempRemainingLeft = tempRemainingLeft + animationWidth;
            tempRemainingRight = tempRemainingRight - animationWidth;
        }
        else if (tempRemainingRight > 0)
        {
            $("#gallery").animate({ marginLeft: theStart - tempRemainingRight }, animationTime);
            theStart = theStart - tempRemainingRight;
            tempRemainingLeft = tempRemainingLeft + tempRemainingRight;
            tempRemainingRight = 0;
        }
    });
    /*** ANIMATE RIGHT **************************************************/
    $("#gallery_left").click(function()
    {
        //alert("THE TOP: " + theStart + "\nTHE HEIGHT: " + theHeight + "\ntempRemainingLeft: " + tempRemainingLeft + "\ntempRemainingRight: " + tempRemainingRight);
        if (tempRemainingLeft >= animationWidth)
        {
            $("#gallery").animate({ marginLeft: theStart + animationWidth }, animationTime);
            theStart = theStart + animationWidth;
            tempRemainingRight = tempRemainingRight + animationWidth;
            tempRemainingLeft = tempRemainingLeft - animationWidth;
        }
        else if (tempRemainingLeft > 0)
        {
            $("#gallery").animate({ marginLeft: 0 }, animationTime);
            theStart = theStart + tempRemainingLeft;
            tempRemainingRight = tempRemainingRight + tempRemainingLeft;
            tempRemainingLeft = 0;
        }
    });
	
	
	
	var the_first = $("#inspiration_slides:first");
	var the_source = $("a", the_first).attr("href");

	
	
	setInspirationImg(the_source);
	
	$("#inspiration_slides li a").click(function(e){e.preventDefault();});
	
	
});
function setInspirationImg(url){
	$("#big_img a").attr("href",url);

	//$("#big_img a img").attr("src",url);
	$("#big_img a img").attr("src", "ThumbnailHandler.ashx?ImgFilePath=" + url + "&width=400&height=400");


	return false;
}
function ShowProductName(){
	var selection = document.getElementById("right_product_select").value;
	var results = document.getElementById("right_product_finder_results");
	var str = "";
	switch (selection)
	{
		case "1":
			str = "<a href=\"prod_selector.aspx\">Builder Series 1100 Vinyl</a>";
			break;
		case "2":
			str = "<a href=\"prod_selector.aspx\">Builder Series 3700 Aluminum</a>";
			break;
		case "3":
			str = "<a href=\"prod_selector.aspx\">Builder Series 3700 Aluminum</a>";
			break;
		case "4":
			str = "<a href=\"prod_selector.aspx\">Builder Series 4700 Aluminum</a>";
			break;
		case "5":
			str = "<a href=\"prod_selector.aspx\">Builder Series 4800 Aluminum</a>";
			break;
		case "6":
			str = "<a href=\"prod_selector.aspx\">Insulate Pro Series 200 Vinyl</a>";
			break;
		case "7":
			str = "<a href=\"prod_selector.aspx\">Insulate Builder Series 400 Vinyl</a>";
			break;
		case "8":
			str = "<a href=\"prod_selector.aspx\">Insulate Builder Series 460 Vinyl</a>";
			break;
		case "9":
			str = "<a href=\"prod_selector.aspx\">Insulate Builder Series 550 Vinyl</a>";
			break;
		case "10":
			str = "<a href=\"prod_selector.aspx\">Insulate Pro Series 700 Vinyl</a>";
			break;
		case "11":
			str = "<a href=\"prod_selector.aspx\">Insulate Pro Series 960 Vinyl</a>";
			break;
		case "12":
			str = "<a href=\"prod_selector.aspx\">Insulate Pro Series 960 Vinyl</a>";
			break;
		case "13":
			str = "<a href=\"prod_selector.aspx\">MW Pro Series Vinyl</a>";
			break;
		case "14":
			str = "<a href=\"prod_selector.aspx\">MW Pro Series Impact Vinyl</a>";
			break;
		case "15":
			str = "<a href=\"prod_selector.aspx\">MW Pro Series Wood</a>";
			break;
		case "16":
			str = "<a href=\"prod_selector.aspx\">Builder Series 100 Wood</a>";
			break;
		case "17":
			str = "<a href=\"prod_selector.aspx\">MW Pro Series 200 Wood/Composite</a>";
			break;
		case "18":
			str = "<a href=\"prod_selector.aspx\">MW Pro Series 300 Vinyl/Composite</a>";
			break;
		case "19":
			str = "<a href=\"prod_selector.aspx\">MW Pro Series 400 Composite</a>";
			break;
		case "20":
			str = "<a href=\"prod_selector.aspx\">Builder Series 600 Vinyl Clad</a>";
			break;
		case "21":
			str = "<a href=\"prod_selector.aspx\">MW Pro Series 800 Vinyl Clad</a>";
			break;
		case "22":
			str = "<a href=\"prod_selector.aspx\">MW Pro Series Vinyl Clad</a>";
			break;
		case "23":
			str = "<a href=\"prod_selector.aspx\">Mira Premium Series Aluminum Clad</a>";
			break;
		case "24":
			str = "<a href=\"prod_selector.aspx\">Builder Series 1700 Vinyl</a>";
			break;
		case "25":
			str = "<a href=\"prod_selector.aspx\">Builder Series 2200 Vinyl</a>";
			break;
		case "26":
			str = "<a href=\"prod_selector.aspx\">Builder Series 5000 Vinyl</a>";
			break;
		case "27":
			str = "<a href=\"prod_selector.aspx\">Builder Series 5700 Vinyl</a>";
			break;
		case "28":
			str = "<a href=\"prod_selector.aspx\">Pro Series Replacement Vinyl</a>";
			break;
		case "29":
			str = "<a href=\"prod_selector.aspx\">Premium Series Replacement Vinyl</a>";
			break;
		case "30":
			str = "<a href=\"prod_selector.aspx\">Premium Series Replacement Vinyl</a>";
			break;
		default:
			str = "";
			break;
	}
	results.innerHTML = str;
}
function showStep3()
{
	$("#step_1-2_wrapper").hide();
	$("#step_3_wrapper").show();
}
function hideStep3()
{
	$("#step_3_wrapper").hide();
	$("#step_1-2_wrapper").show();
}

function toggle(divname){
	var elem = document.getElementById(divname);
	var state = elem.style.display;
	var togImg = document.getElementById( divname + "_img" );
	
	if(state == "none"){
		elem.style.display = "block";
		if( togImg != null) togImg.src="../images/minus.jpg";
	}
	else {
		elem.style.display = "none";
		if( togImg != null) togImg.src="../images/plus.jpg";
	}
}


function closeandredirect()
{
	$.fn.colorbox.close();
	setTimeout('window.top.location=\"prod_selector_series.aspx\"', 200);
}

