	var currentProject = 0;
	var totalProjects = 0;
	
	function fillContent(code,id,bg) {
		$("description").innerHTML=code;
		currentProject = id;

		var offset = (currentProject > 100) ? 100 : 0;
		
		if (id > 0 && id < 101) {
			var projects = $("projects").getElementsByTagName("a");
			totalProjects = projects.length;
			for (i=0;i<totalProjects;i++) {
				projects[i].className = "";
			}
			projects[id-1].className = "active";
		} else if (id > 100) {
			var projects = $("motion").getElementsByTagName("a");
			totalProjects = projects.length;
			for (i=0;i<totalProjects;i++) {
				projects[i].className = "";
			}
			projects[id-101].className = "active";
		}
		
		$('bgimg').src = 'images/' + bg;

		if (id > 100) {
			selectMenuItem(2); //select Motion
			$('projects').style.display = 'none';
			$('motion').style.display = '';
			openVideoTransition();
		} else if (id > 0) {
			selectMenuItem(1); //select Design
			$('projects').style.display = '';
			$('motion').style.display = 'none';
			openTransition();
		} else if (id == 0) { // && $('image').style.height == '385px'
			selectMenuItem(0); //select About
			$('projects').style.display = 'none';
			$('motion').style.display = 'none';
			closeTransition();
		}
	}

	function navProject(go) {
		var offset = (currentProject > 100) ? 100 : 0;
		
		currentProject += go;
		if (currentProject <= offset) currentProject = 1 + offset;
		if (currentProject > totalProjects + offset) {
			var menuitems = $("menu").getElementsByTagName("a");
			if (menuitems[0].className == "active") {
				frames["project"].location.href = "design_01_minus.html";
				return;
			} else if (menuitems[1].className == "active") {
				frames["project"].location.href = "motion_01_reel.html";
				return;
			} else {
				//currentProject = totalProjects + offset;
				frames["project"].location.href = "about.html";
				return;
			}
		}

		frames["project"].location.href = ($(((currentProject > 100) ? "motion" : "projects")).getElementsByTagName("a")[currentProject-offset-1].href);
		return false;
	}

	var fx = undefined;

	function openTransition() {
		try { fx.stop(); } catch(exp) { }
		//alert('open');
		fx = new Fx.Style('image', 'height', {duration:2000, transition: Fx.Transitions.Quart.easeOut});
		fx.start(385);
	}

	function openVideoTransition() {
		try { fx.stop(); } catch(exp) { }
		//alert('video');
		fx = new Fx.Style('image', 'height', {duration:2000, transition: Fx.Transitions.Quart.easeOut});
		fx.start(506);
	}

	function closeTransition() {
		try { fx.stop(); } catch(exp) { }
		//alert('close');
		fx = new Fx.Style('image', 'height', {duration:2000, transition: Fx.Transitions.Quart.easeOut});
		fx.start(0);
	}
	
	function selectMenuItem(id) {
		var menuitems = $("menu").getElementsByTagName("a");
		for (i=0;i< menuitems.length;i++) {
			menuitems[i].className = "";
		}
		menuitems[id].className = "active";
	}

	function centerIE() {
		//vertically center for IE
		document.getElementById('content').innerHTML = "<table height='100%'><tr><td valign='middle'>" + $('inside').innerHTML + "</td></tr></table>";
	}
	
	window.addEvent('domready', function() {
		$('image').style.height = '0px';
		$('projects').style.display = 'none';
		$('motion').style.display = 'none';

		if (location.href.indexOf('?page=') > -1) {
			frames["project"].location.href = location.href.split('?page=')[1] + ".html";
		}
	});