function getTop(element) {
	var top = 0, absoluteAncestor = false, computedStyle = (document.defaultView && document.defaultView.getComputedStyle), currentStyle = (element.currentStyle);
//	so long as the element has an positioning context...
	while (element.offsetParent) {
//		add the top offset of the element
		top += element.offsetTop
//		set the element to the element which provided the positioning context
		element = element.offsetParent;
//		if the element hasLayout (IE-only property)
		if (currentStyle && element.currentStyle.hasLayout && (element.nodeName.toLowerCase() != 'html')) {
//			add the width of the top border
			top += element.clientTop;
//			and if it's absolutely positioned, flag that we've got an absolutely positioned ancestor
			if (element.currentStyle['position'] == 'absolute') {
				absoluteAncestor = true;
			}
//		otherwise, if it's a browser that supports computedStyle & the element is absolutely positioned
		} else if (computedStyle && document.defaultView.getComputedStyle(element, "").getPropertyValue('position') == 'absolute') {
//			add the top border of the element
			top += parseInt(document.defaultView.getComputedStyle(element, "").getPropertyValue('border-top-width'));
//			and flag that we've got an absolutely positioned ancestor
			absoluteAncestor = true;
		}
	}
//	if the browser supports currentStyle (i.e. is IE) and we found an absolutely positioned ancestor, add any top margin on the BODY
	if (!absoluteAncestor && currentStyle) { 
		return (top += document.getElementsByTagName('BODY')[0].offsetTop);
	}
//	otherwise, if we found an absolutely positioned ancestor and the browser supports computed style add any top border from the BODY
	else if (!absoluteAncestor && computedStyle) {
		top += parseInt(document.defaultView.getComputedStyle(document.getElementsByTagName('BODY')[0], "").getPropertyValue('border-top-width'));
	}
	
	return top;
}

function getLeft(element) {
	var left = 0, absoluteAncestor = false, computedStyle = (document.defaultView && document.defaultView.getComputedStyle), currentStyle = (element.currentStyle);
//	so long as the element has an positioning context...
	while (element.offsetParent) {
//		add the left offset of the element
		left += element.offsetLeft
//		set the element to the element which provided the positioning context
		element = element.offsetParent;
//		if the element hasLayout (IE-only property)
		if (currentStyle && element.currentStyle.hasLayout && (element.nodeName.toLowerCase() != 'html')) {
//			add the width of the left border
			left += element.clientLeft;
//			and if it's absolutely positioned, flag that we've got an absolutely positioned ancestor
			if (element.currentStyle['position'] == 'absolute') absoluteAncestor = true;
//		otherwise, if it's a browser that supports computedStyle & the element is absolutely positioned
		} else if (computedStyle && document.defaultView.getComputedStyle(element, "").getPropertyValue('position') == 'absolute') {
//			add the left border of the element
			left += parseInt(document.defaultView.getComputedStyle(element, "").getPropertyValue('border-left-width'));
//			and flag that we've got an absolutely positioned ancestor
			absoluteAncestor = true;
		}
	}
//	if the browser supports currentStyle (i.e. is IE) and we found an absolutely positioned ancestor, add any left margin on the BODY
	if (!absoluteAncestor && currentStyle) return left += document.getElementsByTagName('BODY')[0].offsetLeft;
//	otherwise, if we found an absolutely positioned ancestor and the browser supports computed style add any left border from the BODY
	else if (!absoluteAncestor && computedStyle) left += parseInt(document.defaultView.getComputedStyle(document.getElementsByTagName('BODY')[0], "").getPropertyValue('border-left-width'));
	return left;
}


function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}

function getWindowWidth() {
	var windowWidth = 0;
	if (typeof(window.innerWidth) == 'number') {
		windowWidth = window.innerWidth;
	}
	else {
		if (document.documentElement && document.documentElement.clientWidth) {
			windowWidth = document.documentElement.clientWidth;
		}
		else {
			if (document.body && document.body.clientWidth) {
				windowWidth = document.body.clientWidth;
			}
		}
	}
	return windowWidth;
}


//Muestra una capa con un mensaje de aviso
function LoadWarningPreviousInsuranceLayer(strLayerToShow, strOverlayLayer, blnShowWarningSantander) {
	
	//Solo vamos a mostrar la capa cuando haya pulsado sobre el botón de ver precios
	if (blnShowWarningSantander == false){
		//return;	
	}
	
	var verticalPosition = getTop(document.getElementById('img_posicion_contenido_flotante')); 		//Vertical position
	var horizontalPosition = getLeft(document.getElementById('img_posicion_contenido_flotante')); 	//Horizontal position
	var capa = document.getElementById(strLayerToShow);
	//verticalPosition = parseInt(verticalPosition) - parseInt(capa.style.height);
	if (blnSantanderOfSantander == true || blnSantanderOfBanesto == true ) {
		//El layer de oficinas es menos alto, así que hay que posicionarlo más abajo
		verticalPosition = parseInt(verticalPosition) - 105; //Restamos para subir la capa
	} else {
		verticalPosition = parseInt(verticalPosition) - 185; //Restamos para subir la capa	
	}
	
	//Posicionamos la capa
	capa.style.top = verticalPosition;
	capa.style.left = horizontalPosition;
	capa.style.position='absolute';

	capa.style.visibility='visible';
	capa.style.display='inline';
	
	//Colocamos el estilo
	capa.className = 'modal';
	
	
	/*	
	//CAMBIA EL ESTILO DE LA CAPA DE FONDO Y LA POSICIONA
	var fondo = document.getElementById(strOverlayLayer);
	fondo.className = 'overlay';
	var initPosition = getTop(window.document.getElementById('img_inicio_formulario_autos')); 
	var endPosition = getTop(window.document.getElementById('img_fin_formulario_autos'));
	var lngPaddingBottom = endPosition - initPosition ;
	document.getElementById(strOverlayLayer).style.height = lngPaddingBottom;
	*/
	
	return;
	
}


//Cierra la capa con el aviso
function UnloadWarningPreviousInsuranceLayer(strLayerToShow, strOverlayLayer, blnContinuar) {
	
	//Declaración de varibles
	var objLayer;
	
	objLayer = window.parent.document.getElementById(strLayerToShow);
	
	//Se oculta
	objLayer.style.visibility='hidden';
	objLayer.style.display='none';
	
	//El layer de fondo
	objLayer = window.parent.document.getElementById(strOverlayLayer);
	objLayer.className = '';

	//Si decide continuar sin rellenar validaremos los datos
	if (blnContinuar == true) {
		parent.window['blnShowLayerWarning'] = true;
		//Hay que hace el setObject
		window.parent.setObject('1');
		window.parent.AceptarClick(null,null,null,'false','false',null);
		window.parent.setObject('0');
		return;		
	} else {
		parent.window['blnShowLayerWarning'] = false;
	}
	
}