function rip(ImgOpt) {
	document.getElementById(ImgOpt).src = urlToStart+'images/l_plate_rip.gif';
}
function lplate(ImgOpt) {
	document.getElementById(ImgOpt).src = urlToStart+'images/l_plate.gif';
}
function go() {
     list.push(list.shift());
     setTimeout("fixit()", 1);
}

function fixit() {
     var more=false;
	     i=0;
	     
           var row = list[i];
           var X = 0-568;
           if (row.x != X)
           {
	             if ((row.x-X) > 250) MinusVal = 2;
	             else MinusVal = 1;
                 more = true;
                 if (row.x > X) { row.x=row.x-MinusVal; row.el.style.left = row.x.toString(10); }
                 else { ++row.x; row.el.style.left = row.x.toString(10); }
           }

     if (more) setTimeout("fixit()", 15);
	 else {
		 $("#hdbt").removeClass("road");
		 $("#hdbt").addClass("noRoad");
		 $("#cars").removeClass("noCars");
		 $("#cars").addClass("cars");
		 $("#body").css("overflow","auto");
	 }
}

// Change Frame
function ChangeFrame(frameName,url) {

  if (top.frames[frameName]) {
	var x = ''; //WEB_HOME; //"??";
	var tt = '['+top.frames[frameName].location+']';
	if (tt != '[]') {
	   var test = top.frames[frameName].location.href;
   	   test = test.replace(x,"");
    } else {
	   var test = "[]";
	}
	
	if (test != url || test == "[]") {
	  top.frames[frameName].location.href = url;
    }
  }
  return;
}

function adjustHeight() {
   tmpHeight = $("#content").height() + 20;
   if (tmpHeight < 400) {
     $("#content").css("height","400px" );
   }
   $("#content").fadeOut();
   $("#content").fadeIn();
   //alert('tmpHeight='+tmpHeight);
}

function getContent(inItem) {
   var openUrl = inItem.attr('reqPage');
   //$('#content').
   $('#content').load(openUrl,adjustHeight())
}

function menuHover(inItem) {
   try  {
      var ImgOpt = 'opt_'+inItem.attr('mId');
      document.getElementById(ImgOpt).src = urlToStart+'images/l_plate_rip.gif';
   } catch(err) {}
}

function menuOut(inItem) {
   try  {
      var ImgOpt = 'opt_'+inItem.attr('mId');
      document.getElementById(ImgOpt).src = urlToStart+'images/l_plate.gif';
   } catch(err) {}
}

$(document).ready(function() {
        if (urlPage == "home") {
           go();
        } else {
           $("#hdbt").removeClass("road");
           $("#hdbt").addClass("noRoad");
           $("#cars").removeClass("noCars");
           $("#cars").addClass("cars");
           $("#body").css("overflow","auto");
        }
	adjustHeight();
	$(".mLink").each(function(i) {
     var tmpHref = $(this).attr('href')
     if (tmpHref == "index.php") tmpHref = "home.php";
     $(this).attr('reqPage',tmpHref);
	  var tmpHref = urlToStart+"index.php?page="+$(this).attr('href').replace('.php','');
     $(this).attr('href',tmpHref);
   });
   
	//$(".mLink").click(function() {
     //getContent($(this));
     //return false;
   //});
   
   $(".mLink").hover(function(){
     menuHover($(this));
   },function(){
     menuOut($(this));
   });

});

function headline_rotate() {
  clearInterval(headline_interval);
  current_headline = (old_headline + 1) % headline_count; //remainder will always equal old_headline until it reaches headline_count - at which point it becomes zero. clock arithmetic
  $("div.headline:eq(" + old_headline + ")").animate({top: -205},"slow", function() {
    $(this).css('top','210px');
    });
  $("div.headline:eq(" + current_headline + ")").show().animate({top: 0},3000);  
  old_headline = current_headline;
  
  var timeWait = $("div.headline:eq("+current_headline+")").attr("time") *1 + 3000;
  if (timeWait < 3500) timeWait = 10;
 
  headline_interval = setInterval(headline_rotate, timeWait); //time in milliseconds
}
