var objeto;
var module;
var conten;
var page;
var variables=Array();
var reservado=Array("hsbToRgb","rgbToHsb","rgbToHex","test","each","getLast","getRandom","include","merge","extend","associate","contains","remove","copy","hexToRgb","indexOf","some","every","map","filter","forEach","defer","methodize","wrap","delay","curry","binAsEventListener","bind","argumentNames","from"); //Varores existentes por defecto en un array
var cantidades=Array();
//AŅADE VARIABLE AL ARRAY DE VARIABLES 
function Encriptar()
{
	var texto = document.getElementById("password").value;
	var semilla = document.getElementById("token").value;
    	var suma = 0;
    	var newtexto = "";
        
   	 for(x=0; x < semilla.length; x++)
   	{
        		suma += semilla.charCodeAt(x);
    	}

    	semilla = suma.toString();
    	suma = 0;

	 for(z=0; z < semilla.length; z++)
    	{
        		suma += parseInt(semilla.charAt(z));
    	}
    
    	semilla = parseInt(suma);

    	for(y=0; y < texto.length; y++)
    	{
        		if(texto.charCodeAt(y) + semilla > 126)
        		{
            		suma = ((texto.charCodeAt(y) + semilla) - 126) + 31;
        		}
        		else
        		{
            		suma = (texto.charCodeAt(y) + semilla);
        		}

        		newtexto += String.fromCharCode(suma)
      
 	}

    	document.getElementById("password").value=newtexto;
	document.getElementById("token").value="";

	document.getElementById("login").submit();
}


function onKeyPressBlockLeters(e,obj,prod)
{

	
	var key = window.event ? e.keyCode : e.which;4
	
	var keychar = String.fromCharCode(key);
	reg =/^[0-9]+/;
	
	
		return reg.test(keychar);

	
}

function cambia_cuotas(cuota,valor){
	valor_cuota=valor/cuota;	
	window.document.getElementById("TOTAL_CUOTAS").innerHTML="<span class=\"text-monto2\">Valor cuota: $"+Math.ceil(valor_cuota)+"</span>";
}

function recalculaCuota(){
	var valor_cuota=window.document.getElementById("total_final").value;
	var cuota=window.document.getElementById("cuotas").value;
	if(cuota==0 || valor_cuota==0){
		window.document.getElementById("CUOTAS_X").innerHTML="Sin cuota";
	}else{
		valor_cuota=valor_cuota/cuota;
		window.document.getElementById("CUOTAS_X").innerHTML="Valor: $"+Math.ceil(valor_cuota);
	}
	
}

function cambia_cuotas_total(cuota){
	if(cuota>0){
		var valor_cuota=window.document.getElementById("total_final").value;
		var total=valor_cuota/cuota;
		window.document.getElementById("CUOTAS_X").innerHTML="Valor: $"+Math.ceil(total);
	}else{
		window.document.getElementById("CUOTAS_X").innerHTML="Sin cuota";
	}
}

function cambiaTotal(total,despacho){
		window.document.getElementById("TIPO_DESPACHO").value=despacho_tipo_precio[despacho];
		var valor=(total*1)+(despacho*1);
		window.document.getElementById("TOTAL").innerHTML="$"+addCommas(valor);
		window.document.getElementById("total_final").value=valor;
		recalculaCuota();
}




function recalcular(obj){
	
	if(obj){
			
		if(obj.value<1){
			alert("La cantidad no puede ser 0");	
			obj.value=1;
		}	
	}
	var suma=0;
	var total=0;
	var key;
	var cantidad;
	var cont=1;
	var tmp_val=0;
	var region=0;
	var flag;
	var precio_final=0;;
	var precios=Array();
	for(key in prod_carrito ){
		if(!reservado[key]){
			
				cantidad=window.document.getElementById("PROD_"+key).value;	
				cantidades[key]=cantidad;
				
				precio=window.document.getElementById("PRECIO_"+key).value;	
				
				total=(total*1)+(precio*cantidad);
				window.document.getElementById("VALORPRODUCTO"+key).innerHTML="$"+addCommas(cantidad*precio);
				suma=(suma*1)+(cantidad*1);
			}
		}
			
	

	window.document.getElementById("TOTAL_PROD").innerHTML=suma;
	total=addCommas(total);
	window.document.getElementById("VALOR").innerHTML="$"+total;
	for(dat in precio_santiago){
			if(!reservado[dat]){
					if(cont==1){
						if(cantidades[dat]>1){
							flag=1;
							tmp_val=0;
							for(x=1;x<=cantidades[dat];x++){
								if(flag==1){
									tmp_val=(tmp_val*1)+(precio_santiago[dat]*1);	
								}else{
									tmp_val=(tmp_val*1)+(precio_dos[dat]*1);
									
								}	
								flag=2;
							}
							precios[dat]=tmp_val;
						}else{	
							precios[dat]=precio_santiago[dat]*cantidades[dat];	
						}
						
						
					}else{
						precios[dat]=precio_dos[dat]*cantidades[dat];
						
						
					}
				
				
				
				
				
			}
		}
		
		for(key in precios){
				if(!reservado[key]){
						precio_final=(precio_final*1)+(precios[key]*1)
					
					}
			
		}
		window.document.getElementById("TEST_PRECIO").innerHTML=addCommas(precio_final);
		for(key in precio_region){
				if(!reservado[key]){
						region=(region*1)+((precio_region[key]*1)*(cantidades[key]*1));	
				}
			
		}
		
		window.document.getElementById("ESE_OTRO").innerHTML=addCommas(region);
		
	}
	
function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + '.' + '$2');
	}
	return x1 + x2;
}

function meteCantidad(prod,cant){
				var url;
				if(cant)		
					url="./cant.php?producto="+prod+"&cantidad="+cant;
				else
					url="./cant.php?producto="+prod+"&cantidad=0";
				
			
	
		
		window.document.getElementById("carrito").src=url;
	
	
	}
	
function cargaDatosUsuario(){
			resetVariable();
			setVariable("page","home/misDatos");
			setVariable("unidad",0);
			
			CargaComponente("CARGA_OPCION_USUARIO");
	
	}
	
function misSolicitudes(){
			resetVariable();
			setVariable("page","home/misSolicitudes");
			setVariable("unidad",0);
			CargaComponente("CARGA_OPCION_USUARIO");
	
	}	


function meterAlCarro(obj,otr){
		var url;
		
		
		if(obj.id=="D"){
				url="./carrin.php?producto="+obj.alt+"&"+otr;
				obj.id="A";
				obj.src="./shop_image/trash.gif";
				obj.title="Quitar del carrito";
		}else{
				obj.id="D";
				obj.src="./shop_image/icono-carro.gif";
				url="./carrout.php?producto="+obj.alt+"&"+otr;
				obj.title="Agregar al carrito";
				
			
		}
		
		window.document.getElementById("carrito").src=url;
	
	
	}
	
function sacarDelCarro(producto,url){
		
		
		window.document.getElementById("carrito").src="./carrout.php?producto="+producto.alt;
		window.location.href=url;
	
	
	}	

function despliega(x){
		if(x){
			var z=x;
			x=window.document.getElementById("HIJO_"+x);	
			x.style.display="block";
			$("#P"+z).css("color","#FA9800");
		}
	
	}

function despliegaHijos(x){
	$("#H"+x).css("color","#FA9800");
}
function cargaFormUsado(id){
		if(id)
		Modalbox.show('./?page=home/formulario&id_formulario=21&usado_id='+id, {title: '', width: 430});
	
	}
function cargaImprimi(id){
	
		alert(id);
	}



function setVariable(nom,val){
			this.variables[nom]=val;
		} 
//FIN

//RESETEA ARRAY DE VARIABLES		
function resetVariable(){
			this.variables=Array();			
		} 
//FIN

//FUNCION GENERICA PARA CARGAR UN AJAX
function CargaComponente(contenedor,onComplete){	
	var ajax = new sack();
	ajax.resetData();
	for(key in this.variables ){
			if(!reservado[key]){
				//alert(variables[key]);
				ajax.setVar(key,variables[key]); 
				
			}
			
		}

	ajax.setVar("print","1"); 
	if(onComplete){
		
			funcion="ajax.onCompletion = "+onComplete+";";
			
			eval(funcion);
		
		}
	ajax.requestFile = "./";
	ajax.method = 'GET';
	ajax.element = contenedor;
	ajax.runAJAX();		
	//alert(contenedor);

}

function cambiaModelo(x){
			
			cambiaVersion2(99999);
				resetVariable();
				setVariable("fpage","home/cambia_version");
				setVariable("nmodelo_id",x);
				CargaComponente("version");
			
	
	}

function  cargaSec(sec,uni){
	
			resetVariable();
			setVariable("seccion_id",sec);
			setVariable("unidad",uni);
			
			CargaComponente("contenidoSEc");

}
//FIN
//Inserta datos en fomulario cotizar ya que desde el controler no funciona.. se marea xD
function insertarDatos(pie,version,id){
		
	
	resetVariable();
			setVariable("fpage","home/calculaCuota");
			setVariable("pie",pie);
			setVariable("transaccion_id",id);
			setVariable("version",version);
			CargaComponente("DATOSCREDITO");
	
	}
	
function insertarDatosFin(pie,version,id){
		
	
			resetVariable();
			setVariable("fpage","home/calculaCuotaFin");
			setVariable("pie",pie);
			setVariable("transaccion_id",id);
			setVariable("version",version);
			
			CargaComponente("DATOSCREDITO");
	
	}	

function insertarDatos2(pie,version,id){
		
		
			resetVariable();
			setVariable("fpage","home/calculaCuota2");
			setVariable("pie",pie);
			setVariable("transaccion_id",id);
			setVariable("version",version);
			
			CargaComponente("DATOSCREDITUSADO");
	
	}
	

function listadoUsados(){
	
			
			window.document.getElementById("proceso").src="./?fpage=home/buscaUsado&print=1";
	
	}	
	
function cargaUsados(){
		
	
			resetVariable();
			setVariable("fpage","home/usados_b");
		
			CargaComponente("BUSCADOR","listadoUsados");
	
	}
	
//CAMBIA FORMULARIO COTIZACION
function cambiaFormulario(id){
			x=window.document.getElementById("campo").value;
			
			resetVariable();
			setVariable("page","home/formulario");
			setVariable("id_formulario",id);
			setVariable("vivienda_id",x);
			CargaComponente("DivForm");
		

	}

//

function getSolicitud(id){
			
			window.document.getElementById("XXXXCAMBIADIV").innerHTML="<a href=\"#\" onclick=\"cambiaEstadoSol('"+id+"')\" ><img src='./shop_image/form/bot-solicitar.jpg' border='0'></a>";
	
	
	}
	
	
function cambiaEstadoSol(id){
		window.document.getElementById("proceso").src="./?fpage=home/cambiaEstadoSol&print=1&transaccion_id="+id;
	
	
	}	


//FUNCION PARA CARGAR VENTANAS
function llamaVentana(id){
		new Control.Modal($(id),{
			iframe: true,
			width: 400,
			height: 350
		});
	

}

		
//FIN
//FUNCION PARA CARGAR  FORMULARIO y MENU DE UN OBJETO
function CargaFormulario(mod,pag){
	this.module=mod;
	resetVariable();
	setVariable("bpage",mod+"/"+pag+"_m");
	CargaComponente("NOTICIAS_PORTAL");
	setVariable("bpage",mod+"/"+pag+"_f");
	CargaComponente("ContentBody");

}
//FIN

//FUNCION PARA CARGAR BUSCADOR , LISTADOR Y PROCESO
function CargaBuscador(mod,pag,obj){
		
	this.objeto=obj;	
	this.module=mod;
	this.page=pag;
	resetVariable();
	setVariable("bpage",mod+"/"+pag+"_b");
	CargaComponente("NOTICIAS_PORTAL","setupObjeto");

}





function setupObjeto(ord,obj,mod,pag){
		
		if(obj)
			objeto=obj;
		if(mod)
			module=mod;
		if(pag)
			page=pag;
		if(!ord)
			ord="";
document.getElementById('proceso').src="./?page=home/procesador&print=1&objeto="+objeto+"&mod="+module+"&pag="+page+"&order="+ord;
}
//FIN

//INCLUIR JS DEL MODULO CORRESPONDIENTE (se carga en el onLoad del Page)

function incluirJs(){ 
	var filename="./modules/"+module+"/js/script.js";
	var body = document.getElementsByTagName('body').item(0); 
	script = document.createElement('script'); 
	script.src = filename; 
	script.type = 'text/javascript'; 
	body.appendChild(script) 
	
}

//FIN


//FUNCION VOLVER 
function backList(obj){
	document.getElementById("listForm").style.display="none";
	document.getElementById("ShowroomForm").style.display="none";
	resetVariable();
	setVariable("bpage",module+"/"+obj+"_b");
	CargaComponente("NOTICIAS_PORTAL");
	resetVariable();
	setVariable("bpage",module+"/"+obj+"_L");
	CargaComponente("ContentBody");

	
}//FIN

//Funcion utilizada por  los paginadores
function changePage(page,mod){
		var ajax = new sack();
		x=document.getElementById("offset_list").value;	
		resetVariable();
		setVariable("bpage",mod+"/"+page);
		setVariable("fl",1);
		setVariable("offset_list",x);
		CargaComponente("ContentBody");
	}
	
function changeUsados(page,mod){
		var ajax = new sack();
		x=document.getElementById("offset_list").value;	
		resetVariable();
		setVariable("fpage",mod+"/"+page);
		setVariable("fl",1);
		setVariable("offset_list",x);
		CargaComponente("LISTADO");
	}	

//FIN

function cargarNav(tipo){
		//alert('SII');
		resetVariable();
		
		setVariable("tipo",tipo);
		setVariable("fpage","home/ShowRoomNav");
		//setVariable("id",id);
		CargaComponente("NAVEG");
}

function cargarContenido(t,mo){
		//alert('SII');
		resetVariable();
		if(t == 'des'){
			setVariable("destacado",1);
			setVariable("tipo_nav",10);
		}else{
			setVariable("tipo_nav",t);
			setVariable("modelo_id",mo);
		}
		
		setVariable("fpage","home/contenido_display");
		//setVariable("id",id);
		CargaComponente("MAIN");
}
function cambiaSimulacion(v,m){
		
		
		window.document.getElementById("VERSIONSIMULAR").href="javascript:Modalbox.show('./?page=home/formulario&id_formulario=18&obj_id="+m+"&version_id="+v+"', {title: '', width: 430});";
		//Modalbox.show('./?page=home/formulario&id_formulario=16&obj_id={MODELO_ID}', {title: '', width: 430});
		window.document.getElementById("VERSIONCOTIZAR").href="javascript:Modalbox.show('./?page=home/formulario&id_formulario=16&obj_id="+m+"&version_id="+v+"', {title: '', width: 430});";
	}	
	
function descripcionVersion(id,t,m){
	
		cambiaSimulacion(id,m);
		resetVariable();
		//alert(id);
		setVariable("nuevo_id",id);
		setVariable("tipo",t);
		setVariable("fpage","home/detalle_version");
		CargaComponente("DESCRIP");
	}


function cambiaVersion2(x){
			
			if(x!=99999)
				x=window.document.getElementById("campo_ver").value;
			
		
			resetVariable();
			setVariable("page","home/monto");
			setVariable("nuevo_id",x);
			CargaComponente("monto");
			
}


function cambiaVersion(x){
			
			
				x=window.document.getElementById("campo").value;
			
		
			resetVariable();
			setVariable("page","home/monto");
			setVariable("nuevo_id",x);
			CargaComponente("monto");
			
}


//FUNCONES EXTRAS!!!!!!
function cargaVentana(objeto_id,titulo,ancho,alto,pX,pY){

var clientId=objeto_id; ///este es el objeto
var iniTitle=titulo;//el titulo del div
var iniUrl=null; //si es que se inicia una url aqui se coloca
var iniX=pX;// inicio de posicion X
var iniY=pY;// inicio de posicion Y
var iniW=ancho;
var iniH=alto;


var miniW=150;
var fenceId='';


var conPad=1;
var conBor=1;
var cliBor=1;

var enMove=true;
var enResize=true;
var enMinimize=true;

var enMaximize=true;
var enClose=true;
var enStatus=false;

var enFixed=true;
var fnMove=null;
var fnResize=null;

var fnMinimize=null;
var fnMaximize=null;
var fnRestore=null;

var fnClose=null;
var fnFocus=null;
var fnLoad=null;


var clsCon='xfCon';
var clsCli='xfClient';
var clsTitlebar='xfTBar';

var clsTitlebarFocused='xfTBarF';
var clsStatusbar='xfSBar';
var clsStatusbarFocused='xfSBarF';

var clsResizeIcon='xfRIco';
var clsMinimizeIcon='xfNIco';
var clsMaximizeIcon='xfMIco';

var clsRestoreIcon='xfOIco';
var clsCloseIcon='xfCIco';

var txtResize='Resize';
var txtMin='Minimizar';
var txtMax='Maximizar';
var txtRestore='Restaurar';
var txtClose='Cerrar';


if(!xFenster.instances[objeto_id]){


new xFenster(clientId, iniTitle, iniUrl, iniX, iniY, iniW, iniH, miniW,fenceId, 
			conPad, conBor, cliBor,//12
             enMove, enResize, enMinimize,//15
			 enMaximize, enClose, enStatus,//18
			 enFixed,fnMove, fnResize, //21
			 fnMinimize, fnMaximize, fnRestore,//24
			 fnClose, fnFocus, fnLoad,//27
             clsCon, clsCli, clsTitlebar, //30
			 clsTitlebarFocused, clsStatusbar, clsStatusbarFocused,//33
             clsResizeIcon, clsMinimizeIcon, clsMaximizeIcon,// 36
			 clsRestoreIcon, clsCloseIcon,txtResize, 
			 txtMin, txtMax, 
			 txtRestore, txtClose);
}
if(!xFenster.instances[objeto_id].restore())
	xFenster.instances[objeto_id].show();
}



function debug(s){
	
		if(s==1){
			window.document.getElementById("proceso").style.display="block";
			window.document.getElementById("procesoForm").style.display="block";
			window.document.getElementById("DEBUG").href="javascript:debug('-1');";
		
		}else{
			window.document.getElementById("proceso").style.display="none";
			window.document.getElementById("procesoForm").style.display="none";
			window.document.getElementById("DEBUG").href="javascript:debug('1');";
			
			}
			
		document.getElementById('proceso').style.position = "absolute";
		document.getElementById('proceso').style.zindex = "15000";
		document.getElementById('proceso').style.height = "91";
		document.getElementById('proceso').style.width = "563px";
		document.getElementById('proceso').style.border="double";
		document.getElementById('proceso').style.top = "11px";
		document.getElementById('proceso').style.left = (document.body.clientWidth/2-210)+'px';
		
		document.getElementById('procesoForm').style.position = "absolute";
		document.getElementById('procesoForm').style.zindex = "15000";
		document.getElementById('procesoForm').style.border="double";
		document.getElementById('procesoForm').style.height = "91";
		document.getElementById('procesoForm').style.width = "563px";
		document.getElementById('procesoForm').style.top = "620px";
		document.getElementById('procesoForm').style.left = (document.body.clientWidth/2-203)+'px';
		
		
	
}

function csv(objeto){
		
		window.document.getElementById('proceso').src="./?page=ajax/genera_csv&objeto="+objeto;
		
		
	
	}




function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}


function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_nbGroup(event, grpName) { //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}


//FUNCIONES LOGIN//
function opciones_usuario(){
	//alert('jano');
	ajax.resetData();
	ajax.setVar("page","home/user_option"); // recomended method of setting data to be parsed.
	ajax.setVar("print","1"); // recomended method of setting data to be parsed.
	ajax.requestFile = "./";
	ajax.method = 'POST';
	ajax.element = 'LoginUsuario';
	ajax.runAJAX();

}

function onchange_optionUser(){
	option = document.getElementById('OptionUser').value;
	//alert(option);
	var ajax = new sack();
	if(option == 10){
		window.location.href="./?unidad=0&seccion_id=MIS_DATOS_F";
	}
	if(option == 20){
		window.location.href="./?unidad=1000";
	}
	if(option == 30)
		window.location.href="./?page=admin/index";

	if(option == 40){
		window.location.href="./?unidad=0&seccion_id=INTRANET_F";
	}
	
	if(option == 50){
		window.location.href="./?func=userLogout&unidad=0";
	}
}

//FIN FUNCIONES LOGIN//

function cargaIntra(dir,id_curso){
	//alert('siii');
	//var ajax = new sack();
	resetVariable();
	setVariable("fpage","intranet/"+dir);
	setVariable("id_curso",id_curso);
	CargaComponente("RESULTADO");
	//alert(dir);
	
	
}

//FUNCION PARA LA AGENDA DE MI CURSO//


function cargaCalendario(id_curso,tipo){
	//alert(id_curso);
	m=document.getElementById("mes").value;
	//alert(m);
	resetVariable();
	if(tipo){
		setVariable("page","home/agenda_C");
	}else{
		t=document.getElementById("t_contenido").value;
		setVariable("t_cont",t);
		setVariable("fpage","intranet/agenda_C");
	}
	setVariable("mes",m);
	setVariable("id_curso",id_curso);
	
	CargaComponente("CALENDARIO");
}

function cargaContenido(anno,mes,dia,t_cont,id_curso,tipo){
	//alert(t_cont);
	resetVariable();
	if(tipo){
		setVariable("page","home/agenda_L");
	}else{
		setVariable("id_curso",id_curso);
		setVariable("fpage","intranet/agenda_L");
	}
	setVariable("anno",anno);
	setVariable("mes",mes);
	if(dia){
		setVariable("dia",dia);
	}
	setVariable("t_cont",t_cont);
	CargaComponente("listadoContenido");
}

function detalleAgenda(contenido_id,tipo){
	resetVariable();
	if(tipo){
		setVariable("page","home/agenda_D");
	}else{
		setVariable("fpage","intranet/agenda_D");
	}
	setVariable("contenido_id",contenido_id);
	CargaComponente("DivCuerpoF");
	cargaVentana("DivVentantaF","Detalle Actividad",550,230,310,250);
}

//FIN FUNCIONES AGENDA//

//FUNCION CAMBIA CURSO//
function changeCurso(){
	//alert('siii');
	cur=document.getElementById("curso_asig").value;
	//alert(cur);
	window.location.href="./?seccion_id=INTRANET_F&unidad=0&id_curso="+cur;	
	
}
//FIN FUNCION CAMBIA CURSO//

//CARGAR FORMULARIO//
function cargarFormulario(id){
	//alert(id);
	var contenedor="despliega_formulario";
	ajax.resetData();
	ajax.setVar("page","home/formulario");
	ajax.setVar("print","1");
	ajax.setVar("id_formulario",id);
	ajax.requestFile = "./";
	ajax.method = 'GET';
	ajax.element = contenedor;
	ajax.onLoading = whenLoading;
	ajax.onLoaded = whenLoaded; 
	ajax.onInteractive = whenInteractive;
	ajax.onCompletion = whenCompleted;
	ajax.runAJAX();
	
	document.getElementById(contenedor).style.position = "absolute";
	document.getElementById(contenedor).style.zindex = "5000";
	document.getElementById(contenedor).style.height = "550px";
	document.getElementById(contenedor).style.width = "458px";
	document.getElementById(contenedor).style.top = "120px";
	document.getElementById(contenedor).style.left = (document.body.clientWidth/2-230)+'px';
	document.getElementById(contenedor).style.display = "block";
}
//FIN CARGAR FORMULARIO

function FormularioContenido(anno,mes,dia,t_cont){
	alert(t_cont);
	document.getElementById('listadoContenido').style.height = "370";
	document.getElementById('listadoContenido').style.width = "460";
	document.getElementById('listadoContenido').style.top = "50";
	document.getElementById('listadoContenido').style.left = document.body.clientWidth/2-200;
	document.getElementById('listadoContenido').style.position = "absolute";
	document.getElementById('listadoContenido').style.display = "block";
	document.getElementById('listadoContenido').src = "./?page=home/agenda_L&unidad=0&print=1&t_cont="+t_cont+"&anno="+anno+"&mes="+mes+"&dia="+dia;

}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//MUESTRA EL SHOWRROM DE VIVIENDA//
function load_vivienda(id){
	resetVariable();
	setVariable("vivienda_id",id);
	setVariable("fpage","home/contenido_vivienda");
	CargaComponente("FRONTMAIN");
}
