/***************** Mostrar Menu ****************/
var inter, marg=100, idDiv, menuDo="mos",optMen;
function menu(){
	if(menuDo=="mos"){
		setInter('mos', 'menu', 'menu');
		menuDo="ocul";
	}else{
		setInter('ocul', 'menu', 'menu');
		menuDo="mos";
	}
}

function setInter(act, id, men){
	optMen = men;
	if(optMen=="menu"){
		idDiv = id;
		if(inter){
			clearInterval(inter);
		}
	
		if(act=="mos"){
			inter = setInterval("decrease();",20);
		}else{
			if(marg<100){
				inter = setInterval("increase();",20);
			}
		}
	}else{
		idDivSub = id;
		if(interSub){
			clearInterval(interSub);
		}
	
		if(act=="mos"){
			interSub = setInterval("decrease();",20);
		}else{
			if(margSub<50){
				interSub = setInterval("increase();",20);
			}
		}
	}
}

function decrease(){
	if(optMen=="menu"){
		var div = document.getElementById(idDiv);
		marg-=5;
		div.style.marginTop = "-"+marg+"px";
		if(marg<1){
			clearInterval(inter);
		}
	}else{
		var div = document.getElementById(idDivSub);
		margSub-=5;
		div.style.marginRight= "-"+margSub+"px";
		if(margSub<1){
			clearInterval(interSub);
		}
	}
}

function increase(){
	if(optMen=="menu"){
		var div = document.getElementById(idDiv);
		marg+=5;
		div.style.marginTop = "-"+marg+"px";
		if(marg>99){
			clearInterval(inter);
		}
	}else{
		var div = document.getElementById(idDivSub);
		margSub+=5;
		div.style.marginRight = "-"+margSub+"px";
		if(margSub>119){
			clearInterval(interSub);
		}
	}
}

/*************** Cambiar menu *******************/
var actualOpt="inicio";
function changeMenu(opt){
	if(actualOpt!=opt){
		document.location = "/v2/#"+opt;
		if(opt=="blog" || (opt!="blog" && actualOpt=="blog") || sbmenuDo=="ocul"){
			subMenu();
		}
		actualOpt = opt
		var content = document.getElementById('content');
		if(opt=="cont"){
			content.className = "contacto";
		}else if(opt=="blog"){
			document.getElementById('cats').innerHTML = '<img src="images/loading_cats.gif">';
		}else{
			content.className = "";
		}
		content.innerHTML = "<div class='loading'>Cargando<br><img src='/v2/images/loading.gif' /></div>";
		xajax_changeMenu(opt);
	}
}

/***************** Mostrar SubMenu ****************/
var interSub, margSub=150, idDivSub, sbmenuDo="mos";
function subMenu(){
	if(sbmenuDo=="mos"){
		setInter('mos', 'subMenu', 'sub');
		sbmenuDo="ocul";
	}else{
		setInter('ocul', 'subMenu', 'sub');
		sbmenuDo="mos";
	}
}

/**************** Control Comentario *********************/
function chkComentario(){
	var postear=true;
	var nomb = document.getElementById('nombre');
	var mail = document.getElementById('mail');
	var com = document.getElementById('comentario');
	var nro = document.getElementById('captcha');
	
	if(nomb.value==""){
		alert("Complete el campo: nombre");
		nomb.focus();
		postear = false;
	}else if(mail.value==""){
		alert("Complete el campo: mail");
		mail.focus();
		postear = false;
	}else if(com.value==""){
		alert("Complete el campo: comentario");
		com.focus();
		postear = false;
	}else{
		var capVal = nro.value;
		if(capVal==""){
			alert("Responda la pregunta");
			nro.focus();
			postear = false;
		}else{
			postear = false;
			xajax_controlCap(capVal);
		}
	}
	
	if(postear==true){
		document.comForm.submit();
	}
	
}

function postCom(){
	var divCom = document.getElementById('divForm');
	if(divCom.style.display=="none"){
		divCom.style.display="";
	}else{
		divCom.style.display="none";
	}
}