//  ============================================================================
var siteLang;
var c;  // календар
//  ============================================================================
function init() { // изпълнява се автоматично след зареждането на страницата
  if ( !siteLang ) { siteLang = 'bg'; }
  
  i18n.setLang(siteLang);
  
  c = new OAT.Calendar();
  c.dayNames = i18n.get('dayNames');
  c.monthNames = i18n.get('monthNames');
  c.specialDays = i18n.get('specialDays');
  c.dayZeroIndex = i18n.get('dayZeroIndex');
  c.weekStartIndex = i18n.get('weekStartIndex');
  
  
	if (typeof local_init == 'function') {
		local_init();
	}
	if (typeof admin_toolbar == 'function') {
		admin_toolbar();
	}
}

//  ============================================================================
function popupCalendar(url, current_date) {
  url = '/cal.phtml?' + url;
  url = url.replace('&amp','&');

  if(current_date && current_date.value != '') {
    url += '&sel_date='+ current_date.value;
  }

	nwin = window.open(url,'pop_calendar','status=yes,resizable=yes,scrollbars=no,toolbar=no,location=no,directories=no,menubar=no,width=300,height=300,top=30,left=200,screenX=200,screenY=20');
  nwin.focus();
}

//  ============================================================================
function showCalculator(url) {
  LAT.newWin(url, 600, 600, 100, 100, 'calculator', 1);
}

//==============================================================================
function onOffObj(id) {
  if ($(id).style.display == 'none') {
    $(id).style.display = 'block';
  } else {
    $(id).style.display = 'none';
  }
}
//  ============================================================================
function onOffTable(obj) {  /* Отваря и затватя групите */
  var t = obj.parentNode.tBodies[0].style;

  if (t.display == 'none') {
    t.display = '';
    obj.style.backgroundImage = 'url(i/navminus.gif)';
  } else {
    t.display = 'none';
    obj.style.backgroundImage = 'url(i/navplus.gif)';
  }
}
//  ============================================================================
function onOffDiv(obj,content) {  /* Отваря и затватя групите */
  var t = $(content).style;

  if (t.display == 'none') {
    t.display = '';
    obj.style.backgroundImage = 'url(i/navminus.gif)';
  } else {
    t.display = 'none';
    obj.style.backgroundImage = 'url(i/navplus.gif)';
  }
}

//  ============================================================================
function dd(msg){ /* Debug function */
  if (typeof console != 'undefined') {
    console.debug(msg);  
  }  
}