﻿var ie = navigator.userAgent.toLowerCase().indexOf('msie') != -1;
var yuraAddedTop = 100;
function RequestStart()
{
	var divBackLoading = document.getElementById("divBackLoading");
	var divFrontLoading = document.getElementById("divFrontLoading");

	var _bodyElement = ie ? document.body : document.documentElement;
	window.innerHeight = 0;
	divBackLoading.style.width = _bodyElement.clientWidth + 'px';
	window.innerHeight = window.innerHeight ? window.innerHeight-46 : document.documentElement.clientHeight-46;
	bodyheight = 0;
	var bodyheight = window.innerHeight > _bodyElement.offsetHeight ? window.innerHeight-46 : _bodyElement.offsetHeight-46; /* kills safari bug */
	divBackLoading.style.height = (bodyheight) + 'px';

	divBackLoading.style.top = "0px";
	divBackLoading.style.left = "0px";

	divBackLoading.style.display = "none";

	divFrontLoading.style.display = "block";

	//divFrontLoading.style.left = (_bodyElement.clientWidth - divFrontLoading.offsetWidth) / 2 + 'px';
	var location_windoe = "";
	location_windoe = window.location.href;

	if (document.getElementById("landfId").value == "eng")
		divFrontLoading.style.left = '0px';
		
	else
		divFrontLoading.style.right = '0px';
	divFrontLoading.style.top = '178.5px';
	//divFrontLoading.style.top = yuraAddedTop + (document.documentElement.scrollTop + (window.innerHeight - divFrontLoading.offsetHeight) / 2) + 'px';

	if (!(location_windoe.indexOf('BookingEngine') > -1))
	{

		if (!(document.getElementById('landfId').value == 'eng'))
		{
			divFrontLoading.style.left = getwidth() / 2 - 100;
			divFrontLoading.style.right = '';
		}
		else
		{
			divFrontLoading.style.right = getwidth() / 2 - 100;
			divFrontLoading.style.left = '';
		}
		divFrontLoading.style.top = yuraAddedTop + (document.documentElement.scrollTop + (window.innerHeight - divFrontLoading.offsetHeight) / 2) + 'px';


	}
	else
	{
		divBackLoading.style.display = 'none';
	}

}

function getwidth()
{
	var winW = 630, winH = 460;
	if (document.body && document.body.offsetWidth)
	{
		winW = document.body.offsetWidth;
		winH = document.body.offsetHeight;
	}
	if (document.compatMode == 'CSS1Compat' &&
    document.documentElement &&
    document.documentElement.offsetWidth)
	{
		winW = document.documentElement.offsetWidth;
		winH = document.documentElement.offsetHeight;
	}
	if (window.innerWidth && window.innerHeight)
	{
		winW = window.innerWidth;
		winH = window.innerHeight;
	}
	return winW;

}

function ResponseEnd()
{
	var divBackLoading = document.getElementById("divBackLoading");
	var divFrontLoading = document.getElementById("divFrontLoading");
	divBackLoading.style.display = "none";
	divFrontLoading.style.display = "none";
}

window.onscroll = function ()
{
	if (!ie) ie = navigator.userAgent.toLowerCase().indexOf('msie') != -1;
	var divFrontLoading = document.getElementById("divFrontLoading");
	var _bodyElement = ie ? document.body : document.documentElement;
	try
	{
		window.innerHeight = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight;
		divFrontLoading.style.top = yuraAddedTop + (_bodyElement.scrollTop + window.innerHeight - divFrontLoading.offsetHeight) / 2 + 'px';
	}
	catch (err)
	{
	}
}
