// + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
// | Data: 2004-11-01                                            |
// + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
// | Por:  Fábio Marciano - Artes & Design Portal [4597]         |
// + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
// | Descrição:                                                  |
// | Funções comuns a todas as páginas do portal.                |
// | - PopUp                                                     |
// | - Validação de busca                                        |
// | - Alteração de Stylesheet                                   |
// | - Envio da notícia para comentário no Forum Estadão         |
// + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +

function PopUpAe()
{
	// DESCRIÇÃO DA FUNÇÃO:
	// Cria PopUp
	// ARGUMENTOS DA FUNÇÃO:
	// Argumento  0 = str	[Url destino]
	// Argumento  1 = str	[Nome da página]
	// Argumento  2 = int	[Largura]
	// Argumento  3 = int	[Altura]
	// Argumento  4 = bol	[Barra de Scroll]
	// Argumento  5 = bol	[Menu]
	// Argumento  6 = bol	[Barra de Ferramentas]
	// Argumento  7 = bol	[Barra de Status]
	// Argumento  8 = bol	[Barra de Diretórios]
	// Argumento  9 = bol	[Barra de Endereços]
	// Argumento 10 = bol	[Redimensionável]
	// Argumento 11 = bol	[Dependência]
	// SINTAXE:
	// javascript:PopUpAe(str URL,str NAME,int WIDTH,int HEIGHT,mixed ATTRIBUTES);
	var Page = arguments[0];
	var Name = arguments[1];
	var LenX = arguments[2];
	var LenY = arguments[3];
	Page != "" && Page != null ? Page = Page : Page = "/";
	Name != "" && Name != null ? Name = Name : Name = "PopUpAe";
	LenX != null && LenX >= 100 ? LenX = LenX : LenX = 640;
	LenY != null && LenY >= 100 ? LenY = LenY : LenY = 480;
	var PosX = (screen.width  / 2) - (LenX / 2);
	var PosY = (screen.height / 2) - (LenY / 2);
	var AttrString = new Array()
		AttrString[0] = "width=" + LenX
		AttrString[1] = "height=" + LenY
		AttrString[2] = "left=" + PosX
		AttrString[3] = "top=" + PosY
	var Attributes = new Array()
		Attributes[0] = "scrollbars"
		Attributes[1] = "menubar"
		Attributes[2] = "toolbar"
		Attributes[3] = "statusbar"
		Attributes[4] = "directories"
		Attributes[5] = "location"
		Attributes[6] = "resizable"
		Attributes[7] = "dependent"
	var AttrIdx = AttrString.length;
	for(i = 0; i < Attributes.length; i++)
	{
		var ArgIdx = parseInt(i) + AttrIdx;
		var ArgVal = arguments[ArgIdx];
		ArgVal != null ? ArgVal = ArgVal : ArgVal = 0;
		AttrString[ArgIdx] = Attributes[i] + "=" + ArgVal;
	}
	var Attributes = AttrString.join(",");
	window.open(Page, Name, Attributes);
	return void(0);
}

function consiste()
{
	// DESCRIÇÃO DA FUNÇÃO:
	// Valida Busca
	if(document.busca.palavra.value == "")
	{
		alert("Forneça o texto\npara a Busca.\n\n");
		document.busca.palavra.focus;
		return false;
	}
}

var Limit = 0;
function AlterCss()
{
	// DESCRIÇÃO DA FUNÇÃO:
	// Aumenta e diminui os valores dos textos
	// nos arquivos .css anexados ao arquivo e declarados no array ClsObj
	// ARGUMENTOS DA FUNÇÃO:
	// Argumento  0 = bol	[Modo + / -]
	// SOBRE O ESCOPO:
	// A variável [Limit] declarada anteriormente no escopo global,
	// é incrementada ou decrementada a partir desta função
	var MyMode = arguments[0];
	var MaxLen = 5;
	var MinLen = 0;
	var CssObj = document.styleSheets;
	var CssLen = CssObj.length;
	var LimCnt = 0;
	var ClsObj = new Array()
		ClsObj[0] = "NotTit"
		ClsObj[1] = "NotSin"
		ClsObj[2] = "NotTxt"
		ClsObj[3] = "NotAut"
		ClsObj[4] = "NotLeg"
		ClsObj[5] = "Indice"
		ClsObj[6] = "MaisNot"
		ClsObj[7] = "ChnDir"
		ClsObj[8] = "ChnEsq"
		ClsObj[9] = "ChnSin"
		ClsObj[10] = "ChnTit"
		ClsObj[11] = "SepIdx"
		ClsObj[12] = "Indiced"
		ClsObj[13] = "ihora"
		ClsObj[14] = "sinodiv"
		ClsObj[15] = "NotAuta"		
		ClsObj[15] = "lm"	
		
	for(i = 0; i < CssLen; i++)
	{
		var MyCss = CssObj[i];
		var MyRul = (document.all ? MyCss.rules : MyCss.cssRules);
		var Valid = MyCss.href != document.location && MyCss.href != "" ? true : false;
		if(Valid)
		{
			for(j = 0; j < MyRul.length; j++)
			{
				for(k = 0; k < ClsObj.length; k++)
				{
					var Classe = "#" + ClsObj[k];
					var ClsTxt = MyRul[j].selectorText;
					if(ClsTxt == Classe)
					{
						var MySize = MyRul[j].style.fontSize;
						if(MyMode > 0)
						{
							if(Limit < MaxLen)
							{
								MyRul[j].style.fontSize = (parseInt(MySize) + 1) + "px";
								LimCnt++;
							}
						}
						else
						{
							if(Limit > MinLen)
							{
								MyRul[j].style.fontSize = (parseInt(MySize) - 1) + "px";
								LimCnt++;
							}
						}
					}
				}
			}
			if(LimCnt > 0)
			{
				MyMode > 0 ? Limit++ : Limit--;
			}
		}
	}
	return void(0);
}

function Comentar()
{
	// DESCRIÇÃO DA FUNÇÃO:
	// Valida e submete o formulário do Forum Estadão
	// ARGUMENTOS DA FUNÇÃO:
	// Nenhum
	var MyFrm = document.forms['forum'];
	var MyUrl = document.location;
	if(MyUrl != "")
	{
		MyFrm.url.value = MyUrl;
		MyFrm.submit();
	}
	return void(0);
}
