brName = navigator.appName; brVer = navigator.appVersion; brAgent = navigator.userAgent;

isDOM = document.getElementById ? true:false;
isOpera = (window.opera && isDOM) ? true:false;
isOpera6 = (isOpera && window.print)? true:false;
isOpera7= (isOpera && document.readyState)? true:false;
isOpera8= /Opera[^\d]*8/.test(brAgent);
isOpera9= /Opera[^\d]*9/.test(brAgent);
isIE = (document.all && document.all.item && !isOpera)? true:false
isSafari=/\WSafari\W/.test(brAgent);
isNN= (brName=="Netscape")? true:false;
isMozilla= (isNN && isDOM)? true:false;

function createPictureWindow(Path,Width,Height,Title)
{
	var p = Math.ceil(Math.random()*10000);
	var q = Math.ceil(Math.random()*p);
	windowName = p+'X'+(Width*p)+(Height*q);
	WinFeatures = "top="+(screen.height-Height)/2+",left="+(screen.width-Width)/2+",width="+Width+",height="+Height+",Status=no,toolbar=no,menubar=no,location=no,directories=no,scrollbars=no";
	w = window.open("",windowName,WinFeatures);
	w.document.open();
	w.document.write('<head><title>'+Title+'</title><meta http-equiv="Content-Type" content="text/html; charset=windows-1251"></head>');
	w.document.write("<body bgcolor='#FFFFFF' leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'><img src='"+Path+"' height='"+Height+"' width='"+Width+"' alt='&quot;"+Title+"&quot;'></body>"); 
	w.document.close();
}

function formValid(form) {
	f1 = document.forms[form].elements['field[title]'].value;
	f2 = document.forms[form].elements['field[email]'].value;
	f3 = document.forms[form].elements['field[text]'].value;
	
	if ((f1 == "") || (f1 == "Ваше имя")) {
		alert("Введите, пожалуйста, Ваше имя");
		return false;
	}
 	else if ((f2 == "") || (f2 == "Ваш e-Mail") || (f2.indexOf('@')<0) || (f2.indexOf('.')<0)) {
		alert("Введите, пожалуйста, корректный e-Mail");
		return false;
	}
	else if (f3 == "") {
		alert("Введите, пожалуйста, Ваше сообщение");
		return false;
	}
	else return true;
}

function createDynamicWindow(Path,Width,Height,Title)
{
	var p = Math.ceil(Math.random()*10000);
	var q = Math.ceil(Math.random()*p);
	windowName = p+'X'+(Width*p)+(Height*q);
	WinFeatures = "top="+(screen.height-Height)/2+",left="+(screen.width-Width)/2+",width="+Width+",height="+Height+",Status=no,toolbar=no,menubar=no,location=no,directories=no,scrollbars=no";
	w = window.open("",windowName,WinFeatures);
	w.document.open();
	w.document.write('<head><title>&quot;'+Title+'&quot;</title><meta http-equiv="Content-Type" content="text/html; charset=windows-1251"></head>');
	w.document.write("<body bgcolor='#FFFFFF' leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'><img src='"+Path+"' height='"+Height+"' width='"+Width+"' alt='&quot;"+Title+"&quot;'></body>"); 
	w.document.close();
}

function createPopup(num)
{
	var p = Math.ceil(Math.random()*10000);
	var q = Math.ceil(Math.random()*p);
	windowName = p+'X'+p+p*q;
	WinFeatures = "top=100,left=100,width=1,height=1,Status=no,toolbar=no,menubar=no,location=no,directories=no,scrollbars=no";
	w = window.open(num,windowName,WinFeatures);
}

function MakeImageArray(n)	{
	this.length=n; for (var i=0; i<=n; i++) this[i] = new Image(); return this
	}

button_boutique = new MakeImageArray(2);
button_cakes = new MakeImageArray(2);
button_order = new MakeImageArray(2);

button_boutique[0].src = "pics/menu1.gif";  button_cakes[0].src = "pics/menu2.gif";  button_order[0].src = "pics/menu3.gif";
button_boutique[1].src = "pics/menu1a.gif"; button_cakes[1].src = "pics/menu2a.gif"; button_order[1].src = "pics/menu3a.gif";


function turnOn(num,menu) {
	document.getElementById('menu_item_'+menu).src = eval('button_'+menu)[num].src;
}

// Opacity change
var opacityTo;
var filterStep = 10;
var filterTimeOut = 20;

function setElementOpacity(sElemId, nOpacity){
	var opacityProp = getOpacityProperty(), elem = document.getElementById(sElemId);
	if (!elem || !opacityProp) return;
	if (opacityProp=="filter"){
		nOpacity *= 100;
		var oAlpha = elem.filters['DXImageTransform.Microsoft.alpha'] || elem.filters.alpha;
		if (oAlpha) oAlpha.opacity = nOpacity;
		}
	else elem.style[opacityProp] = nOpacity;
}

function getElementOpacity(sElemId){
	var opacityProp = getOpacityProperty(), elem = document.getElementById(sElemId);
	if (!elem || !opacityProp) return;
	if (opacityProp=="filter"){
		var oAlpha = elem.filters['DXImageTransform.Microsoft.alpha'] || elem.filters.alpha;
		if (oAlpha) _opacity = oAlpha.opacity/100;
		}
  	else _opacity = elem.style[opacityProp];
	return _opacity;
}

function getOpacityProperty() {
	if (typeof document.body.style.opacity == 'string') return 'opacity';
	else if (typeof document.body.style.MozOpacity == 'string') return 'MozOpacity';
	else if (typeof document.body.style.KhtmlOpacity == 'string') return 'KhtmlOpacity';
	else if (document.body.filters && navigator.appVersion.match(/MSIE ([\d.]+);/)[1]>=5.5) return 'filter';
	return false; //нет прозрачности
}

function filterColor(layer){
	_opacity = getElementOpacity(layer);
	_opacity = parseFloat(0+_opacity);
		
	if((isIE || isMozilla || isSafari) && _opacity < 1) {
		clearTimeout(opacityTo);
		_opacity+=filterStep/100;
		setElementOpacity(layer,_opacity);
		opacityTo=setTimeout("filterColor('"+ layer + "')",  filterTimeOut);
	}
	else clearTimeout(opacityTo);
}


// Проверка содержимого полей формы заказа
function orderValid(form)
{
	element = document.forms[form].elements;
	Name = element.contact_name.value;
	Phone = element.phone_mobile.value+element.phone_work.value+element.phone_home.value;

	if (Name == "") {
		alert("Введите, пожалуйста, Ваше имя");
		return false;
	}
 	else if (Phone == "") {
		alert("Введите, пожалуйста, хотя бы один телефон");
		return false;
	}	
	else return true;
}

function createDescriptionWindow(_file,_width,_height)
{
	wTop = (screen.height-_height)/3;
	wLeft = (screen.width-_width)/2;
	WinFeatures = "top="+wTop+",left="+wLeft+",width="+_width+",height="+_height+",maximize=no,minimize=no,Status=no,toolbar=no,menubar=no,location=no,directories=no,scrollbars=yes,resize=no";
	_newDescription = window.open(_file,"frontendDescriptionWindow",WinFeatures);
}

function checkFeedback(form) {
	f1 = document.forms[form].name.value;
	f2 = document.forms[form].email.value;
	f3 = document.forms[form].text.value;
	
	if (f1 == "") {
		alert("Введите, пожалуйста, Ваше имя");
		return false;
	}
 	else if ((f2 == "") || (f2 == "Ваш e-Mail") || (f2.indexOf('@')<0) || (f2.indexOf('.')<0)) {
		alert("Введите, пожалуйста, корректный e-mail");
		return false;
	}
	else if (f3 == "") {
		alert("Введите, пожалуйста, текст сообщения");
		return false;
	}
 	else return true;
}

function AddBookMark() 
{  
if (document.all) 
{    
window.external.AddFavorite("http://www.hospital24.ru","Клиники Германии");  
} 
else 
{    
alert("Ваш браузер не поддерживает функцию добавления закладок.");  
}
}



function add_home(obj) {
   obj.style.behavior='url(#default#homepage)';
   obj.setHomePage('http://www.hospital24.ru/');
   return false;
}

