// Menu - This basically just goes in and attaches all the sexy ajax
//        to the main menu links, that way if someone without javascript
//		  visits the site, they don't get stupid errors and a dumb looking site!
$(function(){
	// Attach logic to all links
	$("#navMenu a").click(function(e){
		// Prevent link from redirecting page
		e.preventDefault();
		// Load next page into #contentDiv
		$("#contentDiv").html("").load($(this).attr("href"));
	});
});


function loadXMLDoc(passvar) {
	if (window.XMLHttpRequest)
	{	// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else
	{	// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			document.getElementById("contentDiv").innerHTML=xmlhttp.responseText;
		}
	}
	xmlhttp.open("GET",passvar,true);
	xmlhttp.send();
}


function PopThatShitSon(passvar) {
	if (passvar != "" ) {
		document.write(passvar);
	}
}

function popLock(theURL,windowname,horz,vert,resizeMe) {
	if (resizeMe == null) { resizeMe = 1; }
	hCent	= (screen.availWidth / 2) - (horz / 2);
	vCent = (screen.availHeight / 2) - (vert / 2);
	window.open(theURL, windowname,'toolbar=0,location=0,directories=0,status=no,left=' + hCent + ',top=' + vCent + ',menubar=0,scrollbars=no,resizable=' + resizeMe + ',width=' + horz + ',height=' + vert );
}

function ajax(theCall,theDiv) {
		var xhr;
		if (window.XMLHttpRequest) { // non-IE
				xhr = new XMLHttpRequest();
		} else if (window.ActiveXObject) { // IE
				xhr = new ActiveXObject("Microsoft.XMLHTTP");
		}
		//assign a handler for the response
		xhr.onreadystatechange = function() {
		 if(xhr.readyState == 4){
	 if(xhr.status  == 200) 
		document.getElementById(theDiv).innerHTML = xhr.responseText;
	 else 
		alert('Cannot contact server: ' + theCall);
		 }
		}
		// open page
		xhr.open('GET', theCall, true);
		xhr.send(null);
}

function swapLinks(theLink,theDiv){
	document.getElementById('about').className = "nav";
	document.getElementById('aboutDiv').className = "hide";
	document.getElementById('contact').className = "nav";
	document.getElementById('contactDiv').className = "hide";
	document.getElementById('projects').className = "nav";
	document.getElementById('projectsDiv').className = "hide";
	document.getElementById('shack').className = "nav";
	document.getElementById('shackDiv').className = "hide";
	document.getElementById('signupDiv').className = "hide";
	document.getElementById(theLink).className = "navActive";
	document.getElementById(theDiv).className = "show";
}



