
$(function(){

  
  //hide "non-JS" elements
  $('#noJs1, #noJs2, #btnList, #phonesList, .hideJS').hide();
  $('.showJS').show();

  //repair banner height
  var height = $('#header').height();
  if (height>200){
    $('#header').css('paddingBottom',23);
  }

  //count creation page entries
  var creationPage = $('#parseData').length?true:false;
  var selectedPhone = (creationPage && ($('#set_model')[0].value!=0))?true:false;
  if (creationPage){
    pageTracker._trackEvent("phone", "creationPageEntry");
  }
  if (selectedPhone){
    pageTracker._trackEvent("phone", "creationPageEntryPhones");
  }

  /**
   * Add tooltips to cheepest
   */
  $(".icons .cheepest").tooltip({
    top: -95,
    left: -115,
    delay: 300,
    showURL: false,
    bodyHandler: function() {
      return $("<img/>").attr("src", "/i/icon_cheepest_big.gif");
    }
  });

  /**
   * Add tooltips to cd-action
   */
  $(".icons .cdAction").tooltip({
    top: -95,
    left: -85,
    delay: 300,
    showURL: false,
    bodyHandler: function() {
      return $("<img/>").attr("src", "/i/icon-cd-action-big.gif");
    }
  });

  /**
   * Add previews to thumbs
   */

    $(".previewImage").tooltip({
      top: 10,
      left: 10,
      delay: 300,
      showURL: false,
      bodyHandler: function() {
        return $("<img/>").attr("src", this.src.substr(0,this.src.length-4)+'.large.'+this.src.substr(this.src.length-3));

      }
    });

  //display last viewed creations
  myCreations = new MyCreations();
  myCreations.getCurrentCreationDetails();
  myCreations.showData();

  myAffiliates = new MyAffiliates();
  myAffiliates.affiliate();
  myAffiliates2 = new MyAffiliates2();
  myAffiliates2.affiliate();

  /**
   * Init player
   */

  myPlayer = new MyPlayer();
  myPlayer.init();

  /**
   * Get selected phone values
   */

  myPhones = new MyPhones();
  myPhones.init();


  myCard = new MyCard();
  myCard.init();

});
