var wgt_Height = 0;
var slide_direction_down = true; 
var currentH = 0;
var movableObjects = new Array();
var iframeresize;

//HybridMainModule.js
var sound = true;

var iframeids=["ifrmurl"]
var isBigFlash = 1;
var isloaded = 0;
var idInterval = 0;
//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="yes"

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers

window.onload = Document_OnLoad;
var flash;
var flashheader;
var flashsoundswf;
var section = '';
var isexplorer = 1;

var tFunc = "";


if (window.addEventListener)
window.addEventListener("load", resizeCaller, false)
else if (window.attachEvent)
window.attachEvent("onload", resizeCaller)
else
window.onload=resizeCaller



function Document_OnLoad()
{
	if(navigator.appName.indexOf("Microsoft") != -1)
	{
		flash = window.flashObject;
		flashheader = window.flashObjectHeader;
		flashsoundswf = window.soundswf;
		isexplorer = 1;
	}
	else
	{
		flash = window.document.flashObject;
		flashheader = window.document.flashObjectHeader;
		flashsoundswf = window.document.soundswf;
		isexplorer = 0;
	}
	
	if(isexplorer == 1)
	{
		flashheader.className = "hidden";
	}
	else
	{
		flashheader.width = "0";
		flashheader.height = "0";
	}
	
	document.getElementById("iframeurl").style.display = "none";
	
}

function resizeCaller() {
var dyniframe=new Array()
for (i=0; i<iframeids.length; i++){
if (document.getElementById)
resizeIframe(iframeids[i])
//reveal iframe for lower end browsers? (see var above):
if ((document.all || document.getElementById) && iframehide=="no"){
var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
tempobj.style.display="block"
}
}
}

function resizeIframe(frameid){
	var currentfr=document.getElementById(frameid)
	iframeresize = frameid;
	var sPageName


	if(navigator.appName.indexOf("Microsoft") != -1)
	{
		//alert(currentfr.Document.location.href);
		sPageName = currentfr.Document.location.href;
	}
	else
	{
		//alert(currentfr.contentDocument.location.href);
		sPageName = currentfr.contentDocument.location.href;		
	}
	
	if(sPageName.lastIndexOf("defaultflash") == -1)
	{
		if (currentfr && !window.opera){
		currentfr.style.display="block"
		if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
		{
			
			//tFunc = setTimeout("agrandadiv()", timeout);
			//var x = 0;
		//for(x=0; x<(currentfr.contentDocument.body.offsetHeight+FFextraHeight); x+ 50)
		//{
			currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight;
			wgt_Height = currentfr.contentDocument.body.offsetHeight+FFextraHeight;
			//currentfr.height = x;
//		}
		}
		else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
		{
//		var x = 0;
//		for(x=0; x<currentfr.Document.body.scrollHeight; x+ 50)
//		{
			currentfr.height = currentfr.Document.body.scrollHeight;
			wgt_Height = currentfr.Document.body.scrollHeight;
			//currentfr.height = x;
			//pause(10);
		//}
		}

		if (currentfr.addEventListener)
		currentfr.addEventListener("load", readjustIframe, false)
		else if (currentfr.attachEvent){
		currentfr.detachEvent("onload", readjustIframe) // Bug fix line
		currentfr.attachEvent("onload", readjustIframe)
		}
		}
	}
	else
	{
		agrandar();	
	}
	currentH = 0
//slide();
}

function readjustIframe(loadevt) {
var crossevt=(window.event)? event : loadevt
var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
if (iframeroot)
resizeIframe(iframeroot.id);
}

function loadintoIframe(iframeid, url){
if (document.getElementById)
document.getElementById(iframeid).src=url
}

function interiores(str_loaded) {
	//alert("js -> "+str_loaded);
	// ACA VA TU CODIGO PARA ESCONDER ESTE FLASH Y MOSTRAR EL OTRO
	//
	//document.getElementById('swf').style.display = 'none';
	isBigFlash = 0;
	
	if(isexplorer == 1)
	{
		flash.className = "hidden";
	}
	else
	{
		flash.width = "0";
		flash.height = "0";
	}

	if(isexplorer == 1)
	{
		flashheader.className = "show";
	}
	else
	{
		flashheader.width = "900";
		flashheader.height = "136";
	}

	document.getElementById("iframeurl").style.display = "none";
	document.getElementById("ifrmurl").src = path + str_loaded;
/*
	switch(str_loaded)
	{
		case arrPaginas[0]:
			document.getElementById("ifrmurl").style.width = iwidth;
			document.getElementById("ifrmurl").height = arrPaginasHeight[0];
			break;
		case arrPaginas[1]:
			document.getElementById("ifrmurl").style.width = iwidth;
			document.getElementById("ifrmurl").height = arrPaginasHeight[1];
			break;
		case arrPaginas[2]:
			document.getElementById("ifrmurl").style.width = iwidth;
			document.getElementById("ifrmurl").height = arrPaginasHeight[2];
			break;
		case arrPaginas[3]:
			document.getElementById("ifrmurl").style.width = iwidth;
			document.getElementById("ifrmurl").height = arrPaginasHeight[3];
			break;
		case arrPaginas[4]:
			document.getElementById("ifrmurl").style.width = iwidth;
			document.getElementById("ifrmurl").height = arrPaginasHeight[4];
			break;
		case arrPaginas[5]:
			document.getElementById("ifrmurl").style.width = iwidth;
			document.getElementById("ifrmurl").height = arrPaginasHeight[5];
			break;
		case arrPaginas[6]:
			document.getElementById("ifrmurl").style.width = iwidth;
			document.getElementById("ifrmurl").height = arrPaginasHeight[6];
			break;
		case arrPaginas[7]:
			document.getElementById("ifrmurl").style.width = iwidth;
			document.getElementById("ifrmurl").height = arrPaginasHeight[7];
			break;
		case arrPaginas[8]:
			document.getElementById("ifrmurl").style.width = iwidth;
			document.getElementById("ifrmurl").height = arrPaginasHeight[8];
			break;
		case arrPaginas[9]:
			document.getElementById("ifrmurl").style.width = iwidth;
			document.getElementById("ifrmurl").height = arrPaginasHeight[9];
			break;
		case arrPaginas[10]:
			document.getElementById("ifrmurl").style.width = iwidth;
			document.getElementById("ifrmurl").height = arrPaginasHeight[10];
			break;
		case arrPaginas[11]:
			document.getElementById("ifrmurl").style.width = iwidth;
			document.getElementById("ifrmurl").height = arrPaginasHeight[11];
			break;
		case arrPaginas[12]:
			document.getElementById("ifrmurl").style.width = iwidth;
			document.getElementById("ifrmurl").height = arrPaginasHeight[12];
			break;
		case arrPaginas[13]:
			document.getElementById("ifrmurl").style.width = iwidth;
			document.getElementById("ifrmurl").height = arrPaginasHeight[13];
			break;
		case arrPaginas[14]:
			document.getElementById("ifrmurl").style.width = iwidth;
			document.getElementById("ifrmurl").height = arrPaginasHeight[14];
			break;
		case arrPaginas[15]:
			document.getElementById("ifrmurl").style.width = iwidth;
			document.getElementById("ifrmurl").height = arrPaginasHeight[15];
			break;
		case arrPaginas[16]:
			document.getElementById("ifrmurl").style.width = iwidth;
			document.getElementById("ifrmurl").height = arrPaginasHeight[16];
			break;
		default:
			document.getElementById("ifrmurl").style.width = iwidth;
			document.getElementById("ifrmurl").style.height = iheight;
	}*/
	
	//document.getElementById('header').style.display = '';

	//flash.height = "100";
	//flash.agrandar_flash(str_loaded);
	section = str_loaded;
}
/*
function resizeIframe(frameid){
	var currentfr=document.getElementById(frameid)
	if (currentfr && !window.opera){
		currentfr.style.display="block"
		if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
		currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight;
		else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
		currentfr.height = currentfr.Document.body.scrollHeight;
		if (currentfr.addEventListener)
		currentfr.addEventListener("load", readjustIframe, false)
		else if (currentfr.attachEvent){
		currentfr.detachEvent("onload", readjustIframe) // Bug fix line
		currentfr.attachEvent("onload", readjustIframe)
}
}
}
*/
function changesize(sPageName)
{
	var str_loaded = "";
	if(isBigFlash == 0)
	{
		document.getElementById("iframeurl").style.display = "";
	}
	
	if(sPageName.lastIndexOf("/") != -1)
	{
		str_loaded = sPageName.substring(sPageName.lastIndexOf("/")+(sPageName.length-sPageName.lastIndexOf("/")), sPageName.lastIndexOf("/")+1);
//alert(str_loaded);
//alert(document.getElementById("ifrmurl").document.location.href);
//resizeIframe("ifrmurl");
				//document.getElementById("ifrmurl").height = document.getElementById("ifrmurl").document.body.offsetHeight + document.getElementById("ifrmurl").document.body.scrollHeight;
/*
			switch(str_loaded.toLowerCase())
			{
				case arrPaginas[0]:
					document.getElementById("ifrmurl").style.width = iwidth;
					document.getElementById("ifrmurl").height = arrPaginasHeight[0];
					break;
				case arrPaginas[1]:
					document.getElementById("ifrmurl").style.width = iwidth;
					document.getElementById("ifrmurl").height = arrPaginasHeight[1];
					break;
				case arrPaginas[2]:
					document.getElementById("ifrmurl").style.width = iwidth;
					document.getElementById("ifrmurl").height = arrPaginasHeight[2];
					break;
				case arrPaginas[3]:
					document.getElementById("ifrmurl").style.width = iwidth;
					document.getElementById("ifrmurl").height = arrPaginasHeight[3];
					break;
				case arrPaginas[4]:
					document.getElementById("ifrmurl").style.width = iwidth;
					document.getElementById("ifrmurl").height = arrPaginasHeight[4];
					break;
				case arrPaginas[5]:
					document.getElementById("ifrmurl").style.width = iwidth;
					document.getElementById("ifrmurl").height = arrPaginasHeight[5];
					break;
				case arrPaginas[6]:
					document.getElementById("ifrmurl").style.width = iwidth;
					document.getElementById("ifrmurl").height = arrPaginasHeight[6];
					break;
				case arrPaginas[7]:
					document.getElementById("ifrmurl").style.width = iwidth;
					document.getElementById("ifrmurl").height = arrPaginasHeight[7];
					break;
				case arrPaginas[8]:
					document.getElementById("ifrmurl").style.width = iwidth;
					document.getElementById("ifrmurl").height = arrPaginasHeight[8];
					break;
				case arrPaginas[9]:
					document.getElementById("ifrmurl").style.width = iwidth;
					document.getElementById("ifrmurl").height = arrPaginasHeight[9];
					break;
				case arrPaginas[10]:
					document.getElementById("ifrmurl").style.width = iwidth;
					document.getElementById("ifrmurl").height = arrPaginasHeight[10];
					break;
				case arrPaginas[11]:
					document.getElementById("ifrmurl").style.width = iwidth;
					document.getElementById("ifrmurl").height = arrPaginasHeight[11];
					break;
				case arrPaginas[12]:
					document.getElementById("ifrmurl").style.width = iwidth;
					document.getElementById("ifrmurl").height = arrPaginasHeight[12];
					break;
				case arrPaginas[13]:
					document.getElementById("ifrmurl").style.width = iwidth;
					document.getElementById("ifrmurl").height = arrPaginasHeight[13];
					break;
				case arrPaginas[14]:
					document.getElementById("ifrmurl").style.width = iwidth;
					document.getElementById("ifrmurl").height = arrPaginasHeight[14];
					break;
				case arrPaginas[15]:
					document.getElementById("ifrmurl").style.width = iwidth;
					document.getElementById("ifrmurl").height = arrPaginasHeight[15];
					break;
				case arrPaginas[16]:
					document.getElementById("ifrmurl").style.width = iwidth;
					document.getElementById("ifrmurl").height = arrPaginasHeight[16];
					break;
				default:
					document.getElementById("ifrmurl").style.width = iwidth;
					document.getElementById("ifrmurl").style.height = iheight;
			}*/
			section = str_loaded;
	}

}

function dame_str_loaded() {
	return (str_loaded);
}

function agrandar()
{
	//document.getElementById('swf').style.display = '';
	//document.getElementById('header').style.display = 'none'
	isBigFlash = 1;
	if(isexplorer == 1)
	{
		flash.className = "";
	}
	else
	{
		flash.width = "900";
		flash.height = "400";
	}
	
	document.getElementById("iframeurl").style.display = "none";
	//document.getElementById("ifrmurl").src = path + "blank.htm";
	
	if(isexplorer == 1)
	{
		flashheader.className = "hidden";
	}
	else
	{
		flashheader.width = "0";
		flashheader.height = "0";
	}
	flash.agrandar_flash(section);
}

function gointeriores(sPageName)
{
	//interiores(sPageName);
	clearInterval(idInterval);
	if(isloaded == 1)
	{
		if(isBigFlash == 1)
		{
			flash.achicar_flash(sPageName);
			//alert("achica Flash");
		}
		else
		{
			interiores(sPageName);
			//alert("achica");
		}
	}
}

function goagrandar()
{
	if(isBigFlash == 1)
	{
	}
	else
	{
		agrandar();
	}
}

function loaded()
{
	isloaded = 1;
	if(document.location.href.lastIndexOf("page=") != -1)
	{
		var str_loaded = "";
		var sPageName = document.location.href;
		
		if(sPageName.lastIndexOf("=") != -1)
		{
			str_loaded = sPageName.substring(sPageName.lastIndexOf("=")+(sPageName.length-sPageName.lastIndexOf("=")), sPageName.lastIndexOf("=")+1);
			//alert(str_loaded);
			idInterval = setInterval("gointeriores('" + str_loaded + "');",1000);
		}
	}
}

function offsound()
{
	if(sound == true)	
	{
		sound = false;
		flashsoundswf.mute();
	}
}

function onsound()
{
	if(sound == false)	
	{
		sound = true;
		flashsoundswf.on();
	}
}

function slide(){
	try{
		var fra = document.getElementById(iframeresize);			
		if (slide_direction_down && currentH < wgt_Height ){				
			currentH +=(wgt_Height/10);	
			if (currentH > wgt_Height ){
				currentH = wgt_Height;
			}	
			fra.style.height = currentH + "px";
			fra.height = currentH;			
			setTimeout('slide();',150);	
		}
		if (!slide_direction_down && currentH > 0){				
			currentH -=(wgt_Height/10);	
			if (currentH < 0 ){
				currentH =0;
			}	
						
			fra.style.height = currentH  + "px";					
			fra.height = currentH;
			setTimeout('slide();',150);							
		}	
		/*
		if (currentH == 0 ){
			document.getElementById('butimage').src=wgt_expand_img;
			document.getElementById('butimage').alt=wgt_expand_alt;		
		}
		if (currentH == wgt_Height){
			document.getElementById('butimage').src=wgt_collapse_img;
			document.getElementById('butimage').alt=wgt_collapse_alt;			
		}	*/
		// Set movable objects		
		if(!navigator.appName.match("Internet Explorer")){								
		}
		// 
		var movableTop = 0;
		for(i=0 ; i < movableObjects.length;i++){
			if(movableObjects[i] != null){
				movableTop = movableObectsTop[i] + currentH;	
				movableObjects[i].style.position = 'absolute';
				movableObjects[i].style.top = movableTop + 'px' ;
			}
		}	
	}catch(e){
		return;		
	}	
}