if (document.images){
	var image1 = new Image();
	var image2 = new Image();
	var image3 = new Image();
	var image4 = new Image();
	var image5 = new Image();
	
	image1.src="images/navbar/home_alt.png";
	image2.src="images/navbar/about_alt.png";
	image3.src="images/navbar/services_alt.png";
	image4.src="images/navbar/portfolio_alt.png";
	image5.src="images/navbar/contact_alt.png";
}

function switchOn(grab){
	var theSplit = grab.split('_');
	var isReal = theSplit[1];
	if(isReal != 'alt'){
		document[grab].src = 'images/navbar/'+grab+'_alt.png';
	}
}

function switchOff(grab){
	var theSplit = grab.split('_');
	var isReal = theSplit[1];
	if(isReal != 'alt'){
		document[grab].src = 'images/navbar/'+grab+'.png';
	}
}

var a = 'new';

function grabPortfolio(grab, from){
	//alert(grab);
	
	if(a == 'new'){
		document.getElementById('Nav_'+from).onmouseover = function() {this.style.backgroundColor = '#4d5c6b'};
		document.getElementById('Nav_'+from).onmouseout = function() {this.style.backgroundColor = '#6d6d6d'};
		//document.getElementById('Nav_'+from).onclick = function () {grabPortfolio(from,grab)};
		document.getElementById('Nav_'+from).style.backgroundColor = '#6d6d6d';
		
		document.getElementById('Nav_'+grab).onmouseover = function() {};
		document.getElementById('Nav_'+grab).onmouseout = function() {};
		//document.getElementById('Nav_'+grab).onclick = function() {};
		document.getElementById('Nav_'+grab).style.backgroundColor = '#2f2f2f';
		
		d = grab;
		a = 'old';
		
		
	}else{

		document.getElementById('Nav_'+d).onmouseover = function() {this.style.backgroundColor = '#4d5c6b'};
		document.getElementById('Nav_'+d).onmouseout = function() {this.style.backgroundColor = '#6d6d6d'};
		//document.getElementById('Nav_'+d).onclick = function () {grabPortfolio(d,grab)};
		document.getElementById('Nav_'+d).style.backgroundColor = '#6d6d6d';
		
		document.getElementById('Nav_'+grab).onmouseover = function() {};
		document.getElementById('Nav_'+grab).onmouseout = function() {};
		//document.getElementById('Nav_'+grab).onclick = function() {};
		document.getElementById('Nav_'+grab).style.backgroundColor = '#2f2f2f';
		
		d = grab;

		
	}
		
	document.mainpic.src = './?page=images&ID='+grab;
	
	ajaxRequest = '';
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	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;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var $Given = ajaxRequest.responseText;
			
			var theSplit = $Given.split('&&&');
			var theName = theSplit[0];
			var theSite = theSplit[1];
			var theInfo = theSplit[2];
			
			document.getElementById('mainname').innerHTML = theName;
			document.getElementById('inner_h1').innerHTML = theName;
			document.getElementById('maininfo').innerHTML = '<p>'+theInfo+'</p>';
			
			document.getElementById('hover').onclick = function() {window.location.href = 'http://www.'+theSite};
			document.getElementById('inner_shadow').onclick = function() {window.location.href = 'http://www.'+theSite};
			document.getElementById('mainlink').href = 'http://www.'+theSite;
			document.getElementById('mainname').href = 'http://www.'+theSite;

		}
	}
	
	var url = "php/update.php";
	var params = 'sent='+grab;
	ajaxRequest.open("POST", url, true);
	
	//Send the proper header information along with the request
	ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequest.setRequestHeader("Content-length", params.length);
	ajaxRequest.setRequestHeader("Connection", "close");

	ajaxRequest.send(params);
}

//whole credits are devoted to orignal author
//
//Use: Call function goto_top()
var goto_top_type = -1;
var goto_top_itv = 0;

function goto_top_timer() {
var y = goto_top_type == 1 ? document.documentElement.scrollTop : document.body.scrollTop;
//alert(y);
var moveby = 15; // set this to control scroll seed. minimum is fast

y -= Math.ceil(y * moveby / 100);
if (y < 0)
y = 0;

if (goto_top_type == 1)
document.documentElement.scrollTop = y;
else
document.body.scrollTop = y;

if (y == 0) {
clearInterval(goto_top_itv);
goto_top_itv = 0;
}
}

function goto_top() {
if (goto_top_itv == 0) {
if (document.documentElement && document.documentElement.scrollTop)
goto_top_type = 1;
else if (document.body && document.body.scrollTop)
goto_top_type = 2;
else
goto_top_type = 0;

if (goto_top_type > 0)
goto_top_itv = setInterval('goto_top_timer()', 25);
}
}