var win = null;
function CenterWindow(page,title,w,h,scrollu,resize){
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scrollu+',resizable='+resize+'';
	win = window.open(page,title,settings);
}

function toggleMenu(object){
	if (document.getElementById(object).style.display == 'block') {
		document.getElementById(object).style.display = 'none';
	} else {
		document.getElementById(object).style.display = 'block';		
	}
}

function showImage(target, imgsrc, txt_target, textToShow) {
	var imgTag = document.getElementById(target);
	imgTag.src = imgsrc;
	
	var txtContainer = document.getElementById(txt_target);
	
	txtContainer.innerHTML = eval(textToShow);
	
}


function slideShow(){
	if (start < totalWork) {
		showImage(start);
		start ++;
		setTimeout("slideShow()", 1250);
	} else {
		start = 0;
	}
}	
	
var scroll = false;

function moveRight(speed){
	var ele = document.getElementById("conteudo-bg");

	if(scroll) {
		ele.scrollLeft = ele.scrollLeft + speed;
		setTimeout("moveRight("+speed+")", 50);
	}
}

function moveLeft(speed) {
	var ele = document.getElementById("conteudo-bg");

	if(scroll) {
		if(ele.scrollLeft > speed - 1) {
			ele.scrollLeft = ele.scrollLeft - speed;
			setTimeout("moveLeft("+speed+")", 50);
		} else {
			ele.scrollLeft = 0;
			scroll = false;
		}
	}
}

var openDiv = null;
var last = '';

function showDiv(object, width, height) {
	//centrar o popup na horizontal
	if(window.innerWidth) {
		document.getElementById(object).style.left = ((window.innerWidth / 2) - (width / 2)) + 'px';
	} else {
		document.getElementById(object).style.left = ((document.body.offsetWidth / 2) - (width / 2)) + 'px';
	}
	
	//centrar o popup na vertical
	if(window.innerHeight) {
		//document.getElementById(object).style.top = ((window.innerHeight / 2) - (height / 2)) + 'px';
		document.getElementById(object).style.top =  height + 'px';
	} else {
		//document.getElementById(object).style.top = ((document.body.offsetHeight / 2) - (height / 2)) + 'px';
		document.getElementById(object).style.top =  height + 'px';
	}
	
	scrollTo(0,0);
	document.getElementById(object).style.display = 'block';
	document.getElementById('overlayDiv').style.display = 'block';
	
	
	openDiv = object;
}

function hideDiv(object) {
	document.getElementById(object).style.display = 'none';
	openDiv = null;
	document.getElementById('overlayDiv').style.display = 'none';
}


function changeImgSource(target, newSource) {
	document.getElementById(target).src = newSource;
}