﻿/*
<!-------------------------------------------------------------------->
<!-- Copyrigth Infopar Informática Ltda.							-->
<!-- ===================================							-->
<!-- Rua José Farias, 98 sala 807									-->
<!-- 29.045-430 - Vitória - ES										-->
<!-- Brasil															-->
<!-- Telefax: 55 27 3235-1766										-->
<!-- infopar@infopar.com											-->
<!-------------------------------------------------------------------->
*/

var strArg = "";
var strURL = "";
var strAtivo = "";
var strModelo = "";

function onLoadRedirect(arg1,arg2)
{
	try
	{
		strArg = arg1;

		if (arg2 != null && arg2 != "" && arg2 != undefined)
		{
			switch (arg2.toLowerCase())
			{
				case "website":
				{
					strURL = "website/software/public/mod-a/index.html" + location.search;
					break;
				}

				case "portal":
				{
					strURL = "website/software/public/mod-b/index.html" + location.search;
					break;
				}

				case "curriculo":
				{
					strURL = "pub/gui/acesso/login/default.aspx?LGN=ALT";
					if (location.search != null && location.search != "" && location.search.length > 1)
					{
						strURL = strURL + "&" + location.search.substring(1);
					}
					break;
				}

				case "oportunidade":
				{
					strURL = "pub/gui/gadget/oportunidade/default.aspx" + location.search;
					break;
				}

				case "acompanhamento":
				{
					strURL = "pub/gui/acesso/login/default.aspx?LGN=RES";
					if (location.search != null && location.search != "" && location.search.length > 1)
					{
						strURL = strURL + "&" + location.search.substring(1);
					}
					break;
				}

				case "faleconosco":
				{
					strURL = "pub/gui/gadget/faleconosco/default.aspx" + location.search;
					break;
				}

				default:
				{
					loadXML();
					break;
				}
			}
		}
		else
		{
			loadXML();
		}

		if (strURL != null && strURL != "" && strURL != undefined)
		{
			loadPage();
		}
	}
	catch (e)
	{
		//alert("onLoadRedirect" + e);
	}
}

function loadXML()
{
	try
	{
		if (window.ActiveXObject)
		{
			xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
			xmlDoc.async = false;
			xmlDoc.load("website/software/public/config.xml");

			strAtivo = xmlDoc.selectSingleNode("DataSet/PAINELCONTROLE/SITEATIVO").text;
			strModelo = xmlDoc.selectSingleNode("DataSet/PAINELCONTROLE/MODELOSITE").text;

			startPage();
		}
		else if (document.implementation && document.implementation.createDocument)
		{
			xmlDoc = document.implementation.createDocument("","",null);
			xmlDoc.load("website/software/public/config.xml");
			xmlDoc.onload = readXML;
		}
	}
	catch (e)
	{
		//alert("startPage" + e);
	}
}

function readXML()
{
	try
	{
		strAtivo = xmlDoc.getElementsByTagName("SITEATIVO")[0].childNodes[0].nodeValue;
		strModelo = xmlDoc.getElementsByTagName("MODELOSITE")[0].childNodes[0].nodeValue;

		startPage();
	}
	catch (e)
	{
		//alert("readXML" + e);
	}
}

function startPage()
{
	try
	{
		if (strAtivo != 1)
		{
			strURL = "webpage_manutencao.html";
		}
		else
		{
			switch (strModelo)
			{
				case "1":
				{
					strURL = "website/software/public/mod-a/index.html" + location.search;					
					break;
				}

				case "2":
				{
					strURL = "website/software/public/mod-b/index.html" + location.search;
					break;
				}

				default:
				{
					strURL = "website/software/public/mod-a/index.html" + location.search;
					break;
				}
			}
		}
	}
	catch (e)
	{
		//alert("startPage" + e);
	}
}

function loadPage()
{
	try
	{
		if (strArg != null && strArg != "" && strArg != undefined)
		{
			switch (strArg.toLowerCase())
			{
				case "frame":
				{
					document.getElementById("container").src = strURL;
					break;
				}

				case "body":
				{
					location.href = strURL;
					break;
				}

				default:
				{
					location.href = strURL;
					break;
				}
			}
		}
		else
		{
			location.href = strURL;
		}
	}
	catch (e)
	{
		//alert("loadPage" + e);
	}
}
