window.name="content";

function change(id,value){
  cart_div=new layer('div_cart_product_'+id);
  if (value==2){
    cart_div.write('');
  } else if (value==1){
    cart_div.write('<b>Добавлено...</b>');
	id=setTimeout("change("+id+",2)",1000);
  } else {
    cart_div.write('<font color="#800000"> Добавление...</font></b>');
  }  
}

function only_change(id,value){
  cart_div=new layer('div_cart_only_product_'+id);
  if (value==2){
    cart_div.write('');
  } else if (value==1){
    cart_div.write('<b>добавлено...</b>');
	id=setTimeout("only_change("+id+",2)",1000);
  } else {
    cart_div.write('<font color="#800000"> добавление...</font></b>');
  }  
}

/*
function change(id,value){
  cart_div=new layer('div_cart_product_'+id);
  if (value==2){
    cart_div.write('<a href="?file=cart" class="a_cart"><img name="cart_img" id="cart_img" src="images/cart_off.gif" width="35" height="35" border="0" align="absmiddle"> Ваша корзина</a>');
  } else if (value==1){
    cart_div.write('<img name="cart_img" id="cart_img" src="images/cart_off.gif" width="35" height="35" border="0" align="absmiddle"> <b>Добавлено...</b>');
	id=setTimeout("change(2)",1000);
  } else {
    cart_div.write('<img name="cart_img" id="cart_img" src="images/cart_off.gif" width="35" height="35" border="0" align="absmiddle"> <b><font color="#800000"> Добавление...</font></b>');
  }  
}
*/

function check_int(obj){
  result=parseInt(obj.value);
  if (isNaN(result)) 
    result="0";
  obj.value=result;
}

function update_record(){
window.open('','message_window','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=no,width=300,height=100,top='+(top.getMyWindowHeight()/2-50)+',left='+(top.getMyWindowWidth()/2-150)+',screenX=,screenY=');
}
function getMyWindowWidth(w){
  if(!w) w=self
  if(isMSIE) return w.document.body.clientWidth
  if(isNC || isOpera) return w.innerWidth
}

function getMyWindowHeight(w){
  if(!w) w=self
  if(isMSIE) return w.document.body.clientHeight
  if(isNC || isOpera) return w.innerHeight
}


//

var item_correct = 'check_correct';
var allok;

// доставка
function insertOptionBefore(num)
{
  var elSel = document.getElementById('order_city');
  if (elSel.selectedIndex >= 0) {
    var elOptNew = document.createElement('option');
    elOptNew.text = 'Москва';
    elOptNew.value = '1';
	
	
    var elOptOld = elSel.options[elSel.selectedIndex];  
    try {
      elSel.add(elOptNew, elOptOld); // standards compliant; doesn't work in IE
	  elOptNew.selected = true;
    }
    catch(ex) {
      elSel.add(elOptNew, elSel.selectedIndex); // IE only
	  elOptNew.selected = true;
    }
  }
}

function showCities(RussiaIdx)
{
	var controlId = 'ccity';
	var cregionId = 'cregion';

	var SelVal = document.getElementById('order_country').value;
	var selectitems = document.getElementById("order_city");
	var items = selectitems.getElementsByTagName("option");
	
	if (SelVal != 0) {
		// если россия - добавить в список москву
		if (SelVal == RussiaIdx){
			if (items.length <= 1){
				insertOptionBefore('2');
			}
			document.getElementById(cregionId).style.display="none";
		} else {
			// если не россия - удалить москву
			if (items.length > 1){
				selectitems.options[0]=null;
			}
			document.getElementById(cregionId).style.display="block";
		}
		// показать список городов
		document.getElementById(controlId).style.display="block";
		
	} else {
		// спрятать список городов
		document.getElementById(controlId).style.display="none";
		document.getElementById(cregionId).style.display="none";
	}
}


function showInputFields(isMoscow)
{
	cregionId = 'cregion';
		
	var SelVal = document.getElementById('order_city').value;
	//alert(SelVal+' -- ' +isMoscow);
	if (SelVal == isMoscow) {
		//alert(controlId);
		document.getElementById(cregionId).style.display="none";
	} else {
		document.getElementById(cregionId).style.display="block";
	}
}


