/****************************/

/* Developed by MediaThread */

/* http://mtcrossmedia.com/ */

/*  Brandsite: Toyota RAV4  */

/****************************/



// Preload images

var img0 = new Image();

img0.src = 'imgs/catalogo-virtual-on.jpg';

var img1 = new Image();

img1.src = 'imgs/registracion-on.jpg';

var img2 = new Image();

img2.src = 'imgs/contactenos-on.jpg';

var img3 = new Image();

img3.src = 'imgs/amigo-on.jpg';

var img4 = new Image();

img4.src = 'imgs/regalos-on.jpg';

var img5 = new Image();

img5.src = 'imgs/dealers-on.jpg';



// Global Vars

var req;

var savedClr = "";

var msgDefault = "[ Nueva Toyota RAV4 ]";

var MSIE = navigator.userAgent.indexOf('MSIE')>=0?true:false;



var aMsg = new Array(6);

aMsg[0] = "Catálogo Virtual";

aMsg[1] = "Regístrese y reciba información preferencial";

aMsg[2] = "Contáctenos";

aMsg[3] = "Recomiende este sitio a un amigo";

aMsg[4] = "Wallpapers y Screensavers";

aMsg[5] = "Red de concesionarios Toyota";



// StatusBar por defecto

window.defaultStatus = msgDefault;



// --= Functions =-- \\

function g(n) {return document.getElementById(n);}



function contact() {

	var popup = '';

	popup=open('http://eventostoyota.com.ar/contacto/index.php?website=rav4', 'Contacto', 'scrollbars=no, width=550, height=400, status=no, menubar=no, location=no, resizable=no, scrollbars=no, hotkeys=no');

	popup.document.close();

}



function referer() {

	var popup = '';

	popup=open('http://eventostoyota.com.ar/webadmin/rav4/amigo.html', 'Recomendar', 'scrollbars=no, width=550, height=300, status=no, menubar=no, location=no, resizable=no, scrollbars=no, hotkeys=no');

	popup.document.close();

}



function gifts() {

	var popup = '';

	popup=open('regalos.html', 'Regalos', 'scrollbars=no, width=650, height=300, status=no, menubar=no, location=no, resizable=no, scrollbars=no, hotkeys=no');

	popup.document.close();

}



function register() {

	var popup = '';

	popup=open('http://eventostoyota.com.ar/webadmin/rav4/registrar.html', 'Registrar', 'width=750, height=450, status=no, menubar=no, location=no, resizable=no, scrollbars=yes, hotkeys=no');

	popup.document.close();

}



function dealerMap() {

	var popup = '';

	popup=open('http://www.eventostoyota.com.ar/mapa/mapa.html', 'Mapa', 'scrollbars=no, width=403, height=505, status=no, menubar=no, location=no, resizable=no, scrollbars=no, hotkeys=no');

	popup.document.close();

}



function popUpper(num, dest, title) {

	var popup = '';

	popup=open(dest, 'Detail'+num, 'scrollbars=yes, width=640, height=480, status=no, menubar=no, location=no, resizable=no, scrollbars=no, alwaysLowered=yes, hotkeys=no');

	popup.document.write("<html><head><title>Detalle: "+title+"</title><meta name='Developer' content='MediaThread'></head>");

	popup.document.write("<body style='margin: 0px; padding: 0px'><div align='center'><img src='"+dest+"' alt='Cargando ...' onClick='window.close()'></div></body></html>");

	popup.document.close();

	popup = '';

}



function thumbIn(src) {

	if (!MSIE) return;

	src.style.filter = '';

}



function thumbOut(src) {

	if (!MSIE) return;

	src.style.filter = 'gray alpha(opacity=80, style=0)';

}



function rollO(aSrc, num, flag) {

	var tImg = '';

	if (flag) {

		switch (num) {

			case 0:

				tImg = 'imgs/catalogo-virtual-on.jpg';

				break;
				
			case 1:

				tImg = 'imgs/registracion-on.jpg';

				break;

			case 2:

				tImg = 'imgs/contactenos-on.jpg';

				break;

			case 3:

				tImg = 'imgs/amigo-on.jpg';

				break;

			case 4:

				tImg = 'imgs/regalos-on.jpg';

				break;

			case 5:

				tImg = 'imgs/dealers-on.jpg';

				break;

		}

	} else {

		switch (num) {

		case 0:

				tImg = 'imgs/catalogo-virtual.jpg';

				break;

			case 1:

				tImg = 'imgs/registracion.jpg';

				break;

			case 2:

				tImg = 'imgs/contactenos.jpg';

				break;

			case 3:

				tImg = 'imgs/amigo.jpg';

				break;

			case 4:

				tImg = 'imgs/regalos.jpg';

				break;

			case 5:

				tImg = 'imgs/dealers.jpg';

				break;

		}

	}

	aSrc.src = tImg;

}



function showSubs() {

	g('ContentBox').style.display = 'block';

}



function hideSubs() {

	g('ContentBox').style.display = 'none';

}



function changeSub( num ) {

	var i=0;

	do {

		i+=1;

		if (g('Sub'+i)) g('Sub'+i).style.display = 'none';

		else break;

		if (g('Flash'+i)) g('Flash'+i).style.display = 'none';

		if (g('lnk'+i)) g('lnk'+i).style.color = '';

	} while (i<5);



	if (g('Sub'+num)) g('Sub'+num).style.display = 'block';

	if (g('Flash'+num)) g('Flash'+num).style.display = 'block';

	if (g('lnk'+num)) g('lnk'+num).style.color = '#BF6000';

}



function processReqChange() {

    if (req.readyState == 4) {

        if (req.status == 200) {

		if (req.responseText != "") {

			tTag = g('ContentBox');

			tTag.innerHTML = req.responseText;

			showSubs();

		} else {

			alert("Hubo un problema al tratar de contactar al servidor.");

		}

        } else {

        	alert("Hubo un problema al tratar de contactar al servidor.\nPor favor inténtelo nuevamente.");

        }

    }

}





function getData(url) {

    // Hide until new data is available

    hideSubs();

    if (window.XMLHttpRequest) {

        req = new XMLHttpRequest();

        req.onreadystatechange = processReqChange;

        req.open("GET", 'tables/'+url, true);

        req.send(null);

    } else if (window.ActiveXObject) {

        req = new ActiveXObject("Microsoft.XMLHTTP");

        if (req) {

            req.onreadystatechange = processReqChange;

            req.open("GET", 'tables/'+url, true);

            req.send();

        }

    }

}



function cellOver (src, color) {

	src.style.cursor = 'default';

	savedClr = src.style.backgroundColor;

	src.style.backgroundColor = color;

}



function cellOut (src) {

	src.style.backgroundColor = savedClr;

}



function cellClick (src) {

	if (!MSIE) return;

	var i = 0;

	do {

		var tTD = src.getElementsByTagName('TD')[i];

		if (tTD.style.backgroundColor.toUpperCase() == '#FFB56A') tTD.style.backgroundColor = '';

		else tTD.style.backgroundColor = '#FFB56A';

		i++;

	} while ( src.getElementsByTagName('TD')[i] );

}


