Event.observe(
	window,
	'load',
	fInicio
);

function fInicio() {
	
	load_content();
}

function load_content(parent) {
var	a_e = []; 
	if (Object.isUndefined(parent)){
		a_e = $$("div[class~='content_loader']");
	}
	else {
		a_e = parent.select("div[class~='content_loader']");
	}
	a_e.each (
		function(div) {
		var url = div.getAttribute("url");
			if (url) {
				new Ajax.Updater (
					div.id
					,url
					,{
						onComplete: eval(div.getAttribute('callback')),
						onCreate: function(){
							div.update('<img src="images/ajax-loading.gif" alt="Cargando" />');
						}

					}
				); 
			}
			else{
				eval(div.getAttribute('callback')+'()');
			}
		}
	);
}

function lightwindowInit_lst_portfolio(){
	$('lst_portfolio').select('a').each(
		function(e_a,index){
			myLightWindow.createWindow(e_a.identify());
		}
	);
}

function lightwindowInit_portfolio(){
	$('portfolio').select('a').each(
		function(e_a,index){
			myLightWindow.createWindow(e_a.identify());
		}
	);
}

function lightwindowInit_lst_notcs() {
	$('lst_notcs').select('a').each(
		function(e_a,index){
			myLightWindow.createWindow(e_a.identify());
		}
	);
}

function lightwindowInit_agencia() {
	$('agencia').select('a').each(
		function(e_a,index){
			myLightWindow.createWindow(e_a.identify());
		}
	);
}

function lightwindowInit_destamos() {
	$('destamos').select('a').each(
		function(e_a,index){
			myLightWindow.createWindow(e_a.identify());
		}
	);
}

function lightwindowInit_q_somos() {
	$('q_somos_index').select('a').each(
		function(e_a,index){
			myLightWindow.createWindow(e_a.identify());
		}
	);
}

function lightwindowInit_noticias() {
	$('noticias_todas').select('a').each(
		function(e_a,index){
			myLightWindow.createWindow(e_a.identify());
		}
	);
}
/*
	FUNCION LLAMADA POR EL FLASH PARA CARGAR UN CONTENIDO DENTRO DE UN CONTENEDOR EXISTENTE.
	DICHO CONTENEDOR PUEDE REQUERIR UNA EVALUACION JS PARA DARLE FUNCIONALIDAD.
*/
function load_div_content(URL){
	try {
		new Ajax.Request(URL, {
			parameters: {
			}
			,onCreate: function() {
				$("mainContent").update('<img src="images/ajax-loading.gif" alt="Cargando" />');
			}.bind(this)
			,onComplete: function (t) {
				try{
					// ACTUALIZA MAINCONTENT CON EL RESULTADO HTML DEL SERVIDOR.
					$("mainContent").update(t.responseText);

					// EVALUA TODO EL CONTENIDO JAVASCRIPT DENTRO DEL HTML DEL CONTENEDOR.
					t.responseText.extractScripts().map(
						function(script) {
							return eval(script);
						}
					);
					// UNA VEZ INSERTAFO EL CONTENIDO PASA A CARGAR EL CONTENIDO DENTRO DE SI MISMO.
					load_content.defer($("mainContent"));
				}
				catch(e){
					Prototype.Exeption.handle(e,"onComplete", "integral.js");
				}
			}.bind(this)
			,onFailure: function() {
				throw "Error de servidor!";
			}.bind(this)
		});
	}
	catch(e){
		Prototype.Exeption.handle(e,"ajax_get_prec_colrnt", "BusquedaDeColores");
	}
}

