function Display(object) {
    object = document.getElementById (object);
    if ( !object.style ) {
        return false;
    }
    object.style.display = '';
}

function Hide(object) {
    object = document.getElementById (object);
    if ( !object.style ) {        return false;
    }
    object.style.display = 'none';
}

function HideAllPayment(arr) {
    for (i=0; i < arr.length; i++) {        Hide('pay_'+arr[i]);
    }
}

function ShowPayment(arr) {
    for (i=0; i < arr.length; i++) {
        Display('pay_'+arr[i]);
    }
}

function CheckValues(prefix, arr) {    for (i=0; i<arr.length; i++) {        if (document.getElementById(prefix+arr[i]).value == '') {            document.getElementById('div_error').innerHTML = 'Заполните поля';
            return false;
        }
    }
  return true;
}

function SetTimerAndRedirect(time, span, url) {  document.getElementById(span).innerHTML = time;
  for (i=1; i<=time; i++) {
      setTimeout ("document.getElementById('" +span+ "').innerHTML = (" +(time-i)+ ");", 1000*(i+1));
  }
  setTimeout ("document.location.href = '" +url+ "';", 1000*(time+1));
}

function OpenWindowIf(select, value, url, widthx, heightx) {  if (document.getElementById(select).options[document.getElementById(select).selectedIndex].value == value) {    window.open (url, '', 'width='+widthx+', height='+heightx+', location=no, menubar=no, resizable=no, scrollbars=no, statusbar=no');
  }
}

function goToUrlIf(select, value, url) {
  if (document.getElementById(select).options[document.getElementById(select).selectedIndex].value == value) {
    document.location.href =  url;
  }
}

function AddOption (select, value, text) {
  var select = opener.document.getElementById(select);
  // добавляем новый объект OPTION к нашему SELECT
  select.options[select.options.length] = new Option(text, value, false, false);
  select.options[select.options.length-1].selected = "selected";
}

var delivery_company_id = 0;
function saveDeliveryCompany() {
    document.getElementById('del_company_name').value = "";
	document.getElementById('del_company_id').value = delivery_company_id;
	if (document.getElementById('del_txt').value !== "") {
	    document.getElementById('del_company_name').value = document.getElementById('del_txt').value;
		document.getElementById('del_company_id').value = "";
    }

	/*alert (document.getElementById('del_company_name').value);*/

}



