// Любая страница, с ценами
function prices(coll, state) {
	var bgColor = coll.bgColor;
	if(state == 1) {
		coll.style.backgroundColor = "#f1efdd";
	} else {
		coll.style.backgroundColor = bgColor;
	}
}

// Контакты
function highlight(fieldId) {
	$("#"+fieldId).addClass("input-error");
}

function normalize(fieldId) {
	$("#"+fieldId).removeClass("input-error");
}

function checkValue(fieldId, minLen, maxLen) {
	result = true;
	
	fieldVal = $("#"+fieldId).val();
	if (
		fieldVal.length < minLen || fieldVal.length > maxLen
		|| (fieldId == "email" && !/^[a-z0-9\._-]+@[a-z0-9\._-]+\.[a-z]{2,6}$/i.test(fieldVal))
		|| (fieldId == "code" && !/^[0-9]*$/i.test(fieldVal))
	) {
		highlight(fieldId);
		result = false;
	} else {
		normalize(fieldId);
	}
	
	return result;
}

function verifyForm() {
	var result = true;
	
	if(!checkValue("fio", 1, 128)) {
		result = false;
	}
	if(!checkValue("phone", 1, 32)) {
		result = false;
	}
	if(!checkValue("email", 1, 128)) {
		result = false;
	}
	if(!checkValue("order", 1, 5000)) {
		result = false;
	}
	if(!checkValue("code", 4, 4)) {
		result = false;
	}
	
	return result;
}

function insertEmail() {
	document.getElementById("site_email").innerHTML = '<a href="javascript:void(0);" onclick="location.href=\'mailto:stanislav'+'@'+'nika'+'.'+'org'+'.'+'ua\'; return false;">stanislav'+'@'+'nika'+'.'+'org'+'.'+'ua</a>';
}

$(document).ready(function() {
	try{
		$("#banking_details_link").click(function() {
			$('#banking_details_content').stop(true, true).slideToggle(300);
		});
	} catch(e) { }
});
