// JavaScript Document
var seccion_activa;

function centrado_pagina(){
	var hz=window.screen.height;
	if ( hz > 864 ) {
		document.getElementById("capa_general").style.top="50%";
		document.getElementById("capa_general").style.marginTop="-340px";
	 } else {
		document.getElementById("capa_general").style.top="0px";
		document.getElementById("capa_general").style.marginTop="0px";
	 }	
}

//funcion contra el spam
function antispam(cuenta,clase)
{
	var usuario = cuenta;
	var dominio = "grouporganiza.com";
	document.write("<a class='" + clase + "' href=\"mailto:" + usuario + "@" + dominio + "\">" + usuario + "@" + dominio + "</a>");
}
var control = 0;

//funciones para las animaciones
function cargar_texto() {
	$('#capa_informacion_seccion').animate({width: 'toggle'}, {duration: 1000});
}

//aperturas y cierres de paneles
function cargar_info() {
	if (control == 0){$("#capa_masinformacion").show('blind',1000);control = 1;}
}
function cerrar_panel() {
	if (control == 1){$("#capa_masinformacion").hide('blind',1000);control = 0;}
}

function cargar_inves(numero) {
	var num_panel = numero;
	if (num_panel == 1){
		$("#capa_informacion_2").hide();
		$("#capa_informacion_1").show('blind',1000);
		control = 1;
	}
	if (num_panel == 2){
		$("#capa_informacion_1").hide();
		$("#capa_informacion_2").show('blind',1000);
		control = 1;
	}
}
function cerrar_inves(panel) {
	var objeto_cerrar = panel;
	if (control == 1){$("#"+objeto_cerrar).hide('blind',1000);control = 0;}
}

//apertura y cierre de proyectos
function abrir_panel_proyecto() {
	if (control == 0){
		$("#capa_proyecto").fadeIn(250, function(){
			$('#capa_scroll').jScrollPane({scrollbarWidth:5});
			$('#capa_scroll_lateral').jScrollPane({scrollbarWidth:5});
		});
		control = 1;
	}
}

function cerrar_panel_proyecto() {
	if (control == 1){$("#capa_proyecto").fadeOut(250);control = 0;}
}


function cargar_animacion(valor){
	if(valor == 0){
		$('#capa_imagen').fadeIn('slow');
	}	
	else{
		$('#capa_imagen').fadeIn('slow', function() {
			cargar_texto();
		});	
	}
}

function cargar_animacion_legal(valor){
	if(valor == 0){
		$('#capa_imagen').fadeIn(200);
		//$('#capa_imagen').show();
	}	
	else{
		$('#capa_imagen').fadeIn(200, function() {
			$('#capa_scroll').jScrollPane({scrollbarWidth:5});
		});	
	}
}

function cargar_animacion_inicio(valor){
	if(valor == 0){
		$('#capa_imagen').fadeIn('slow');
	}	
	else{
		$('#capa_imagen').fadeIn('slow', function() {
			$('#capa_informacion_seccion_inicio').animate({width: 'toggle'}, {duration: 1000});
		});	
	}
}

function cambiar_imagen_proyectos(imagen){
	document.getElementById("imagen_principal_proyecto").src = imagen;
}


//control del menu
function opcionmenu(idioma){
	switch (idioma) {
		case 'es':
			var secciones=new Array("Equipo","Experiencia","Objetivos","Subvenciones","B&uacute;squeda de financiaci&oacute;n","Project Management","Nuevos Proyectos","Activos","Proyectos en desarrollo");
			break;
		case 'en':
			var secciones=new Array("Team","Experience","Objectives","Grants and incentives","Finance search","Project Management","New projects","Sales Portfolio","Working projects");
			break;
		case 'de':
			var secciones=new Array("Team","Erfahrung","Ziele","Subventionen","Suche nach Finanzierung","Project Management","Neue Projekte","Aktiva","Projekte in der Entwicklungsphase");
			break;
		case 'fr':
			var secciones=new Array("L&rsquo;&Eacute;quipe","Exp&eacute;rience","Objectifs","Subventions","Recherche de financement","Direction du projet","Nouveaux projets","Actifs","Projets en cours de d&eacute;veloppement");
			break;
		default:
		   var secciones=new Array("Equipo","Experiencia","Objetivos","Subvenciones","B&uacute;squeda de financiaci&oacute;n","Project Management","Nuevos Proyectos","Activos","Proyectos en desarrollo");
	} 

	if ((self.location.href == 'http://servidor.grouporganiza/en/') || (self.location.href == 'http://www.grouporganiza.com/en/')||(self.location.href == 'http://servidor.grouporganiza/es/') || (self.location.href == 'http://www.grouporganiza.com/es/')||(self.location.href == 'http://servidor.grouporganiza/fr/') || (self.location.href == 'http://www.grouporganiza.com/fr/')||(self.location.href == 'http://servidor.grouporganiza/de/') || (self.location.href == 'http://www.grouporganiza.com/de/'))
	{
		var marcado='index';
	}
	else
	{	
		var documento = self.location.href.match( /\/([^/]+)$/ )[1];
		var punto = documento.indexOf(".",0);
		var opcion = documento.substring(0,punto);
		var num_boton;
		if ((opcion == 'equipo')||(opcion == 'experiencia')||(opcion == 'objetivos')){
			switch (opcion) {
				case 'equipo':num_boton = 0; break;
				case 'experiencia':num_boton = 1; break;
				case 'objetivos':num_boton = 2; break;
				default:num_boton = 0;
			} 
			var combinacion = ("#botones_1 .boton_"+ (num_boton + 1));
			$(combinacion).css({ color: "#E2A612"});
		    $('#botones_1').toggleClass('active').slideDown();
			$(combinacion).html("<span style='color:#CF9200; font-size:12px; font-family:Arial, Helvetica, sans-serif; font-weight:bold;'>"+ secciones[num_boton] +"</span>");
		}
		if ((opcion == 'subvenciones')||(opcion == 'financiacion')||(opcion == 'project_management')){
			switch (opcion) {
				case 'subvenciones':num_boton = 3; break;
				case 'financiacion':num_boton = 4; break;
				case 'project_management':num_boton = 5; break;
				default:num_boton = 0;
			} 
			var combinacion = ("#botones_2 .boton_"+ (num_boton + 1));
			$(combinacion).css({ color: "#E2A612"});
		    $('#botones_2').toggleClass('active').slideDown();
			$(combinacion).html("<span style='color:#CF9200; font-size:12px; font-family:Arial, Helvetica, sans-serif; font-weight:bold;'>"+ secciones[num_boton] +"</span>");
		}	
		if ((opcion == 'nuevos_proyectos')||(opcion == 'activos')||(opcion == 'acceso_desarrollo')||(opcion == 'desarrollo')||(opcion == 'detalle_proyecto')||(opcion == 'detalle_proyecto_activo')||(opcion == 'detalle_proyecto_desarrollo')){
			switch (opcion) {
				case 'nuevos_proyectos':num_boton = 6; break;
				case 'detalle_proyecto':num_boton = 6; break;
				case 'activos':num_boton = 7; break;
				case 'detalle_proyecto_activo':num_boton = 7; break;
				case 'acceso_desarrollo':num_boton = 8; break;
				case 'desarrollo':num_boton = 8; break;
				case 'detalle_proyecto_desarrollo':num_boton = 8; break;				
				default:num_boton = 0;
			} 
			var combinacion = ("#botones_3 .boton_"+ (num_boton + 1));
			$(combinacion).css({ color: "#E2A612"});
		    $('#botones_3').toggleClass('active').slideDown();
			$(combinacion).html("<span style='color:#CF9200; font-size:12px; font-family:Arial, Helvetica, sans-serif; font-weight:bold;'>"+ secciones[num_boton] +"</span>");
		}
	}
}

//carga de videos de youtube, google video y vimeo
function preparar_videos(){
	$.nyroModalSettings({
		debug: false,
		processHandler: function(settings) {
			var url = settings.url;
			if (url && url.indexOf('http://www.youtube.com/watch?v=') == 0) {
				$.nyroModalSettings({
					type: 'swf',
					height: 400,
					width: 525,
					url: url.replace(new RegExp("watch\\?v=", "i"), 'v/')
				});
			}
			if (url && url.indexOf('http://vimeo.com/') == 0){
				var urlcompleta = new String(url);
				var idvideo = urlcompleta.split(".com/");
				var idvimeo = idvideo[1];
				$.nyroModalSettings({
					type: 'swf',
					url: 'http://vimeo.com/moogaloop.swf?clip_id='+ idvimeo,
					height: 400,
					width: 525
				});
			}
		}
	});
	function preloadImg(image) {
		var img = new Image();
		img.src = image;
	}
	preloadImg('img/ajaxLoader.gif');
	preloadImg('img/prev.gif');
	preloadImg('img/next.gif');
}
