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(index, total) {
	var imgTag = document.getElementById('imgFile');
	if (index > (total-1)) {
		index = 0
	} else if (index < 0){
		index = total-1;
	}
	
	imgTag.src = img[index].src;
	
	lastWork = index;
	nextIndex = index+1;
	document.getElementById('currentImage').innerHTML = nextIndex;
	
	
}

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 showProductCategory(product) {
	document.getElementById('productBK_'+product).style.display = 'block';
	document.getElementById('productTitle_'+product).style.display = 'block';
}

function hideProductCategory(product) {
	document.getElementById('productBK_'+product).style.display = 'none';
	document.getElementById('productTitle_'+product).style.display = 'none';
}


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';
	} else {
		document.getElementById(object).style.top = ((document.body.offsetHeight / 2) - (height / 2)) + 'px';
	}
	
	document.getElementById(object).style.display = 'block';
	
	openDiv = object;
}

function hideDiv(object) {
	document.getElementById(object).style.display = 'none';
	openDiv = null;
}

