//rollover scripts for the "product features" page

jQuery(document).ready(function(){
    
    ChangeText();
    
    SetDefaultTextAndImage();
    
    SetTextArea("back panel");

	jQuery("#cons > div").attr("id", function(index){ // Get all the hidden div tags and give them each an unique ID
		return "holder"+index;	 //Set the ID to #holder and a number after, e.g.: #holder0, #holder1							 
	});
						   
	jQuery(".spot").attr("id", function(i){ //Find all the "hot spots" of map with a class named "spot" in them and give them unique ID's
		return "spot"+i; //Set the ID to #spot0, #spot1, #spot2 etc...		   
	}).each(function(dex){ //looping on each of the "spot"
		jQuery(this).hover( 
			function(){
				jQuery("#cons > div").hide(); //Hide any active class
				jQuery("#holder"+dex).show(); //then fade in the corresponding object
				
				
				/* change image ( alexander Oct 19, 2010 @HZ ) */
				
				jQuery("#main-middle-table>ul>li").removeClass("default");
				var text = $("#holder"+dex).find("strong:eq(0)").text();
				jQuery("#main-middle-table>ul>li").find("span:eq(0)").each( 
				    function(index, obj){ 
				        if($(obj).text() == text)
				        {
				            $(obj).parent().addClass("default");
				            SetTextArea($(obj).text());
				        }
                        else if (text == "cabinet interior" && $(obj).text() == "cabinet box")
                        {
                            $(obj).parent().addClass("default");
                            SetTextArea($(obj).text());
                        }
                        else if (text == "hinges" && $(obj).text() == "hinge for full overlay")
                        {
                            $(obj).parent().addClass("default");
                            SetTextArea($(obj).text());
                        }
                        else if (text == "shelf support sytem" && $(obj).text() == "door styles")
                        {
                            $(obj).parent().addClass("default");
                            SetTextArea($(obj).text());
                        }
				    }
				);
			},
			
			/* alexander : hide all images when one of them lose focus */
			function(){
//			    $("#cons > div").hide();
//			    alert($("#main-middle-table>ul>li .default").html());
			}
		);
	});

	
});

/* set text area */
function SetTextArea(text)
{
    var result = text;
    
    switch(text)
    {
         
    }
    
    jQuery("#why-does-it-matter>p").html(result);
}

/* set default text and image */
function SetDefaultTextAndImage()
{
    jQuery("#main-middle-table>ul>li:eq(0)").addClass("default");
    jQuery(".con-img:eq(0)").show();
}

/* change text ( alexander Oct 19, 2010 @HZ ) */
function ChangeText()
{
    jQuery("#main-middle-table>ul>li").mouseover(
        function()
        {
           $("#main-middle-table>ul>li").removeClass("default");
           
           $(this).addClass("default");
            var text = $(this).find("span:eq(0)").text();
            SetTextArea(text);
            
            $(".con-img").hide();
            
            $(".con-img").find("strong").each(
                function(index, obj){
                    if (text == $(obj).text())
                    {
                        $(obj).parent().show();
                    }
                    else if ($(obj).text() == "cabinet interior" && text == "cabinet box")
                    {
                        $(obj).parent().show();
                    }
                    else if ($(obj).text() == "hinges" && text == "hinge for full overlay")
                    {
                        $(obj).parent().show();
                    }
                    else if ($(obj).text() == "shelf support sytem" && text == "door styles")
                    {
                        $(obj).parent().show();
                    }
                }
            );
        }
    );   
}
