// CLASS : DN_System_Load
// Init
function DN_System_Load(){
this.wib = screen.width;
this.heb = screen.height;
this.documes = (document.getElementById || document.createElement || document.getElementsByTagName) ? true : false;
this.objects = window.addEventListener || window.attachEvent ? window : document.addEventListener ? document : null;
this.types = 'load';
}
// ADDSEVENT
DN_System_Load.prototype.addsevent = function(func){
if(this.objects.addEventListener){
this.objects.addEventListener(this.types,func,false);
return true;
} else if (this.objects.attachEvent){
this.objects.attachEvent("on" + this.types,func);
} else {
return false;
}
}




// FIND OBJ
DN_System_Load.prototype.findobj = function(obj){
this.parent = window.document;
if(this.parent[obj]){ return this.parent[obj]; }
if(this.parent.all && this.parent.all[obj]){ return this.parent.all[obj]; }
if(this.parent.layers && this.parent.layers[obj]){ return this.parent.layers[obj]; }
if(this.parent.getElementById && this.parent.getElementById(obj)){ return this.parent.getElementById(obj); }
return null;
}



// INIT CLASS
var DN = new DN_System_Load();
// INIT CLASS




// CLASS : DN_System_Hint
// Init
function DN_System_Hint(){}
// SHOW
DN_System_Hint.prototype.show = function(obj,str){
var hint = DN.findobj('hint');
if(!obj){ return; }
if(!DN.documes){ return; }
if(!hint){ return; }
hint.className = 'hint';
hint.style.left = '15px';
hint.style.top = '19px';

obj.onmouseout = function(advance){
hint.style.width = '';
hint.style.visibility = 'hidden';
if(hint.firstChild) hint.removeChild(hint.firstChild);
hint.appendChild(document.createTextNode(str));
};

obj.onmousemove = function(advance){
hint.innerHTML = str;
if  (navigator.appName == "Microsoft Internet Explorer"){ 
var vc = document.getElementsByTagName((!window.ie && document.compatMode && document.compatMode=="CSS1Compat") ? "HTML":"BODY")[0];
} else {
var vc = document.getElementsByTagName((!window.ie && document.compatMode && document.compatMode=="css1compat") ? "html":"body")[0];
}
if(vc){
x = window.event ? event.clientX + vc.scrollLeft : advance.pageX;
y = window.event ? event.clientY + vc.scrollTop : advance.pageY;
//hint.innerHTML = x + ' - ' + y;
vcwidth = vc.clientWidth ? vc.clientWidth + vc.scrollLeft : window.innerWidth + window.pageXOffset;
vcheight = vc.innerHeight ? window.innerHeight + window.pageYOffset : vc.clientHeight + vc.scrollTop;
 hint.style.visibility = 'visible';
 hint.style.opacity = '.90';
 if(hint.offsetWidth>200){ hint.style.width = '200px'; }
  if((x + hint.offsetWidth + 12) > vcwidth){
   hint.style.left = (x - hint.offsetWidth - 4) + 'px';
  } else {
   hint.style.left = (x + 12) + 'px';
  }
  if((y + hint.offsetHeight + 19) > vcheight){
   hint.style.top = (y - hint.offsetHeight) + 'px';
  } else {
   hint.style.top = (y + 19) + 'px';
  }
}
}
}
// INITIALIZE
DN_System_Hint.prototype.initialize = function(){
// CREATE DIV
var hint = document.createElement("DIV");
hint.setAttribute('id','hint');
document.getElementsByTagName('body')[0].appendChild(hint);
hint.style.visibility = 'hidden';
// CREATE DIV
// MARKER
var hintmarker = ['a','img'];
var textmarker = ['title','alt'];
var lenmarker = hintmarker.length;
// MARKER
for(var i=0; i<lenmarker; i++) {
 atr = document.getElementsByTagName(hintmarker[i]);
 for(var j=0; j<atr.length; j++)
 if(viewhint=atr[j].getAttribute(textmarker[i])){
  atr[j].removeAttribute(textmarker[i]);
  HINT.show(atr[j],viewhint);
 }
}
}
// CLASS : DN_System_Hint

// INIT CLASS
var HINT = new DN_System_Hint();
// INIT CLASS
// LOAD || ONLOAD
if(DN.objects){ DN.addsevent(HINT.initialize); }

//Scroll
function DN_System_Scroll(){
this.type = -1; this.intval = 0;
}

DN_System_Scroll.prototype.step = function(){
 var y = ((this.type == 1) ? document.documentElement.scrollTop : document.body.scrollTop), step = 35;
 y -= Math.ceil(y * step / 100);
 y = (y < 0) ? 0 : y;
 if(this.type == 1){
   document.documentElement.scrollTop = y;
 } else {
   document.body.scrollTop = y;
 }
 if(y == 0){
  clearInterval(this.intval); this.intval = 0;
 }
}

DN_System_Scroll.prototype.begin = function(){
 if(this.intval == 0){
  if(document.documentElement && document.documentElement.scrollTop) {
   this.type = 1;
  } else if (document.body && document.body.scrollTop){
   this.type = 2;
  } else {
   this.type = 0;
  }
  if(this.type > 0){
   this.intval = setInterval('SCROLL.step()',50);
  }
 }
}

var SCROLL = new DN_System_Scroll();

// FONTSIZE
DN_System_Load.prototype.fontsize = function(obj,gui){
var fontcont = this.findobj(obj);
  if(gui<0){ var fsize=-1; } else { var fsize=1; }
   var resize = parseInt(fontcont.style.fontSize) + fsize;
 if(resize >= 9 && resize < 17){
  fontcont.style.fontSize = resize + 'px';

 }
 return false;
}



// Time
function showtime() {
	var obj_el = document.getElementById('time');
	var now = new Date();
	var hours = now.getHours();
	var minutes = now.getMinutes();
	var seconds = now.getSeconds();
	minutes = ((minutes < 10) ? "0" : "") + minutes;
	seconds = ((seconds < 10) ? "0" : "") + seconds;
	obj_el.innerHTML = hours + ':' + minutes + ':' + seconds;
	setTimeout("showtime()", 1000);
}

//DATE
function showdate() {
	var obj_eld = document.getElementById('date');
	var now = new Date();
	var dates = now.getDate(); //Дата недели
	var month = now.getMonth(); //Месяц
	var year = now.getYear(); //Год
	var day = now.getDay(); // день недели
	var x = new Array("Воскресенье", "Понедельник", "Вторник");
	var x = x.concat("Среда","Четверг", "Пятница");
	var x = x.concat("Суббота");
	var y = new Array(" января ", " февраля ", " марта ");
	var y = y.concat(" апреля "," мая ", " июня ");
	var y = y.concat(" июля "," августа ", " сентября ");
	var y = y.concat(" октября "," ноября ", " декабря ");
	if (year < 1000) year += 1900;

	obj_eld.innerHTML = dates+y[month]+year +'<BR>'+x[day];
		
}




