function openSearchForm() {
	window.open('/searchform.php', 'searchform', 'width=500, height=600, scrollbars=yes, top=100, left=100');
}

function checkAllCredits( ob ) {
	for ( i = 0; i< allcredits.length; i++ ) {
		allcredits[i].checked = ob;
	}
}

function addToFav() {
	allcredits.action = "/addtofav";
	allcredits.submit();
}

function compareCredits() {
	str = '?smth=change';
	for ( i = 0; i< allcredits.length; i++ ) {
		if ( allcredits[i].checked && allcredits[i].name == "id[]" ) {
			
			str = str + "&" + "id[]=" + allcredits[i].value;
		}
	}
	if ( str == '?smth=change' ) {
		alert('Вы не выбрали ни одного предложения.');
	} else {
		window.open("/compare"+str, 'compare', 'width=500, height=600, scrollbars=yes, top=100, left=100');
	}
}


function Calculator( credit_id ) {
	window.open("/calculator"+credit_id, 'calculator', 'width=500, height=600, scrollbars=yes, top=100, left=100');
}


function creditDescrView() {
	if (document.getElementById("creditDescr").style.display == '') {
		document.getElementById("creditDescr").style.display = 'none';
	} else {
		document.getElementById("creditDescr").style.display = '';
	}
	return false;
}

function modifyForm( val  ) {

var allFields = new Array( "currency" , "summ" , "period" , "poruch", "zalog", "zalog_data", "vznos", "age", "citizenship", "second_doc", "dohod", "address_register" , "address_fact" , "address_fact_data" , "have_smth", "flat_square", "home_taked", "home_period" , "work_period" );
		
for (var k in allFields) { 
	document.getElementById(allFields[k]).style.display = 'none'
}
		
if ( val == 2 ) {
	// Ипотека
	var iFields = new Array( "currency" , "summ" , "period" , "age", "citizenship", "second_doc", "dohod", "address_register" , "address_fact" , "address_fact_data" , "have_smth", "flat_square", "home_taked", "home_period", "work_period" );
	for (var i in iFields ) { 
		document.getElementById(iFields[i]).style.display = ''
	}
}
		
else if ( val == 5 ) {
	// Образование
	var iFields = new Array( "currency" , "summ" , "period" , "poruch", "age", "citizenship", "second_doc", "dohod", "address_register" , "work_period" );
	for (var i in iFields ) { 
		document.getElementById(iFields[i]).style.display = ''
	}
}
		
		
else if ( val == 6 ) {
	// Отдых
	var iFields = new Array( "currency" , "summ" , "period" , "poruch", "age", "citizenship", "second_doc", "dohod", "address_register" ,  "work_period" );
	for (var i in iFields ) { 
		document.getElementById(iFields[i]).style.display = ''
	}
}
		
else if ( val == 7 ) {
	// Автомобиль
	var iFields = new Array( "currency" , "summ" , "period" , "vznos", "age", "citizenship", "second_doc", "dohod", "address_register" ,  "work_period" );
	for (var i in iFields ) { 
		document.getElementById(iFields[i]).style.display = ''
	}
}
		
else if ( val == 3 || val == 8 ) {
	// Кредитные карты и Потреб.
	var iFields = new Array( "currency" , "summ" , "period" , "poruch", "zalog", "zalog_data", "age", "citizenship", "second_doc", "dohod", "address_register" , "work_period" );
	for (var i in iFields ) { 
		document.getElementById(iFields[i]).style.display = ''
	}
}
		
}

function pause() {
	var i = 1;
	i++;
	// пустой метод
}

function checkMainPageSearchForm(frm) {
	if ( frm.credit_type.value == 0 ) {
		alert('Не выбран тип кредита');
		frm.credit_type.focus();
		return false;
	}
	
	if ( isNaN(parseInt(frm.summ.value)) || parseInt(frm.summ.value) == 0 ) {
		alert('Не указана сумма кредита');
		frm.summ.focus();
		return false;
	}
	
	return true;
}


function StartPTest( mui ) {
	window.open('/inc/user/test.php?mui='+mui, 'test', 'width=500, height=200, scrollbars=yes, top=100, left=100');
}

function showhide(id){
	if (document.getElementById){
		obj = document.getElementById(id);
		if (obj.style.display == "none"){
			obj.style.display = "";
		} else {
			obj.style.display = "none";
		}
	}
}

function mshow(id){
	if (document.getElementById){
		obj = document.getElementById(id);
		obj.style.display = "";
	}
}

function mhide(id){
	if (document.getElementById){
		obj = document.getElementById(id);
		obj.style.display = "none";
	}
}

function confdel( url ) {
	if ( !confirm('Вы уверены, что хотите удалить запись?') ) {
		return false;
	}
	window.location.href=url;
}
