/*
Copyright (c) 2005 The Hertz Corporation
All Rights Reserved.  (Unpublished.)

The information contained herein is confidential and
proprietary to The Hertz Corporation and may not be
duplicated, disclosed to third parties, or used for any
purpose not expressly authorized by it.  Any unauthorized
use, duplication, or disclosure is prohibited by law.
*/


/*
PUPROSE:  Display an interstitial image over the image used to submit a form.

STEPS:		1.) Find the coordinates of the button used to submit a form.
			2.) Display the interstitial clock image over the button used to submit the form.
						**(using the coordinates found for the 'submit' button)**
			3.) Submit the form after the image is displayed over the 'submit' button.

*/

/*
****************************************************
This function finds the 'X' coordinate of the object
it is called on.
X - coordinate = Distance from the left
(i.e. X-coordinate of an image or div element)
****************************************************
*/
function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	
	return curleft;
}




/*
****************************************************
This function finds the 'Y' coordinate of the object
it is called on.
Y - coordinate = Distance from the top
(i.e. Y-coordinate of an image or div element)
****************************************************
*/

function findPosY(obj)
{
	var curtop = 0;
	var printstring = '';
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}




/*
**************************************************
This function sets an object's X-Y coordinates
to the ones found above. In this case, it will be
the interstitial clocks coordinates being set.
**************************************************
*/
function setXY(obj,lyr)
{
	var newX = findPosX(obj);
	var newY = findPosY(obj);
	if (lyr == 'clock') newX -= -10;
	var x = new getObj(lyr);
	x.style.top = newY + 'px';
	x.style.left = newX + 'px';
}

/*
***************************************************
This is a modified version of setXY(obj,lyr)
to force clock over continue button on the pdp 
overlay when coming from res conf page
***************************************************
*/

function setXYForResPDP(obj,lyr)
{
	var newX = findPosX(obj);
	var newY = findPosY(obj);
	if (lyr == 'clock') newX -= -10;
	var x = new getObj(lyr);
	
	if (obj.getAttribute("offsetWidth")){
	newX += -250;
	newY += -66;
	}
	else {	
	newX += -250;
	newY += -74;
	}
	

	x.style.top = newY + 'px';
	x.style.left = newX + 'px';
}

/*
**************************************************
The interstial clock is in a hidden div.
This function unhides the div & displays the clock 
**************************************************
*/
function show(divID,buttonID)
{
	if ((buttonID)&&(buttonID != "")){	
		var buttonObj = document.getElementById(buttonID);
		var transLayer = document.getElementById("invisibleLayer");
	
		transLayer.style.width = buttonObj.width;
		transLayer.style.height = buttonObj.height;

//	alert("Button Height = " + buttonObj.height + "\nButton Width = " + buttonObj.width + "\nLayer Height = " + transLayer.height + "\nLayer Width = " + transLayer.width);

	}
	
	if (document.getElementByID)
			document.getElementById(''+divID+'').innerHTML=html;
			document.getElementById(''+divID+'').style.visibility = 'visible';
}


/*
**************************************************
The interstial clock is in a hidden div.
This function hide the div & hide the clock 
**************************************************
*/
function hide(divID,buttonID)
{
	if ((buttonID)&&(buttonID != "")){	
		var buttonObj = document.getElementById(buttonID);
		var transLayer = document.getElementById("invisibleLayer");
	
		transLayer.style.width = buttonObj.width;
		transLayer.style.height = buttonObj.height;

//	alert("Button Height = " + buttonObj.height + "\nButton Width = " + buttonObj.width + "\nLayer Height = " + transLayer.height + "\nLayer Width = " + transLayer.width);

	}
	
	if (document.getElementByID)
			document.getElementById(''+divID+'').innerHTML=html;
			document.getElementById(''+divID+'').style.visibility = 'hidden';
}

/*
***************************************************
This is a modified version of show(divID,buttonID).
This calculates div width dynamically.
***************************************************
*/

function showOverlay(divID,buttonID)
{
	if ((buttonID)&&(buttonID != "")){	
		var buttonObj = document.getElementById(buttonID);
		var transLayer = document.getElementById("invisibleLayer");
		
		if(buttonObj.getAttribute("offsetWidth")){
			transLayer.style.width = buttonObj.getAttribute("offsetWidth");
			transLayer.style.height = buttonObj.getAttribute("offsetHeight");
		}else{
			transLayer.style.width="200px";
			transLayer.style.height="30px";
		}

	}
	
	if (document.getElementByID)
			document.getElementById(''+divID+'').innerHTML=html;
			document.getElementById(''+divID+'').style.visibility = 'visible';
}


/*
***************************************************
This is a modified version of show(divID,buttonID).
This calculates div width dynamically.
***************************************************
*/

function hideOverlay(divID,buttonID)
{
	if ((buttonID)&&(buttonID != "")){	
		var buttonObj = document.getElementById(buttonID);
		var transLayer = document.getElementById("invisibleLayer");
		
		if(buttonObj.getAttribute("offsetWidth")){
			transLayer.style.width = buttonObj.getAttribute("offsetWidth");
			transLayer.style.height = buttonObj.getAttribute("offsetHeight");
		}else{
			transLayer.style.width="200px";
			transLayer.style.height="30px";
		}

	}
	
	if (document.getElementByID)
			document.getElementById(''+divID+'').innerHTML=html;
			document.getElementById(''+divID+'').style.visibility = 'hidden';
}

/*
**************************************************
This function submits the form through the 'submit'
button which the clock appears over.
**************************************************
*/
function formSubmit(formName)
{
document.eval(formName).submit();
}
	



/*
**************************************************
This function allows you to call objects based on 
the unique name assigned to them.
**************************************************
*/

function getObj(name)
{
 if (document.getElementById)
 {
	   this.obj = document.getElementById(name);
	   this.style = document.getElementById(name).style;
 }
 else if (document.all)
 {
	   this.obj = document.all[name];
	   this.style = document.all[name].style;
 }
 else if (document.layers)
 {
	   if (document.layers[name])
	   {
	   	this.obj = document.layers[name];
	   	this.style = document.layers[name];
	   }
	   else
	   {
	    this.obj = document.layers.testP.layers[name];
	    this.style = document.layers.testP.layers[name];
	   }
 }
}

