
clicks = function() {

  $('.column .car_menu div').click(function() {
    side = this.id.split('_')[0];
    car  = parseInt( this.id.split('_')[1] );
    image = content.path + content.bigFiles[car];

    $('#'+side+'_focus').css({backgroundImage:'url('+image+')'}).load('/lexus/plugins/copy/'+car+'.html');
    $(this).addClass('selected');
    $(this).siblings().each(function(){$(this).removeClass('selected').find('p').removeClass('selected')})
    menuItem = $('#home_container .car_menu div')[car];
    $(menuItem).find('p').addClass('selected');

    $('#container .car_menu p').removeClass('selected');
    menuItem = $('#container .car_menu div')[car];
    $(menuItem).find('p').addClass('selected');
    setTimeout(function() {
      instantiateCarLink();
    }, 100);
  });

  $('#footer_center p, #footer_center h4').click(function() {
    $('#footer_draw').slideToggle(500);
  });

  setTimeout(function() {
    instantiateCarLink();
  }, 100);

}

instantiateCarLink = function() {
  $('.closeBtn').click(function(){
    $(this).parent().toggle().prev().toggleClass('carLinkSelected carLink');
  });
  $('.carEnquireLink').click(function(){
    $(this).toggleClass('carLinkSelected carLink').next().toggle();
  });
}

preloadImages = function() {
  $(content.bigFiles).each(function(){
    $('<img/>')[0].src = content.path + this;
  });
}

$(function(){

  // focus
  $('#left_focus').css({backgroundImage:'url('+content.path + content.bigFiles[0]+')'}).load('/lexus/plugins/copy/0.html');
  $('#right_focus').css({backgroundImage:'url('+content.path + content.bigFiles[3]+')'}).load('/lexus/plugins/copy/3.html');
  // menu
  carMenu = $('#home_container .car_menu div');
  for (var i = 0; i < carMenu.length; i++) {
    menuItem = $('#home_container .car_menu div')[i];
    $(menuItem).css({backgroundImage:'url('+content.path + content.smallFiles[i]+')'});
  };

  setTimeout(function() {
    clicks();
  }, 100);

  setTimeout(function() {
    preloadImages();
  }, 1000);

});



function getInternetExplorerVersion()
// Returns the version of Windows Internet Explorer or a -1
// (indicating the use of another browser).
{
   var rv = -1; // Return value assumes failure.
   if (navigator.appName == 'Microsoft Internet Explorer')
   {
      var ua = navigator.userAgent;
      var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
      if (re.exec(ua) != null)
         rv = parseFloat( RegExp.$1 );
   }
   return rv;
}
function checkIEVersion()
{
   var msg = "You're not using Windows Internet Explorer.";
   var ver = getInternetExplorerVersion();
   if ( ver> -1 )
   {
      if ( ver>= 8.0 )
         msg = "You're using Windows Internet Explorer 8.";
      else if ( ver == 7.0 )
    	  msg = "You're using Windows Internet Explorer 7.";
      else if ( ver == 6.0 )
    	  msg = "You're using Windows Internet Explorer 6.";
      else
    	  msg = "You should upgrade your copy of Windows Internet Explorer";
    }
   alert( msg );
}

var ver = getInternetExplorerVersion();

if ( ver < 8.0 )
{
	document.write("<link rel='stylesheet' type='text/css' href='/lexus/plugins/assets/stylesheets/ie.css'>");
}
