var timeout = 0;

function comentar(id){
	getObj('c' + id).style.display = '';
	location.hash = "p" + id;
}
function comentario(id){
	getObj('t' + id).style.display = '';
	location.hash = "p" + id;
}
function fechar(id){
	getObj('c' + id).style.display = 'none';
}
function post(id){
	getObj('g' + id).style.display = '';
	getObj('h' + id).style.display = 'none';
	
}
function fecharX(id){
	getObj('g' + id).style.display = 'none';
	getObj('h' + id).style.display = '';
	
}

function comentarios(id){
	getObj('t' + id).style.display = '';
	getObj('tx' + id).style.display = '';
}
function fecharC(id){
	getObj('t' + id).style.display = 'none';
	getObj('tx' + id).style.display = 'none';
}

function topo(){
	location.hash = "#";
}
function categoria(id){
	if(s==1){
		window.location = '?d=' + dataAtual.join(",") + "&c=" + id;
	}else{
		window.location = "?c=" + id;
	}
}
function enviar(id,div){
	checkCampos(getObj('form' + id),id,div,"closet/comentarios.php");
}
function checkCampos(obj,id,div,url){
	if(obj.nome.value.length < 3){
		alerta(id,"Complete o campo nome.");
		return false;
	}
	var email = obj.email.value;
	if(email.length < 5 || email.indexOf("@") < 1 || email.indexOf("@") != email.lastIndexOf("@") || email.lastIndexOf(".") < email.indexOf("@")){
		alerta(id,"Complete corretamente o campo e-mail.");
		return false;
	}
	if(obj.texto.value.length < 3){
		alerta(id,"Escreva um comentário.");
		return false;
	}
	alerta(id,"Seu comentário está sendo enviado.");
	//obj.submit();
	 ajax_carrega(url,div,createQuery(obj));
}
function alerta(id, txt){
	clearTimeout(timeout);
	getObj('a' + id).innerHTML = txt;
	timeout = setTimeout(function(){
		getObj('a' + id).innerHTML = '&nbsp;';
	},2500);
}

String.prototype.trim = function() {
	return this.replace(/^\s*|\s*$/g,"");
}
String.prototype.replace = function(searchStr,replaceStr){
	return this.split(searchStr).join(replaceStr);
}

var mes = new Array('','Janeiro','Fevereiro','Mar&ccedil;o','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro');

var IE = document.all?true:false;
function include(src){
	script = document.createElement("script");
	script.src = src;
	document.getElementsByTagName("head")[0].appendChild(script);
}
function getObj(o){
	return document.getElementById(o);
}
function newTag(tName){
	return document.createElement(tName);
}

function menuOver(obj){
	obj.className='menuOver';
}
function menuOut(obj){
	obj.className='';
}
function menuClick(obj){
	window.location = obj.getAttribute("link");
}

function flash(arq,w,h,transparent,bgColor,id){
	if(w==undefined){
		w='100%';
	}
	if(h==undefined){
		h='100%';
	}
	if(id == undefined){
		id="flashObj";
	}
	if(transparent==undefined || transparent==true){
		transparent=true;
		t='wmode="transparent"';
	}else{
		t='';
	}
	objeto='<obj'+'ect classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'+w+'" height="'+h+'" id="'+id+'" align="middle">';
	objeto+='<par'+'am name="allowScriptAccess" value="sameDomain" />';
	objeto+='<par'+'am name="movie" value="'+arq+'" />';
	if(bgColor!=undefined){
		objeto+='<par'+'am name="bgcolor" value="'+bgColor+'" />';		
		bgColor=' bgcolor="'+bgColor+'"';
	}else{
		bgColor='';
	}
	objeto+='<par'+'am name="quality" value="high" />';
if(transparent){
	objeto+='<par'+'am name="wmode" value="transparent" />';
}
	objeto+='<par'+'am name="menu" value="false" />';
	objeto+='<emb'+'ed src="'+arq+'" '+t+' '+bgColor+' quality="high" width="'+w+'" height="'+h+'" name="'+id+'" swliveconnect="true" align="middle" allowScriptAccess="sameDomain" menu="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	objeto+='</object>';
	return objeto;
}
function getFlashObj(movieName){
	if (window.document[movieName]){
		return window.document[movieName];
	}
	if (navigator.appName.indexOf("Microsoft Internet")==-1){
		if (document.embeds && document.embeds[movieName]) return document.embeds[movieName]; 
	}else{
		return document.getElementById(movieName);
	}
}
document.getElementsByName = function(someName, someElement, elementsListDel) {
    if(someElement == undefined) someElement = this.childNodes[0];
    if(document.___elementsList == undefined) document.___elementsList = new Array();
    if(someElement.getAttribute('name') == someName) {
        document.___elementsList.push(someElement);
    }
    for(var i = 0; i < someElement.childNodes.length; i++) {
        if(someElement.childNodes[i].nodeType == 1) {
            this.getElementsByName(someName, someElement.childNodes[i],true);
        }
    }
    if(!elementsListDel) {
        var tempList = document.___elementsList;
        document.___elementsList = new Array();
        return tempList;
    }
}
