/*  для корзины */
function doRemoveAction(fname,id,glass_color_id) {
    document.shopcart.item_id.value = id;
    document.shopcart.glass_color_id.value = glass_color_id;
    doAction(fname,'del');        
}

function checkAmount(field, id, type) {
    field.value = Math.abs(field.value);
}
/*  /для корзины */

/* показыаем большую картинку элемента каталога продукции */
function photo(lang, id) {
//alert('/'+lang+'/photo'+id+'.html');
   var ph = document.getElementById('hgc_'+id); 
   var gc_id = (ph == null) ? '0' : ph.value;

//   alert('/'+lang+'/catalog/photo'+id+'.html?glass_color_id='+gc_id);

   window.open('/'+lang+'/catalog/photo'+id+'.html?glass_color_id='+gc_id,  '_blank',
                'resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no, width=600, height=400');
};

function largeImage(path) {
   window.open('/ru/photo'+path,  '_blank',
                'resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no, width=600, height=400');
};


function cartWin(path, anch) {
//alert('Извините! Корзина временно недоступна. \nИдет обновление каталога продукции.');
//return;

    get = new String(window.location);
    window.location.href = get.split('#')[0]+anch
    window.open(path,  '_blank',
                'resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes, width=600, height=400');
                
};

function toBasket(prod_id) {
//    alert('Извините! Корзина временно недоступна. \nИдет обновление каталога продукции.');
//    return;

    var ph = document.getElementById('hgc_'+prod_id);
    if( ph != "undefined" ) {
        var gc_id = ph.value;
        var path = "/ru/shopcart/add.html?id="+prod_id;
        if(gc_id >0) {
            path = path+"&gc="+gc_id;
        }
        window.open(path,  '_blank',
            'resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes, width=600, height=400');
    } else {
        alert('Error!');
    }
};

function doAction(name, action) {
    a = document.getElementById(name+'_action');
    a.value = action;
//    document.getElementById(name).submit();
}

function cancelAction(name) {
    a = document.getElementById(name+'_action');
    a.value = '';
//    document.getElementById(name).submit();
}

function setRadioValue(id, value) {
    checkbox=document.getElementById(id);   
    checkbox.value = value;
}

function setCheckBoxValue(id, value) {

    checkbox=document.getElementById(id);   
    checkbox.checked = (value==''? false:true);

    variable=document.getElementById(checkbox.name);    
    variable.value = value;
}

function onCheckBoxClicked(checkbox) {
    variable=document.getElementById(checkbox.name);    
    variable.value = checkbox.checked?1:0;
}

function doOrder(loc, action) {     
    window.opener.location.href=loc;    
//    window.opener.document.main.action.value = action;
//    window.opener.document.main.submit(); 
    window.close(); 
}

function printOrder(loc) {     
    window.open(loc, '_blank',
                'resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes, width=570, height=630');
}

function chat() {
    window.open('http://chat.lotusmebel.ru', '_blank',
                'resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes, width=750, height=500');
}

function doLoginAction(fname, action) {

    var str='';

    if( !checkField('lastname') )               
    str += 'Фамилия\n';

//    if( !checkField('firstname') )                
//  str += 'Имя\n';

//    if( !checkField('middlename') )               
//  str += 'Отчество\n';

//    if( !checkField('phone') )                
//  str += 'Телефон\n';

    if( !checkField('email') )              
    str += 'Электронная почта\n';

//    if( !checkField('zipcode') )              
//  str += 'Индекс\n';

    if( !checkField('city') )               
    str += 'Город\n';

//    if( !checkField('street') )               
//  str += 'Улица\n';

    if( !checkField('region') )             
    str += 'Область\n';

    if( !checkField('login') )              
    str += 'Логин\n';

    if( !checkField('pwd') )                
    str += 'Пароль\n';

    if(str.length > 0 ) {
        alert('Ошибка! Не введены следующие поля: \n'+str);
//        cancelAction(fname);

//        return;
    } else {
        doAction(fname, action);
    }

    ib1=document.getElementById('pwd');
    ib2=document.getElementById('pconfirm');

    if(ib1.value==ib2.value)    {
//        document.main.action.value = action;
  //      document.main.submit(); 
        doAction(fname,action);
    } else {
        alert('Введенные пароли не совпадают.');
        ib1.focus();
        cancelAction(fname);
    }
}


function checkField(id) {
    field=document.getElementById(id);
    if( field.value=='' )   
    return false
    else
    return true;        
}
