//	############ Declare ############
var browserPosX = 0;
var browserPosY = 0;
var browserWidth = 0;
var browserHeight = 0;
var screenWidth = screen.width;
var screenHeight = screen.height;
var firefox =  document.all ? false : true;
var viewportwidth = 0;
var viewportheight = 0;
var scrollWidth = 0;
var scrollHeight = 0;

//	############ Events ############
//	Event handler onresize
function EventResize()
{
	//	Refresh browser details
	SetBrowserDetails();
	
	/*
	//	Set x position for centering loading division
	var posX = (browserWidth - 970) / 2;

	//	Decrement eight pixels, needed for firefox browsers
	posX = firefox ? posX -= 8 : posX;
	
	//	Center loading division
	SetDivPosition("div_Loading", posX, 212);
	* */
}


//	############ Common functions ############
//	Set browser details
function SetBrowserDetails()
{
	//	Continue if browser is firefox
	if (firefox)
	{
		browserPosX = window.screenX;
		browserPosY = window.screenY;
		browserWidth = window.outerWidth;
		browserHeight = window.outerHeight;
		scrollWidth = document.body.offsetWidth;
		scrollHeight = document.body.offsetHeight;
	}
	//	Continue if browser is internet explorer
	else
	{
		browserPosX = window.screenLeft;
		browserPosY = window.screenTop;
		//browserWidth = document.body.scrollWidth;
		//browserHeight = document.body.scrollHeight;
		browserWidth = 0;	//	Not possible with ie
		browserHeight = 0;
		scrollWidth = document.body.scrollWidth;
		scrollHeight = document.body.scrollHeight;
	}
	
	// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
	if (typeof window.innerWidth != 'undefined')
	{
		viewportwidth = window.innerWidth,
		viewportheight = window.innerHeight
	}
	
	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
	
	else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0)
	{
		 viewportwidth = document.documentElement.clientWidth,
		 viewportheight = document.documentElement.clientHeight
	}
	
	// older versions of IE
	
	else
	{
		 viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
		 viewportheight = document.getElementsByTagName('body')[0].clientHeight
	}
}

//	Show a site in a popup window
function ShowPopup(UrlLocation, Width, Height, PosX, PosY, Scrollbars)
{
	var popupWindow = window.open(UrlLocation,"_blank","toolbar=no,location=no,status=no,menubar=no,scrollbars=" + Scrollbars + ",width=" + Width + ",height=" + Height + ",resizable=no,screenX=0,screenY=0");

	popupWindow.moveTo(PosX, PosY);
}

//	Show a site in a popup window centered
function ShowPopupCentered(UrlLocation, Width, Height, Scrollbars)
{
	var posX = 0;
	
	if (firefox)
	{
		posX = ((browserWidth + browserPosX) - Width) / 2;
		posY = ((browserHeight + browserPosY) - Height) / 2;
	}
	else
	{
		posX = ((viewportwidth + browserPosX) - Width) / 2;
		posY = ((viewportheight + browserPosY) - Height) / 2;
	}
	
	ShowPopup(UrlLocation, Width, Height, posX, posY, Scrollbars)
}

//	Create post input object
function AddPostToForm(ParamValue, ParamName, ParamForm)
{
	//	Continue if object exist and delete it
	if (document.getElementById(ParamName))
		document.getElementById(ParamForm).removeChild(document.getElementById(ParamName));
	
	//	Create post object
	var postObject = document.createElement("INPUT");
	postObject.type = "hidden";
	postObject.value = ParamValue;
	postObject.name = ParamName;
	postObject.id = ParamName;
	document.getElementById(ParamForm).appendChild(postObject);
}


//	############ Div functions ############
//	Show div
function ShowDiv(ParamObject)
{
	//	Set object display style none
	ParamObject.style.display = "block";
}

//	Hide div
function HideDiv(ParamObject)
{
	//	Set object display style none
	ParamObject.style.display = "none";
}

//	Set div position
function SetDivPosition(ParamName, ParamX, ParamY)
{
	//	Create object reference
	var divObject = document.getElementById(ParamName);
	
	//	Set x position
	divObject.style.left = ParamX + "px";
	
	//	Set y position
	divObject.style.top = ParamY + "px";
}

//	Change cursor
function ChangeCursor(ParamName)
{
	//	Change cursor style
	document.body.style.cursor = ParamName;
}


//	############ Load ############
//	Site common initalize
function SiteCommon_Initialize()
{
	//	Initialize site reservation objects
	SiteReservation_Initialize();
	
	//	Initialize site slider objects
	Slider_Initialize();
	
	//	Process event resize function operations
	EventResize();
	
	//	Create onresize event handler
	window.onresize = EventResize;

	//	Show reservation panel
	ShowDiv(ContentCarDetails);
	
	//	Show reservation panel
	ShowDiv(PanelReservation);
}