﻿
function changeheight(Altura)
{
	umaDiv = document.getElementById("Layer1");

	if (Altura < '120')
	{
		umaDiv.style.height = '120px';
	}
	else
	{
		Altura += 3;
		umaDiv.style.height = Altura + 'px';    
	}
}

function replaceContentInnerHTML(contentID,inerHTML)
 {
        var content = document.getElementById(contentID);
        content.innerHTML = "";
        content.innerHTML = inerHTML;
 }

/* SkyScrapper */
function getSkyscrapper(src)
{
		document.getElementById('bufferSkyscrapper').src = src;
		document.getElementById('bufferSkyscrapper').onload = onLoadIF;
}

function onLoadIF()
{
	loadFinish('contentSkyscrapper', 'bufferSkyscrapper');
	initSkyscrapper();
}


function strReplace(str1, str2, str3)
{
	while(str1.indexOf(str2) != -1)
	{
		str1 = str1.replace(str2, str3);
	}
	return str1;
}

function GetOBJBy_ID(str,Iframe)
{
	if (BW.ns4)
		return document.layers[str];
	
	if (BW.ns6 || BW.gecko)
		return document.getElementById(str);
	
	if (BW.ie || BW.opera)
	{
		if(Iframe)
			return document.frames[str];
		return document.all[str];
	}
}

function DBGGln(str)
{
	DBGG(str + "\n");
}

function DBGG(str)
{
	var dbg = new DBG();
	if(dbg)
		dbg.DEBUG(str);
}

function DBG()
{
	this.debug = false;
	if(this.debug)
		this.caixaDebug = new GetOBJByID("DebugFloating");
	this.DEBUG = function(str)
		{
			if(this.debug && this.caixaDebug.objt)
				this.caixaDebug.objt.innerHTML = str.replace('\n','<br>') + this.caixaDebug.objt.innerHTML;
		};
}

function loadFinish(id1, id2)
{

	if(BW.ie)
	{
		if(BW.ie5 || BW.ie6)
			document.domain = dominioGlobal;
			
		try
		{
			if (GetOBJBy_ID(id2,true).document.domain != dominioGlobal)
				return 0;		
		}
		catch(exc)
		{		
			setTimeout("loadFinish('" + id1 + "','" + id2 + "');", 500);		
			return 0;
		}
	}

	var IFrame = GetOBJBy_ID(id2,true);

	var html;
	
	if (IFrame.contentDocument)// For NS6 , gecko?
		html = IFrame.contentDocument.body.innerHTML; 
	else if (IFrame.contentWindow)// For IE5.5 and IE6
		html = IFrame.contentWindow.document.body.innerHTML;
	else if (IFrame.document)// For IE5
		html = IFrame.document.body.innerHTML;
	else
		return 0;
	
	if(html=='')return;
		
	GetOBJBy_ID(id1,false).innerHTML = html;
}

//grafic debug function
function DBG_BORDER(start)
{
	if(start)
	{
		document.body.onmouseover = function(){event.srcElement.style.border = '1px solid #000000'};
		document.body.onmouseout = function(){event.srcElement.style.border = '0'};
	}
	else
	{
		document.body.onmouseover = null;
		document.body.onmouseout = null;
	}
}

// Function to resize Iframes
function iFrameSize(iframe) 
{
	document.domain = dominioGlobal;
	if(document.getElementById && !(document.all)) 
	{
		//NETSCAPE
		var h = document.getElementById(iframe).contentDocument.body.scrollHeight;
		var w = document.getElementById(iframe).contentDocument.body.scrollWidth;
		document.getElementById(iframe).style.height = (h + 20);
		
		if (iframe != "bufferAdvFilter")
			document.getElementById(iframe).style.width = (w + 20);
	}
	else if(document.all)
	{
		if (document.frames(iframe).innerHeight)
		{
			//Opera or other that support innerheigth
			document.getElementById(iframe).style.height = '966';			
		}
		else
		{
			if(BW.ie5 || BW.ie55)
				document.getElementById("bufferAdvFilter").style.height = '1230';
			else{
				h = document.frames(iframe).document.body.scrollHeight;
				w = document.frames(iframe).document.body.scrollWidth;
				
				document.getElementById(iframe).style.height = h ;
			}
		}
	} 	
}

function GetOBJByID(str)
{
	if (BW.ns4)
		this.objt = document.layers[str];
		
	if (BW.ns6)
		this.objt = document.getElementById(str);
		
	if (BW.ie || BW.opera)
		this.objt = document.getElementById(str);
	
	try
	{
		if(this.objt.style)
			this.style = this.objt.style;
		else
			this.style = this.objt;
	}
	catch(ex)
	{
		this.style = this.objt;
	}
}

function GetContentDocument(objIframe)
{
	var contentDocument;
	
	if (objIframe.contentDocument)
		contentDocument = objIframe.contentDocument; // For NS6
		
	else if (objIframe.contentWindow)
		contentDocument = objIframe.contentWindow.document; // For IE5.5 and IE6
		
	else if (objIframe.document)
		contentDocument = objIframe.document; // For IE5
	
	return contentDocument;
}