// Funcion generica para abrir ventanas
function A_AbreVentana(strLiga, intAncho, intAlto, strAttrs) {
	var strAtributos = "";
	if (intAncho != undefined) strAtributos += ("width=" + intAncho + ", height=" + intAlto);
	if (strAttrs != undefined) strAtributos += strAttrs;
	var intWndID = window.open(strLiga, "", strAtributos);
	if(intWndID!=null) intWndID.focus();
}

// Funcion generica para navegacion
function A_ProcesaClave(strClave){
	switch (strClave){
		case "PAIS":
			//alert("estoy en USA");
			//strLiga = "inicioUSA.asp?strPais=USA"
			strLiga = "paises.asp"
			location.href = strLiga;
		break;
		case "IGREEN_ES":
			strLiga = "http://www.interceramicgreen.com/MEX"
			var intVentana = window.open(strLiga);
			intVentana.focus();
		break;
		case "IGREEN_IN":
			strLiga = "http://www.interceramicgreen.com/USA"
			var intVentana = window.open(strLiga);
			intVentana.focus();
		break;
		case "POP_DECOR":
			strliga = "popups/decorados.htm";
			A_AbreVentana(strliga, 800, 600);
		break;
	}
}

//* 100419 JCV - Se agrega funcion para procesar ligas y abrir ventanas de Decorador DIGITAL*/
function A_ProcesaLigaDecDigital(intLen){
	//alert("Voy a decorador digital en idioma = "+intLen);
	if (intLen == 1){
		strLiga = "http://www.interceramic.degha.com/deghaweb/deghamlweb.htm?Idioma=0&lbhb=1";
		A_AbreVentana(strLiga, 810, 690);
	}
	else
		strLiga = "http://www.interceramicusa.degha.com/deghaweb/deghamlweb.php?Idioma=1&lbhb=1";
		A_AbreVentana(strLiga, 810, 690);
}

//* 100420 JCV - Se agrega funcion para procesar ligas y abrir ventanas de Decorador VIRTUAL*/
//* 100506 JCV - Se cambia funcion y se actualizan ligas de acuerdo a email recibido */
function A_ProcesaLigasDecVirtual(strPais, strTipo, intNumLiga){
	//alert("Pais = "+strPais+" | Tipo = "+strTipo+" | Numero liga = "+intNumLiga);
	if (strPais == "MEX")
		A_ProcesaLigasMEX(strTipo, intNumLiga);
	else
		A_ProcesaLigasUSA(strTipo, intNumLiga);
}

function A_ProcesaLigasMEX(strTipo, intNumLiga){
	//alert("estoy en MEX");
	switch (strTipo){
		case "HOG_COL":
			var strLigaBase = "http://www.webvdecor.com/clientsites/rlogin.asp?CatID=7&amp;Lang=es&amp;RUserID=1&amp;Prog=2&amp;FileName=%25custom%25interceramic_std/Project%20Templates/Designer%20Rooms/";
			var Proyecto = new Array (
			/*posicion 0*/"Bano%20Principal-17.v2t",
			/*posicion 1*/"Bano%20Principal-80.v2t",
			/*posicion 2*/"Medio%20Bano.v2t",
			/*posicion 3*/"Bano%20Rec%20Principal%2073-80.v2t",
			/*posicion 4*/"Sala%20Comedor%20Entrada.v2t",
			/*posicion 5*/"Decorado%20Muro%20Sala%20-%20Comedor.v2t",
			/*posicion 6*/"Cocina.v2t",
			/*posicion 7*/"Fachada.v2t"
			);
			//alert(Proyecto[intNumLiga-1]);
			var strLiga = strLigaBase + Proyecto[intNumLiga-1];
			A_AbreVentana(strLiga);
		break;
		case "HOG_PLA":
			var strLigaBase = "http://www.webvdecor.com/clientsites/rlogin.asp?CatID=7&amp;Lang=es&amp;RUserID=1&amp;Prog=1&amp;FileName=%25custom%25virtualdecor/data/Project%20Templates/general/";
			var strLigaProyecto5 = "http://www.webvdecor.com/clientsites/rlogin.asp?CatID=7&amp;Lang=es&amp;RUserID=1";
			var Proyecto = new Array (
			/*posicion 0*/"Rectangular%20Plan.v2t",
			/*posicion 1*/"L%20Plan.v2t",
			/*posicion 2*/"Double%20Square.v2t",
			/*posicion 3*/"U%20Plan.v2t",
			/*posicion 4*/""
			);
			//alert("Num Liga = "+intNumLiga + " | Proyecto = " + Proyecto [intNumLiga-1]);
			if (intNumLiga == 5){ 
				A_AbreVentana(strLigaProyecto5);
			}
			else {
				var strLiga = strLigaBase + Proyecto[intNumLiga-1];
				A_AbreVentana(strLiga);
			}
		break;
		case "PRO":
			var strLiga = "http://www.webvdecor.com/clientsites/rlogin.asp?CatID=23&amp;Lang=es&amp;RUserID=2";
			A_AbreVentana(strLiga);
		break;
	}
}
function A_ProcesaLigasUSA(strTipo, intNumLiga){
	//alert("estoy en USA");
	switch (strTipo){
		case "HOG_COL":
			var strLigaBase = "http://www.webvdecor.com/clientsites/rlogin.asp?CatID=60&amp;Lang=uk&amp;RUserID=3&amp;Prog=2&amp;FileName=%25custom%25interceramic_std/Project%20Templates/Designer%20Rooms/";
			var Proyecto = new Array (
			/*posicion 0*/"Bano%20Principal-17.v2t",
			/*posicion 1*/"Bano%20Principal-80.v2t",
			/*posicion 2*/"Medio%20Bano.v2t",
			/*posicion 3*/"Bano%20Rec%20Principal%2073-80.v2t",
			/*posicion 4*/"Sala%20Comedor%20Entrada.v2t",
			/*posicion 5*/"Decorado%20Muro%20Sala%20-%20Comedor.v2t",
			/*posicion 6*/"Cocina.v2t",
			/*posicion 7*/"Fachada.v2t"
			);
			//alert(Proyecto[intNumLiga-1]);
			var strLiga = strLigaBase + Proyecto[intNumLiga-1];
			A_AbreVentana(strLiga);
		break;
		case "HOG_PLA":
			var strLigaBase = "http://www.webvdecor.com/clientsites/rlogin.asp?CatID=60&amp;Lang=uk&amp;RUserID=3&amp;Prog=1&amp;FileName=%25custom%25virtualdecor/data/Project%20Templates/general/";
			var strLigaProyecto5 = "http://www.webvdecor.com/clientsites/rlogin.asp?CatID=60&amp;Lang=uk&amp;RUserID=3";
			var Proyecto = new Array (
			/*posicion 0*/"Rectangular%20Plan.v2t",
			/*posicion 1*/"L%20Plan.v2t",
			/*posicion 2*/"Double%20Square.v2t",
			/*posicion 3*/"U%20Plan.v2t",
			/*posicion 4*/""
			);
			//alert("Num Liga = "+intNumLiga + " | Proyecto = " + Proyecto [intNumLiga-1]);
			if (intNumLiga == 5){ 
				A_AbreVentana(strLigaProyecto5);
			}
			else {
				var strLiga = strLigaBase + Proyecto[intNumLiga-1];
				A_AbreVentana(strLiga);
			}
		break;
		case "PRO":
			var strLiga = "http://www.webvdecor.com/clientsites/rlogin.asp?CatID=58&amp;Lang=uk&amp;RUserID=4";
			A_AbreVentana(strLiga);
		break;
	}
}

// 100507 JCV - Funcion para mostrar mapas de tiendas
function A_ProcesaMapa(strLiga){
	//alert(strLiga);
	//A_AbreVentana(strLiga,  500, 500);
	var IntVent = window.open(strLiga,"mapatiendas","menubar=0,toolbar=0,location=0,status=0,resizable=0,titlebar=0,width=604,height=454")
	IntVent.focus();
}


// ====================================================================================
// JCV 101013 - Se agergan funciones para mostrar y ocultar layers


// resize fix for ns4
var origWidth, origHeight;
if (document.layers) {
	origWidth = window.innerWidth; origHeight = window.innerHeight;
	window.onresize = function() {
		if (window.innerWidth != origWidth || window.innerHeight != origHeight)
			history.go(0);
	}
}

var cur_lyr;	// holds id of currently visible layer
function swapLayers(id) {
	if (cur_lyr) hideLayer(cur_lyr);
	showLayer(id);
	cur_lyr = id;
}

function showLayer(id) {
	var lyr = getElemRefs(id);
	if (lyr && lyr.css) {
		lyr.css.visibility = "visible";
		lyr.css.display = "block"; /*Soporte para Mozilla Firefox - JCV 070924*/
	}
}

function hideLayer(id) {
	var lyr = getElemRefs(id);
	if (lyr && lyr.css) {
		lyr.css.visibility = "hidden";
		lyr.css.display = "none"; /*Soporte para Mozilla Firefox - JCV 070924*/
	}
}

function getElemRefs(id) {
	var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? getLyrRef(id,document): null;
	if (el) el.css = (el.style)? el.style: el;
	return el;
}

// get reference to nested layer for ns4
// from old dhtmllib.js by Mike Hall of www.brainjar.com
function getLyrRef(lyr,doc) {
	if (document.layers) {
		var theLyr;
		for (var i=0; i<doc.layers.length; i++) {
			theLyr = doc.layers[i];
			if (theLyr.name == lyr) return theLyr;
			else if (theLyr.document.layers.length > 0)
			if ((theLyr = getLyrRef(lyr,theLyr.document)) != null)
				return theLyr;
		}
		return null;
	}
}


//JCV 110414 - SE AGREGA FUNCION PARA DETECTAR BROWSER
if(typeof jsExa=="undefined"){var jsExa=new Object();}
if(typeof jsExa.Browser=="undefined"){jsExa.Browser=new Object();}
jsExa.Browser = function() {
    var intIdx = 0;
    var strUA = navigator.userAgent.toLowerCase();
    strUA = strUA.toLowerCase();
    this.appVersion = navigator.appVersion;
    this.appProduct = navigator.product;
    this.appPlatform = navigator.platform;
    this.appName = navigator.appName;
    this.appCodeName = navigator.appCodeName;
    this.intVer = 0;
    this.sngVer = 0;
    this.strVer = "";
    this.bolIE = false;
    this.bolNav = false;
    this.bolFF = false;
    this.bolSaf = false;
    this.bolWin32 = false;
    this.bolWin16 = false;
    this.bolUnix = false;
    this.bolLinux = false;
    this.bolMac = false;
    this.bolWinCE = false;
    this.bolChrome = false;
    //---  080218  HMO  Browser y version 
    if (strUA.indexOf("msie") != -1) {
        this.bolIE = true;
        this.strNom = "Microsoft Internet Explorer";
        this.strVer = strUA.substring(intIdx = strUA.indexOf("msie") + 5, strUA.indexOf(";", intIdx));
    }
    else
        if (strUA.indexOf("netscape6/") != -1 || strUA.indexOf("netscape/") != -1) {
        this.bolNav = true;
        this.strNom = "NETSCAPE";
        this.strVer = strUA.indexOf("netscape6/") != -1 ? strUA.split(' netscape6/')[1] : strUA.split(' netscape/')[1];
    }
    else
        if (strUA.indexOf("firefox/") != -1) {
        this.bolFF = true;
        this.strNom = "MOZILLA FIREFOX";
        this.strVer = strUA.split(' firefox/')[1];
    }
    else
        if (strUA.indexOf("chrome") != -1) {
        this.bolChrome = true;
        this.strNom = "GOOGLE CHROME";
        this.strVer = strUA.split(' chrome/')[1].split(' ')[0];
    }
    else
        if (strUA.indexOf("safari/") != -1) {
        this.bolSaf = true;
        this.strNom = "APPLE SAFARI";
        this.strVer = strUA.split(' safari/')[1];
    }
    else
        if (strUA.indexOf("opera") != -1) {
        this.bolOpe = true;
        this.strNom = "OPERA";
        //---  090729  HMO  Se corrige un problema al obtener la version, se tomaba strUA.agent cuando strUA es tan solamente un string...
        this.strVer = strUA.split('opera')[1].substring(1).split(' (')[0];
    }

    //---  080218  HMO  Plataforma...
    if (strUA.indexOf("windows 95") > 0 || strUA.indexOf("win95") != -1 || strUA.indexOf("win98") != -1 || strUA.indexOf("windows 98") != -1 || strUA.indexOf("windows nt") != -1) { this.bolWin32 = true; }
    else if (strUA.indexOf("windows 3.1") != -1 || strUA.indexOf("win16") != -1) { this.bolWin16 = true; }
    else if (strUA.indexOf("mac") != -1) { this.bolMac = true; }
    else if (strUA.indexOf("linux") != -1) { this.bolLinux = true; }
    else if (!this.bolLinux && (strUA.indexOf("sunos") != -1 || strUA.indexOf("hp-ux") != -1 || strUA.indexOf("x11") != -1)) { this.bolUnix = true; }
    else if (strUA.indexOf("windows ce") != -1) { this.bolWinCE = true; }

    this.sngVer = parseFloat(this.strVer);
    this.intVer = Math.floor(this.sngVer);
};
var objBC = new jsExa.Browser();
