// JavaScript Document
window.addEvent('domready', function() 
{

		$$(".menu_li").each(function(Menuelemento){
								 					 
			Menuelemento.addEvents(
			{
				'mouseenter': function()
				{
					var submenu = Menuelemento.getFirst().getNext();
					if (submenu){
						
						Menuelemento.setStyle('background', 'url(imagenes/top_menu_bg2.jpg) repeat-x top center');
						Menuelemento.getFirst().setStyle('color', '#FFFFFF');
						submenu.setStyle('display', 'block'); //muestro el submenu
						
					}
				},
				'mouseleave': function()
				{
					var submenu = Menuelemento.getFirst().getNext();
					if (submenu){
						
						Menuelemento.setStyle('background', 'none');
						Menuelemento.getFirst().setStyle('color', '#454545');
						submenu.setStyle('display', 'none');
					}
				}
			});							
												
	});





	/**************************************************** CONTACTO **************************************************/

	
	$$('#contacto input', '#contacto textarea').each(function(inputEl)
	{
		if (inputEl.getProperty('class')!="form_button")
		{
			inputEl.addEvents(
			{
				'focus': function()
				{
					inputEl.setStyle('background', '#FFFFCC ');
				},
				'blur': function()
				{
					inputEl.setStyle('background', '#FFFFFF');
				}
			});
		}
	});




}); //end  domload



/*************************************************** POP UP **************************************************/

var popUpWin =0;
function popUpWindow(URLStr, left, top, width, height,scrollb)
{
  width = width + 40;
  height = height + 20;
  left = screen.width/2 - width/2
  top = screen.height/2 - height/2
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin= open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+scrollb+',resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

var popUpWin2 =0;
function popUpWindow2(URLStr, left, top, width, height)
{
  left = screen.width/2 - width/2
  top = screen.height/2 - height/2
  if(popUpWin2)
  {
    if(!popUpWin2.closed) popUpWin2.close();
  }
  popUpWin2 = open(URLStr, 'popUpWin2', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

/*************************************************** AGRANDAR TEXTO **************************************************/

minsize=8;
maxsize=18;
deft=10;
actual=13;

function MasTxt(div){
actual = actual+1;
if (actual > maxsize) {
actual = maxsize
}
var divID = document.getElementById(div);
divID.style.fontSize = actual+"px";
// px porque estoy usando css
}

function MenosTxt(div) {
actual = actual-1;
if (actual < minsize) {
actual = minsize
}
var divID = document.getElementById(div);
divID.style.fontSize = actual+"px";
}

/*************************************************** PRINT **************************************************/
function printPage() { print(document); }

/*************************************************** BOOKMARK **************************************************/
function agregar(){
   if ((navigator.appName=="Microsoft Internet Explorer") && (parseInt(navigator.appVersion)>=4)) {
      var url="http://www.TuSitio.com/";
      var titulo=" Descripcion de mi sitio web";
      window.external.AddFavorite(url,titulo);
   }
   else {
      if(navigator.appName == "Netscape")
         alert ("Presione Crtl+D para agregar este sitio en sus Bookmarks");
   }
} 


/*************************************************** BLINK **************************************************/
/*

	var opciones = {
		'property' : 'color',
		'from' : new Color('#fff'),
		'to' : new Color('#f00'),
		'endActive' : false,
		'times':80,
		'duration' : 300
	};

	var els = new blinkProperty('DIV ID',opciones);
	els.doIt();

*/


var blinkProperty = new Class({
	opciones : {},
	element : null,

	initialize : function(el, opciones) {
		this.opciones = Object.extend({
			'property' : 'border-color',
			'duration' : 500,
			'margin' : 50,
			'from' : new Color('#000'),
			'to' : new Color('#fff'),
			'times' : 3,
			'transition' : Fx.Transitions.linear,
			'endActive' : true
		}, opciones || {});

		this.element = el;
	},

	doIt : function() {
		var blink = new Fx.Style(this.element, this.opciones['property'], {'duration': this.opciones['duration'], 'transition': this.opciones['transition']});
		blink.start(this.opciones['from'], this.opciones['to']);
		for(var i = 0; i < this.opciones['times']; i++) {
			blink.start.pass([this.opciones['to'], this.opciones['from']], blink).delay((this.opciones['duration']+this.opciones['margin']) * ((i*2)+1));
			blink.start.pass([this.opciones['from'], this.opciones['to']], blink).delay((this.opciones['duration']+this.opciones['margin']) * ((i*2)+2));
		}
		if(!this.opciones['endActive'])
			blink.start.pass([this.opciones['to'], this.opciones['from']], blink).delay((this.opciones['duration']+this.opciones['margin']) * ((i*2)+1));
	}
});

/*************************************************** LIGHTBOX **************************************************/
function lightbox(url,boxX,boxY){
	

	var alturaTotal = window.getScrollHeight();
	
	//fondo opaco
	var div_bg = new Element('div',
	{
		  'id':'light_box_bg',
		  'styles':
		  {
				'position':'absolute',
				'top':'0px',
				'left':'0px',
				'display':'block',
				'width':'100%',
				'height':alturaTotal+'px',
				'z-index':'99990'
		  }
	});
	div_bg.injectAfter('subbody');
	

	var misEfectos = new Fx.Styles('light_box_bg');
	misEfectos.start(
	{
		'background-color':['#FFFFFF','#000000'],
		'opacity': [0, 0.7]
	});

	
	
	//creo el box
	var tamW = window.getSize();	
	//var tamE = $('Lightbox_Container').getSize();
	
	var posX = (tamW.size.x/2 - boxX/2) + tamW.scroll.x;
	var posY = (tamW.size.y/2 - boxY/2) + tamW.scroll.y;

	var div_box_container = new Element('div',
	{
		  'id':'Lightbox_Container',
		  'styles':
		  {
				'position':'absolute',
				'top':posY+'px',
				'left':posX+'px',
				'width':boxX,
				'height':boxY,
				'z-index':'999991'
		  }
	});
	
	div_box_container.injectAfter('light_box_bg');

	var miAjax = new Ajax(url,
	{
		method: 'get',
		encoding:'iso-8859-1',
		update:$('Lightbox_Container'),
		evalScripts: false
	});
	miAjax.request();
	
	
	
	//cerrar el lightbox
	$('light_box_bg').addEvent('click', function()
	{
		$('Lightbox_Container').remove();
		$('light_box_bg').remove();
	});




}

function light_box_cerrar(){

	//cerrar el lightbox
	$('light_box_cerrar').addEvent('click', function()
	{
		$('Lightbox_Container').remove();
		$('light_box_bg').remove();
	});
	
}
