/* ==============================================================================
Code to solve the problem of double-click the flash elements in IE
============================================================================== */
var theObjects = document.getElementsByTagName("object"); 
for (var i = 0; i < theObjects.length; i++) 
{ 
	theObjects[i].outerHTML = theObjects[i].outerHTML; 
}
/* ============================================================================= */

/* ==============================================================================
FUNCTION:	OpenPopupWindow(winURL, winName, winFeatures)
- Opens a new browser window with the parameters passed into the function
============================================================================== */
function OpenPopupWindow(winURL, winName, winFeatures) 
{
	var objWin = window.open(winURL, winName, winFeatures);
	objWin.focus();
}

/* ==============================================================================
FUNCTION:	ResetForm()

	- Puts all the fields in the Form set to blank (empty)
============================================================================== */
function ResetForm()
{
	if(window.confirm("Tem a certeza que quer apagar todos os campos?"))
	{	
		var i;
		var theform;
		
		if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1)
		{
			theform = document.getElementById("GenericForm");
		}
		else {
			theform = document.forms["GenericForm"];
		}
		
		if (document.images)
		{
			for (i=0; i<theform.length; i++)
			{
				var tempobj = theform.elements[i];
				
				if (tempobj.type == "text")
				{
					eval(tempobj.value = "");
				}
				else if (tempobj.type == "checkbox")
				{
					eval(tempobj.checked = 0);
				}
				else if (tempobj.type == "select-one")
				{
					eval(tempobj.selectedIndex = 0);
				}
			}
		}
	}
}

/* ==============================================================================
FUNCTION:	CheckboxOnOff(fldChkboxObj)
INPUT:		fldChkboxObj - Checkbox Object to turn On or Off
RETURNS:		
============================================================================== */
function CheckboxOnOff(fldChkboxObj)
{
	var fldChkboxObj_src = fldChkboxObj.src;

	if (fldChkboxObj_src.match("checkbox_on.gif"))
		fldChkboxObj.src = "/images/checkbox_off.gif";
	else
		fldChkboxObj.src = "/images/checkbox_on.gif";
}

/* ==============================================================================
FUNCTION:	CheckboxOn_CheckboxOff(fldID, fldValue, fldChkboxOn, fldChkboxOff)
INPUT:		fldID - The ID of the field to be changed
				fldValue - String with the value to be assigned to the fldID
				fldChkboxOn - Checkbox to be turned On 
				fldChkboxOff - Checkbox to be turned Off
RETURNS:		
============================================================================== */
function CheckboxOn_CheckboxOff(fldID, fldValue, fldChkboxOn, fldChkboxOff)
{
	document.getElementById(fldID).value			= fldValue;
	document.getElementById(fldChkboxOn).src		= "/images/checkbox_on.gif";
	document.getElementById(fldChkboxOff).src		= "/images/checkbox_off.gif";
}

/* ==============================================================================
FUNCTION:	CheckboxChangeOnOff(fldID, fldValOn, fldValOff, fldChkbox)
INPUT:		fldID - The ID of the field to be changed
				fldValOn - Value to be assigned to the fldID when the Checkbox is On
				fldValOff - Value to be assigned to the fldID when the Checkbox is Off
				fldChkbox - Checkbox field that can be turned On or Off
RETURNS:		
============================================================================== */
function CheckboxChangeOnOff(fldID, fldValOn, fldValOff, fldChkbox)
{
	if (document.getElementById(fldID).value == fldValOn)
	{	
		document.getElementById(fldID).value		= fldValOff;
		document.getElementById(fldChkbox).src		= "/images/checkbox_off.gif";
	}
	else
	{
		document.getElementById(fldID).value		= fldValOn;
		document.getElementById(fldChkbox).src		= "/images/checkbox_on.gif";
	}
}

/* ==============================================================================
FUNCTION:	CheckboxOnOff_ShowHideDiv(fldID, fldVal, fldChkboxOn, fldChkboxOff, divObj, divDisplay)
INPUT:		fldID - The ID of the field to be changed
				fldVal - Value to be assigned to the fldID 
				fldChkboxOn - Checkbox to be turned On 
				fldChkboxOff - Checkbox to be turned Off				
				divObj - DIV Object to show or hide
				divDisplay - Attribute value to show or hide the DIV Object				
RETURNS:		
============================================================================== */
function CheckboxOnOff_ShowHideDiv(fldID, fldVal, fldChkboxOn, fldChkboxOff, divObj, divDisplay)
{
	document.getElementById(fldID).value					= fldVal;
	document.getElementById(fldChkboxOn).src 				= "/images/checkbox_on.gif";
	document.getElementById(fldChkboxOff).src 			= "/images/checkbox_off.gif";		
	document.getElementById(divObj).style.display		= divDisplay;
}

/*** Layer search engine: index.html *********************************************/
function ChangeLayers(layerId) 
{
	document.getElementById("search_aviao").style.display 					= "none";
	document.getElementById("search_hotel").style.display 					= "none";
	document.getElementById("search_ferias").style.display 					= "none";
	
	document.getElementById("right_table_aviao").style.background 			= "#FFFFFF";
	document.getElementById("right_table_hotel").style.background			= "#FFFFFF";
	document.getElementById("right_table_ferias").style.background			= "#FFFFFF";
	
	/*** os layers que faltam devem ser listados aqui usando o modelo em cima ***/
	
	var bgcolor = document.getElementById("table_" + layerId).style.background;
	
	document.getElementById("search_" + layerId).style.display 				= "block";
	document.getElementById("right_table_" + layerId).style.background	= bgcolor;
	
	//alert(bgcolor);
}

/* ==============================================================================
FUNCTION:	GetWeekDayText(weekday)
INPUT:		weekday - Value representing the day of the week 
				0 - Sunday (Domingo)
				1 - Monday (2ª feira) 
				3 - Tuesday (3ª feira) ...
RETURNS:		The text associated with the number of the day of the week
============================================================================== */
function GetWeekDayText(weekday)
{
	var arrWeekdays = new Array("Dom.", "Seg.", "Ter.", "Qua.", "Qui.", "Sex.", "Sáb.");

	return arrWeekdays[weekday];
}

/* ==============================================================================
FUNCTION:	GetMonthText(month)
INPUT:		month - Value representing the month 
				0 - January (Janeiro)
				1 - February (Fvereiro) 
				3 - March (Março) ...
RETURNS:		The text associated with the number of the month
============================================================================== */
function GetMonthText(month)
{
	var arrMonths = new Array("Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro");

	return arrMonths[month];
}


