// JavaScript Document
//models roll over function	
function Swap(name,over)
	{
		if(window.document.images) 
		{
			if (over){
			//changes the button image
				window.document.images[name].src = "images/" + name + "_over.gif";
			}else{
			//changes the button image
				window.document.images[name].src =  "images/" + name + ".gif";
			}
		}
	}
	
	

//flash object
function thisMovie(movieName) {
        var isIE = navigator.appName.indexOf("Microsoft") != -1;
        return (isIE) ? window[movieName] : document[movieName];
    }
//send info to flash to show car
function makeCallOver(clp) {
        //thisMovie("lexusLine").asFuncOver(clp);
    }
//send info to flash to not show car
function makeCallOut(clp) {
        //thisMovie("lexusLine").asFuncOut(clp);
    }

var classname = 'menuButton';// this will test the class values, it holds the current value, and should correspond to the off state class
var classname1 = 'menuButton';// static value, change this to your class 1 name
var classname2 = 'menuButtonOver';// static value, change this to your class 2 name
var feature = 'single';// sets if only hover element or all changes :: options: 'single' or 'all'

// gets all the elements of that have class classname and returns them as an array
function getElementsByClassName(needle)
{
   var my_array = document.getElementsByTagName("*");
   var retvalue = new Array();
   var i;
   var j;

   for (i=0,j=0;i<my_array.length;i++)
   {
      var c = " " + my_array[i].className + " ";
      if (c.indexOf(" " + needle + " ") != -1) retvalue[j++] = my_array[i];
   }
   return retvalue;
}

// if feature is set to all, this will switch all of the class items
// loops through the classname array and switches them to their opposite values
function toggle()
{
   var divs = getElementsByClassName(classname)
   for(i=0; i <divs.length;i++)
   {
      if(divs[i].className == classname1)
      {
         divs[i].className = classname2;
         classname = classname2;
      }
      else
      {
         divs[i].className = classname1;
         classname = classname1;
      }
   }
}

// for onmouseover
function rollon(e)
{
   var srcId, srcElement, targetElement;
   if (window.event) e = window.event;
   srcElement = ( e.srcElement ) ? e.srcElement : e.target;

   if ( srcElement.className == classname1 )
   {
      if ( feature == 'all' )
      {
         toggle();
      }
      else if ( feature == 'single' )
      {
         srcElement.className = classname2;
         classname = classname2;
      }
   }
}
// for mouseoff
function rolloff(e)
{
   var srcId, srcElement, targetElement;
   if (window.event) e = window.event;
   srcElement = ( e.srcElement ) ? e.srcElement : e.target;

   if ( srcElement.className == classname2 )
   {
      if ( feature == 'all' )
      {
         toggle();
      }
      else if ( feature == 'single' )
      {
         srcElement.className = classname1;
         classname = classname1;
      }
   }
}

// assign rollon() to handle onMouseOver events
document.onmouseover = rollon;

// assign rolloff() to handle onMouseOut events
document.onmouseout = rolloff;

var newwindow = '';
function popWindow(theURL,winname,width,height, winfeatures) {
    x = (640 - width)/2, y = (480 - height)/2;

    if (screen) {
        y = (screen.availHeight - height)/2;
        x = (screen.availWidth - width)/2;
    }
		if(winfeatures.indexOf("maxscreen=yes")==-1){
			winfeatures += ',width='+width+',height='+height;
		}else{
				if(screen.availWidth > width){
					width = screen.availWidth - 10;
					x = 0;
				}
				if(screen.availHeight > height){
					height = screen.availHeight - 10;
					y = 0;
				}
			winfeatures += ',width='+width+',height='+height;
		}
		
   	if(!newwindow.closed && newwindow.location) {
			 newwindow.location.href = theURL;
		}
		else {
			newwindow=window.open(theURL,winname,'screenX='+x+',screenY='+y+',top='+y+',left='+x+',' + winfeatures + ',status=no,resizable=yes');
			if (!newwindow.opener) newwindow.opener = self;
		}
		if (window.focus) {newwindow.focus()}
}


