//Include del archivo de configuracion.
document.write("<"+"script type='text/javascript' src='/global_parametros.js'><"+"/script>")

var ini = '';
var fin = '';
if (document.getElementById){
	ini = "document.getElementById('";
	fin = "')";
}
else {
	ini = 'document.all.';
	fin = '';
}


function showLang(){
	if (eval(ini+'slang'+fin+'.style.display == "none"')) {
		eval(ini+'slang'+fin+'.style.display="block"');
		eval(ini+'slang'+fin+'.style.position="absolute"');
	}
	else {
		eval(ini+'slang'+fin+'.style.display="none"');
	}

}
function chgStyle(obj){
	if (eval(ini+obj.id+fin+'.style.backgroundColor') == '#ffffff'){
		eval(ini+obj.id+fin+'.style.backgroundColor="#EEEEEE"');
	}
	else {
		eval(ini+obj.id+fin+'.style.backgroundColor="#FFFFFF"');
	}
}
function chgLang(lang) {
	var newUrl;
	var url = document.URL;

	/*
	*
	* Prueba para solucionar el tema del error
	* js al queres cambiar el lenguaje
	*
	* @autor:Matias Muñoz
	*
	* valor original :var parc = url.split("plenitas.com");
	*
	*/
	var parc;
	if ( hostName == "www.plenitas.com" || (hostName == "plenitas.com") )
	{
		var parc = url.split("plenitas.com");
	}
	else
	{
		var temp_test;
		var temp_test=hostName;
		var parc = url.split(temp_test);
	}		


	var doc = parc[1];
	var tmp = doc.split("/");
	
	dirs = new Array ("es","en","fr","de");

	//para toda la data generada en los directorios de idioma
	if (tmp.length == 3 && tmp[1]!='mt'){
		newUrl = "/"+dirs[lang-1]+"/"+tmp[2];			
	}
	//para todos los asp de la raiz
	else if (tmp.length == 2 && tmp[1] != '') {
		//Esto lo pregunto para el caso que sea en la raiz, una landing o la home solo con el /
		// Solo el /
		if (tmp[1] == '#'){
			newUrl = "/?lang="+lang;
		}
		//Las landings
		else if (tmp[1].indexOf('landple') == 0){
			if (tmp[1].indexOf("lang=") != -1){newUrl = "/"+tmp[1].substr(0,tmp[1].indexOf("lang=")+5)+lang;}
			else {newUrl = "/"+tmp[1].replace(/\#/,"")+"&lang="+lang;}
		}
		//todos los ASP de la raiz
		else {
			newUrl = "/"+tmp[1].substr(0,tmp[1].indexOf("lang=")+5)+lang;
		}
	}
	//para el directorio del mt
	else if (tmp.length == 3 && tmp[1] == 'mt') {
		newUrl = "/mt/"+tmp[2].substr(tmp[2].indexOf("/"),tmp[2].indexOf("lang=")+5)+lang;			
	}
	//para cualquier cosa extraña que surja
	else {
		newUrl = "/home.asp?lang="+lang;	
	}
	document.location.href=newUrl;
}

function getColor(){
	var seccion = 1;
	if (eval(ini+"rec_prin"+fin)){
		
			var color = eval(ini+"rec_prin"+fin+".style.background");
			var seccion;
			if (color == "#d8bf28"){seccion = 2;}
	}
	return(seccion);
}
function PopupImagenes(grupoImg,tpopup,lang)
{
	var l, t, w, h;
	t = screen.availHeight / 4;
	l = screen.availWidth / 4;
	w=430;
	h=410;
	if (tpopup == 1){
		tpopup = "&entidad=1";
		w=413;
		h=358;
	}
	else {tpopup = "";}
	window.open('/Visor.asp?grupo='+grupoImg+tpopup+'&lang='+lang, '_blank', 'scrollbars=no,width='+w+',height='+h+',top='+t +',left=' + l )
}

function PopUPMT(entidad, grupoImg)
{

	var l, t;
	t = screen.availHeight / 4;
	l = screen.availWidth / 4;	
	window.open('/Visor.asp?entidad='+ entidad +'&grupo='+grupoImg, '_blank', 'scrollbars=no,width=400,height=400,top='+t +',left=' + l )
}



function openMTVie(lang)
{
	//utiliza el protocolo http
	
	var l, t;
	t = screen.availHeight / 4;
	l = screen.availWidth / 4;	
	window.open('/mt_new/mtFormu.asp?lang='+lang, 'MT', 'scrollbars=yes,resizable=yes,width=600,height=400,top='+t +',left=' + l )
	//window.open('/mt/mtStep1.asp?lang='+lang, 'MT', 'scrollbars=yes,resizable=yes,width=600,height=400,top='+t +',left=' + l )
}


function openMT(lang,trat)
{
	var l, t;
	t = 10;
	l = screen.availWidth / 4;	

	//var hostName = window.location.hostname 
	if ( (hostName == "www.plenitas.com") || (hostName == "plenitas.com") )
	{
	window.open('https://www.plenitas.com/mt_uni/mtUniFor.asp?lang='+lang+'&trat='+trat, 'MT', 'scrollbars=yes,resizable=yes,width=600,height=650,top='+t +',left=' + l);		
	}
	else
	{
	window.open('http://' + hostName + '/mt_uni/mtUniFor.asp?lang='+lang+'&trat='+trat, 'MT', 'scrollbars=yes,resizable=yes,width=600,height=650,top='+t +',left=' + l);		
	}	
}


function openMT_ORD(lang)
{
	//utiliza el protocolo http
	
	var l, t;
	t = screen.availHeight / 4;
	l = screen.availWidth / 4;	
	window.open('/mt_ORD/mtFormu.asp?lang='+lang, 'MT', 'scrollbars=yes,resizable=yes,width=600,height=400,top='+t +',left=' + l )
}


//function openMT(lang)
//{
	//utiliza el protocolo http

//	var l, t, sitio;
//	var url = document.location.href;
//	t = screen.availHeight / 4;
//	l = screen.availWidth / 4;	
	
//	if (url.indexOf('www',0) > 0)		
//		window.open('http://www.plenitas.com/mt_new/mtFormu.asp?lang='+lang, 'MT', 'scrollbars=yes,resizable=yes,width=600,height=400,top='+t +',left=' + l);
//	else
//		window.open('/mt_new/mtFormu.asp?lang='+lang, 'MT', 'scrollbars=yes,resizable=yes,width=600,height=400,top='+t +',left=' + l);	
//}


function openContactVie(lang)
{
//	var l, t;
//	t = screen.availHeight / 4;
//	l = screen.availWidth / 4;	
//	window.open('/mt/contactoPle.asp?lang='+lang, 'CONTACT', 'scrollbars=yes,resizable=yes,width=600,height=400,top='+t +',left=' + l )
	
	document.URL  = '/mt/contactoPle.asp?lang='+lang
	//var hostName = window.location.hostname 
	//window.location.href = 'http://'+ hostName + '/mt_http/mtformu.asp?lang='+lang
	
}

function openContact(lang,trat)
{
	var l, t;
	t = 10;
	l = screen.availWidth / 4;	

	//window.open('http://www.plenitas.com/mt_uni/mtFormu.asp?lang='+lang+'&trat=0', 'MT', 'scrollbars=yes,resizable=yes,width=600,height=650,top='+t +',left=' + l);	

	//hostname var global del include
	//var hostName = window.location.hostname 
	if ( (hostName == "www.plenitas.com") || (hostName == "plenitas.com") )
	{
	//window.open('https://www.plenitas.com/mt_uni/mtUniFor.asp?lang='+lang+'&trat=0', 'MT', 'scrollbars=yes,resizable=yes,width=600,height=650,top='+t +',left=' + l);		
	window.open('https://www.plenitas.com/mt_uni/mtUniFor.asp?lang='+lang+'&trat='+trat, 'MT', 'scrollbars=yes,resizable=yes,width=600,height=650,top='+t +',left=' + l);		
	}
	else
	{
	//window.open('http://' + hostName + '/mt_uni/mtUniFor.asp?lang='+lang+'&trat=0', 'MT', 'scrollbars=yes,resizable=yes,width=600,height=650,top='+t +',left=' + l);		
	window.open('http://' + hostName + '/mt_uni/mtUniFor.asp?lang='+lang+'&trat='+trat, 'MT', 'scrollbars=yes,resizable=yes,width=600,height=650,top='+t +',left=' + l);		
	}	

}
