﻿jQuery(function( $ ){
    var isOverdd = false;
	//*************
    //DOM ready
    //*************
    $(document).ready(function(){
        function SetProduct(id, obj)
        {
            var title = (products[id-1].title);
            var descr = (products[id-1].descr);
            $("#product").find("h1").html(title);
            $("#product").find("p").html(descr);
            $(".box").removeClass("selected");
            $(".box").children(".preview").children(".selected").stop().animate({marginTop: '38px'},400).removeClass("selected");
            $(".box").children(".info").children(".selected").css({color: '#888888'}).removeClass("selected");
            $(obj).addClass("selected");
            $(obj).children(".preview").children("img").addClass("selected");
            $(obj).children(".info").children("span").addClass("selected");
        }
        $('.box').each(function(i, elem){ 
            var id = $(this).attr("id");
            $(this).bind('click', function(){if (!$(this).hasClass("selected")) { SetProduct(id, elem);} });
        });
        $('#products').bxSlider({
            displaySlideQty: 5,
            moveSlideQty: 1,
            infiniteLoop: false,
            hideControlOnEnd: true
        }); 
        //$('#map').colorbox();
        $('#colli').colorbox();       
    }); 
    //*************
    //WIN ready, also IMAGES...
    //*************
    $(window).load(function(){         
    });
    //*************
    //resize listener
    //*************
    $(window).resize(function(){     
    });  
    //*******************
    // EVENTS DOM ELEMENT
    //******************
    $(".box").hover(
            function() {	//On hover...
                  var img = $(this).children(".preview").children("img");
                  var title = $(this).children(".info").children("span");
                  if (!$(img).hasClass("selected")){ $(img).stop().animate({marginTop: '5px'},400); }
                  if (!$(title).hasClass("selected")){ $(title).css({color: '#434343'}); }
               
                  
                
            } ,
            function() { //On hover out...
                  var img = $(this).children(".preview").children("img");
                  var title = $(this).children(".info").children("span");
                  if (!$(img).hasClass("selected")){ $(img).stop().animate({marginTop: '38px'},400); }
                  if (!$(title).hasClass("selected")){ $(title).css({color: '#888888'}); }
                
            }
    );    

});






