// JavaScript Document
var products = { 

//  modelsPos:null,

  init:function () {
    // Categories events
    
//    products.modelsPos = new Array();
    
    $("img[alt=model]").css("cursor", "hand");
    
    $("img[alt=model]").click(function () {
      products.changePicture($(this).get(0).src);
    });    

    $("img[alt=model]").css("cursor", "pointer");
    
    if (jQuery.browser == "msie") {
//      $("div.productItem>img").fadeTo(10, 0.6);
      $("img[alt=layout]").fadeTo(10, 0.6);
      $("img[alt=model]").fadeTo(10, 0.6);
    }
    else {
//      $("div.productItem>img").css("opacity", "0.6");
      $("img[alt=layout]").css("opacity", "0.6");
      $("img[alt=model]").css("opacity", "0.6");
    }
/*
    $("div.productItem>img").mouseover(function(){
      $(this).animate({ 
        width: "250px",
        height: "169px",
        opacity: 1,
        marginTop: "-1px",
        marginLeft: "-10px"
      }, 50 );
    });
    
    $("div.productItem>img").mouseout(function(){
      $(this).animate({ 
        width: "230px",
        height: "159px",
        opacity: 0.6,
        marginTop: "0px",
        marginLeft: "0px"
      }, 50 );
    });
*/

    $("img[alt=layout]").mouseover(function(){
      $(this).animate({ 
        width: "150px",
       height: "113px",
        opacity: 1,
        marginLeft: "-10px"
      }, 50 );
    });
    
    $("img[alt=layout]").mouseout(function(){
      $(this).animate({ 
        width: "133px",
        height: "100px",
        opacity: 0.6,
        marginLeft: "0px"
      }, 50 );
    });


    $("img[alt=model]").mouseover(function(){
    
    
//      $(this).css("position", "absolute");
//      var off = $(this).offset();
//      $(this).css("top", off.top - 30);
/*
      if (products.modelsPos[$(this).attr("id")] == null) {
        var top = $(this).css("top");
        products.modelsPos[$(this).attr("id")] = top;
      }
      else var top = products.modelsPos[$(this).attr("id")];
*/      
//      $(this).css("top", top - 30);

//      alert (off.top);
/*      
      $(this).parents().each(function () {
//        alert (this);
//        var off = this.offset();
//        var thisEl = $(this).offset();
//        $(this).offset(thisEl.left + off.left, thisEl.top + off.top);
      });
*/      
      $(this).animate({ 
        width: "150px",
        height: "113px",
        opacity: 1
 //       marginLeft: "-10px"
      }, 1 );
    });
    
    $("img[alt=model]").mouseout(function(){
    
      
      $(this).animate({ 
       width: "133px",
       height: "100px",
        opacity: 0.6
//        marginLeft: "0px"
      }, 1 );
      
//      $(this).offset(0, 0);
//      $(this).css("top", 0);
//      $(this).css("position", "relative");
      
    });
    
  },
  
  changePicture:function (picture) {
//    $("img[alt=big_model_pic]").get(0).src = picture;
    var extPos = picture.lastIndexOf(".");
    var picName = picture.slice(0, extPos) + picture.slice(extPos, picture.length);
    $("img[alt=big_model_pic]").get(0).src = picName;
//    $("img[alt=big_model_pic]").get(0).src = picture;

  }
};

$(function() {
    products.init();
    
  }
)

