//	############ Declare ############
var ContentCarDetails;
var PanelCarpicker;
var PanelCarpickerLoading;
var PanelEquipment;
var PanelEquipmentLoading;
var PanelReservation;
var PanelComplete;
var PickupDropMenu;
var PickupTextfield;
var DeliveryDropMenu;
var DeliveryTextfield;
var WaitBackground;
var WaitForeground;
var PanelDone;

//	This value will be setted by reservation.php
var currentCarId = -1;
var panelVisible = false;

//	Interval (timer)
var Timer;

//	Allow send
var allowSend = false;
var sendActive = false;
var blinkField0 = false;
var blinkField0Time = -1;
var blinkField1 = false;
var blinkField1Time = -1;
var blinkField2 = false;
var blinkField2Time = -1;




//	############ Initialize ############
//	Set up objects
function SiteReservation_Initialize()
{
	//	Set object reference
	ContentCarDetails = document.getElementById("div_ContentCarDetails");
	
	//	Set object reference
	PanelCarpicker = document.getElementById("div_PanelCarpicker");
	
	//	Set object reference
	PanelCarpickerLoading = document.getElementById("div_PanelCarpickerLoading");
	
	//	Set object reference
	PanelEquipment = document.getElementById("div_PanelEquipment");
	
	//	Set object reference
	PanelEquipmentLoading = document.getElementById("div_PanelEquipmentLoading");
	
	//	Set object reference
	PanelReservation = document.getElementById("div_PanelReservation");
	
	//	Set object reference
	PanelComplete = document.getElementById("div_PanelComplete");
	
	//	Set object reference
	PickupDropMenu = document.getElementById("div_PanelReservation_PickupDropMenu");
	
	//	Set object reference
	PickupTextfield = document.getElementById("div_PanelReservation_PickupText");
	
	//	Set object reference
	ReturnDropMenu = document.getElementById("div_PanelReservation_ReturnDropMenu");
	
	//	Set object reference
	ReturnTextfield = document.getElementById("div_PanelReservation_ReturnText");
	
	//	Set object reference
	WaitBackground = document.getElementById("div_WaitBackground");
	
	//	Set object reference
	WaitForeground = document.getElementById("div_WaitForegroundground");
	
	//	Set object reference
	PanelDone = document.getElementById("div_PanelDone");
}




//	############ Common ############
//	Change car id
function ChangeCarId(ParamId)
{
	//	Change car id
	currentCarId = ParamId;
}

//	Button date picker start clicked
function ShowDatePicker(ParamControl)
{
	//	Set browser details
	SetBrowserDetails();
	
	//	Position x, y
	var posX = 0;
	var posY = 0;
	
	//	Continue if firefox
	if (firefox)
	{
		//	Set position x
		posX = browserPosX + ((browserWidth - 380) / 2);
		
		//	Set position y
		posY = (browserPosY + browserHeight - viewportheight - 75) + ((viewportheight - 145) / 2);
	}
	//	Continue if ie
	else
	{
		//	Set position x
		posX = browserPosX + ((viewportwidth - 430) / 2);
		
		//	Set position y
		posY = browserPosY + ((viewportheight - 145 - 80) / 2);
	}
	
	//	Create popup window
	var popupWindow = window.open("modules/window_datepicker.php?ShowControl=" + ParamControl, "window_reservation", "xpos=" + posX + ", ypos=" + posY + ", xoffset=0, yoffset=0 ,name='window_reservation', scrollbars='no', resizable='no', status='no', location='no', toolbar='no', directories='no, menubar='no', width=215, height=145");

	//	Move popup window
	popupWindow.moveTo(posX, posY);
	
	//	Focus popup window
	popupWindow.focus();
}

//	Clip first zero chars
function ClipFirstZero(ParamString)
{
	//	Parse string
	for (i = 0; i < ParamString.length; i++)
	{
		//	Get char
		var Char = ParamString.slice(i, i + 1);
		
		if (Char != "0")
		{
			ParamString = ParamString.slice(i, ParamString.length);
			break;
		}
	}
	
	return ParamString;
}

//	Proofe if a string is plain numeric
function IsNumeric(ParamString)
{
	if (ParamString.length > 0)
	{
		//	Parse string
		for (i = 0; i < ParamString.length; i++)
		{
			//	Get char
			var char = ParamString.slice(i, i + 1);
			
			//	Continue if char is a number
			if (char == "1" || char == "2" || char == "3" || char == "4" || char == "5" || char == "6" || char == "7" || char == "8" || char == "9" || char == "0")
			{
				//	Continue ...	
			}
			//	Continue if char is everything elese
			else
				return false;
		}
		
		return true;
	}
	else
		return false;
}




//	############ Panel reservation  ############


//	############ Button pick car functions ############
//	Button pick car clicked
function ButtonPickcarClicked()
{
	//	Continue if both car picker panels are hidden
	if (PanelCarpickerLoading.style.display == "none" && PanelCarpicker.style.display == "none")
	{
		//	Panel visible
		panelVisible = true;
		
		//	Change image
		document.getElementById("PanelReservation_CarButton").src = "graphics/content/panel_reservation/button_switchright.png";
		
		//	Change image
		document.getElementById("PanelReservation_EquipmentButton").src = "graphics/content/panel_reservation/button_switchleft.png";
		
		//	Hide division content car details
		HideDiv(ContentCarDetails);
		
		//	Hide panel equipment loading
		HideDiv(PanelEquipmentLoading);
		
		//	Hide panel equipment
		HideDiv(PanelEquipment);
		
		//	Show panel car picker loading
		ShowDiv(PanelCarpickerLoading);
		
		//	Parse reservation
		parent.iframe_reservation.location.href = "modules/reservation.php?aid=1";
	}
	else
	{
		//	Panel visible
		panelVisible = false;
		
		//	Change image
		document.getElementById("PanelReservation_CarButton").src = "graphics/content/panel_reservation/button_switchleft.png";
		
		//	Hide division content car details
		HideDiv(PanelCarpickerLoading);
		
		//	Hide division content car details
		HideDiv(PanelCarpicker);
		
		//	Show panel car picker loading
		ShowDiv(ContentCarDetails);
	}
}

//	Button pick car mouse over
function ButtonPickcarMouseover()
{
	//	Change cursor
	ChangeCursor("pointer");
}

//	Button pick car mouse out
function ButtonPickcarMouseout()
{
	//	Change cursor
	ChangeCursor("default");
}


//	############ Button date picker start functions ############
//	Button date picker start clicked
function ButtonDatepickerStartClicked()
{
	//	Set date picker control
	ShowDatePicker(1);
}

//	Button date picker start mouse over
function ButtonDatepickerStartMouseover()
{
	//	Change cursor
	ChangeCursor("pointer");
}

//	Button date picker start mouse out
function ButtonDatepickerStartMouseout()
{
	//	Change cursor
	ChangeCursor("default");
}


//	############ Button date picker end functions ############
//	Button date picker end clicked
function ButtonDatepickerEndClicked()
{
	//	Set date picker control
	ShowDatePicker(2);
}

//	Button date picker end mouse over
function ButtonDatepickerEndMouseover()
{
	//	Change cursor
	ChangeCursor("pointer");
}

//	Button date picker end mouse out
function ButtonDatepickerEndMouseout()
{
	//	Change cursor
	ChangeCursor("default");
}


//	############ Button next step functions ############
//	Button next step clicked
function ButtonNextstepClicked()
{
	//	Hide div
	HideDiv(PanelReservation);
	
	//	Change image
	document.getElementById("PanelReservation_CarButton").src = "graphics/content/panel_reservation/button_switchleft.png";
	
	//	Hide div
	HideDiv(PanelCarpickerLoading);
	
	//	Hide div
	HideDiv(PanelCarpicker);
	
	//	Change image
	document.getElementById("PanelReservation_EquipmentButton").src = "graphics/content/panel_reservation/button_switchleft.png";
	
	//	Hide div
	HideDiv(PanelEquipmentLoading);
	
	//	Hide div
	HideDiv(PanelEquipment);
	
	//	Show div
	ShowDiv(ContentCarDetails);
	
	//	Initialize and start timer
	Timer = window.setInterval("ValidatorInterval()", 1000);
	
	//	Show div
	ShowDiv(div_PanelComplete);
	
	//	Focus first textfield
	document.site_form.PanelComplete_Name.focus();
}

//	Button next step mouse over
function ButtonNextstepMouseover()
{
	//	Change cursor
	ChangeCursor("pointer");
}

//	Button next step mouse out
function ButtonNextstepMouseout()
{
	//	Change cursor
	ChangeCursor("default");
}


//	############ Button equipment functions ############
//	Button equipment clicked
function ButtonEquipmentClicked()
{
	//	Continue if both equipment panels are hidden
	if (PanelEquipmentLoading.style.display == "none" && PanelEquipment.style.display == "none")
	{
		//	Panel visible
		panelVisible = true;
		
		//	Change image
		document.getElementById("PanelReservation_EquipmentButton").src = "graphics/content/panel_reservation/button_switchright.png";
		
		//	Change image
		document.getElementById("PanelReservation_CarButton").src = "graphics/content/panel_reservation/button_switchleft.png";
		
		//	Hide division content car details
		HideDiv(ContentCarDetails);
		
		//	Hide panel car picker loading
		HideDiv(PanelCarpickerLoading);
		
		//	Hide panel car picker
		HideDiv(PanelCarpicker);
		
		//	Show panel car picker loading
		ShowDiv(PanelEquipmentLoading);
		
		//	Parse reservation
		parent.iframe_reservation.location.href = "modules/reservation.php?aid=2";
	}
	else
	{
		//	Panel visible
		panelVisible = false;
		
		//	Change image
		document.getElementById("PanelReservation_EquipmentButton").src = "graphics/content/panel_reservation/button_switchleft.png";
		
		//	Hide division content car details
		HideDiv(PanelEquipmentLoading);
		
		//	Hide division content car details
		HideDiv(PanelEquipment);
		
		//	Show panel car picker loading
		ShowDiv(ContentCarDetails);
	}
}

//	Button equipment mouse over
function ButtonEquipmentMouseover()
{
	//	Change cursor
	ChangeCursor("pointer");
}

//	Button equipment mouse out
function ButtonEquipmentMouseout()
{
	//	Change cursor
	ChangeCursor("default");
}

//	Button equipment clicked
function ButtonEquipmentCloseClicked()
{
	//	Panel visible
	panelVisible = false;
	
	//	Change image
	document.getElementById("PanelReservation_EquipmentButton").src = "graphics/content/panel_reservation/button_switchleft.png";
	
	//	Hide division content car details
	HideDiv(PanelEquipmentLoading);
	
	//	Hide division content car details
	HideDiv(PanelEquipment);
	
	//	Show panel car picker loading
	ShowDiv(ContentCarDetails);
}


//	############ Drop down menus  ############
//	Drop down menu start hour changed
function DropdownStarthourChanged()
{
	//	Get value of drop down menu
	var timeChanged = document.site_form.PanelReservation_StartHour.options[document.site_form.PanelReservation_StartHour.selectedIndex].value;
	
	//	Create location href strting
	var loactionHref = 'modules/reservation.php?aid=7&time_res_start_hours=' + timeChanged;
	
	//	Continue if panel car picker is visible
	if (PanelCarpicker.style.display == 'block' || PanelCarpickerLoading.style.display == 'block')
	{
		//	Hide panel
		HideDiv(PanelCarpicker);
		
		//	Show panel
		ShowDiv(PanelCarpickerLoading);
		
		//	Add det value to location href string
		loactionHref += '&ApplyCarpickerRefresh=true';
	}

	//	Parse reservation
	parent.iframe_reservation.location.href = loactionHref;
}

//	Drop down menu start minute changed
function DropdownStartminuteChanged()
{
	//	Get value of drop down menu
	var timeChanged = document.site_form.PanelReservation_StartMinute.options[document.site_form.PanelReservation_StartMinute.selectedIndex].value;
	
	//	Create location href strting
	var loactionHref = 'modules/reservation.php?aid=8&time_res_start_minutes=' + timeChanged;
	
	//	Continue if panel car picker is visible
	if (PanelCarpicker.style.display == 'block' || PanelCarpickerLoading.style.display == 'block')
	{
		//	Hide panel
		HideDiv(PanelCarpicker);
		
		//	Show panel
		ShowDiv(PanelCarpickerLoading);
		
		//	Add det value to location href string
		loactionHref += '&ApplyCarpickerRefresh=true';
	}

	//	Parse reservation
	parent.iframe_reservation.location.href = loactionHref;
}

//	Drop down menu end hour changed
function DropdownEndhourChanged()
{
	//	Get value of drop down menu
	var timeChanged = document.site_form.PanelReservation_EndHour.options[document.site_form.PanelReservation_EndHour.selectedIndex].value;
	
	//	Create location href strting
	var loactionHref = 'modules/reservation.php?aid=9&time_res_end_hours=' + timeChanged;
	
	//	Continue if panel car picker is visible
	if (PanelCarpicker.style.display == 'block' || PanelCarpickerLoading.style.display == 'block')
	{
		//	Hide panel
		HideDiv(PanelCarpicker);
		
		//	Show panel
		ShowDiv(PanelCarpickerLoading);
		
		//	Add det value to location href string
		loactionHref += '&ApplyCarpickerRefresh=true';
	}

	//	Parse reservation
	parent.iframe_reservation.location.href = loactionHref;
}

//	Drop down menu end minute changed
function DropdownEndminuteChanged()
{
	//	Get value of drop down menu
	var timeChanged = document.site_form.PanelReservation_EndMinute.options[document.site_form.PanelReservation_EndMinute.selectedIndex].value;
	
	//	Create location href strting
	var loactionHref = 'modules/reservation.php?aid=10&time_res_end_minutes=' + timeChanged;
	
	//	Continue if panel car picker is visible
	if (PanelCarpicker.style.display == 'block' || PanelCarpickerLoading.style.display == 'block')
	{
		//	Hide panel
		HideDiv(PanelCarpicker);
		
		//	Show panel
		ShowDiv(PanelCarpickerLoading);
		
		//	Add det value to location href string
		loactionHref += '&ApplyCarpickerRefresh=true';
	}

	//	Parse reservation
	parent.iframe_reservation.location.href = loactionHref;
}

//	Drop down menu Pickup
function DropdownPickupChanged()
{
	//	Get value of drop down menu
	var valueChanged = document.site_form.PanelReservation_Pickup.options[document.site_form.PanelReservation_Pickup.selectedIndex].value;
	
	//	Create location href strting
	var loactionHref = 'modules/reservation.php?aid=11&res_location_start=' + valueChanged;

	//	Parse reservation
	parent.iframe_reservation.location.href = loactionHref;
}

//	Drop down menu return
function DropdownReturnChanged()
{
	//	Get value of drop down menu
	var valueChanged = document.site_form.PanelReservation_Return.options[document.site_form.PanelReservation_Return.selectedIndex].value;
	
	//	Create location href strting
	var loactionHref = 'modules/reservation.php?aid=14&res_location_end=' + valueChanged;

	//	Parse reservation
	parent.iframe_reservation.location.href = loactionHref;
}

//	Drop down menu insurance
function DropdownInsuranceChanged()
{
	//	Get value of drop down menu
	var valueChanged = document.site_form.PanelReservation_Insurance.options[document.site_form.PanelReservation_Insurance.selectedIndex].value;
	
	var res_sbvk_reduce = false;
	var res_sbvk_zero = false;
		
	if (valueChanged == 1)
	{
		res_sbvk_reduce = true;
	}
	else if (valueChanged == 2)
	{
		res_sbvk_reduce = true;
		res_sbvk_zero = true;
	}	
	
	//	Create location href strting
	var loactionHref = 'modules/reservation.php?aid=17&res_sbvk_reduce=' + res_sbvk_reduce + '&res_sbvk_zero=' + res_sbvk_zero;

	//	Parse reservation
	parent.iframe_reservation.location.href = loactionHref;
}


//	############ Checkboxes  ############
//	Checkbox delivery changed
function CheckboxDeliveryChanged()
{
	//	Get value of drop down menu
	var valueChanged = document.site_form.PanelReservation_DeliveryCheckbox.checked;
	
	//	Create location href strting
	var loactionHref = 'modules/reservation.php?aid=12&res_delivery_start=' + valueChanged;
	
	//	Parse reservation
	parent.iframe_reservation.location.href = loactionHref;
}

//	Checkbox pickup changed
function CheckboxPickupChanged()
{
	//	Get value of drop down menu
	var valueChanged = document.site_form.PanelReservation_PickupCheckbox.checked;
	
	//	Create location href strting
	var loactionHref = 'modules/reservation.php?aid=15&res_delivery_end=' + valueChanged;
	
	//	Parse reservation
	parent.iframe_reservation.location.href = loactionHref;
}


//	############ Textfields  ############
//	Textfield delivery lost focus
function TextfieldDeliveryLostFocus()
{
	//	Get value of drop down menu
	var valueChanged = document.site_form.PanelReservation_Delivery.value;
	
	//	Create location href strting
	var loactionHref = 'modules/reservation.php?aid=13&res_delivery_start_adress=' + valueChanged;
	
	//	Parse reservation
	parent.iframe_reservation.location.href = loactionHref;
}

//	Textfield pick up lost focus
function TextfieldPickupLostFocus()
{
	//	Get value of drop down menu
	var valueChanged = document.site_form.PanelReservation_PickupService.value;
	
	//	Create location href strting
	var loactionHref = 'modules/reservation.php?aid=16&res_delivery_end_adress=' + valueChanged;
	
	//	Parse reservation
	parent.iframe_reservation.location.href = loactionHref;
}

//	Textfield delivery focus
function TextfieldKilometersFocus()
{
	document.getElementById("PanelReservation_KilometersTextSpan").style.display = "none";
	document.getElementById("PanelReservation_KilometersButtonSpan").style.display = "block";
	document.site_form.PanelReservation_Kilometers.focus();
	document.site_form.PanelReservation_Kilometers.select();
}

//	Textfield delivery lost focus
function TextfieldKilometersLostFocus()
{
	document.getElementById("PanelReservation_KilometersTextSpan").style.display = "block";
	document.getElementById("PanelReservation_KilometersButtonSpan").style.display = "none";
	
	//	Get value of drop down menu
	var valueChanged = document.site_form.PanelReservation_Kilometers.value;
	
	//	Clip first zero chars
	valueChanged = ClipFirstZero(valueChanged);
	
	//	Replace value if itīs not numeric
	valueChanged = IsNumeric(valueChanged) ? valueChanged : 100;
	
	//	Kilometers not less than 100
	valueChanged = valueChanged < 100 ? 100 : valueChanged;
	
	//	Set slider value (site_slider.js)
	SetSliderByValue(valueChanged);
	
	//	Create location href strting
	var loactionHref = 'modules/reservation.php?aid=19&res_mileage=' + valueChanged;
	
	//	Continue if panel car picker is visible
	if (PanelCarpicker.style.display == 'block' || PanelCarpickerLoading.style.display == 'block')
	{
		//	Hide panel
		HideDiv(PanelCarpicker);
		
		//	Show panel
		ShowDiv(PanelCarpickerLoading);
		
		//	Add det value to location href string
		loactionHref += '&ApplyCarpickerRefresh=true';
	}

	//	Parse reservation
	parent.iframe_reservation.location.href = loactionHref;
}




//	############ Panel car picker  ############


//	############ Panel car picker items functions ############
//	Car picker item mouse over
function CarpickerItemMouseOver(ParamId)
{
	//	Continue if panel is visible
	if (panelVisible)
	{
		//	Change cursor
		ChangeCursor("pointer");
		
		//	Parse preview
		parent.iframe_reservation.location.href = "modules/reservation.php?aid=3&selected_car=" + ParamId;
	}
}

//	Car picker item mouse out
function CarpickerItemMouseOut()
{
	//	Continue if panel is visible
	if (panelVisible)
	{
		//	Change cursor
		ChangeCursor("default");
		
		//	Parse current
		parent.iframe_reservation.location.href = "modules/reservation.php?aid=3&selected_car=" + currentCarId;
	}
}

//	Car picker item mouse over
function CarpickerItemClicked(ParamId)
{
	//	Continue if panel is visible
	if (panelVisible)
	{
		//	Panel visible
		panelVisible = false;
		
		//	Change image
		document.getElementById("PanelReservation_CarButton").src = "graphics/content/panel_reservation/button_switchleft.png";
		
		//	Change cursor
		ChangeCursor("default");
		
		//	Parse preview
		parent.iframe_reservation.location.href = "modules/reservation.php?aid=4&selected_car=" + ParamId;
	}
}




//	############ Panel equipment  ############


//	############ Panel equipment textfields ############
//	Textfield nav changed
function TextfieldNavChanged()
{
	//	Get value of drop down menu
	var valueChanged = document.site_form.PanelEquipment_Nav.checked;
	
	//	Create location href strting
	var loactionHref = 'modules/reservation.php?aid=18&res_acc_1_quantity=' + (document.site_form.PanelEquipment_Nav.checked ? "1" : "0");

	//	Parse reservation
	parent.iframe_reservation.location.href = loactionHref;
}

//	Textfield navigation system focus
function TextfieldBoxFocus()
{
	//	Enable button
	document.site_form.PanelEquipment_BoxButton.disabled = false;
	
	//	Select value of textfield
	document.site_form.PanelEquipment_Box.select();
	
	//	Focus textfield again
	document.site_form.PanelEquipment_Box.focus();
}

//	Textfield box lost focus
function TextfieldBoxLostFocus()
{
	document.site_form.PanelEquipment_BoxButton.disabled = true;
	
	//	Get value of drop down menu
	var valueChanged = document.site_form.PanelEquipment_Box.value;
	
	//	Clip first zero chars
	valueChanged = ClipFirstZero(valueChanged);
	
	//	Replace value if itīs not numeric
	valueChanged = IsNumeric(valueChanged) ? valueChanged : 0;
	
	//	Create location href strting
	var loactionHref = 'modules/reservation.php?aid=18&res_acc_2_quantity=' + valueChanged;
	
	//	Parse reservation
	parent.iframe_reservation.location.href = loactionHref;
}

//	Textfield navigation system focus
function TextfieldBlanketFocus()
{
	//	Enable button
	document.site_form.PanelEquipment_BlanketButton.disabled = false;
	
	//	Select value of textfield
	document.site_form.PanelEquipment_Blanket.select();
	
	//	Focus textfield again
	document.site_form.PanelEquipment_Blanket.focus();
}

//	Textfield blanket lost focus
function TextfieldBlanketLostFocus()
{
	document.site_form.PanelEquipment_BlanketButton.disabled = true;
	
	//	Get value of drop down menu
	var valueChanged = document.site_form.PanelEquipment_Blanket.value;
	
	//	Clip first zero chars
	valueChanged = ClipFirstZero(valueChanged);
	
	//	Replace value if itīs not numeric
	valueChanged = IsNumeric(valueChanged) ? valueChanged : 0;
	
	//	Create location href strting
	var loactionHref = 'modules/reservation.php?aid=18&res_acc_3_quantity=' + valueChanged;
	
	//	Parse reservation
	parent.iframe_reservation.location.href = loactionHref;
}

//	Textfield navigation system focus
function TextfieldBeltAFocus()
{
	//	Enable button
	document.site_form.PanelEquipment_BeltAButton.disabled = false;
	
	//	Select value of textfield
	document.site_form.PanelEquipment_BeltA.select();
	
	//	Focus textfield again
	document.site_form.PanelEquipment_BeltA.focus();
}

//	Textfield belt a lost focus
function TextfieldBeltALostFocus()
{
	document.site_form.PanelEquipment_BeltAButton.disabled = true;
	
	//	Get value of drop down menu
	var valueChanged = document.site_form.PanelEquipment_BeltA.value;
	
	//	Clip first zero chars
	valueChanged = ClipFirstZero(valueChanged);
	
	//	Replace value if itīs not numeric
	valueChanged = IsNumeric(valueChanged) ? valueChanged : 0;
	
	//	Create location href strting
	var loactionHref = 'modules/reservation.php?aid=18&res_acc_4_quantity=' + valueChanged;
	
	//	Parse reservation
	parent.iframe_reservation.location.href = loactionHref;
}

//	Textfield navigation system focus
function TextfieldBeltBFocus()
{
	//	Enable button
	document.site_form.PanelEquipment_BeltBButton.disabled = false;
	
	//	Select value of textfield
	document.site_form.PanelEquipment_BeltB.select();
	
	//	Focus textfield again
	document.site_form.PanelEquipment_BeltB.focus();
}

//	Textfield belt b lost focus
function TextfieldBeltBLostFocus()
{
	document.site_form.PanelEquipment_BeltBButton.disabled = true;
	
	//	Get value of drop down menu
	var valueChanged = document.site_form.PanelEquipment_BeltB.value;
	
	//	Clip first zero chars
	valueChanged = ClipFirstZero(valueChanged);
	
	//	Replace value if itīs not numeric
	valueChanged = IsNumeric(valueChanged) ? valueChanged : 0;
	
	//	Create location href strting
	var loactionHref = 'modules/reservation.php?aid=18&res_acc_5_quantity=' + valueChanged;
	
	//	Parse reservation
	parent.iframe_reservation.location.href = loactionHref;
}

//	Textfield navigation system focus
function TextfieldBarrowFocus()
{
	//	Enable button
	document.site_form.PanelEquipment_BarrowButton.disabled = false;
	
	//	Select value of textfield
	document.site_form.PanelEquipment_Barrow.select();
	
	//	Focus textfield again
	document.site_form.PanelEquipment_Barrow.focus();
}

//	Textfield barrow lost focus
function TextfieldBarrowLostFocus()
{
	document.site_form.PanelEquipment_BarrowButton.disabled = true;
	
	//	Get value of drop down menu
	var valueChanged = document.site_form.PanelEquipment_Barrow.value;
	
	//	Clip first zero chars
	valueChanged = ClipFirstZero(valueChanged);
	
	//	Replace value if itīs not numeric
	valueChanged = IsNumeric(valueChanged) ? valueChanged : 0;
	
	//	Create location href strting
	var loactionHref = 'modules/reservation.php?aid=18&res_acc_6_quantity=' + valueChanged;
	
	//	Parse reservation
	parent.iframe_reservation.location.href = loactionHref;
}

//	Textfield navigation system focus
function TextfieldCreeperFocus()
{
	//	Enable button
	document.site_form.PanelEquipment_CreeperButton.disabled = false;
	
	//	Select value of textfield
	document.site_form.PanelEquipment_Creeper.select();
	
	//	Focus textfield again
	document.site_form.PanelEquipment_Creeper.focus();
}

//	Textfield creeper lost focus
function TextfieldCreeperLostFocus()
{
	document.site_form.PanelEquipment_CreeperButton.disabled = true;
	
	//	Get value of drop down menu
	var valueChanged = document.site_form.PanelEquipment_Creeper.value;
	
	//	Clip first zero chars
	valueChanged = ClipFirstZero(valueChanged);
	
	//	Replace value if itīs not numeric
	valueChanged = IsNumeric(valueChanged) ? valueChanged : 0;
	
	//	Create location href strting
	var loactionHref = 'modules/reservation.php?aid=18&res_acc_7_quantity=' + valueChanged;
	
	//	Parse reservation
	parent.iframe_reservation.location.href = loactionHref;
}

//	Textfield snow tyre changed
function TextfieldSnowtyreChanged()
{
	//	Get value of drop down menu
	var valueChanged = document.site_form.PanelEquipment_Snowtyre.checked;
	
	//	Create location href strting
	var loactionHref = 'modules/reservation.php?aid=18&res_acc_8_quantity=' + (document.site_form.PanelEquipment_Snowtyre.checked ? "1" : "0");

	//	Parse reservation
	parent.iframe_reservation.location.href = loactionHref;
}




//	############ Panel complete  ############


//	############ Button back (panel complete) functions ############
//	Button back clicked
function ButtonBackClicked()
{
	//	Clear interval
	clearInterval(Timer); 
	
	//	Hide div
	HideDiv(div_PanelComplete);
	
	//	Show div
	ShowDiv(div_PanelReservation);
}

//	Button back mouse over
function ButtonBackMouseover()
{
	//	Change cursor
	ChangeCursor("pointer");
}

//	Button back mouse out
function ButtonBackMouseout()
{
	//	Change cursor
	ChangeCursor("default");
}


//	############ Button send (panel complete) functions ############
//	Button send clicked
function ButtonSendClicked()
{
	if (!sendActive)
	{
		//	Proofe textfields to send (... will set allowSend)
		ProofeSendTextfields();
		
		//	Send allowed
		if (allowSend)
		{
			WaitBackground.style.width = scrollWidth + "px";
			WaitBackground.style.height = scrollHeight + "px";
			
			
			//	Show wait div
			ShowDiv(WaitBackground);
			
			//	Show wait div
			ShowDiv(WaitForeground);
			
			//	Clear interval
			clearInterval(Timer); 
			
			//	Send active
			sendActive = true;

			//	Change image
			document.getElementById("PanelComplete_SendButton").src = "graphics/content/panel_complete/button_send_disabled.png";

			//	############ Send datas by post ############ 
			
			//	Action id
			AddPostToForm(20, "aid", "site_form");
			
			//	Name
			AddPostToForm(document.site_form.PanelComplete_Name.value, "send_order_name", "site_form");
			
			//	Street
			AddPostToForm(document.site_form.PanelComplete_Street.value, "send_order_street", "site_form");
			
			//	Code & City
			AddPostToForm(document.site_form.PanelComplete_Code.value + " " + document.site_form.PanelComplete_City.value, "send_order_location", "site_form");
			
			//	Phone
			AddPostToForm(document.site_form.PanelComplete_Phone.value, "send_order_telephone", "site_form");
			
			//	Email
			AddPostToForm(document.site_form.PanelComplete_Email.value, "send_order_email", "site_form");
			
			//	send_temp_delivery
			AddPostToForm(document.site_form.PanelReservation_Pickup.options[document.site_form.PanelReservation_Pickup.selectedIndex].text, "send_temp_delivery", "site_form");
			
			//	send_temp_return
			AddPostToForm(document.site_form.PanelReservation_Return.options[document.site_form.PanelReservation_Return.selectedIndex].text, "send_temp_return", "site_form");
			
			//	send_temp_insurance
			AddPostToForm(document.site_form.PanelReservation_Insurance.options[document.site_form.PanelReservation_Insurance.selectedIndex].text, "send_temp_insurance", "site_form");
			
			//	Submit form
			document.getElementById("site_form").submit();
			
			//	############ Send datas by post end ############ 
		}
		//	Send denied
		else
		{
			//	Already focused
			var alreadyFocused = false;
			
			var name = document.site_form.PanelComplete_Name.value;
			name = name.replace(".'/ /g'.",'');
			
			var email = document.site_form.PanelComplete_Phone.value;
			email = email.replace(".'/ /g'.",'');
			
			var phone = document.site_form.PanelComplete_Email.value;
			phone = phone.replace(".'/ /g'.",'');
			
			//	Field is empty
			if (name.length == 0)
			{
				//	Set border color
				document.site_form.PanelComplete_Name.style.borderColor = '#AA0000'
				
				//	Reset value
				document.site_form.PanelComplete_Name.value = "";
				
				//	Focus field
				document.site_form.PanelComplete_Name.focus();
				
				//	Set already focused true
				alreadyFocused = true;
				
				//	Set blink field 0
				blinkField0 = true;
			}
			
			//	Field is empty
			if (phone.length == 0)
			{
				//	Set border color
				document.site_form.PanelComplete_Phone.style.borderColor = '#AA0000'
				
				//	Reset value
				document.site_form.PanelComplete_Phone.value = "";
				
				if (!alreadyFocused)
				{
					//	Focus field
					document.site_form.PanelComplete_Phone.focus();
					
					//	Set already focused true
					alreadyFocused = true;
				}
				
				if (!blinkField0)
					//	Set blink field 1
					blinkField1 = true;
			}
		}
	}
}

//	Button send mouse over
function ButtonSendMouseover()
{
	if (allowSend)
		//	Change cursor
		ChangeCursor("pointer");
}

//	Button send mouse out
function ButtonSendMouseout()
{
	//	Change cursor
	ChangeCursor("default");
}


//	############ Panel complete functions ############
//	Validator interval (timer)
function ValidatorInterval()
{
	//	Proofe textfields to send
	ProofeSendTextfields();
	
	//	Blink textfields
	BlinkTextfields();
}

//	Proofe textfields to send
function ProofeSendTextfields()
{
	var name = document.site_form.PanelComplete_Name.value;
	name = name.replace(".'/ /g'.",'');
	
	var email = document.site_form.PanelComplete_Phone.value;
	email = email.replace(".'/ /g'.",'');
	
	var phone = document.site_form.PanelComplete_Email.value;
	phone = phone.replace(".'/ /g'.",'');
	
	//	Continue if fields are not empty after space clipping
	if (name.length > 0 && (email.length > 0 || phone.length > 0))
	{
		//	Allow send true
		allowSend = true;
		
		//	Change image
		document.getElementById("PanelComplete_SendButton").src = "graphics/content/panel_complete/button_send.png";
	}
	else
	{
		//	Allow send false
		allowSend = false;
		
		//	Change image
		document.getElementById("PanelComplete_SendButton").src = "graphics/content/panel_complete/button_send_disabled.png";
	}
}

//	Blink textfields
function BlinkTextfields()
{
	if (blinkField0)
	{
		blinkField0Time++;
		
		if (blinkField0Time == 0 || blinkField0Time == 2)
		{
			//	Set border color
			document.site_form.PanelComplete_Name.style.background = '#EE0000';
		}
		else if (blinkField0Time == 1 || blinkField0Time == 3)
		{
			//	Set border color
			document.site_form.PanelComplete_Name.style.background = '#FFFFFF';
			
			if (blinkField0Time == 3)
			{
				//	Set blink field 0
				blinkField0 = false;
				
				//	Set blink field 0 times
				blinkField0Time = -1;
			}
		}
	}
	
	if (blinkField1)
	{
		blinkField1Time++;
		
		if (blinkField1Time == 0 || blinkField1Time == 2)
		{
			//	Set border color
			document.site_form.PanelComplete_Phone.style.background = '#EE0000';
		}
		else if (blinkField1Time == 1 || blinkField1Time == 3)
		{
			//	Set border color
			document.site_form.PanelComplete_Phone.style.background = '#FFFFFF';
			
			if (blinkField1Time == 3)
			{
				//	Set blink field 1
				blinkField1 = false;
				
				//	Set blink field 1 times
				blinkField1Time = -1;
			}
		}
	}	
}




//	############ Panel done functions ############
//	Button print clicked
function PanelDone_FormSubmit(ParamForm, ParamTarget, ParamWidth, ParamHeight)
{
	if (!window.focus)
		return true;
	
	var popupWindow = window.open('', ParamTarget, 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,width=' + ParamWidth + ',height=' + ParamHeight + ',resizable=no,screenX=0,screenY=0');
	
	//window.open('', ParamTarget, 'height=200,width=400,scrollbars=yes');

	ParamForm.target=ParamTarget;
	
	var posX = 0;
	var posY = 0;
	
	if (firefox)
	{
		posX = (screenWidth - ParamWidth) / 2;
		posY = (screenHeight - ParamHeight) / 2;
	}
	else
	{
		posX = (screenWidth - ParamWidth) / 2;
		posY = (screenHeight - ParamHeight) / 2;
	}
	
	popupWindow.moveTo(posX, posY);
	
	return true;
}

//	Button print mouse over
function ButtonPrintMouseover()
{
	//	Change cursor
	ChangeCursor("pointer");
}

//	Button print mouse out
function ButtonPrintMouseout()
{
	//	Change cursor
	ChangeCursor("default");
}

//	Close clicked
function ButtonCloseMouseclicked()
{
	//	Reset values
	currentCarId = -1;
	panelVisible = false;
	allowSend = false;
	sendActive = false;
	blinkField0 = false;
	blinkField0Time = -1;
	blinkField1 = false;
	blinkField1Time = -1;
	blinkField2 = false;
	blinkField2Time = -1;
	
	//	Reset client address
	document.getElementById("PanelComplete_Name").value = "";
	document.getElementById("PanelComplete_Street").value = "";
	document.getElementById("PanelComplete_Code").value = "";
	document.getElementById("PanelComplete_City").value = "";
	document.getElementById("PanelComplete_Phone").value = "";
	document.getElementById("PanelComplete_Email").value = "";
	
	//	Hide panel
	HideDiv(PanelDone);
	
	//	Hide panel
	HideDiv(WaitBackground);	
	
	//	Common initialize
	SiteCommon_Initialize();
	
	//	Parse reservation
	parent.iframe_reservation.location.href = "modules/reservation.php";
}