﻿

function Splash() {}

Splash.base_el = null;
Splash.logo_el = null;
Splash.text_el = null;

Splash.width = 505;
Splash.height = 145;

Splash.status = "Пожалуйста подождите пока приложение загрузится.";

Splash.start = function() {

    	window.status = this.status; 

	this.base_el = document.createElement('div');
	this.base_el.style.cssText = "position: absolute; border: 0px none; background: null; vertical-align: middle;";

	this.logo_el = document.createElement('img');
	this.logo_el.src = "http://static.okarta.ru/img/splashscreen.png";

	this.text_el = document.createElement('div');
	this.text_el.style.cssText = "position: absolute; left: 20px; top: 123px; font-family: 'arial'; color: #CEEED0; font-size: 14px; font-weight: normal; font-style: normal; white-space: nowrap;";
	this.text_el.innerHTML = "";

	this.base_el.appendChild(this.logo_el);
	this.base_el.appendChild(this.text_el);

	this.align2Center();
	window.onresize = function() { this.align2Center(); }

	document.body.appendChild(this.base_el);
};

Splash.setPosition = function(x, y) { this.base_el.style.left = x; this.base_el.style.top = y; };

Splash.align2Center = function() { 
	var x = parseInt((getClientWidth() - this.width)/2);
	var y = parseInt((getClientHeight() - this.height)/2);
	this.setPosition(x, y);
};

Splash.process = function(str, per) { this.text_el.innerHTML = per + "&nbsp;%&nbsp;&nbsp;" + str; };

Splash.end = function(str, per) {
    	this.base_el.style.display = 'none';
    	window.status = "";
};

function getClientWidth() {
  	return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}

function getClientHeight() {
  	return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}
