/*
+--------------------------------------------------------------------------
| Get element by id
+--------------------------------------------------------------------------
*/

	function getbyid(id)
	{
		itm = null;
	
		if (document.getElementById)
		{
			itm = document.getElementById(id);
		}
		else if (document.all)
		{
			itm = document.all[id];
		}
		else if (document.layers)
		{
			itm = document.layers[id];
		}
	
		return itm;
	}

//Main Nav

function Browser() {

  var ua, s, i;

  this.isIE    = false;  // Internet Explorer
  this.isNS    = false;  // Netscape
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

var browser = new Browser();

function removeClassName(el, name) {

  var i, curList, newList;

  if (el.className == null)
    return;

  // Remove the given class name from the element's className property.

  newList = new Array();
  curList = el.className.split(" ");
  for (i = 0; i < curList.length; i++)
    if (curList[i] != name)
      newList.push(curList[i]);
  el.className = newList.join(" ");
}

var activeButton = null;

function nav(event, which, id, id2) {

  var button;

  // Get the target button element.

  if (browser.isIE)
    button = window.event.srcElement;
  else
    button = event.currentTarget;
	
  // Blur focus from the link to remove that annoying outline.
	button_id = button.getAttribute("id")
	button.blur();

  // Reset the currently active button, if any.

  if (activeButton != null)
    resetButton(activeButton, button_id);

  // Activate this button, unless it was the currently active one

  if (button_id != activeButton) {
    depressButton(button, button_id);
    activeButton = button_id;
	if (id != '') toggleview(id);
	hide(getbyid(id2));
  }
  
  else {
	if (id != '') toggleview(id);
	hide(getbyid(id2));
    activeButton = null;
  }

	

  return false;
}

function depressButton3(button) {
button.className += "active";
}

function depressButton(button, button_id) {
	getbyid(button_id + 'b').className = "huh";
}

function resetButton(button_id) {
	getbyid(button_id + 'b').className = null;
}

function resetSub(button) {
  getbyid('subnav').innerHTML = "";
}





//==========================================
// Hide / Unhide menu elements
//==========================================

function showhide(id1, id2)
{

}
	


function toggleview(id)
{
	if ( ! id ) return;
	
	if ( itm = getbyid(id) )
	{
		if (itm.style.display == "none")
		{
			show(itm);
		}
		else
		{
			hide(itm);
		}
	}
}

//==========================================
// Set DIV ID to hide
//==========================================

function hide(itm)
{
	if ( ! itm ) return;
	
	itm.style.display = "none";
}

//==========================================
// Set DIV ID to show
//==========================================

function show(itm)
{
	if ( ! itm ) return;
	
	itm.style.display = "block";
}




/*-------------------------------------------------------------------------*/
// Get cookie
/*-------------------------------------------------------------------------*/

function getcookie( name )
{
	cname = name + '=';
	cpos  = document.cookie.indexOf( cname );
	
	if ( cpos != -1 )
	{
		cstart = cpos + cname.length;
		cend   = document.cookie.indexOf(";", cstart);
		
		if (cend == -1)
		{
			cend = document.cookie.length;
		}
		
		return unescape( document.cookie.substring(cstart, cend) );
	}
	
	return null;
}

/*-------------------------------------------------------------------------*/
// Set cookie
/*-------------------------------------------------------------------------*/

function setcookie( name, value, sticky )
{
	expire = "";
	
	if ( sticky )
	{
		expire = "; expires=Wed, 1 Jan 2020 00:00:00 GMT";
	}
	
	document.cookie = name + "=" + value + "; path=" + "/" + expire + ';';

}


function remember_email()
{
	if( (getbyid('emailadd').value != "") &&  (getbyid('remember').checked == true) )
	{
		
		email_addy = getbyid('emailadd').value;

		setcookie('2kemail', email_addy, 1);

	}
	

}


function remember_contact()
{
	setcookie( "contact_name", getbyid('name').value, 1 );
	setcookie( "contact_email", getbyid('email').value, 1 );
	setcookie( "contact_phone", getbyid('phone').value, 1 );
	setcookie( "contact_os", getbyid('os').value, 1 );
}