
function tocart(id,price,cnt_name) {
  obj = document.getElementById('korz');
  cnt = document.getElementById(cnt_name).value; 	// откуда количество
	//alert(id);
  obj.src = '/modules/korz.php?type=add&id='+id+'&price='+price+'&cnt='+cnt;
  
}

function checkZapros() {
	
	ima = document.getElementById('z_ima');
	ima_mes = document.getElementById('z_mes_ima');
	zap = document.getElementById('z_zap');
	zap_mes = document.getElementById('z_mes_zap');
	//alert(ima.value);
	err = 0;
	
	if (  ima.value == '' ) {
		ima_mes.style.color = 'red';
		err = 1;
	} else { ima_mes.style.color = ''; }
	
	if (  zap.value == '' ) {
		zap_mes.style.color = 'red';
		err = 1;
	} else { zap_mes.style.color = ''; }
	
	
	if ( err ) {
		return false;
	}
	return true;
}

var bookmarkurl="http://add.majestics.ru"  
var bookmarktitle="Сделано в Covico"  
function addbookmark(){
	if (document.all)
		window.external.AddFavorite(bookmarkurl,bookmarktitle)
} 







// ф-ция, возвращающая массив моделей
function getHouseValuesByStreet(index){
	var brendName = document.forms["search"].elements["brend"][index].value;
	grIndex = document.getElementById('gr').selectedIndex;
	var grName = document.forms["search"].elements["gr"][grIndex].value;
	//alert(grName);
	//var grName = document.forms["search"].elements["brend"][index].value;
	//alert(document.forms["search"].elements["brend"][index].value);
    var sHouseValues = aHouseValuesSort[grName][brendName];
    //return sHouseValues;
    //alert(sHouseValues);
    return sHouseValues.split(","); // преобразуем строку в массив домов
}

function setModel(index){
    var aCurrHouseValues = getHouseValuesByStreet(index);
    var nCurrHouseValuesCnt = aCurrHouseValues.length;
    var oHouseList = document.forms["search"].elements["name"];
    var oHouseListOptionsCnt = oHouseList.options.length;
    oHouseList.length = 0; // удаляем все элементы из списка домов
    for (i = 0; i < nCurrHouseValuesCnt; i++){
        // далее мы добавляем необходимые дома в список
        if (document.createElement){
            var newHouseListOption = document.createElement("OPTION");
            newHouseListOption.text = aCurrHouseValues[i];
            newHouseListOption.value = aCurrHouseValues[i];
            // тут мы используем для добавления элемента либо метод IE, либо DOM, которые, alas, не совпадают по параметрам…
            (oHouseList.options.add) ? oHouseList.options.add(newHouseListOption) : oHouseList.add(newHouseListOption, null);
        }
    }
}

// ф-ция, возвращающая массив брендов
function getBrendValuesByStreet(index){
	// сначала удаляем все
	var oHouseList = document.forms["search"].elements["brend"];
	oHouseList.length = 0; // удаляем все элементы из списка домов
	var oHouseList = document.forms["search"].elements["name"];
	oHouseList.length = 0; // удаляем все элементы из списка домов
	// <
	
	var brendName = document.forms["search"].elements["gr"][index].value;
	//alert(document.forms["search"].elements["brend"][index].value);
	//alert(brendName);
    var sHouseValues = aGrValues[brendName];
    //return sHouseValues;
    return sHouseValues.split(","); // преобразуем строку в массив домов
}

function setGr(index){
    var aCurrHouseValues = getBrendValuesByStreet(index);
    var nCurrHouseValuesCnt = aCurrHouseValues.length;
    var oHouseList = document.forms["search"].elements["brend"];
    var oHouseListOptionsCnt = oHouseList.options.length;
    oHouseList.length = 0; // удаляем все элементы из списка домов
    for (i = 0; i < nCurrHouseValuesCnt; i++){
        // далее мы добавляем необходимые дома в список
        if (document.createElement){
            var newHouseListOption = document.createElement("OPTION");
            newHouseListOption.text = aCurrHouseValues[i];
            newHouseListOption.value = aCurrHouseValues[i];
            // тут мы используем для добавления элемента либо метод IE, либо DOM, которые, alas, не совпадают по параметрам…
            (oHouseList.options.add) ? oHouseList.options.add(newHouseListOption) : oHouseList.add(newHouseListOption, null);
        }
    }
    setModel(0);
}
