
//Copyright (c), 2001, Innovagency

NS=(document.layers && !document.all)?1:0
NS6=(document.getElementById && !document.all)?1:0


//******************************
// Rollover Imagens
//******************************

function MM_swapImgRestore() {
	var i,x,a=document.MM_sr;
	for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) {
	var p,i,x;
	if(!d) d=document;
	if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document;
		n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all) x=d.all[n];
	for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) {
		x = MM_findObj(n,d.layers[i].document);
	}
	if(!x && document.getElementById) x=document.getElementById(n);
	return x;
}

function MM_swapImage() {
	var i,j=0,x,a=MM_swapImage.arguments;
	document.MM_sr=new Array;
	for(i=0;i<(a.length-2);i+=3) {
		if ((x=MM_findObj(a[i]))!=null) {
			document.MM_sr[j++]=x;
			if(!x.oSrc) x.oSrc=x.src;
			x.src=a[i+2];
		};
	};
}


//******************************
// Popup
//******************************

function PopUpwithDimensions( sUrl_IN, iWidth_IN, iHeight_IN, bSCroll ) {
	var popWin;
	var winleft = (screen.width - iWidth_IN) / 2;
	var wintop = (screen.height - iHeight_IN) / 2;

	popWin = window.open( sUrl_IN, 'PopUpUCP','left=' + winleft + ',top=' + wintop + ',resizable=1,scrollbars=' + bSCroll + ',toolbar=0,menubar=0,width=' + iWidth_IN + ',height=' + iHeight_IN + ',');
}


// ---------------------------------------------- //
// Abre uma janela em popup						  //
// ---------------------------------------------- //

function NewWindow( sName, sUrl, iWidth, iHeight ) {
	var iLeft;
	var iTop;

	if ( screen.width > iWidth ) {
		iLeft = parseInt( ( screen.width - iWidth ) / 2 );
	} else {
		iLeft = 0
	}

	if ( screen.height > iHeight ) {
		iTop = parseInt( ( screen.height - iHeight ) / 2 );
	} else {
		iTop = 0
	}

	window.open( sUrl, sName, 'width=' + iWidth + ',height=' + iHeight + ',location=1,menubar=1,resizable=1,scrollbars=1,status=1,titlebar=1,toolbar=1,left=' + iLeft + ',top=' + iTop );
}

// ---------------------------------------------- //
// Abre uma janela simples em popup				  //
// ---------------------------------------------- //

function NewWindowSimple( sName, sUrl, iWidth, iHeight ) {
	var iLeft;
	var iTop;

	if ( screen.width > iWidth ) {
		iLeft = parseInt( ( screen.width - iWidth ) / 2 );
	} else {
		iLeft = 0
	}

	if ( screen.height > iHeight ) {
		iTop = parseInt( ( screen.height - iHeight ) / 2 );
	} else {
		iTop = 0
	}

	window.open( sUrl, sName, 'width=' + iWidth + ',height=' + iHeight + ',location=0,menubar=0,resizable=1,scrollbars=1,status=0,titlebar=0,toolbar=0,left=' + iLeft + ',top=' + iTop );
}


// ------------------------------------------------------------------- //
// Formata a dimensão de uma popup através das dimensões de uma imagem //
// ------------------------------------------------------------------- //

function FormatWindow( sPathImg_IN, sNameImg_IN, iHeight_IN ) {
	if( sPathImg_IN == "" ) {
		window.close();
	} else {
		var oIm = document.all( sNameImg_IN );
		var iWidth = oIm.width + 45;
		var iHeight;
		var iNewWindow = 0;

		if (iHeight_IN != 0)
		{
			iHeight = oIm.height + iHeight_IN;
		}
		else
		{
			iHeight = oIm.height + 140;
		}

		if( iWidth > 800 ) {
			iWidth = 800;
			//oIm.width = iWidth - 45;
			iNewWindow = 1;
		} else {
			if( iWidth < 248 ) {
				iWidth = iWidth + ( 248 - iWidth );
			}
		}

		if( iHeight > 600 ) {
			iHeight = 600;
			//oIm.height = iHeight - 140;
			iNewWindow = 1;
		}

		if (iNewWindow == 1) {
			var iLeft;
			var iTop;

			if ( screen.width > iWidth ) {
				iLeft = parseInt( ( screen.width - iWidth ) / 2 );
			} else {
				iLeft = 0
			}

			if ( screen.height > iHeight ) {
				iTop = parseInt( ( screen.height - iHeight ) / 2 );
			} else {
				iTop = 0
			}

			window.open( 'ucp_popup_00.asp?ok=1&img=' + sPathImg_IN, 'newWindow', 'width=' + iWidth + ',height=' + iHeight + ',resizable=1,scrollbars=1,left=' + iLeft + ',top=' + iTop );
			window.close()
		} else {
			window.resizeTo( iWidth, iHeight );
			window.moveTo( ( ( screen.width - iWidth ) / 2 ), ( ( screen.height - iHeight ) / 2 ) );
		}
	}
}


//******************************
// Show and Hide TD's
//******************************
var selectedTD='';

function ShowHideTD( sPrefix_IN, iPosition_IN ) {
	var elem;

	// IE
	if (document.all) {
		elem = document.all[sPrefix_IN + iPosition_IN];
	// Netscape 6
	} else if (document.getElementById) {
		elem = document.getElementById(sPrefix_IN + iPosition_IN);
	}

	if ( selectedTD == '' ) {
		elem.style.display = 'block';
	} else {
		if ( selectedTD != elem ) {
			selectedTD.style.display = 'none';
		}
		if ( elem.style.display == 'none' ) {
			elem.style.display = 'block';
		} else {
			elem.style.display = 'none';
		}
	}

	// IE
	if (document.all) {
		selectedTD = document.all[sPrefix_IN + iPosition_IN];
	// Netscape 6
	} else if (document.getElementById) {
		selectedTD = document.getElementById(sPrefix_IN + iPosition_IN);
	}
}


//*********************************************
// Javascript para redimensionamento de iframe
//*********************************************

function resize_iframe(real_height){
	document.getElementById("sizeframe").height=100; // required for Moz bug, value can be "", null, or integer
	document.getElementById("sizeframe").height=real_height;
}