function portfolio(website) {
	var portfolio = document.getElementsByName("portfolio");
	for(x=0;x<portfolio.length;x=x+1) {
		portfolio[x].style.display="none";
	}
	document.getElementById(website).style.display="";
}
function highlight(activeLink) {
	document.getElementById("body").className=activeLink;
}

function init() {
	document.getElementById("p1").style.top=0+"px";
	document.getElementById("nav").style.display="block";
}

function animate(content) {
	if(content=="p2") {
		animateX(0,'work');
	}
	if(content=="p3") {
		animateX(0,'news');
	}
	for (x=1;x<5;x=x+1) {
		div = "p"+parseInt(x);
		if(document.getElementById(div).offsetTop==0) {
			exit = new Tween(document.getElementById(div).style,'top',Tween.strongEaseIn,0,-1000,0.65,'px');
			exit.onMotionFinished = function(){entrance = new Tween(document.getElementById(content).style,'top',Tween.strongEaseOut,1000,0,0.65,'px');entrance.start();};
			exit.start();
		}
	}
}

function animateX(content,page) {
	if(page=="work"){var loop=7;}
	if(page=="news"){var loop=6;}
	var newContent = page+content;
	loopNumber = document.getElementsByName(page+"Item");
	for (x=0;x<loop;x=x+1) {
		div = page+parseInt(x);
		if(document.getElementById(div).offsetLeft==0) {
			exit = new Tween(document.getElementById(div).style,'left',Tween.strongEaseIn,0,-500,0.4,'px');
			exit.onMotionFinished = function(){entrance = new Tween(document.getElementById(newContent).style,'left',Tween.strongEaseOut,500,0,0.4,'px');entrance.start();};
			exit.start();
		}
	}
}

function animateXReverse(content,page) {
	if(page=="work"){var loop=7;}
	if(page=="news"){var loop=6;}	
	var newContent = page+content;
	loopNumber = document.getElementsByName(page+"Item")
	for (x=0;x<loop;x=x+1) {
		div = page+parseInt(x);
		if(document.getElementById(div).offsetLeft==0) {
			exit = new Tween(document.getElementById(div).style,'left',Tween.strongEaseIn,0,500,0.4,'px');
			exit.onMotionFinished = function(){entrance = new Tween(document.getElementById(newContent).style,'left',Tween.strongEaseOut,-500,0,0.4,'px');entrance.start();};
			exit.start();
		}
	}
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function validation() {

	var emailField = document.getElementById("email").value;
	var commentsField = document.getElementById("comments").value;
	if (!emailField) {
		alert("Please enter an email address");
		return false;
	}else if(!commentsField){
		alert("Please enter a comment");
		return false;
	}else{
		return true;
	}			
}
