  Cufon.replace('.headlines h1', {fontWeight: 'bold'});  
  Cufon.replace('.subheadline', {fontWeight: 'bold'});  
  Cufon.replace('#backLink', {hover:true});  
  Cufon.replace('#backLinkLeft', {hover:true});  
  Cufon.replace('#appLink a', {hover:true});
  var restartLooping  = null;
  var currentSkinName = 'skin0';
  var skinChange = 1;
  var nextSrc = 0;
  var appStoreBgHi = buildValidServerRelativeUrl("/_common/shared/newvehicles/mseries/g_meter/img/appstore_bg_hi.gif");
  var appStoreBg = buildValidServerRelativeUrl("/_common/shared/newvehicles/mseries/g_meter/img/appstore_bg.gif");
  
  
function thisMovie(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	} else {
		return document[movieName];
	}
}
 
function changeSkin(){    
  clearTimeout(restartLooping);  
  nextSrc = nextSrc+1;
  if(nextSrc==4){
    nextSrc=0; 
  }
  if(skinChange==1){
    $("#iphoneSkin2").attr('src',skins[currentSkinName][nextSrc]).load (function() {  
     skinChange = 2;
     $(".iphoneSkin div").fadeIn("slow","linear");
     $("#iphoneSkin2").unbind("load");
    // $("#iphoneSkin2").attr('src',skins[currentSkinName][nextSrc]).unbind("load");
     
    });       
  }else{
    $("#iphoneSkin1").attr('src',skins[currentSkinName][nextSrc]).load (function() {  
     skinChange = 1;
     $(".iphoneSkin div").fadeOut("slow","linear");
     $("#iphoneSkin1").unbind("load");
     
    // $("#iphoneSkin1").attr('src',skins[currentSkinName][nextSrc]).unbind("load");
     
    });  
  }
  restartLooping = setTimeout("changeSkin()", 3000);
}
  
  
function toggleLayer(layerName){ 
 if($("#"+layerName+"").css("display")=="none"){
  $(".hiddenLayer").css("display", "none");
   $("#"+layerName+"").css("display", "block");
 }else{
  $("#"+layerName+"").css("display", "none");
 }
}

function resetApps(){
 $("#functionHeadlines").show();
 $("#hintsHeadlines").hide();  
 $("#appsFunctionsContainer").show();
 $("#appsHintsContainer").hide();        
 $("#appsFunctionLink").css("color","#1f73fe");
 $("#appsFunctionLink img").css("background-position","left bottom");
}

function resetSkins(){
 clearTimeout(restartLooping);
 currentSkinName = 'skin0';
 skinChange = 1;
 nextSrc = 3;
 $(".skinPreviewImg  a.highlightable").css("color","#adadad");
 $(".skinPreviewImg  a.highlightable img").css("background-position","left top"); 
}

$(document).ready(function(){   
  
     
   var matches = null; 
    if(document.referrer){
      matches = document.referrer.match(/experience\.html/);
      if (matches) {
        $("#specialLink").css("display","block"); 
      }
    }
     
    $("#content a").focus(function() {
      this.blur();
    });



    $("#appsFunctionsContainer").show(); 
    var activeLink = null;
    var currentLink= null;
  
    $("#content a").click(function(){
      $("#content a.highlightable").css("color","#adadad");
      $("#content a.highlightable img").css("background-position","left top");
    });      
    $("#content a.highlightable").click(function(){
      currentLink =this.id;
      $("#content a.highlightable").css("color","#adadad");
      $("#content a.highlightable img").css("background-position","left top");
      $("#"+currentLink+"").css("color","#1f73fe");
      $("#"+currentLink+" img").css("background-position","left bottom");      
      activeLink = this.id;
    });      
    $("#content a.highlightable").mouseover(function(){
      currentLink =this.id;
      $("#"+currentLink+"").css("color","#1f73fe");
      $("#"+currentLink+" img").css("background-position","left bottom");  
    });      
    $("#content a.highlightable").mouseout(function(){
        currentLink =this.id;
      if(activeLink!=currentLink){
        $("#"+currentLink+"").css("color","#adadad");        
        $("#"+currentLink+" img").css("background-position","left top");
      }      
    });      
      
   
    $(".gotostart").click(function(){
      clearTimeout(restartLooping);      
     $("#slides").animate({
      marginLeft: "0px"
     }, "slow" );
    });      
   
    $(".gotoskins").click(function(){
     if(highbandUser) {
      thisMovie("mainFlash").stopPlaying();
     }
     resetSkins();
     $("#slides").animate({ 
      marginLeft: "-1024px"
     }, "slow", "linear", changeSkin() );
     
    });     
    
    $(".gotoapp").click(function(){     
     if(highbandUser) {
      thisMovie("mainFlash").stopPlaying();
     }
     resetApps();
     $("#slides").animate({ 
      marginLeft: "1024px"
     }, "slow" );
    });      
  
  
     
    $(".showfunctions").click(function(){
      $("#appsFunctionsContainer").show();
      $("#appsHintsContainer").hide();  
      $("#hintsHeadlines").hide();        
      $("#functionHeadlines").show();
    });
    
    $(".showhints").click(function(){
     $("#appsFunctionsContainer").hide();
     $("#appsHintsContainer").show();    
     $("#functionHeadlines").hide();
     $("#hintsHeadlines").show();    
    });
    
    $("#appLink").mouseover(function(){
     $("#appLink").css('background-image','url('+appStoreBgHi+')');
    });
    $("#appLink").mouseout(function(){
     $("#appLink").css('background-image','url('+appStoreBg+')');
    });
    $("#legalDisclaimerContent #closeAllButton a").click(function(){
     $("#legalDisclaimerContainer").hide();
    });
    $("#appleDisclaimerContent #closeAllButton a").click(function(){
     $("#appleDisclaimerContainer").hide();
    });
      
     
    
    
    $(".skinPreviewImg a.buttonHref").click(function(){ 
       clearTimeout(restartLooping);
       currentSkinName = this.id;     
       nextSrc = 0;
        $("#iphoneSkin1").attr('src',skins[currentSkinName][nextSrc]).load (function() { 
         if($(".iphoneSkin div").css("visibility","visible")){
          $(".iphoneSkin div").fadeOut(1);
         }
         skinChange = 1;
         
         $("#iphoneSkin1").unbind("load");
         restartLooping = setTimeout("changeSkin()", 3000);
        });       

      
    });
   
  
  });
