// JavaScript Document
var box = {};
var box1 = {};
var box2 = {};

var tamano = 12;
var classname1 = '';
var classname2 = '';


window.addEvent('domready', function() {

	//myCal = new Calendar({ date1: 'Y-m-d' }, { navigation: 2});
				
	if(document.getElementById("itemJardin1") != null)
	{
		//1	
		$('itemJardin1').addEvent('mouseover', function(e) {
			
			RollOver(e, 'itemJardin1', '.tex_button2');
		});
			
		$('itemJardin1').addEvent('mouseout', function(e) {
			RollOut(e, 'itemJardin1', '.tex_button');
		});
		
		//2	
		$('itemJardin2').addEvent('mouseover', function(e) {
			
			RollOver(e, 'itemJardin2', '.tex_button2');
		});
			
		$('itemJardin2').addEvent('mouseout', function(e) {
			RollOut(e, 'itemJardin2', '.tex_button');
		});
		
		//3	
		$('itemJardin3').addEvent('mouseover', function(e) {
			
			RollOver(e, 'itemJardin3', '.tex_button2');
		});
			
		$('itemJardin3').addEvent('mouseout', function(e) {
			RollOut(e, 'itemJardin3', '.tex_button');
		});
		
		//4	
		$('itemJardin4').addEvent('mouseover', function(e) {
			
			RollOver(e, 'itemJardin4', '.tex_button2');
		});
			
		$('itemJardin4').addEvent('mouseout', function(e) {
			RollOut(e, 'itemJardin4', '.tex_button');
		});
		
		//5	
		$('itemJardin5').addEvent('mouseover', function(e) {
			
			RollOver(e, 'itemJardin5', '.tex_button2');
		});
			
		$('itemJardin5').addEvent('mouseout', function(e) {
			RollOut(e, 'itemJardin5', '.tex_button');
		});
		
		//6	
		$('itemJardin6').addEvent('mouseover', function(e) {
			
			RollOver(e, 'itemJardin6', '.tex_button2');
		});
			
		$('itemJardin6').addEvent('mouseout', function(e) {
			RollOut(e, 'itemJardin6', '.tex_button');
		});
		
		if(document.getElementById("itemJardin8") != null)
		{
			//7	
			$('itemJardin7').addEvent('mouseover', function(e) {
				
				RollOver(e, 'itemJardin7', '.tex_button2');
			});
				
			$('itemJardin7').addEvent('mouseout', function(e) {
				RollOut(e, 'itemJardin7', '.tex_button');
			});
		}
		
		if(document.getElementById("itemJardin8") != null)
		{
			//8
			$('itemJardin8').addEvent('mouseover', function(e) {
				
				RollOver(e, 'itemJardin8', '.tex_button2');
			});
				
			$('itemJardin8').addEvent('mouseout', function(e) {
				RollOut(e, 'itemJardin8', '.tex_button');
			});
		}
		
		//-------------------------Servicios------------------------
		//1	
		$('itemServicios1').addEvent('mouseover', function(e) {
			
			RollOver(e, 'itemServicios1', '.tex_button3');
		});
			
		$('itemServicios1').addEvent('mouseout', function(e) {
			RollOut(e, 'itemServicios1', '.tex_button');
		});
		
		//2	
		$('itemServicios2').addEvent('mouseover', function(e) {
			
			RollOver(e, 'itemServicios2', '.tex_button4');
		});
			
		$('itemServicios2').addEvent('mouseout', function(e) {
			RollOut(e, 'itemServicios2', '.tex_button');
		});
		
		//3	
		$('itemServicios3').addEvent('mouseover', function(e) {
			
			RollOver(e, 'itemServicios3', '.tex_button5');
		});
			
		$('itemServicios3').addEvent('mouseout', function(e) {
			RollOut(e, 'itemServicios3', '.tex_button');
		});
		
		//4	
		$('itemServicios4').addEvent('mouseover', function(e) {
			
			RollOver(e, 'itemServicios4', '.tex_button6');
		});
			
		$('itemServicios4').addEvent('mouseout', function(e) {
			RollOut(e, 'itemServicios4', '.tex_button');
		});
		
		//5	
		$('itemServicios5').addEvent('mouseover', function(e) {
			
			RollOver(e, 'itemServicios5', '.tex_button7');
		});
			
		$('itemServicios5').addEvent('mouseout', function(e) {
			RollOut(e, 'itemServicios5', '.tex_button');
		});
		
		//6	
		$('itemServicios6').addEvent('mouseover', function(e) {
			
			RollOver(e, 'itemServicios6', '.tex_button8');
		});
			
		$('itemServicios6').addEvent('mouseout', function(e) {
			RollOut(e, 'itemServicios6', '.tex_button');
		});
		
		//1	
		$('itemProyectos1').addEvent('mouseover', function(e) {
			
			RollOver(e, 'itemProyectos1', '.tex_button2');
		});
			
		$('itemProyectos1').addEvent('mouseout', function(e) {
			RollOut(e, 'itemProyectos1', '.tex_button');
		});
		
		//2	
		$('itemProyectos2').addEvent('mouseover', function(e) {
			
			RollOver(e, 'itemProyectos2', '.tex_button2');
		});
			
		$('itemProyectos2').addEvent('mouseout', function(e) {
			RollOut(e, 'itemProyectos2', '.tex_button');
		});
		
		//3	
		$('itemProyectos3').addEvent('mouseover', function(e) {
			
			RollOver(e, 'itemProyectos3', '.tex_button2');
		});
			
		$('itemProyectos3').addEvent('mouseout', function(e) {
			RollOut(e, 'itemProyectos3', '.tex_button');
		});
		
		if(document.getElementById("itemProyectos4") != null)
		{
			//4
			$('itemProyectos4').addEvent('mouseover', function(e) {
				
				RollOver(e, 'itemProyectos4', '.tex_button2');
			});
				
			$('itemProyectos4').addEvent('mouseout', function(e) {
				RollOut(e, 'itemProyectos4', '.tex_button');
			});
		}
	
	}
	
	if(document.getElementById("fondoNoticia") != null)
	{
		//Noticia1
		var myEffect = new Fx.Tween($('vinculoNoticia'));
		
		$('fondoNoticia').setStyle("opacity", "0");
		
		$('vinculoNoticia').addEvent('mouseover', function(e) {
			e.stop();
			
			$('fondoNoticia').fade(0.1);
						
		});
			
		$('vinculoNoticia').addEvent('mouseout', function(e) {
			e.stop();
				
			$('fondoNoticia').fade(0);
		
		});
	}
	
	if(document.getElementById("fondoNoticia2") != null)
	{
		//Noticia2
		var myEffect2 = new Fx.Tween($('vinculoNoticia2'));
		
		$('fondoNoticia2').setStyle("opacity", "0");
		
		$('vinculoNoticia2').addEvent('mouseover', function(e) {
			e.stop();
			
			$('fondoNoticia2').fade(0.1);
						
		});
			
		$('vinculoNoticia2').addEvent('mouseout', function(e) {
			e.stop();
				
			$('fondoNoticia2').fade(0);
		
		});
	}
	
	if(document.getElementById("fondoNoticia3") != null)
	{
		//Noticia3
		var myEffect3 = new Fx.Tween($('vinculoNoticia3'));
		
		$('fondoNoticia3').setStyle("opacity", "0");
		
		$('vinculoNoticia3').addEvent('mouseover', function(e) {
			e.stop();
			
			$('fondoNoticia3').fade(0.1);
						
		});
			
		$('vinculoNoticia3').addEvent('mouseout', function(e) {
			e.stop();
				
			$('fondoNoticia3').fade(0);
		
		});
	}
	
	if(document.getElementById("fondoItemMenuLateral") != null)
	{
		
		//Vinculos laterales.
		var mySideEffect = new Fx.Tween($('fondoItemMenuLateral'));
		
		$('fondoItemMenuLateral').setStyle("opacity", "0");
		
		$('vinculoItemMenuLateral').addEvent('mouseover', function(e) {
			e.stop();
			
			$('fondoItemMenuLateral').fade(0.1);
						
		});
			
		$('vinculoItemMenuLateral').addEvent('mouseout', function(e) {
			e.stop();
				
			$('fondoItemMenuLateral').fade(0);
		
		});
		
		var mySideEffect1 = new Fx.Tween($('fondoItemMenuLateral1'));
		
		$('fondoItemMenuLateral1').setStyle("opacity", "0");
		
		$('vinculoItemMenuLateral1').addEvent('mouseover', function(e) {
			e.stop();
			
			$('fondoItemMenuLateral1').fade(0.1);
						
		});
			
		$('vinculoItemMenuLateral1').addEvent('mouseout', function(e) {
			e.stop();
				
			$('fondoItemMenuLateral1').fade(0);
		
		});
		
		var mySideEffect2 = new Fx.Tween($('fondoItemMenuLateral2'));
		
		$('fondoItemMenuLateral2').setStyle("opacity", "0");
		
		$('vinculoItemMenuLateral2').addEvent('mouseover', function(e) {
			e.stop();
			
			$('fondoItemMenuLateral2').fade(0.1);
						
		});
			
		$('vinculoItemMenuLateral2').addEvent('mouseout', function(e) {
			e.stop();
				
			$('fondoItemMenuLateral2').fade(0);
		
		});
		
		var mySideEffect3 = new Fx.Tween($('fondoItemMenuLateral3'));
		
		$('fondoItemMenuLateral3').setStyle("opacity", "0");
		
		$('vinculoItemMenuLateral3').addEvent('mouseover', function(e) {
			e.stop();
			
			$('fondoItemMenuLateral3').fade(0.1);
						
		});
			
		$('vinculoItemMenuLateral3').addEvent('mouseout', function(e) {
			e.stop();
				
			$('fondoItemMenuLateral3').fade(0);
		
		});
		
		var mySideEffect4 = new Fx.Tween($('fondoItemMenuLateral4'));
		
		$('fondoItemMenuLateral4').setStyle("opacity", "0");
		
		$('vinculoItemMenuLateral4').addEvent('mouseover', function(e) {
			e.stop();
			
			$('fondoItemMenuLateral4').fade(0.1);
						
		});
			
		$('vinculoItemMenuLateral4').addEvent('mouseout', function(e) {
			e.stop();
				
			$('fondoItemMenuLateral4').fade(0);
		
		});
		
		var mySideEffect5 = new Fx.Tween($('fondoItemMenuLateral5'));
		
		$('fondoItemMenuLateral5').setStyle("opacity", "0");
		
		$('vinculoItemMenuLateral5').addEvent('mouseover', function(e) {
			e.stop();
			
			$('fondoItemMenuLateral5').fade(0.1);
						
		});
			
		$('vinculoItemMenuLateral5').addEvent('mouseout', function(e) {
			e.stop();
				
			$('fondoItemMenuLateral5').fade(0);
		
		});
		
		if($('fondoItemMenuLateral6') != null)
		{
			var mySideEffect5 = new Fx.Tween($('fondoItemMenuLateral6'));
			
			$('fondoItemMenuLateral6').setStyle("opacity", "0");
			
			$('vinculoItemMenuLateral6').addEvent('mouseover', function(e) {
				e.stop();
				
				$('fondoItemMenuLateral6').fade(0.1);
							
			});
				
			$('vinculoItemMenuLateral6').addEvent('mouseout', function(e) {
				e.stop();
					
				$('fondoItemMenuLateral6').fade(0);
			
			});
		}
		
		if($('fondoItemMenuLateral7') != null)
		{
			var mySideEffect5 = new Fx.Tween($('fondoItemMenuLateral6'));
			
			$('fondoItemMenuLateral7').setStyle("opacity", "0");
			
			$('vinculoItemMenuLateral7').addEvent('mouseover', function(e) {
				e.stop();
				
				$('fondoItemMenuLateral7').fade(0.1);
							
			});
				
			$('vinculoItemMenuLateral7').addEvent('mouseout', function(e) {
				e.stop();
					
				$('fondoItemMenuLateral7').fade(0);
			
			});
		}
	}
				
	/*var divRegistrese = new Fx.Tween($('divRegistrese'));
	var divTooltipRegistrese = new Fx.Tween($('divTooltipRegistrese'));
		
	$('divTooltipRegistrese').setStyle("opacity", "0");
	
	$('divRegistrese').addEvent('mouseover', function(e) {
		e.stop();
		
		$('divRegistrese').fade(0.5);
		$('divTooltipRegistrese').fade(1);
		
					
	});
		
	$('divRegistrese').addEvent('mouseout', function(e) {
		e.stop();
			
		$('divRegistrese').fade(1);
		$('divTooltipRegistrese').fade(0);
	
	});*/
	
});

function RollOver(e, idObj, nombreClase)
{
	var obj = $(idObj);
	
	MostrarSubMenu1(idSubMenu);
	
	EjecutarAnimacion(e, idObj, nombreClase);
	
	obj.setStyle("font-weight", "bold");
}

function RollOut(e, idObj, nombreClase)
{
	var obj = $(idObj);
	EjecutarAnimacion(e, idObj, nombreClase);
	
	obj.setStyle("font-weight", "normal");
	OcultarSubMenu(idSubMenu);
}

function EjecutarAnimacion(e, idObj, nombreClase)
{
	var obj = $(idObj);
	var morph = new Fx.Morph(idObj, {duration: 100});
	
	e.stop();
	obj.morph(nombreClase);
}

function RegistrarPersona()
{
	var genero;
	
	for (i=0;i<document.form1.genero.length;i++)
	{
	  if (document.form1.genero[i].checked)
	  {
			genero = document.form1.genero[i].value;
	  }
	} 
	
	var nombres = document.getElementById('nombres').value;
	var apellidos = document.getElementById('apellidos').value;
	var fechaNacimiento = document.getElementById('anios').value + "-" + document.getElementById('meses').value + "-" + document.getElementById('dias').value;
	var correo = document.getElementById('email').value;
	var telefono = document.getElementById('telefono').value;
	var celular = document.getElementById('celular').value;
	var empresa = document.getElementById('empresa').value;
	var ciudad = document.getElementById('ciudad').value;
	var pais = document.getElementById('pais').value;
	
	if(nombres == "" || apellidos == "" || fechaNacimiento == "" || correo == "" || correo.indexOf("@") == -1)
	{
		document.getElementById('mensaje').style.display ='block';
		document.getElementById('mensaje').innerHTML = "Llene todos los datos obligatorios.";
		
		return;
	}
	else
		document.getElementById('mensaje').style.display ='none';
		
	var req = new Request({

		url: 'fcms/php_sitio/registro/CreacionPersona.php?idPersona=0&nombres=' + nombres + '&apellidos=' + apellidos + '&correo=' + correo + '&telefono=' + telefono +
				'&celular=' + celular + '&empresa=' + empresa + '&genero=' + genero + '&idEmpresa=' + idEmpresa + '&nuevo=true&idPais=' + pais + '&fechaNacimiento=' + fechaNacimiento,
		
		onSuccess: function(resultado){
			
			document.getElementById('mensaje').style.display ='block';
			document.getElementById('mensaje').innerHTML = "* El registro se ha efectuado con &eacute;xito.";
			
			document.getElementById('nombres').value = "";
			document.getElementById('apellidos').value = "";
			document.getElementById('email').value = "";
			document.getElementById('telefono').value = "";
			document.getElementById('celular').value = "";
			document.getElementById('empresa').value = "";
			document.getElementById('ciudad').value = "";
			document.getElementById('pais').value = "";
			
		},

		onFailure: function(){
			alert('Request fallo!!');
		}

	});
	
	req.send();
}

function PosicionarImagen(id, idDiv)
{
	var pic = document.getElementById(id);
	
	if(pic != null)
	{
		var h = pic.offsetHeight;
		var w = pic.offsetWidth;
	
		if(h == 0)
		{
			h = document.images[id].height;
			w = document.images[id].width;
		}
			
		if(h > 170)
		{
			var top = -((h - 170) / 2);
		
			document.getElementById(idDiv).style.top = top + 'px';
		}	
	}
}

function InicializarModales()
{
	box = new multiBox({
						mbClass: '.mbRegistro',//class you need to add links that you want to trigger multiBox with (remember and update CSS files)
						container: $(document.body),//where to inject multiBox
						descClassName: 'multiBoxDesc',//the class name of the description divs
						path: './Files/',//path to mp3 and flv players
						useOverlay: true,//use a semi-transparent background. default: false;
						maxSize: {w:1024, h:768},//max dimensions (width,height) - set to null to disable resizing
						addDownload: false,//do you want the files to be downloadable?
						pathToDownloadScript: './Scripts/ForceDownload.asp',//if above is true, specify path to download script (classicASP and ASP.NET versions included)
						addRollover: false,//add rollover fade to each multibox link
						addOverlayIcon: false,//adds overlay icons to images within multibox links
						addChain: true,//cycle through all images fading them out then in
						recalcTop: true,//subtract the height of controls panel from top position
						addTips: false,//adds MooTools built in 'Tips' class to each element (see: http://mootools.net/docs/Plugins/Tips)
						showNumbers: false,
						showControls: false
					});
		
				box1 = new multiBox({
						mbClass: '.mbRecomendacion',//class you need to add links that you want to trigger multiBox with (remember and update CSS files)
						container: $(document.body),//where to inject multiBox
						descClassName: 'multiBoxDesc',//the class name of the description divs
						path: './Files/',//path to mp3 and flv players
						useOverlay: true,//use a semi-transparent background. default: false;
						maxSize: {w:1024, h:768},//max dimensions (width,height) - set to null to disable resizing
						addDownload: false,//do you want the files to be downloadable?
						pathToDownloadScript: './Scripts/ForceDownload.asp',//if above is true, specify path to download script (classicASP and ASP.NET versions included)
						addRollover: false,//add rollover fade to each multibox link
						addOverlayIcon: false,//adds overlay icons to images within multibox links
						addChain: true,//cycle through all images fading them out then in
						recalcTop: true,//subtract the height of controls panel from top position
						addTips: false,//adds MooTools built in 'Tips' class to each element (see: http://mootools.net/docs/Plugins/Tips)
						showNumbers: false,
						showControls: false
					});	
				
				box2 = new multiBox({
						mbClass: '.mb',//class you need to add links that you want to trigger multiBox with (remember and update CSS files)
						container: $(document.body),//where to inject multiBox
						descClassName: 'multiBoxDesc',//the class name of the description divs
						path: './Files/',//path to mp3 and flv players
						useOverlay: true,//use a semi-transparent background. default: false;
						maxSize: {w:900, h:700},//max dimensions (width,height) - set to null to disable resizing
						addDownload: false,//do you want the files to be downloadable?
						pathToDownloadScript: './Scripts/ForceDownload.asp',//if above is true, specify path to download script (classicASP and ASP.NET versions included)
						addRollover: true,//add rollover fade to each multibox link
						addOverlayIcon: false,//adds overlay icons to images within multibox links
						addChain: true,//cycle through all images fading them out then in
						recalcTop: true,//subtract the height of controls panel from top position
						addTips: false,//adds MooTools built in 'Tips' class to each element (see: http://mootools.net/docs/Plugins/Tips)
						showNumbers: false,
						showControls: false
					});
				
				box3 = new multiBox({
						mbClass: '.mbArquitectura',//class you need to add links that you want to trigger multiBox with (remember and update CSS files)
						container: $(document.body),//where to inject multiBox
						descClassName: 'multiBoxDesc',//the class name of the description divs
						path: './Files/',//path to mp3 and flv players
						useOverlay: true,//use a semi-transparent background. default: false;
						maxSize: {w:600, h:400},//max dimensions (width,height) - set to null to disable resizing
						addDownload: false,//do you want the files to be downloadable?
						pathToDownloadScript: './Scripts/ForceDownload.asp',//if above is true, specify path to download script (classicASP and ASP.NET versions included)
						addRollover: false,//add rollover fade to each multibox link
						addOverlayIcon: false,//adds overlay icons to images within multibox links
						addChain: true,//cycle through all images fading them out then in
						recalcTop: true,//subtract the height of controls panel from top position
						addTips: false,//adds MooTools built in 'Tips' class to each element (see: http://mootools.net/docs/Plugins/Tips)
						showNumbers: false,
						showControls: false
					});
				
				box4 = new multiBox({
						mbClass: '.mbGaleria',//class you need to add links that you want to trigger multiBox with (remember and update CSS files)
						container: $(document.body),//where to inject multiBox
						descClassName: 'multiBoxDesc',//the class name of the description divs
						path: './Files/',//path to mp3 and flv players
						useOverlay: true,//use a semi-transparent background. default: false;
						maxSize: {w:600, h:400},//max dimensions (width,height) - set to null to disable resizing
						addDownload: false,//do you want the files to be downloadable?
						pathToDownloadScript: './Scripts/ForceDownload.asp',//if above is true, specify path to download script (classicASP and ASP.NET versions included)
						addRollover: false,//add rollover fade to each multibox link
						addOverlayIcon: false,//adds overlay icons to images within multibox links
						addChain: true,//cycle through all images fading them out then in
						recalcTop: true,//subtract the height of controls panel from top position
						addTips: false//adds MooTools built in 'Tips' class to each element (see: http://mootools.net/docs/Plugins/Tips)
						
					});
}

function CambiarTamano(incremento) 
{
	var node;
	var classname;	
	
	if(classname1 == "")
		classname1 = "tex_eve";
	
	tamano = tamano + incremento;
	
	if(tamano < 12)
		tamano = 12;
	
	if(tamano > 16)
		tamano = 16;
		
	if(tamano == 12)
		classname = 'tex_eve';
	
	if(tamano == 14)
		classname = 'tex_eve1';
	
	if(tamano == 16)
		classname = 'tex_eve2';	
	
    node = document.getElementsByTagName("body")[0];   
	   
    var re = new RegExp('\\b' + classname1 + '\\b');
    var els = node.getElementsByTagName("*");

    for(var i=0,j=els.length; i<j; i++)   
	  if(re.test(els[i].className))
	  {
	  	els[i].className = classname;
	  } 
	  
	  classname1 = classname;
	  
	  CambiarFecha();
}

function CambiarFecha()
{
	var node;
	var classname;
	
	if(classname2 == "")
		classname2 = "tex_fecha";
	
	if(tamano == 12)
		classname = 'tex_fecha';
	
	if(tamano == 14)
		classname = 'tex_fecha1';
	
	if(tamano == 16)
		classname = 'tex_fecha2';	
	
    node = document.getElementsByTagName("body")[0];   
	   
    var re = new RegExp('\\b' + classname2 + '\\b');
    var els = node.getElementsByTagName("*");

    for(var i=0,j=els.length; i<j; i++)   
	  if(re.test(els[i].className))
	  {
	  	els[i].className = classname;
	  } 
	  
	  classname2 = classname;	
}
