
var T = {};             

var menu_abierto=0;



var pasos=20;
var tiempopaso=20;

/*function menu_abierto(id,idioma) {
	document.getElementById(id).style.display="block";
}*/
function abrir_menu(parent,id,idioma,animar) {
	var paddingrightmenu;

	document.getElementById(id).style.display="block";
	var heightsubmenumax=40;
	switch (idioma) {
		case "es":
			widthmenumin=160;
			widthmenumax=319;
			leftsubmenu=0;
		break;
	}


	if (menu_abierto) {
		animar_abrirmenu(widthmenumin,widthmenumax,heightsubmenumax,0);
		menu_abierto=0;
	} else {
		if (animar==1) {
			animar_abrirmenu(widthmenumin,widthmenumax,heightsubmenumax,1);
		} else {
			document.getElementById("menu_areas").style.width = widthmenumax+"px";
			document.getElementById("submenu_areas").style.height = heightsubmenumax+"px";
			//document.getElementById(id).style.borderTop = "1px solid #450627";
		}
		document.getElementById(id).style.left = leftsubmenu+"px";
		menu_abierto=1;
	}
}
function animar_abrirmenu(widthmin,widthmax,heightmax,abrir) {
	// abrir == { 1 | 0 }
	var varwidth = (widthmax-widthmin)/pasos;
	var varheight = heightmax/pasos;

	for (var i=1; i<=pasos; i++) {
		if (abrir=="1") {
			mi_width=widthmin+(i*varwidth);
			mi_height=i*varheight;
			setTimeout("establecer_width("+mi_width+")", i*tiempopaso);
			setTimeout("establecer_height("+mi_height+")", (i+pasos)*tiempopaso);
		} else {
			mi_width=widthmax-(i*varwidth);
			mi_height=heightmax-(i*varheight);
			setTimeout("establecer_height("+mi_height+")", i*tiempopaso);
			setTimeout("establecer_width("+mi_width+")", (i+pasos)*tiempopaso);
		}
	}
	if (abrir=="0") {
		setTimeout("establecer_height(0)",i*tiempopaso);
	}
}

function establecer_width(w) {
	document.getElementById("menu_areas").style.width = w+"px";
}
function establecer_height(h) {
	if (h=="0") {
		document.getElementById("submenu_areas").style.borderTop = "none";
	} else {
		document.getElementById("submenu_areas").style.borderTop = "1px solid #450627";
	}
	document.getElementById("submenu_areas").style.height = h+"px";
}

function cargar_imagen(num) {
	document.getElementById("fotoampliada").innerHTML="<img src='"+the_theme_uri+"/fotos/"+num+".jpg' />";
	document.getElementById("fotoampliada").style.display="block";
	document.getElementById("mapa").style.visibility="hidden";
	document.getElementById("cerrarfotoampliada").style.visibility="visible";
}
function descargar_imagenes() {
	document.getElementById("fotoampliada").innerHTML="";
	document.getElementById("fotoampliada").style.display="none";
	document.getElementById("mapa").style.visibility="visible";
	document.getElementById("cerrarfotoampliada").style.visibility="hidden";
}

$(document).ready( function() {
	var _fieldset = $("#windownload fieldset").html();
	
	// $("a.filedownload").click(function() {
	// 	$("#windownload fieldset").html( _fieldset );
	// 
	// 	$("#windownload").css({
	// 		'position': 'absolute',
	// 		'top': $(this).position().top - 130, 
	// 		'left': $(this).position().left - 50 
	// 	});
	// 
	// 	var _id = $(this).attr("id");
	// 	var _href = $(this).attr("href");
	// 	_fieldset = $("#windownload fieldset").html();
	// 
	// 	$("#filename").html( $(this).text() );
	// 	$(this).attr("href",'JavaScript:;');
	// 
	// 	$("form[name='cip_download']").submit(function() {
	// 		var _email = encodeURIComponent( $("form[name='cip_download'] input[name='cip_download_email']").attr("value") );
	// 		$.getJSON(
	// 			_href+'/pluginsjson/download/?cip_download_id='+_id+'&email='+_email,
	// 			function(data){
	// 				var _html = '';
	// 				$.each(data.cip_download, function(i,result){
	// 					$("#windownload fieldset").html( _html += '<h1>'+result.title+'</h1>'+ '<p>'+result.content+'</p>' );
	// 					return false;
	// 				});
	// 
	// 				$(this).attr("href", _href );
	// 			}
	// 		);
	// 	});
	// 
	// 	$("#windownload").show("slow");
	// });
	// 
	// $("#windownload_close").click(function() {
	// 	$("#filename").html( '' );
	// 	$("form[name='cip_download'] > input[name='cip_download_id']").attr("value",( 0 ));
	// 
	// 	$("#windownload").fadeOut();
	// });
}); 

function sheetopen(url) {
	var opciones="toolbar=no, location=no, scrollbars=yes, directories=no, status=no, menubar=no, width=744, height=700, top=85, left=140";
	window.open(url,"",opciones);
}

