if (location.href.indexOf('index.php') != -1 || location.href.length == 27) {
	top.location = 'default.php';
}

function insereFlash(filename,name,largura,altura){
			AC_FL_RunContent(
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
			'width', largura,
			'height', altura,
			'src', 'a',
			'quality', 'high',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'align', 'middle',
			'play', 'true',
			'loop', 'true',
			'scale', 'showall',
			'wmode', 'transparent',
			'devicefont', 'false',
			'id', 'a',
			'bgcolor', '#ffffff',
			'name', 'a',
			'menu', 'true',
			'allowScriptAccess','sameDomain',
			'movie', filename,
			'salign', ''
			); //end AC code
	
}

function insereFlashJogos(filename,name,largura,altura){
			AC_FL_RunContent(
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
			'width', largura,
			'height', altura,
			'src', 'a',
			'quality', 'high',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'align', 'middle',
			'play', 'true',
			'loop', 'true',
			'scale', 'showall',
			'devicefont', 'false',
			'id', 'a',
			'bgcolor', '#ffffff',
			'name', 'a',
			'menu', 'true',
			'allowScriptAccess','sameDomain',
			'movie', filename,
			'salign', ''
			); //end AC code
	
}

function limitaTexto(campo,div,tamanho)
{
	campo = document.getElementById(campo)
	div	  = document.getElementById(div)
    quant = tamanho;
    total = campo.value.length;
    if(total <= quant)
    {
        resto = quant - total;
        div.innerHTML = resto;
    }
    else
    {
         campo.value = campo.value.substr(0,quant);
    }
}

function getEstados(uf,obj){
	new Ajax.Request('includes/getEstados.php?uf='+uf, {
			onComplete: function(xhr) {
			document.getElementById(obj).innerHTML = xhr.responseText;
	}});
}
function getCidades(id,uf,obj){
	new Ajax.Request('includes/getCidades.php?uf='+uf+"&id="+id, {
			onComplete: function(xhr) {
			if(xhr.responseText==0){
				document.cadastro.estado.focus();
				alert('Escolha seu estado')
			}else{
				document.getElementById(obj).innerHTML = xhr.responseText;
			}
	}});
}

function showDiv(id){
	document.getElementById('div0').style.display='none';
	document.getElementById('div1').style.display='none';
	document.getElementById('div2').style.display='none';
	document.getElementById('div'+id).style.display='block';
}

function generateLoading() {
	return "<div class='ajaxLoader'><img src='imagens/ajax-loader.gif' width='42' height='42' /></div>";
}

var ingComentarioPg = 0;
var ingQtdItems = 3;
function comentarioExibirPagina(id, direction) {
	if (direction == "next") {
		//if (ingComentarioPg > 0) {
			//ingComentarioPg += pg;
			ingComentarioPg = (ingComentarioPg + ingQtdItems);
		//}
	}
	if (direction == "previous") {
		if (ingComentarioPg > 0) {
			//ingComentarioPg += pg;
			ingComentarioPg = (ingComentarioPg - ingQtdItems);
		}
	}

	document.getElementById("comments-result").innerHTML = generateLoading();
	new Ajax.Request('includes/getComentarios.php?id='+id+'&pg='+ingComentarioPg, {
		onComplete: function(xhr) {
		document.getElementById("comments-result").innerHTML = xhr.responseText;
	}});
}

