function changePage(page) {
  if (window.XMLHttpRequest) { // Mozilla, Safari,...
    http_request = new XMLHttpRequest();
  } else if (window.ActiveXObject) { // IE
    try {
      http_request = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        http_request = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {}
    }
  }
  if (!http_request) {
    alert('Cannot create XMLHTTP instance');
    return false;
  }
  url = "/ajax.php";
  parameters = "page=" + page;
  http_request.onreadystatechange = alertContents;
  http_request.open('POST', url, true);http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");http_request.setRequestHeader("Content-length", parameters.length);http_request.setRequestHeader("Connection", "close");http_request.send(parameters);
  
  switch (page) {
  	case 'main':
  		document.getElementById('nav').style.background = 'transparent url(images/nav.gif) no-repeat scroll 0 0';
  		break;
  	case 'about':
  		document.getElementById('nav').style.background = 'transparent url(images/nav.gif) no-repeat scroll 0 -25px';
  		break;
  	case 'application':
  		document.getElementById('nav').style.background = 'transparent url(images/nav.gif) no-repeat scroll 0 -50px';
  		break;
  	case 'ventures':
  		document.getElementById('nav').style.background = 'transparent url(images/nav.gif) no-repeat scroll 0 -75px';
  		break;
  	case 'contact':
  		document.getElementById('nav').style.background = 'transparent url(images/nav.gif) no-repeat scroll 0 -100px';
  		break;
  }
}

function alertContents() {
  if (http_request.readyState == 4) {
    if (http_request.status == 200) {
      result = http_request.responseText; 
      if (result.match('<script>')) {
	      script = result.split('<script>');
	      script = script[1].split('</script>');
	      eval(script[0]);
	}
      document.getElementById('tab').innerHTML = result;
    } else {
      alert('There was a problem with the request.');
    }
  }
}

var textInput = {
	'name' : 'Name',
	'company' : 'Company',
	'email' : 'Email',
	'message' : 'Message'
}

var colors = {
	'normal' : '#000000',
	'error' : '#ff0000'
}

function checkValue (el, text) { if (el.value == textInput[text]) el.value = ''; else if (el.value == "") el.value = textInput[text]; }
function checkValColor (el, text) { if (el.value != textInput[text]) el.style.color = colors['normal']; }
function checkForm (form) { error = 0; for (x in textInput) { if (textInput[x] == form[x].value && x != 'company') { form[x].style.color = colors['error']; error = 1; } else form[x].style.color = colors['normal'];} if (error == 1) return false; 
$.post('/email.php', {'name':form.name.value,'company':form.company.value,'email':form.email.value,'message':form.message.value,'key':'4da036f77eabc0a6d2165f83669116f1'},
function (data) {
	if (data.emailed == 'yes')
		$(".sent").attr('innerHTML','Message Sent Successfully');
	else
		$(".sent").attr('innerHTML','Error While Sending Message');
	$(".sent").toggle().fadeIn("slow");
},
 "json"); return false;}
function clearForm (form) {for (x in textInput){form[x].value = textInput[x];}}

function changeVenture (id) {
	document.getElementById('vent'+cur_venture).style.display = 'none';
	document.getElementById('vent'+id).style.display = 'block';
	cur_venture = id;
}
