// Визитка 
function showVizitka(){
	document.getElementById('vizitka').style.display = 'block';
	document.getElementById('mviza').style.display = 'none';
}

function showVizitkaClose(){
	document.getElementById('vizitka').style.display = 'none';
	document.getElementById('mviza').style.display = 'block';
}

// ручки
function showHTML(element, responseObject) {
  if (typeof(element)=="string") element=document.getElementById(element);
  element.innerHTML=responseObject.result;
}

// AJAX
function createXMLHttpRequest() {
  var xmlReq = false;
  // branch for native XMLHttpRequest object
  if(window.XMLHttpRequest) {
    try {
      xmlReq = new XMLHttpRequest();
    } catch(e) {
      xmlReq = false;
    }
  // branch for IE/Windows ActiveX version
  } else if(window.ActiveXObject) {
    try {
      xmlReq = new ActiveXObject("Msxml2.XMLHTTP");
    } catch(e) {
      try {
        xmlReq = new ActiveXObject("Microsoft.XMLHTTP");
      } catch(e) {
        xmlReq = false;
      }
    }
  }
  return xmlReq;
}

var userAgent = { };
userAgent.isAJAX = (createXMLHttpRequest()?true:false);
userAgent.isMozilla = (navigator.userAgent.match(/\bGecko\b/));
userAgent.isOpera = (navigator.userAgent.match(/\bOpera\b/));
userAgent.isInternetExplorer = (navigator.userAgent.match(/\bMSIE\b/) && !userAgent.isOpera);

function callServer(method, url, data, dataType, func, arg) {
  if (!method) method='GET';
  var xmlReq = createXMLHttpRequest();
  if(xmlReq) {
    xmlReq.onreadystatechange = function() {
        // only if xmlReq shows "loaded"
        if (xmlReq.readyState == 4) {
          func(arg, xmlReq.responseText, xmlReq.responseXML, xmlReq.status, xmlReq.statusText);
        }
      };
    xmlReq.open(method, url, true);
    if (data) {
      if (!dataType) dataType='application/xml';
      if (typeof(data)!="string" && dataType.indexOf("charset=")<0 && userAgent.isMozilla) dataType=dataType+';charset=utf-8'; // in Mozilla XML always serialized as UTF-8
      xmlReq.setRequestHeader('Content-Type', dataType);
    }
    xmlReq.send(data);
    return false;
  }
  return true;
}

function showHTML(element, responseText, responseXML, statusCode, statusText) {
  if (typeof(element)=="string") element=document.getElementById(element);
  if (statusCode==200 || statusCode==201) {
    element.innerHTML=responseText;
  } else {
      if(statusText == 'OK') {
         alert("Ошибка 404\nСтраница не найдена");
      } else {
        // alert("Загрузить информацию не удалось:\n"+statusText);
      }
  }
}

// AJAX script
var callbacks=new Object();
function callJSONP(url, func, arg) {
  var cbId;
  do cbId = 'c' + Math.floor(Math.random() * 99999); while (callbacks[cbId]);
  callbacks[cbId] = function(obj) { func(arg, obj); delete callbacks[cbId]; };
  var script = document.createElement('script');
  script.src = url+(url.indexOf('?')>=0 ? '&' : '?')+'callback=callbacks.'+cbId;
  script.type = 'text/javascript';
  document.body.appendChild(script);
}

// ---------------------------  Cтили сайта Скины
// Пишем cookie
function set_cookie(name, value, expires)
{
if (!expires)
{
expires = new Date();
}
document.cookie = name + "=" + escape(value) + "; expires=" + expires.toGMTString() +  "; path=/";
}

function get_cookie(name)
{
cookie_name = name + "=";
cookie_length = document.cookie.length;
cookie_begin = 0;
while (cookie_begin < cookie_length)
{
value_begin = cookie_begin + cookie_name.length;
if (document.cookie.substring(cookie_begin, value_begin) == cookie_name)
{
var value_end = document.cookie.indexOf (";", value_begin);
if (value_end == -1)
{
value_end = cookie_length;
}
return unescape(document.cookie.substring(value_begin, value_end));
}
cookie_begin = document.cookie.indexOf(" ", cookie_begin) + 1;
if (cookie_begin == 0)
{
break;
}
}
return null;
}

// Пишем или затираем cookie
function save_cookie(wid) {
 var name = 'style';// имя cookie
 var tmp = '_' + wid; // записываемое значение
 expires = new Date(); // получаем текущую дату
 expires.setTime(expires.getTime() + (10*365*24*60*60*1000)); // вычисляем срок хранения cookie
 set_cookie(name, tmp, expires); // устанавливаем cookie с помощью функции set_cookie
 document.getElementById('style').className = 'style_' + wid;
	for(q=1; q <= 4; q++) {
		if(wid == q){
		    document.getElementById('skin' + q).className = 'skin' + q + ' skin_on';
		} else {
			document.getElementById('skin' + q).className = 'skin' + q;
		}
	}
}

// Двигаем ручку :-))
function $(v) { return(document.getElementById(v));}
function agent(v) { return(Math.max(navigator.userAgent.toLowerCase().indexOf(v),0)); }
function xy(e,v) { return(v?(agent('msie')?event.clientY+document.body.scrollTop:e.pageY):(agent('msie')?event.clientX+document.body.scrollTop:e.pageX));}
function dragOBJ(d,e) {
    function drag(e) { if(!stop) { d.style.top=(tX=xy(e,1)+oY-eY+'px'); d.style.left=(tY=xy(e)+oX-eX+'px'); document.getElementById('dpen').style.display = 'none'} }
    var oX=parseInt(d.style.left),oY=parseInt(d.style.top),eX=xy(e),eY=xy(e,1),tX,tY,stop; document.onmousemove=drag; document.onmouseup=function(){ stop=1; document.onmousemove=''; document.onmouseup=''; };
}
function dragOBJ2(d,e) {
    function drag(e) { if(!stop) { d.style.top=(tX=xy(e,1)+oY-eY+'px'); d.style.left=(tY=xy(e)+oX-eX+'px'); document.getElementById('dpen').style.display = 'none'} }
    var oX=parseInt(d.style.left),oY=parseInt(d.style.top),eX=xy(e),eY=xy(e,1),tX,tY,stop;
    
	// -!-
    if(oY == -22 || oY == -21 || oY == -20 || oY == -19 || oY == -18 || oY == -17 || oY == -16 || oY == -15 || oY == -14 || oY == -13 || oY == -12 || oY == -11 || oY == -10 || oY == -9 || oY == -8 || oY == -7 || oY == -6 || oY == -5 || oY == -4 || oY == -3 || oY == -2 || oY == -1 || oY == 0  || oY == 1 || oY == 2 || oY == 3 || oY == 4 || oY == 5 || oY == 6 || oY == 7 || oY == 8 || oY == 9 || oY == 10) {
        if(oX == -3 || oX == -2 || oX == -1 || oX == 0 || oX == 1 || oX == 2 || oX == 3){
        document.getElementById('dpen').style.display = ''
        }
    }
}

// +++++
function statMen() {
callJSONP('/hits.php', showHTML, 'po_sait');
}

function statMen2() {
callJSONP('/men.php', showHTML, 'po_sait');
}

//opendiv
function opendiv(col, url) {
  if(!col){
        col = "50";
        col2 = ".5";
    } else {
        if(col == 100) {
            col2 = 1;
        } else {if(col == 0) {
            col2 = 0;
        } else {
            col2 = "." + col/10;
        }
        }
    }

	if (document.getElementById("toplayer")) {
		var loadingDiv = document.getElementById("toplayer");
		
		if (loadingDiv.style.display == "block") {
		
            document.getElementById('toplayer').innerHTML = '';
			loadingDiv.style.display = "none";
			
		} else {
		
            document.getElementById('toplayer').innerHTML = '<iframe style="opacity:' + col2 +'; filter:alpha(opacity=' + col +');" frameborder="0" src="/color.html"></iframe><div style="opacity:' + col2 +'; filter:alpha(opacity=' + col +');" class="overlay"></div><div id="box_div"></div>';
			loadingDiv.style.display = "block";
			
		}
	}
}

function citata(what) {
    opendiv();
    var x=what.id;
    document.getElementById('box_div').innerHTML = "<a href=\"#\" onClick=\"opendiv(); return false;\"><img alt=\"\" src=\"/img/citata/big/citati_0" + x + ".jpg\"/></a>";
    document.getElementById('box_div').className = ("citata_b");
	return false;
}

// Затемнение экрана и смена курсора мышки на ожидание
function loading() {
    window.clearInterval(idtimer);
    Status_off();
    opendiv("0");
    document.getElementById('boxr').innerHTML = '<br /><br /><img style="margin-left:120px; margin-top:100px;" src="/img/fon/pic/ajax-loading.gif" alt="" />';
    document.getElementById('boxx').innerHTML = '<br /><br /><img style="margin-left:120px; margin-top:100px;" src="/img/fon/pic/ajax-loading.gif" alt="" />';
    document.getElementById('box_div').innerHTML = "";
    document.getElementById('box_div').className = ("loading");
    setTimeout ('opendiv()',2000);
	return false;
}

function update_clock() {
	callJSONP('/data_update.php', showHTML, 'clock');
}

function update_date() {
	callServer(null, '/data.php', null, null, showHTML, 'po_data');
}

function update_all() {
	thispage=window.location.href;
	suffix2=thispage.substring(thispage.lastIndexOf('#')+1,thispage.length);
	detect(suffix2,1);
}

function update_radio() {
	thispage=window.location.href;
	suffix3=thispage.substring(thispage.lastIndexOf('#')+1,thispage.length);
	if(suffix3 == 'radio'){
		detect(suffix3,1);
	}
}

// location.hash
var suffix;
var anchor;

function location_hash(anchor) {
	if(anchor == 'index') {
	location.hash = '#main';
	} else {
	suffix = anchor;
	location.hash = '#'+anchor;
	}

	if(anchor == 'main' || anchor == 'about' || anchor == 'news' || anchor == 'work' || anchor == 'work2' || anchor == 'miscellaneous' || anchor == 'www' || anchor == 'contact' || anchor == 'sitemap' || anchor == 'example' || anchor == 'radio') {
		callServer(null, '/page/'+anchor+'_l.html', null, null, showHTML, 'boxr');
		callServer(null, '/page/'+anchor+'_r.html', null, null, showHTML, 'boxx');
		callJSONP('/page/menu/menu.php?id='+anchor+'', showHTML, 'boxm');
	}

	return false;
}

// Меню 
function menu_main() {
	location_hash('index');
	loading();	
	foto_on();
	return false
}

function menu_about() {
	location_hash('about');
	loading();
	foto_on();
	return false
}

function menu_news() {
	location_hash('news');
	loading();
	return false
}

function menu_work() {
	location_hash('work');
	loading();
	return false
}

function menu_work2() {
	location_hash('work2');
	loading();
	return false
}

function menu_miscellaneous() {
	location_hash('miscellaneous');
	loading();
	return false
}

function menu_www() {
	location_hash('www');
	loading();
	return false
}

function menu_contact(lo) {
	location_hash('contact');
	if(!lo) loading();
	setTimeout ('callServer(null, \'/page/status.html\', null, null, showHTML, \'status\')',500);
	Status_on();
	return false
}

function email() {
	location_hash('email');
	callServer(null, '/email/mail.html', null, null, showHTML, 'boxx');
	return false   
}

function menu_email(lo) {
	location_hash('email');
	if(!lo) loading();
	callServer(null, '/page/contact_l.html', null, null, showHTML, 'boxr');
	callServer(null, '/email/mail.html', null, null, showHTML, 'boxx');
	callJSONP('/page/menu/menu.php?id=email', showHTML, 'boxm');
	setTimeout ('callServer(null, \'/page/status.html\', null, null, showHTML, \'status\')',500);
	Status_on();
	return false   
}

function menu_sitemap() {
	location_hash('sitemap');
	loading();
	return false   
}

function menu_example(lo) {
	location_hash('example');
	if(!lo) loading();
	return false
}

// admin
function menu_authorization(fo,lo) {
	location_hash('authorization');
	if(!lo) loading();

	if(fo == 'ok'){
	callServer(null, '/admin/admin_l.php?id=ok', null, null, showHTML, 'boxr');
	} else {
	callServer(null, '/admin/admin_l.php', null, null, showHTML, 'boxr');
	}

	callServer(null, '/admin/admin_r.php', null, null, showHTML, 'boxx');
	callJSONP('/page/menu/menu.php?id=authorization', showHTML, 'boxm');

	return false
}

// Радио 
function menu_radio(lo) {
	location_hash('radio');
	if(!lo) loading();
	return false
}

function play_radio(station, name){
	document.getElementById('play_name').innerHTML = name;
	document.getElementById('play').innerHTML = '<object type="application/x-shockwave-flash" data="http://www.lonwan.ru/musicplayer.swf?&amp;song_url='+station+'&amp;autoplay=true" height="17" width="17"><param autoplay="true" name="movie" value="http://www.lonwan.ru/musicplayer.swf?&amp;song_url='+station+'&amp;autoplay=true"><param name="wmode" value="transparent" /></object>';
}
// end Радио 

// Адресная строка
function detect(suf,up) {
  if(!up) up = 0;

  thispage=window.location.href;
  suffix=thispage.substring(thispage.lastIndexOf('#')+1,thispage.length);
  
  if(suffix == 'http://www.lonwan.ru/' && suffix != suf || suffix == 'http://www.lonwan.ru/' &&  up == 1 || suffix == 'http://www.lonwan.ru/index.html' && suffix != suf) {
      window.clearInterval(idtimer);
      setTimeout ("location_hash('index');",500);
  }
  
  if(suffix != suf || up == 1) {
      window.clearInterval(idtimer);
      
		if(suffix == 'main' || suffix == 'about' || suffix == 'news' || suffix == 'work' || suffix == 'work2' || suffix == 'miscellaneous' || suffix == 'www' || suffix == 'sitemap' || suffix == 'example' || suffix == 'radio') {
		location_hash(suffix);
		}
		
		if(suffix == 'contact'){
		menu_contact(1);
		}

		if(suffix == 'email'){
		menu_email(1);
		}

		if(suffix == 'authorization'){
		menu_authorization(0, 1);
		}
  }
  
  setTimeout ('detect(suffix)',1000);
  
  return false;
}

// Status
var idtimerstatus;

function Status_off() {
    window.clearInterval(idtimerstatus);
}

function Status_on() {
    idtimerstatus = setInterval('Status_next()',6000);
}

var name_status = "mystatus";
var tmp = 0;
function Status_next() {
	if(document.getElementById("status")) {
	
		var mystatus = get_cookie(name_status);

		tmp = tmp + 1;
		expires = new Date();
		expires.setTime(expires.getTime() + 7000);
		set_cookie(name_status, tmp, expires);
		
		if(mystatus >= 100){
			menu_main();
		} else {
			callServer(null, '/page/status.html', null, null, showHTML, 'status');
		}
	}
}

// фотографии
var slide = new Array;
var pictureName = new Array("/img/foto/1.jpg", "/img/foto/2.jpg", "/img/foto/3.jpg", "/img/foto/4.jpg", "/img/foto/5.jpg", "/img/foto/6.jpg", "/img/foto/7.jpg", "/img/foto/8.jpg", "/img/foto/9.jpg", "/img/foto/10.jpg", "/img/foto/11.jpg", "/img/foto/12.jpg");
for (var i = 0; i < pictureName.length; i++) {
     slide[i] = new Image();
     slide[i].src = pictureName[i];
}

var m = new Array(0, 100);
var nextImage = 0;
var t = "";
var idtimer;

function next() {
   //if(t != "") return;
   if(!document.getElementById("on_img")) {
   } else {
   m[0] = 0;
   m[1] = 100;
   nextImage = nextImage + 1;
   if (nextImage == pictureName.length) { nextImage = 0; }  
   document.getElementById("on_img").src = slide[nextImage].src;
   change_slide();
   }
}

function change_slide() {
	if(document.getElementById("img_b") && document.getElementById("img_a") && document.getElementById("off_img")){
	  m[0] += 1;
	  m[1] -= 1;
	  document.getElementById("img_b").style.opacity = m[1]/100;
	  document.getElementById("img_a").style.opacity = m[0]/100;
	  document.getElementById("img_a").style.filter="alpha(opacity="+m[0]+")";
	  document.getElementById("img_b").style.filter="alpha(opacity="+m[1]+")";
	  t = setTimeout("change_slide()",5);
	  if (m[0] > 98) {
		 clearTimeout(t);
		 document.getElementById("off_img").src = slide[nextImage].src;
		 document.getElementById("img_b").style.opacity = 100;
		 document.getElementById("img_b").style.filter="alpha(opacity=0)";
  }
  }
  }

function foto_on() {
	nextImage = 0;
	window.clearInterval(idtimer);
    idtimer = setInterval('next()',7000);
}

function foto_next() {
	if(document.getElementById("img_c")){
		window.clearInterval(idtimer);
		document.getElementById("img_c").innerHTML = '<div class="foto_p cursor"><div>';
		next();
		setTimeout ('foto_next2()',1000);
	}
}

function foto_next2() {
	if(document.getElementById("img_c")){
		document.getElementById("img_c").innerHTML = '<div onclick="foto_next();" class="foto_p"><div>';
		idtimer = setInterval('next()',10000);
	}
}

// Отпрака письма
   function text (str) { return /[0-9_;:'!~?=+<|>]/g.test(str); }
   //function numeric (str) { return /^[0-9-\+\(\)\s]+z/.test(str + "z"); }
   function mail (str) { return /^[a-z0-9_\.-]+@[a-z0-9_\.-]+.[a-z]{2,3}$/.test(str); }

   function checkForm(){
      var title;
      var elem;
      var dutyField = "Не заполнено поле ";
      var wrongField = "Неверное значение поля ";
      var check = true;

      function checkError (field, str)
         {
         document.getElementById('alert_name').className = ('ddd');
         document.getElementById('alert_email').className = ('ddd');
         document.getElementById('alert_message').className = ('ddd');
         
           document.getElementById("alert").innerHTML = str;
           check = false;
         
         document.getElementById('alert_' + field).className = ('ddd_error');
         document.getElementById('alert_' + field + '_pole').focus();
         
         }
         document.getElementById("alert").innerHTML = "";

      if (check)
         {
         title = '"Имя"';
         elem = document.preview.name.value;
         if (elem.length == 0) checkError('name', dutyField + title);
         else if (text(elem)) checkError('name', wrongField + title);
         }
         
      if (check)
         {
         title = '"E-mail"';
         elem = document.preview.email.value;
         if (elem.length == 0) checkError('email', dutyField + title);
         else if (!mail(elem)) checkError('email', wrongField + title);
         }
		 
      if (check)
         {
         title = '"Сообщение"';
         elem = document.preview.message.value;
         if (elem.length == 0) checkError('message', dutyField + title);
         //if (text(elem)) checkError('message', wrongField + title);
         }
		 
      /*if (check)
         {
         title = '"Телефон"';
         elem = document.preview.phone.value;
         if (elem.length == 0) checkError('phone', dutyField + title);
         else if (!numeric(elem)) checkError('phone', wrongField + title);
         }
         
      if (check)
         {
         elem = document.preview.message.checked;
         if (!elem) checkError('message', 'Вы должны принять условия');
         }*/         
         
      if (check)  { 
		// document.preview.submit(); 
		
		var ajx = typeof window.external=='object' && typeof document.all=='object'
		? new ActiveXObject("Microsoft.XMLHTTP")
		: new XMLHttpRequest();
		var q1 = "name="+document.getElementById('alert_name_pole').value;
		var q2 = "email="+document.getElementById('alert_email_pole').value;
		var q3 = "message="+document.getElementById('alert_message_pole').value;
		var q = q1 + '&' + q2 + '&' + q3;
		ajx.open('post','/email/ajx.php',true);
		ajx.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		ajx.setRequestHeader('Accept-Charset', 'windows-1251');
		ajx.send(q);
		
        callServer(null, '/email/mail.html?id=ok', null, null, showHTML, 'boxx');
		}

  return check;
  }
        
// admin
   function checkForm2(){
      var title;
      var elem;
      var dutyField = "Не заполнено поле ";
      var check = true;

      function checkError (field, str)
         {
         document.getElementById('alert_user_name').className = ('ddd');
         document.getElementById('alert_user_pass').className = ('ddd');
         
           document.getElementById("alert").innerHTML = str;
           check = false;
         
         document.getElementById('alert_' + field).className = ('ddd_error');
         document.getElementById('alert_' + field + '_pole').focus();
         
         }
         document.getElementById("alert").innerHTML = "";

      if (check)
         {
         title = '"Логин"';
         elem = document.preview.user_name.value;
         if (elem.length == 0) checkError('user_name', dutyField + title);
         }
         
      if (check)
         {
         title = '"Пароль"';
         elem = document.preview.user_pass.value;
         if (elem.length == 0) checkError('user_pass', dutyField + title);
         }
		        
      if (check)  { 

		var ajx = typeof window.external=='object' && typeof document.all=='object'
		? new ActiveXObject("Microsoft.XMLHTTP")
		: new XMLHttpRequest();
		var q1 = "user_name="+document.getElementById('alert_user_name_pole').value;
		var q2 = "user_pass="+document.getElementById('alert_user_pass_pole').value;
		var q = q1 + '&' + q2;
		ajx.open('post','/admin/authorize.php',true);
		ajx.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		ajx.setRequestHeader('Accept-Charset', 'windows-1251');
		ajx.send(q);
		
    setTimeout ('menu_authorization("ok")',500);
		}

  return check;
  }
// end. admin
	  
function checkOpen(url) {
	var params = "menubar=no,toolbar=no,resize=no,location=no,resizable=no,scrollbars=yes,status=no,width="+screen.availWidth+",height="+screen.availHeight+",fullscreen,channelmode";
	window.open(url, "Вёрстка", params);
}

// popup
function openWindow(anchor, options) {
 
	var args = '';
 
	if (typeof(options) == 'undefined') { var options = new Object(); }
	if (typeof(options.name) == 'undefined') { options.name = 'win' + Math.round(Math.random()*100000); }
 
	if (typeof(options.height) != 'undefined' && typeof(options.fullscreen) == 'undefined') {
		args += "height=" + options.height + ",";
	}
 
	if (typeof(options.width) != 'undefined' && typeof(options.fullscreen) == 'undefined') {
		args += "width=" + options.width + ",";
	}
 
	if (typeof(options.fullscreen) != 'undefined') {
		args += "width=" + screen.availWidth + ",";
		args += "height=" + screen.availHeight + ",";
	}
 
	if (typeof(options.center) == 'undefined') {
		options.x = 0;
		options.y = 0;
		args += "screenx=" + options.x + ",";
		args += "screeny=" + options.y + ",";
		args += "left=" + options.x + ",";
		args += "top=" + options.y + ",";
	}
 
	if (typeof(options.center) != 'undefined' && typeof(options.fullscreen) == 'undefined') {
		options.y=Math.floor((screen.availHeight-(options.height || screen.height))/2)-(screen.height-screen.availHeight);
		options.x=Math.floor((screen.availWidth-(options.width || screen.width))/2)-(screen.width-screen.availWidth);
		args += "screenx=" + options.x + ",";
		args += "screeny=" + options.y + ",";
		args += "left=" + options.x + ",";
		args += "top=" + options.y + ",";
	}
 
	if (typeof(options.scrollbars) != 'undefined') { args += "scrollbars=1,"; }
	if (typeof(options.menubar) != 'undefined') { args += "menubar=1,"; }
	if (typeof(options.locationbar) != 'undefined') { args += "location=1,"; }
	if (typeof(options.resizable) != 'undefined') { args += "resizable=1,"; }
 
	var win = window.open(anchor, options.name, args);
	return false;
}

// C Т А Р Т
callServer(null, '/page/menu/menu.html', null, null, showHTML, 'menu_left');
callJSONP('/data_update.php', showHTML, 'clock');
document.getElementById('pen').style.display = 'block';
document.getElementById('mviza').style.display = 'block';
document.getElementById('dpen').style.display = 'block';
setTimeout ('foto_on()',10000);
detect();
statMen2();

//document.title
var timer = setInterval(migalka,5000);

var newTxt="Портфолио";
var oldTxt="Шустров Андрей"; 

function migalka(){
	if(document.title==oldTxt){
		document.title=newTxt;
	}else{
		document.title=oldTxt;
	}
}

// Timer
var idtimerclock;
var timeStamp;
var seconds;
var minutes;
var hours;

function myclock() {
seconds = seconds + 1;

if (seconds == 60) {
	seconds = 0;
	minutes = minutes + 1;
if (minutes == 60) {
	minutes = 0;
	hours = hours + 1;
if(hours == 24) {
	hours = 0;
}}}
  
if(seconds == 9){
	statMen2();
} else {if(seconds == 19){
	statMen();
} else {if(seconds == 25){
	update_clock();
} else {if(seconds == 29){
	statMen2();
} else {if(seconds == 39){
	statMen();
} else {if(seconds == 49){
	statMen2();
} else {if(seconds == 55){
	update_clock();
} else {if(seconds == 59){
	statMen();
}}}}}}}}

if(minutes == 14 && seconds == 59) {
	window.clearInterval(idtimerclock);
	update_radio();
}

if(minutes == 00 && seconds == 01) {
	update_date();
}

if(hours == 00 && minutes == 00 && seconds == 00) {
	update_all();
}

timeStamp = "" + ((hours < 10) ? "0" : "") + hours;
timeStamp+=":" + ((minutes < 10) ? "0" : "") + minutes;
timeStamp+=":" + ((seconds < 10) ? "0" : "") + seconds;
document.getElementById("clock").innerHTML = timeStamp;
idtimerclock = setTimeout('myclock()',1000);
}

setTimeout('myclock()',5000);

// Предварительная загрузка картинок
function init() {
	// quit if this function has already been called
	if (arguments.callee.done) return;
	
	// flag this function so we don't do the same thing twice
	arguments.callee.done = true;

	// preload images
    preload([
		'img/fon/pic/link.gif',
		'img/fon/bg_fon.jpg',
		'img/fon/bg_fon2.jpg',
		'img/fon/bg_fon3.jpg',
		'img/fon/bg_fon4.jpg',
		'img/fon/pic/png/pen/pen_1.png',
		'img/fon/pic/png/pen/pen_2.png',
		'img/fon/pic/png/pen/pen_3.png'
	]);

   };

/* for Mozilla */
if (document.addEventListener)
{
	document.addEventListener("DOMContentLoaded", init, false);
}

/* for Internet Explorer */
/*@cc_on @*/
/*@if (@_win32)
	document.write("<script defer src=/js/ie_onload.js><"+"/script>");
/*@end @*/

/* for other browsers */
window.onload = init;

function preload(images) {
    if (typeof document.body == "undefined") return;
    try {

        var div = document.createElement("div");
        var s = div.style;
		    s.position = "absolute";
			s.top = s.left = 0;
			s.visibility = "hidden";
			s.width = "100%";
			s.overflow = "hidden";
        document.body.appendChild(div);
		div.innerHTML = "<img src=\"" + images.join("\" /><img src=\"") + "\" />";
		var lastImg = div.lastChild;
		lastImg.onload = function() { document.body.removeChild(document.body.lastChild); };
	 }
	 catch(e) {
        // Error. Do nothing.
	}
}

// Key
document.onkeyup = function checkKeycode(event) {
	var keycode, keyShift, keyCtrl;
	if(!event) var event = window.event;
	if (event.keyCode) keycode = event.keyCode;
	else if(event.which) keycode = event.which;
	keyShift = event.shiftKey;
	keyCtrl = event.ctrlKey;
	
	if(keyShift && keyCtrl && keycode==49) save_cookie(4);
	if(keyShift && keyCtrl && keycode==50) save_cookie(3);
	if(keyShift && keyCtrl && keycode==51) save_cookie(2);
	if(keyShift && keyCtrl && keycode==52) save_cookie(1);
	
	if(keyShift && keyCtrl && keycode==90) menu_example(1);
}