//determine user location
if (location.search.indexOf('server_path') != -1){
   js_server_path = new String(location.search);
   js_server_path.replace("server_path=","");
   var js_pathparts = js_server_path.split("/");
}
else{
   var js_server_path = location.pathname.replace('.php','');
   var js_pathparts = js_server_path.split("/");
}

// preload core images
if(document.images){

  var nav_sweepstakes = new Image();
  nav_sweepstakes.src = "/images/nav/sweepstakes.gif";

  var nav_sweepstakes_over = new Image();
  nav_sweepstakes_over.src = "/images/nav/sweepstakes_over.gif";

  var nav_the_pit = new Image();
  nav_the_pit.src = "/images/nav/the_pit.gif";

  var nav_the_pit_over = new Image();
  nav_the_pit_over.src = "/images/nav/the_pit_over.gif";

  var nav_car_seven = new Image();
  nav_car_seven.src = "/images/nav/car_seven.gif";

  var nav_car_seven_over = new Image();
  nav_car_seven_over.src = "/images/nav/car_seven_over.gif";

  var nav_nextel_cup = new Image();
  nav_nextel_cup.src = "/images/nav/nextel_cup.gif";

  var nav_nextel_cup_over = new Image();
  nav_nextel_cup_over.src = "/images/nav/nextel_cup_over.gif";

  var nav_promotion = new Image();
  nav_promotion.src = "/images/nav/get_direct_tv.gif";

  var nav_promotion_over = new Image();
  nav_promotion_over.src = "/images/nav/get_direct_tv_over.gif";

  var home_nav = new Image();
  home_nav.src = "/images/nav/home_nav.gif";

  var home_nav_over = new Image();
  home_nav_over.src = "/images/nav/home_nav_over.gif";

//phase out nav

  var email_signup_go = new Image();
  email_signup_go.src = "/images/core/email_signup_go.gif";

  var email_signup_go_over = new Image();
  email_signup_go_over.src = "/images/core/email_signup_go_over.gif";

  var inside_track_nav = new Image();
  inside_track_nav.src  = "/images/nav/nav_inside_track.gif";

  var inside_track_nav_over = new Image();
  inside_track_nav_over.src  = "/images/nav/nav_inside_track_over.gif";

  var view_schedule_nav = new Image();
  view_schedule_nav.src  = "/images/nav/nav_view_schedule.gif";

  var view_schedule_nav_over = new Image();
  view_schedule_nav_over.src  = "/images/nav/nav_view_schedule_over.gif";


if(js_pathparts[1] == "sweepstakes") {
  
    var nav_crew_chief_ballot = new Image();
    nav_crew_chief_ballot.src = "/images/nav/sweepstakes/crew_chief_ballot.gif";

    var nav_crew_chief_ballot_over = new Image();
    nav_crew_chief_ballot_over.src = "/images/nav/sweepstakes/crew_chief_ballot_over.gif";

    var nav_registration = new Image();
    nav_registration.src = "/images/nav/sweepstakes/registration.gif";
    
    var nav_registration_over = new Image();
    nav_registration_over.src = "/images/nav/sweepstakes/registration_over.gif";    

    var nav_official_rules = new Image();
    nav_official_rules.src = "/images/nav/sweepstakes/official_rules.gif";
    
    var nav_official_rules_over = new Image();
    nav_official_rules_over.src = "/images/nav/sweepstakes/official_rules_over.gif";

    var nav_prizes = new Image();
    nav_prizes.src = "/images/nav/sweepstakes/prizes.gif";

    var nav_prizes_over = new Image();
    nav_prizes_over.src = "/images/nav/sweepstakes/prizes_over.gif";
    
    var nav_winners = new Image();
    nav_winners.src = "/images/nav/sweepstakes/winners.gif";

    var nav_winners_over = new Image();
    nav_winners_over.src = "/images/nav/sweepstakes/winners_over.gif";
    
    var nav_send_to_a_friend = new Image();
    nav_send_to_a_friend.src = "/images/nav/sweepstakes/send_to_a_friend.gif";

    var nav_send_to_a_friend = new Image();
    nav_send_to_a_friend.src = "/images/nav/sweepstakes/send_to_a_friend_over.gif";    
    
}

if(js_pathparts[1] == "car_no_7") {
  
    var nav_meet_the_driver = new Image();
    nav_meet_the_driver.src = "/images/nav/car_no_7/meet_the_driver.gif";

    var nav_meet_the_driver_on = new Image();
    nav_meet_the_driver_on.src = "/images/nav/car_no_7/meet_the_driver_on.gif";

    var nav_meet_the_driver_over = new Image();
    nav_meet_the_driver_over.src = "/images/nav/car_no_7/meet_the_driver_over.gif";
  
    var nav_meet_the_owner = new Image();
    nav_meet_the_owner.src = "/images/nav/car_no_7/meet_the_owner.gif";

    var nav_meet_the_owner_on = new Image();
    nav_meet_the_owner_on.src = "/images/nav/car_no_7/meet_the_owner_on.gif";

    var nav_meet_the_owner_over = new Image();
    nav_meet_the_owner_over.src = "/images/nav/car_no_7/meet_the_owner_over.gif";

    var nav_meet_the_crew = new Image();
    nav_meet_the_crew.src = "/images/nav/car_no_7/meet_the_crew.gif";

    var nav_meet_the_crew_on = new Image();
    nav_meet_the_crew_on.src = "/images/nav/car_no_7/meet_the_crew_on.gif";

    var nav_meet_the_crew_over = new Image();
    nav_meet_the_crew_over.src = "/images/nav/car_no_7/meet_the_crew_over.gif";

    var nav_car_info_and_schedule = new Image();
    nav_car_info_and_schedule.src = "/images/nav/car_no_7/car_info_and_schedule.gif";

    var nav_car_info_and_schedule_on = new Image();
    nav_car_info_and_schedule_on.src = "/images/nav/car_no_7/car_info_and_schedule_on.gif";

    var nav_car_info_and_schedule_over = new Image();
    nav_car_info_and_schedule_over.src = "/images/nav/car_no_7/car_info_and_schedule_over.gif";

    var nav_photo_gallery = new Image();
    nav_photo_gallery.src = "/images/nav/car_no_7/photo_gallery.gif";

    var nav_photo_gallery_on = new Image();
    nav_photo_gallery_on.src = "/images/nav/car_no_7/photo_gallery_on.gif";

    var nav_photo_gallery_over = new Image();
    nav_photo_gallery_over.src = "/images/nav/car_no_7/photo_gallery_over.gif";

    var track_by_track_stats = new Image();
    track_by_track_stats.src = "/images/car_no_7/track_by_track_stats.gif";

    var track_by_track_stats_over = new Image();
    track_by_track_stats_over.src = "/images/car_no_7/track_by_track_stats_over.gif";

    var journal = new Image();
    journal.src = "/images/car_no_7/journal.gif";

    var journal_over = new Image();
    journal_over.src = "/images/car_no_7/journal_over.gif";
        
   var meet_the_driver_header_bio = new Image();
   meet_the_driver_header_bio.src = "/images/car_no_7/info_tab_bio.gif";

   var meet_the_driver_header_stats = new Image();
   meet_the_driver_header_stats.src = "/images/car_no_7/info_tab_stats.gif";

   var meet_the_driver_header_journal = new Image();
   meet_the_driver_header_journal.src = "/images/car_no_7/info_tab_journal.gif";

        var driver_bio = new Image();
      driver_bio.src = "/images/car_no_7/driver_bio.gif";
        
        var driver_bio_over = new Image();
      driver_bio_over.src = "/images/car_no_7/driver_bio_over.gif";     
        
        var driver_bio_b = new Image();
      driver_bio_b.src = "/images/car_no_7/driver_bio.gif"; 
        
        var driver_bio_b_over = new Image();
      driver_bio_b_over.src = "/images/car_no_7/driver_bio_over.gif";   
        
        var driver_bio_c = new Image(); 
      driver_bio_c.src = "/images/car_no_7/driver_bio.gif"; 

        var driver_bio_c_over = new Image(); 
      driver_bio_c_over.src = "/images/car_no_7/driver_bio_over.gif";   

        var track_by_track_stats_b = new Image();
      track_by_track_stats_b.src = "/images/car_no_7/track_by_track_stats.gif";     

        var track_by_track_stats_b_over = new Image();
      track_by_track_stats_b_over.src = "/images/car_no_7/track_by_track_stats_over.gif";       

        var track_by_track_stats_c = new Image();
      track_by_track_stats_c.src = "/images/car_no_7/track_by_track_stats.gif"; 

        var track_by_track_stats_c_over = new Image();
      track_by_track_stats_c_over.src = "/images/car_no_7/track_by_track_stats_over.gif";   
                          
        var journal_b = new Image();
      journal_b.src = "/images/car_no_7/journal.gif";   

        var journal_b_over = new Image();
      journal_b_over.src = "/images/car_no_7/journal_over.gif";

        var journal_c = new Image();
      journal_c.src = "/images/car_no_7/journal.gif";

        var journal_c_over = new Image();
      journal_c_over.src = "/images/car_no_7/journal_over.gif"; 
        
}

  
}

// Begin Popup

function popup(url, xw, xh, name, scroll){

   // SPECIFY THE POPUP WINDOW NAME
   var win_popup_name = name;

   // SPECIFY URL OF MAIN POPUP WINDOW
   var win_popup_url = url;

   // SPECIFY THE WINDOW HEIGHT AND WIDTH
   var win_width = xw;
   var win_height = xh;

   // SPECIFY THE LOCATION OF THE TOP-LEFT CORNER OF THE WINDOW
   var win_left = (screen.width - win_width) / 2;
   var win_top = (screen.height - win_height) / 2;
   var popup_window = window.open(win_popup_url,win_popup_name,'width=' + win_width + ',height=' + win_height + ',top=' + win_top + ',left=' + win_left + ',directories=no,location=no,menubar=no,scrollbars=' + scroll + ',status=no,toolbar=no,resizable=no')
   popup_window.focus();
}

// End Popup

function init(sPage) {

  switch(sPage) {

    case "meet_the_driver":
    document.getElementById('meet_the_driver_journal').style.display = "none";
    document.getElementById('meet_the_driver_stats').style.display = "none";
    break;
    default:
    break;

  }

}

function swap_src(img_a, img_b) {
  if( !document.images ) return;
  document.images[img_a].src = eval(img_b + ".src");
}

function swap_element(element_id, swap_me) {
  if(element_id.src != eval(swap_me + ".src")) { 
    element_id.src = eval(swap_me + ".src"); 
  } else {
  element_id.src = element_id.src;   
  }
}

function ask_larry(container, week) {

var sLarryQuestion = "";

for(i=1;i<5;i++) {
  alt_id = "week_" + i;
  alt_id_a = "week_a_" + i;
  document.getElementById(alt_id).style.textDecoration = "underline";
  document.getElementById(alt_id_a).style.textDecoration = "underline";
  document.getElementById(alt_id).style.color = "#000000";
  document.getElementById(alt_id_a).style.color = "#000000";

  if(i==week) {
  this_id = "week_" + i;
  this_id_a = "week_a_" + i;
  document.getElementById(this_id).style.textDecoration = "none";
  document.getElementById(this_id_a).style.textDecoration = "none";
  document.getElementById(this_id).style.color = "#FB7013";
  document.getElementById(this_id_a).style.color = "#FB7013";
  }
}

switch(week) {

  case 1:
  sLarryQuestion = "<h1>WEEK 1:</h1>\n\n<h2>Q: Bristol and Martinsville are back to back short track races.  Do the crew chiefs set up the cars the same for both tracks?</h2>\n\n<p><img src=\"/images/misc/px.gif\" width=\"400\" height=\"1\" alt=\"\" />- submitted by Dale8fan</p>\n\n<p>A: Hi Dale8fan.  The answer is no.  The tracks may be similar in length at quarter mile but Bristol is steeply banked, more so than even Daytona.  Martinsville is a relatively flat track with not much banking in the corner.  Lap times run four to five seconds faster in Bristol where the cars slam off hard in the corners and crew chiefs fight to keep their suspensions from bottoming out.  In Martinsville, the cars tend to float more in the corners and the crew chiefs can run softer springs in the front.  The gear ratios are a big difference, too, as crew chiefs run about a 6:50 gear at Martinsville and a 5:43 at Bristol.  The one thing that is common to both tracks is that the drivers can be aggressive on the gas in the middle of the corners.  Martinsville should be a great race as tensions spill over from Bristol!</p>\n\n";
  break;

  case 2:
  sLarryQuestion = "<h1>WEEK 2:</h1>\n\n<h2>Hi Larry, I love watching you on the race broadcast!  My question is what do the crew chiefs mean when they talk about positive and negative camber on the cars? </h2>\n\n<p>\n<img src=\"/images/misc/px.gif\" width=\"400\" height=\"1\" alt=\"\" />- Submitted by: TonyRocks\n</p>\n\n<p>\nA: I&#8217;m glad you asked that question because a crew chief uses these terms on a daily basis.  Positive camber means that a tire is tilted outward (away from the engine) at the top and negative camber is just the opposite where the tire is tilted inward.  The teams run camber in a car to get the car to &#8220;bite&#8221; in the corners so when the suspension travels the full footprint of the tires contacts the track.\n</p>\n\n<p>\nMost teams run positive camber (leaning out) on the left front tire and negative camber (leaning in) on the right front for the majority of the tracks on the circuit with the exception of the two road courses that NASCAR runs during the season.  The crew chiefs will run negative camber on both front tires for those road courses.\n</p>\n\n<p>\nThe last thing I want to mention is that crew chiefs run the risk of running too much negative camber on some track and what that does is on the straights the right front tire has very little contact with the track mostly on the inside edge.  That&#8217;s why you see some teams blowing out right front tires on speedways.\n</p>\n\n<p>\nThe last thing I want to mention is that crew chiefs run the risk of running too much negative camber on some track and what that does is on the straights the right front tire has very little contact with the track mostly on the inside edge.  That&#8217;s why you see some teams blowing out right front tires on speedways.\n</p>\n\n<p>\nThanks again for your question and make sure you tune into the Texas race where camber will be a factor.\n</p>\n\n";
  break;

  case 3:
  sLarryQuestion = "<h1>WEEK 3:</h1>\n\n<h2>I hear you talking about aero push at some of the larger tracks. What does that mean and how do crew chiefs tackle that problem? </h2>\n\n<p>\n<img src=\"/images/misc/px.gif\" width=\"400\" height=\"1\" alt=\"\" />- Submitted by: anonymous\n</p>\n\n<p>\nA: What we mean when we say the car picked up an aero push, means racecars at the higher speed tracks depend a lot on front down force to help the car turn through the corners. When the car is somewhat in clean air, it is able to take full advantage of the front down force the car has. When it gets close to the rear of another car, it looses some of the front down force, because the car it is behind is taking the clean air off the nose of the car, therefore the car will not turn as good, and we call that aero push. The only thing a crew chief can do to help this is when you are working with the car in practice, make the car turn more mechanically/chassis wise, than with aero/front down force. The car chassis wise doesn&#8217;t know if it&#8217;s in clean air, or behind or in front of another car:  \n</p>\n\n";
  break;

  case 4:
  sLarryQuestion = "<h1>WEEK 4:</h1><h2>Is the spoiler on the deck lid set at the same angle for every track? Other than at the restrictor plate racetracks (Daytona and Talladega).</h2><p><img src=\"/images/misc/px.gif\" width=\"400\" height=\"1\" alt=\"\" />- Submitted by: anonymous</p><p>A: NASCAR does not mandate the angle of the rear spoiler. But because of how small the rear spoiler is, (4 1/2&#34; tall x 55&#34; wide), teams pretty much every where run it at maximum angle, which is roughly 70 to 75 degrees. For the 2 restrictor plate tracks, they not only mandate the size (6 3/4&#34; tall x 57&#34; wide), they do also enforce a minimum angle of 55 degrees, which they do enforce very closely, knowing every bit of less angle would significantly help the speed of the car (reduce the aero drag).</p>";
  break;

}

document.getElementById(container).innerHTML = sLarryQuestion;

}


function set_focus(section) {

    document.getElementById('meet_the_driver_bio').style.display='none';
    document.getElementById('meet_the_driver_stats').style.display='none';
    document.getElementById('meet_the_driver_journal').style.display='none';

switch(section) {

  case "driver_bio":

    document.getElementById('meet_the_driver_bio').style.display='block';

    break;

  case "track_by_track_stats":

    document.getElementById('meet_the_driver_stats').style.display='block';

  break;

  case "journal":

    document.getElementById('meet_the_driver_journal').style.display='block';

  break;
    
  default:
  break;

}

function showLayer (layer_id) {
var z = 0;
var layer_ids = new Array("meet_the_driver_bio","meet_the_driver_stats","meet_the_driver_journal");

  for (z = 0; z < 3; z ++) {
  //setTimeout("javascript:void(0)",2000);
    if (layer_id == layer_ids[z]) {
    document.getElementById(layer_ids[z]).style.display='block';
    }
    
    else {
    document.getElementById(layer_ids[z]).style.display='none';
    }
  }
}

}

function submit_form(form_id) {
  document.getElementById(form_id).submit();
}