/* Locations Functions*/

var old_link_id;
var old_rc;
var current_tab = "mission";

old_rc = "alta_california";
old_link_id = "a_alta_california";

function showRC(name) {
	if(old_link_id) {
		document.getElementById(old_link_id).style.fontWeight = "normal";
		document.getElementById(old_rc).style.display = "none";
	}
	
	var link_id;
	
	link_id = "a_" + name;
	
	document.getElementById(link_id).style.fontWeight = "bold";
	
	old_link_id = link_id;
	old_rc = name;
	name = "#" + name;
    
    $(name).fadeIn("slow");  
}

/* Font-Size Functions */

function fontBig(div) {
	document.getElementById(div).style.fontSize = "125%";
}
function fontSmall(div) {
	document.getElementById(div).style.fontSize = "100%";
}


/* We Include */


function showInfo() {
	$("#top10").fadeIn("slow");
}
        
function closeInfoBox() {
	$("#top10").fadeOut("slow");
}

function showBFacts() {
	document.getElementById("top10").style.display = "none";
	
	$("#bfacts").fadeIn("slow");	
}

function closeBFacts() {
	$("#bfacts").fadeOut("slow");
}

function show_tab(tab) {
	var box_name;
	var old_box_name;
	
	document.getElementById(current_tab).style.backgroundImage = "none";	
	
	document.getElementById(tab).style.backgroundImage = "url(images/we_nav2.jpg)";
	
	box_name = "#" + tab + "_box";
	old_box_name = current_tab + "_box";
	
	document.getElementById(old_box_name).style.display = "none";
	
	$(box_name).fadeIn("slow");
	
	current_tab = tab;
}


/* Contact Form */

var ajaxRequest;  // The variable that makes Ajax possible!

function submitForm() {
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	
	document.getElementById('sub').style.display = "none";
	
	var ajaxDisplay = document.getElementById('status');
	ajaxDisplay.innerHTML = "Sending...";
	
	var doc = document.we_contact;
	
	var url = "send_form.php?name=" + doc.name.value + "&company=" + doc.company.value + "&title=" + doc.title.value + "&address=" + doc.address.value + "&city=" + doc.city.value + "&phone=" + doc.phone.value + "&email=" + doc.email.value + "&comments=" + doc.comments.value;
	
	ajaxRequest.open("GET", url, true);
	ajaxRequest.onreadystatechange = processReqChange;
	ajaxRequest.send(null); 
}

function processReqChange() {
	if(ajaxRequest.readyState == 4){
		//document.myForm.time.value = ajaxRequest.responseText;
		var ajaxDisplay = document.getElementById('status');
		
		if(ajaxRequest.responseText == "OK") {
			ajaxDisplay.innerHTML = "Thank you! Your form has been sent.";
		} else {
			ajaxDisplay.innerHTML = "Sorry -- there was an error!";
		}
	}

}

