/*
-- Script sitio.js
-- Autor: Melquisedec Wilchez Tinoco (mwilchez@compudev.com.ec)
-- Copyright (c) 2008 [CompuDev](http://www.compudev.com.ec/).
*/
function cargaAjax(url, metodo, datos , contenedor, evaluar, funComp){
	var divCarga = new Element('div',{'class': 'precarga','html': 'Cargando...'});
	new Request.HTML({
		url: url,
		method: metodo,
		data: datos,
		evalScript: evaluar,
		onRequest: function(){
			creaPreload(contenedor, divCarga);
		},
		onComplete: function(responseTree, responseElements, responseHTML, responseJavaScript){
			botones();
			destruyePreload(divCarga);
			$(contenedor).set('html',responseHTML);
			if(funComp != null){
				funComp.run();
			}
		}
	}).send();
}

function creaPreload(cont, divCarga){
	$(cont).empty();
	$(cont).grab(divCarga);
	divCarga.setStyle('display','block');
}

function destruyePreload(divCarga){
	divCarga.setStyle('display','none');
	divCarga.empty();
	divCarga.destroy();
}

function rollover(img, src){
	$(img).set('opacity', 0.4);
	$(img).set('src', src);
	$(img).fade(1);
}

function botones(){
	$$('.boton-up').addEvents({
		'mouseenter': function(){
			this.morph('.boton-over');
		},
		'mouseleave': function(){
			this.morph('.boton-up');
		}
	});
}

function btnGal(){
	$('bngal').set('opacity', 0.6);
	$('bnvid').set('opacity', 0.6);
	$('bngal').addEvents({
		'mouseenter': function(){
			$('bngal').fade(1);
		},
		'mouseleave': function(){
			$('bngal').fade(0.6);
		}
	});
	$('bnvid').addEvents({
		'mouseenter': function(){
			$('bnvid').fade(1);
		},
		'mouseleave': function(){
			$('bnvid').fade(0.6);
		}
	});
}
function VBox(){
	var virtual = new Virtual.Box({
		enable: {
			arrows: true,
			closeButton: true
		},
		style: true,
		effect: 'open',
		leftArrowText: '',
		rightArrowText: '',
		closeButtonText: '',
		captionOpacity: 0.6
	});
}
function VAjax(funComp){
	var virtual = new Virtual.Ajax({
		enable: {
			arrows: false,
			closeButton: true,
			caption: false
		},
		style: true,
		effect: 'fix',
		leftArrowText: ' ',
		rightArrowText: ' ',
		closeButtonText: ' ',
		captionOpacity: 0.6,
		requestOptions: {
			onRequest: function() {
				virtual.wrapreq.set('html', '<p style="text-align:center;"><img src="./images/ajax-loader.gif" alt="Cargando"><br /><b>Cargando...</b></p>');
			},
			onSuccess: function(rt, rxml){
				if(funComp != null){
					funComp.run();
				}
			}
		}
	});
}