/* <![CDATA[ */

var ttSlider;
var slideDuration = 500;
//var curcont = 'content0';
function divSwitch(id) {
	
	// brand summary boxes on front page
	document.getElementById('div1').style.display = 'none';
	document.getElementById('div2').style.display = 'none';
	document.getElementById('div3').style.display = 'none';
	document.getElementById('div4').style.display = 'none';
	document.getElementById('div5').style.display = 'none';

	// model slideouts for different brands
	document.getElementById('iv1').style.display = 'none';
	document.getElementById('iv2').style.display = 'none';
	document.getElementById('iv3').style.display = 'none';
	document.getElementById('iv4').style.display = 'none';
	document.getElementById('iv5').style.display = 'none';
	
	document.getElementById(id).style.display = 'block';
	document.getElementById( id.substr(1,3) ).style.display = 'block';
}
window.onload = function() {

	ttSlider = new Fx.Slide($('modelContent'), {duration: slideDuration,wait: false});
	
	$('tabTT').addEvent( 'mouseover', function() { toggleTT(); });
	if($('flash')) $('flash').addEvent( 'mouseover', function() { hideTabContent(); });
	$('innerContent').addEvent( 'mouseover', function() { hideTabContent(); });
	//$('content').addEvent( 'mouseover', function() { hideTabContent(); });
	//$('modelContent').addEvent( 'mouseout', function () { hideTabContent(); });
	$('wellslogo').addEvent( 'mouseover', function() { hideTabContent(); });
	//$('modelIcons').addEvent( 'mouseover', function() { hideTabContent(); });

	hideTabContent();
}
function toggleTT() {
	hideTabContent();
	toggleSlidebox();
	var tabcontent = document.getElementById('modelContent');
	if(tabcontent.getStyle('display') == 'none') tabcontent.style.display = 'block';
	ttSlider.toggle();
}

function toggleSlidebox() {
	if($('slideBox').style.display == 'none') $('slideBox').style.display = 'block';
	
	// iframe is for linux only
	if ( ( $('linuxiframe') ) && ( $('linuxiframe').style.display == 'none' ) ) $('linuxiframe').style.display = 'block';
}

function hideTabContent() {
	$('slideBox').style.display = 'none';
	
	// iframe is for linux only
	if ( $('linuxiframe') ) $('linuxiframe').style.display = 'none';

	ttSlider.hide();
	ttSlider.clearTimer();
}
function jump(fe){
	var opt_key = fe.selectedIndex;
	var uri_val = fe.options[opt_key].value;
	window.open(uri_val,'_top');
	return true;
}

function SetContent(curcont) {
	if (document.getElementById(curcont)) {
		curdiv = document.getElementById(curcont);
		curdiv.style.display = 'block';
	}
	return;
}

function SwitchContent(curcont, choice) {
	curdiv = document.getElementById(curcont);
	curdiv.style.display = 'none';
	newdiv = document.getElementById(choice);
	newdiv.style.display = 'block';
	curcont = choice;
	return;
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function loadFlash() {
	if($('flash')) {
		var flashdiv = document.getElementById('flash');
		flashdiv.innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="748" height="456" id="home" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="media/flash/home.swf" /><param name="wmode" value="transparent"><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="media/flash/home.swf" quality="high" wmode="transparent" bgcolor="#ffffff" width="748" height="456" name="home" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
	}
}

addLoadEvent(loadFlash);

/* ]]> */

function getkey(e)
{
if (window.event)
   return window.event.keyCode;
else if (e)
   return e.which;
else
   return null;
}

function goodchars(e, goods)
{
var key, keychar;
key = getkey(e);
if (key == null) return true;

// get character
keychar = String.fromCharCode(key);
keychar = keychar.toLowerCase();
goods = goods.toLowerCase();

// check goodkeys
if (goods.indexOf(keychar) != -1)
        return true;

// control keys
if ( key==null || key==0 || key==8 || key==9 || key==13 || key==27 )
   return true;

// else return false
return false;
}

