function updateClock()
{
//   alert('aaa');
  var currentTime = new Date();

  var currentHours = currentTime.getHours();
  var currentMinutes = currentTime.getMinutes();
  var currentSeconds = currentTime.getSeconds();

  currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
  currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;

  currentHours = ( currentHours == 0 ) ? 12 : currentHours;

  var currentTimeString = currentHours + ":" + currentMinutes;

  document.getElementById("clock").firstChild.nodeValue = currentTimeString;
};

function GoIssueBlock(aid) {
  var host = location.hostname;	
  var url = "http://"+host+"/"+lang_sub_dir+"get_issue.ins.php?type_i=issue&id=" + escape(aid);
  xmlHttp.open("GET", url, true);
  xmlHttp.onreadystatechange = updateIssueBlock;
  xmlHttp.send(null);
}

function updateIssueBlock() {
  if (xmlHttp.readyState == 4) {
    var response = xmlHttp.responseText;
    document.getElementById('ajax_cashe').innerHTML = response;
	var obj2 = document.getElementById('issue_block');
	obj2.innerHTML = document.getElementById('ajax_cashe').innerHTML;
  }
}

function GoNewsOnlineBlock() {
  var host = location.hostname;	
  var url = "http://"+host+"/"+lang_sub_dir+"get_newsonline.ins.php?type_i=news";
  xmlHttp.open("GET", url, true);
  xmlHttp.onreadystatechange = updateNewsOnlineBlock;
  xmlHttp.send(null);
}

function updateNewsOnlineBlock() {
  if (xmlHttp.readyState == 4) {
    var response = xmlHttp.responseText;
    document.getElementById('ajax_cashe').innerHTML = response;
	var obj2 = document.getElementById('newsonline_block');
	obj2.innerHTML = document.getElementById('ajax_cashe').innerHTML;
  }
}

function GoIssueBlockArc(ayear,amonth,aid,aclc) {
  var host = location.hostname;	
  var url = "http://"+host+"/"+lang_sub_dir+"get_issue.ins.php?type_i=issue_arc&y=" + escape(ayear) + "&m=" + escape(amonth) + "&id=" + escape(aid) + "&clc=" + escape(aclc);
  xmlHttp.open("GET", url, true);
  xmlHttp.onreadystatechange = updateIssueBlockArc;
  xmlHttp.send(null);
}

function updateIssueBlockArc() {
  if (xmlHttp.readyState == 4) {
    var response = xmlHttp.responseText;
    document.getElementById('ajax_cashe').innerHTML = response;
	var obj2 = document.getElementById('issue_block');
	obj2.innerHTML = document.getElementById('ajax_cashe').innerHTML;
  }
}

function GoNewsOnlineBlockArc(ayear,amonth,aday) {
  var host = location.hostname;	
  var url = "http://"+host+"/"+lang_sub_dir+"get_newsonline.ins.php?type_i=news_arc&y=" + escape(ayear) + "&m=" + escape(amonth) + "&d=" + escape(aday);
  xmlHttp.open("GET", url, true);
  xmlHttp.onreadystatechange = updateNewsOnlineBlockArc;
  xmlHttp.send(null);
};

function updateNewsOnlineBlockArc() {
  if (xmlHttp.readyState == 4) {
    var response = xmlHttp.responseText;
    document.getElementById('ajax_cashe').innerHTML = response;
	var obj2 = document.getElementById('newsonline_block');
	obj2.innerHTML = document.getElementById('ajax_cashe').innerHTML;
 
 }
};

function InfClc(atype)
{
 var inf_urls = new Array;
 inf_urls['weather'] = 'http://www.ukrbiznes.com/weather/informer.php?id=2&cityid=19';
 inf_urls['courses'] = 'http://bin.ua/cgi-bin/cash-inform-text.pl?currencies=USD,EUR,RUB,CHF,GBP,CAD';
 var f_obj = getObj('weather');
 f_obj.style.color = '#000000';
 var f_obj = getObj('courses');
 f_obj.style.color = '#000000';
 var f_obj = getObj(atype);
 f_obj.style.color = '#E58227';
 window.frames['inform'].location = inf_urls[atype];
};

function RtClc(atype)
{
 var st1 = getStyle('rotate');
 var st2 = getStyle('webcam_block');
 var st = getStyle('webcam_lnk');
 st.color = '#000000';
 st = getStyle('rotate_lnk');
 st.color = '#000000';
 if (atype == 'rotate')
  {
   st1.display='';
   st = getStyle('rotate_lnk');
   st.color = '#E58227';
   st2.display='none';
  }
 else
  {
   st2.display='';
   st = getStyle('webcam_lnk');
   st.color = '#E58227';
   st1.display='none';
  };
};

var webcam_w = 0;
var webcam_h = 0;

function GetWebCamSnap(aw,ah)
{
 var is_next = 1;
 if (aw == 270)
  {
   var st1 = getStyle('webcam_lnk');
   if (st1.display =='none')
	{
	 setTimeout('GetWebCamSnap('+aw+','+ah+')',webcam_interval);
	 is_next = 0;
	};
  };
 if (is_next == 1)
  {
   webcam_w = aw;
   webcam_h = ah;
   var host = location.hostname;	
   var url = "http://"+host+"/mix/webcam.ins.php?w="+escape(aw)+"&h="+escape(ah);
   xmlHttp.open("GET", url, true);
   xmlHttp.onreadystatechange = updateWebCamSnap;
   xmlHttp.send(null);
  };
};

function updateWebCamSnap() {
  if (xmlHttp.readyState == 4) {
    var response = xmlHttp.responseText;
	var obj = document.getElementById('webcam_block');
	obj.innerHTML = response;
	setTimeout('GetWebCamSnap('+webcam_w+','+webcam_h+')',webcam_interval);
 };
};

function sc_init(id) {
  var obj = document.getElementById(id);
  if (obj) {
    obj.state = 0;//?????????????? ?????????
    obj.timer = null;
    obj.maxHor = obj.scrollWidth - obj.offsetWidth;
  };
};

function sc_scroll_right(id,timer) {
//alert('123');
  var obj = document.getElementById(id);
  if (!obj.maxHor) sc_init(id);
  if (timer == undefined) obj.state = 1;
  //alert(obj.scrollTop);
  if ((obj.maxHor > obj.scrollLeft) && (obj.state == 1)) {
    obj.scrollLeft = obj.scrollLeft + 3;
    obj.timer = setTimeout('sc_scroll_right(\''+id+'\',true)',10);
  };
}; 

function sc_scroll_left(id,timer) {
  var obj = document.getElementById(id);
  if (!obj.maxHor) {
  sc_init(id);
  };
  if (timer == undefined) obj.state = -1;
  //alert(obj.scrollTop);
  if ((obj.scrollLeft > 0) && (obj.state == -1)) {
  ///alert('aaa');
    obj.scrollLeft = obj.scrollLeft > 10 ? obj.scrollLeft - 3 : 0;
    obj.timer = setTimeout('sc_scroll_left(\''+id+'\',true)',10);
  }
};

function sc_scroll_stop(id) {
  var obj = document.getElementById(id);
  if (obj) {
    if (obj.timer) clearTimeout(obj.timer);
    obj.state = 0;
  }
}; 

function ScrollIconsInit()
{
var ob = document.getElementById('scroll_icons');
if (ob) {
var st_up = document.getElementById('scroll_side_right').style;
var st_down = document.getElementById('scroll_side_left').style;
var sw = parseInt(ob.scrollWidth) - parseInt(ob.offsetWidth);
if (sw > 0)
{
st_up.visibility='visible';
st_down.visibility='visible';
};
ob.scrollLeft = 0;
};
};

function LoadPrImg(aid) {
  var host = location.hostname;	
  var url = "http://"+host+"/mix/get_pr_img.ins.php?id="+escape(aid);
  xmlHttp.open("GET", url, true);
  xmlHttp.onreadystatechange = updatePrImg;
  xmlHttp.send(null);
};

function updatePrImg() {
  if (xmlHttp.readyState == 4) {
    var response = xmlHttp.responseText;
	var obj = document.getElementById('news_photo');
	obj.innerHTML = response;
 };
};

function Open_Cam()
{
 var host = location.hostname;
 var url = "http://"+host+"/"+lang_sub_dir+"show_webcam.php";
 mywin = window.open( url, 'win', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=350,height=350' );
 mywin.focus();
};
