// JavaScript Document
(function($){$.fn.defaultvalue=function(){var elements=this;var args=arguments;var c=0;return(elements.each(function(){var el=$(this);var def=args[c++];el.val(def).focus(function(){if(el.val()==def){el.val("");}el.blur(function(){if(el.val()==""){el.val(def);}});});}));}})(jQuery)

jQuery.fn.main = function() 
{
    $("#burners").animate({left:295, top:80, width:150}, 500); 
    $("#radiators").animate({left:205, top:220}, 500); 
    $("#cauldrons").animate({left:175, top:340, width:150}, 500); 
    $("#pumps").animate({left:500, top:60}, 500); 
    $("#boylers").animate({left:630, top:230}, 500); 
    $("#pipes").animate({left:660, top:320}, 500); 
    $("#water_conditionings").animate({left:690, top:500, width:200}, 500);

    $("#pipes dt a").attr('style', 'color:#000; border-color:#000;')
    $("#radiators dt a").attr('style', 'color:#000; border-color:#000;')
    $('#devices img').remove();
};


$(window).load(function () {
  $("#burners, #alternative li:eq(2)").load(function(){
        
        if (!$("#burners").hasClass("active"))
        {
            $("#device").attr("style", 'background:url(./i/burners.jpg) 269px 59px no-repeat; display:none;').animate({opacity: "show"}, 500).main();
            $("#devices li").attr("class", 'not_active');
            $($("#burners")).attr("class", 'active');
            $("<img>").attr("src", "./i/arrow/arrow4.png").appendTo($("#burners"));
            $("#burners").animate({left:310, top:185, width:215}, 500);
            $("#radiators").animate({left:125, top:240}, 500);
            $("#radiators dt a").attr('style', 'color:#fff; border-color:#fff;');
            $("#arrow").show().animate({left:'49.4%'}, 500);
            return false;
        }
        
    });
});

$(document).ready(function(){
    //test();
    $("#switch_currency #eu").click(function(){
	    $("#eu").attr("class", 'active');
	    $("#ru").attr("class", 'not_active');
	    $(".ru").attr("style", 'display:none');
	    $(".eu").attr("style", 'display:inline');
	});
    $("#switch_currency #ru").click(function(){
	    $("#eu").attr("class", 'not_active');
	    $("#ru").attr("class", 'active');
	    $(".ru").attr("style", 'display:inline');
	    $(".eu").attr("style", 'display:none');
	});
	  
    $("#cauldrons, #alternative li:eq(0)").click(function(){
        if (!$("#cauldrons").hasClass("active"))
        {
            $("#device").attr("style", 'background:url("./i/cauldrons.jpg") 139px 201px no-repeat; display:none;').animate({opacity: "show"}, 500).main();
            $("#devices li").attr("class", 'not_active');
            $($("#cauldrons")).attr("class", 'active').animate({width:260, left:65});
            $("<img>").attr("src", "./i/arrow/arrow5.png").appendTo($("#cauldrons"));
            $("#arrow").show().animate({left:'29.4%'}, 500);
            return false;
        }
    });

    $("#radiators, #alternative li:eq(1)").click(function(){
        if (!$("#radiators").hasClass("active")) 
        {
            $("#device").attr("style", 'background:url(./i/radiators.jpg) 218px 110px no-repeat; display:none;').animate({opacity: "show"}, 500).main();
            $("#devices li").attr("class", 'not_active'); 
            $($("#radiators")).attr("class", 'active');	
            $("<img>").attr("src", "./i/arrow/arrow4.png").appendTo($("#radiators"));
            $("#burners").animate({left:295, top:60}, 500); 
            $("#radiators").animate({left:160, top:270}, 500);
            $("#cauldrons").animate({left:30, top:460}, 500);
            $("#arrow").show().animate({left:'39.4%'}, 500); 		
            return false;
        }
    });
		  
    $("#burners, #alternative li:eq(2)").click(function(){
        return showBurners();
    });
    
    function showBurners()
    {
        if (!$("#burners").hasClass("active"))
        {
            $("#device").attr("style", 'background:url(./i/burners.jpg) 269px 59px no-repeat; display:none;').animate({opacity: "show"}, 500).main();
            $("#devices li").attr("class", 'not_active');
            $($("#burners")).attr("class", 'active');
            $("<img>").attr("src", "./i/arrow/arrow4.png").appendTo($("#burners"));
            $("#burners").animate({left:310, top:185, width:215}, 500);
            $("#radiators").animate({left:125, top:240}, 500);
            $("#radiators dt a").attr('style', 'color:#fff; border-color:#fff;');
            $("#arrow").show().animate({left:'49.4%'}, 500);
            return false;
        }
    }
    
	$("#burners, #alternative li:eq(2)").ready(function(){
        return showBurners();
    });  
    
		 $("#pumps, #alternative li:eq(3)").click(function(){if ($("#pumps").hasClass("active") != true) {
			$("#device").attr("style", 'background:url(./i/pumps.jpg) no-repeat 744px 17px; display:none;').animate({opacity: "show"}, 500).main();
			$("#devices li").attr("class", 'not_active');
			$($("#pumps")).attr("class", 'active');
			$("<img>").attr("src", "./i/arrow/arrow3.png").appendTo($("#pumps"));
			$("#pumps").animate({left:610, top:240}, 500); 
			$("#boylers").animate({left:835, top:365}, 500); 
			$("#pipes").animate({left:670, top:410}, 500); 
			$("#arrow").show().animate({left:'59.4%'}, 500); 		
		 return false }});

		     $("#boylers, #alternative li:eq(4)").click(function(){
				if ($("#boylers").hasClass("active") != true) {
					$("#device").attr("style", 'background:url(./i/boylers.jpg) 755px 146px no-repeat; display:none;').animate({opacity: "show"}, 500).main();
					$("#devices li").attr("class", 'not_active');
					$($("#boylers")).attr("class", 'active');
					$("<img>").attr("src", "./i/arrow/arrow2.png").appendTo($("#boylers"));
					$("#pipes").animate({left:720, top:445}, 500); 
					$("#arrow").show().animate({left:'69.4%'}, 500); 		
       		return false }});
		  
		  $("#pipes, #alternative li:eq(5)").click(function(){if ($("#pipes").hasClass("active") != true) {
			$("#device").attr("style", 'background:url(./i/pipes.jpg) 840px 237px no-repeat; display:none;').animate({opacity: "show"}, 500).main();
			$("#devices li").attr("class", 'not_active');
			$($("#pipes")).attr("class", 'active');
			$("<img>").attr("src", "./i/arrow/arrow1.png").appendTo($("#pipes"));
			$("#water_conditionings").animate({left:670, top:550}, 500);
			$("#arrow").show().animate({left:'79.4%'}, 500); 		
         return false}});
		  
		  
		   $("#water_conditionings, #alternative li:eq(6)").click(function(){
				if ($("#water_conditionings").hasClass("active") != true) {
					$("#device").attr("style", 'background:url(./i/water_conditionings.jpg) 738px 235px no-repeat; display:none;').animate({opacity: "show"}, 500).main();
					$("#devices li").attr("class", 'not_active');
					$($("#water_conditionings")).attr("class", 'active');
					$("<img>").attr("src", "./i/arrow/arrow1.png").appendTo($("#water_conditionings"));
					$("#water_conditionings").animate({left:680, top:330, width:220}, 500);
					$("#pipes").animate({left:680, top:590}, 500);
					$("#pipes dt a").attr('style', 'color:#fff; border-color:#fff;')
					$("#arrow").show().animate({left:'89.4%'}, 500); 		
         return false}});
      });

    $(function(){
        
        $('#images a').click(function(){
            $('#image').attr("class", 'active');
            $('#image img').remove();
            $('#images a').animate({opacity:1}, 300);
            $(this).animate({opacity:0.5}, 300);
            var image = $('<img src="' + $(this).attr('href') + '" alt="' + $(this).attr('title') + '"/>');
            image.load(function(){
                $('#image').animate({width:image.width()+15, height:image.height()+15},500)
                $('#title').animate({left:image.width()+60}, 500)
            });
            $('#title').text($(this).text());
            image.appendTo('#image');
            return false;
        });
    });
  
    $(function(){
	    //$('#search input').defaultvalue('Поиск');
	    $(".table tr:nth-child(even)").addClass("odd"); // я индус =)
	
 
/*	$(".min").each(
            function()
            {$(this).children().children().children('tr:gt(3)').hide()}
			)
	
	$(".open").toggle(
			function(){
				$(this).text('Скрыть')
				$(this).parents('table').children().children("tr:hidden").show() 
			},
			function(){
				$(this).text('Расскрыть')
				$(this).parents('table').children().children('tr:gt(3)').hide()
			}) */

    });
