﻿function validateinput()
{
    if (document.getElementById('bank').value == 1)
    {
        alert('Выберите банк');
        return false;
    }
   
    if (document.getElementById('credit_data').disabled)
    {
        alert('Минимальная сумма кредита банка превышает цену недвижимости');
        return false;
    }    
    if (document.getElementById('checkcurrency').value != '')
    {
    	if (document.getElementById('checkcurrency').value != document.getElementById('currency').value)
    	{
      		alert('Пожалуйста ждите...');
         	return false;
        }
    }
   
    return true;
} //end popup functions

function addtocompare()
{
    var chbox = document.getElementsByName('comparelist');
    var str = '';
    for(var i=0;i<chbox.length;i++)
    {
			var checkid = document.getElementById('compstr').value.split(',');
			
			if (chbox[i].checked)
			{
					var add = true;				
			    for (var k=0;k<checkid.length - 1;k++)
			    {
						if (chbox[i].value == checkid[k])
						{
							  add = false;
							  break;
						}
					}
					if (add)
					{
					    str += chbox[i].value + ',';
					}
			}
    }
    document.getElementById('compstr').value += str;
    document.getElementById('postthis').value = document.getElementById('compstr').value;
}

function compare()
{
    addtocompare();

    var str = document.getElementById('postthis').value;

    if (str.split(',').length<3)
    {
        alert('Сравнение требует выбора минимум двух объектов');
        return false;
    }
    else {

        document.getElementById('compstr').value = '';
    }

    return true;
}

function resetcompare()
{
    document.getElementById('compstr').value = '';
}
