function jsChangeLangTo(lang) {
	document.getElementById('id_curr_lang').value = lang;
	document.getElementById('id_form').submit();
}
function jsChangeTabTo(tab) {
  try {
    // Empty selected office location to prevent redirecting from Main contact' screen
    document.getElementById('office_location').value = '';
  } catch (e) {}

	//document.getElementById('id_form').target = document.location.href.split('#')[0];
	document.getElementById('id_form').target = '';
	document.getElementById('id_curr_tab').value = tab;
	document.getElementById('id_form').submit();
}
function jsChangeParagraphTo (paragraph, tab) {
	if (paragraph != '') {
	 	var currentTab = '<?=$curr_tab?>';
 		document.getElementById('id_curr_paragraph').value = paragraph;
	 	if (tab != '' && tab != currentTab) jsChangeTabTo(tab);
		else document.location.href = '#'+paragraph;
	}
}
function jsOnLoaded () {
	jsChangeParagraphTo(document.getElementById('id_curr_paragraph').value, '');
}
function jsFocus(elem) {
	elem.style.backgroundColor = '#92ba5d';
}
function jsBlur(elem) {
	elem.style.backgroundColor = 'transparent';
}
function jsShowImage(id, src, srcLow, largeSrc) {
	try {
		document.getElementById(id).innerHTML = '<img lowsrc="images/' +srcLow +'" src="images/' +src +'" style="width: 500px; margin-top: 15px; cursor: pointer"' +(largeSrc == '' && largeSrcLow == '' ? '' : ' onClick="window.open(\'images/' +largeSrc +'\', \'largeImage\')"') +'>';
	}
	catch (e) { alert('Target does not exist.') }
}

function popupUhyI() {
  centerPopup('http://www.uhy.com', '', 'width=810, height=750, location=0, status=0, scrollbars=1, resizable=1');
}
function popupLatBel(lang) {
  var params = lang === undefined || (lang != 'ru' && lang != 'lv') ? '' : '?lang=' + lang;
  centerPopup('http://www.latbel.lv' + params, '', 'width=1140, height=850, location=0, status=0, scrollbars=1, resizable=1');
}

if (!window.uhyOrients) {
  var uhyOrients = {
    submitForm: function () {
      document.getElementById('id_form').submit();
    },

    Contacts: {
      chooseOfficeByLocation: function (location) {
        if (location === undefined || location != 'minsk')
          var location = 'riga';

        document.getElementById('office_location').value = location;
        uhyOrients.submitForm();
      }
    }
  }
}
