function toggleDesign(url) {
	new Ajax.Request(url,
		{
			method: 'post',
			parameters: { simple: 1, nocache: parseInt(Math.random() * 1000000) }
		});
	location.href = url + '?nocache=' + parseInt(Math.random() * 1000000);
	location.reload(true);
}

function FormSUb(){
	
	var required = {
		"fname"		:	"Вы не представились",
		"email"		:	"Не введен или введен некорректный e-mail"
	};
	
	for (i in required) {
		var el = document.getElementById(i);
		if(el.id == 'email' && el.value && !checkEmail(el.value)){
			alert(required['email']);
			el.focus();
			return false;
		}
		
		if (!el.value) {
			alert(required[i]);
			el.focus();
			return false;
		}
	}
	return true;
}


function checkStrSearch(str) {
   if((str.value.length) < 3) {
        alert('Строка поиска должна быть не менее 3 символов');
        return false;
    } else return true;
}


function preloadImg(src) {
	if (document.images) {
		var image = new Image();
		image.src = src;
		images.push(image);
	}
}

function checkEmail(email) {
	if(!email) return email;
	if(!email.match(/^[\w\.\-]+@[\w\.\-]+\.[a-zA-Z]{2,}$/i, "")) return false;
	return true;
}

function checkUrl(url) {
	pattern = /https?:\/\/(?:[-_A-Z0-9]*)\.[A-Z0-9]{2,5}(?:\/[-A-Z0-9+&@#/%=~_|]*)?/i;
	return url.match(pattern);
}

function showHiddenElem(id) {
	//alert(id);
	if(!document.getElementById(id)) {
		return false;
	}
	elem = document.getElementById(id);
	if(elem.style.display == 'block') elem.style.display = 'none';
	else elem.style.display = 'block';
}

function getElem(id) {
	return document.getElementById(id);
}

function preloadImages() {
	var d = document; 
	
	if(d.images) {
		var i, a = preloadImages.arguments;
		for(i = 0; i < a.length; i++) {
			d.preloadedImages[a[i]] = new Image;
			d.preloadedImages[a[i]].src = a[i];
		}
	}
}

function changeImage(image, url) {
	image.src = url;
}

function isInt(num, chara)
{
	if(((num >= 48) && (num <= 57)) || num == 37 || num == 8)
	{
		event.keyCode = num;
		return event.keyCode;
	}
	if(((chara >= 48) && (chara <= 57)) || chara == 37 || chara == 8)
	{
		event.charCode = chara;
		return event.charCode;
	}
	else
	{
		return false;
	}
}

function trim(str) {
	while (str.substr(0, 1) == ' ') {str = str.substr(1);};
	while (str.substr(str.length - 1, 1) == ' ') {str = str.substr(0, str.length - 1);};
	return str;
}

function setHttp(link) {
	if(link && link.substr(0, 7) != 'http://') link = 'http://' + link;
	return link;
}

function dump(elem) {
	var str="";
	for(var key in elem) {
		str += key + ": " + elem[key] + "\n<br>";
	}
	document.write(str);
}


function checkFeedbackForm() {
	var required = {
		"name"		:	"Вы не ввели Ваше ФИО",
		"org"		:	"Вы не ввели оганизацию",
		"email"		:	"Не введен или введен некорректный e-mail",
		"msg"		:	"Вы не ввели сообщение"
	};

	for (i in required) {
		var el = document.getElementById(i);
		if(el.id == 'email' && el.value && !checkEmail(el.value))
		{
			alert(required['email']);
			el.focus();
			return false;
		};
		if (!el.value) {
			alert(required[i]);
			el.focus();
			return false;
		}
	}
	return true;
}


function checkFeedbackFormFeedback() {
	var required = {
		"name"		:	"Вы не представились",
		"address"		:	"Вы не ввели контактный телефон",
		"msg"		:	"Вы не ввели сообщение"
	};

	for (i in required) {
		var el = document.getElementById(i);
		if(el.id == 'email' && el.value && !checkEmail(el.value))
		{
			alert(required['email']);
			el.focus();
			return false;
		};
		if (!el.value) {
			alert(required[i]);
			el.focus();
			return false;
		}
	}
	return true;
}

function auto_form_check(required) {
	if(!required) return true;
	for (var i in required) {
		var el = document.getElementById(i);
		if (!el.value) {
			alert(required[i]);
			el.focus();
			return false;
		}
	}
	return true;
}

function faq(id)
{
	var div = document.getElementById('answer_'+id);
	if(div.style.display == 'none')
	{
		div.style.display = 'block';
	}
	else
	{
		div.style.display = 'none';
	}
}




var isDOM = document.getElementById //DOM1 browser 
var isO   = isO5 = window.opera && isDOM; //Opera 5+
var isO6  = isO && window.print //Opera 6+
var isO7  = isO && document.readyState //Opera 7+
var isIE  = document.all && document.all.item && !isO //Microsoft Internet Explorer 4+
var isIE5 = isIE && isDOM //MSIE 5+
var isMZ  = isDOM && (navigator.appName=="Netscape")