function portfolioInit() {
	if (!Nav || Nav.section == "portfolio") {
		if ($ && Scroll && $("PrjDescription") && $("Over")) {
			Scroll.build("Over", 10);
			Scroll.build("PrjDescription", 10);
		} else {
			setTimeout(portfolioInit, 100);
		}
	}
}

function flashInit(url) {
	if ($ && Scroll && $("Description") && $("Over")) {
		Nav.useCurrentData = true;
		
		var so = new SWFObject("/web/cabezal.swf", "header", "1000", "515", "8", "#FFFFFF", false);
		so.addParam("wmode", "transparent");
		so.addVariable("section", "portfolio");
		so.write("SwfHeader");
		
		var _cnt = $("Header");
		while (_cnt.childNodes[0] != null) _cnt.removeChild(_cnt.firstChild);
		
		var repositionHeader = function() {
			var pos = Position.cumulativeOffset($("Header"));
			Element.setStyle($("SwfHeader"), { "left": pos[0]-7 + "px", "top" : pos[1] + "px"});
		}
		
		window.onresize = repositionHeader;
		repositionHeader();
	} else {
		setTimeout(flashInit, 100);
	}
}

function show(obj) {
	obj = $(obj);
	obj.className = obj.className.replaceAll("Hidden", "");
}

function hide(obj) {
	Position.prepare();
	
	if (!Position.withinIncludingScrolloffsets(obj, Mouse.x, Mouse.y)) {
		obj = $(obj);
		obj.className += " Hidden";
	}
}

function previous() {
	current--;
	if (current<0) current = 0;
	update();
}

function next() {
	current++;
	if (current >= images.length ) current = images.length - 1;
	update();
}

function update() {
	$("current").innerHTML = ((current+1) < 10 ? "0" : "") + (current+1).toString();
	$("tv_image").src = "/viewers/tv.php?id=" + images[current];
}