function openwindow(url, name, width, height)
{
    var left = parseInt((screen.availWidth/2)-(width/2));
    var top = parseInt((screen.availHeight/2)-(height/2));
    var windowProperties = "width="+width+",height="+height+",left="+left+",top="+top;
	win = window.open(url, name, windowProperties+",resizable=no,toolbar=0,location=0,status=yes,menubar=0,directories=0,scrollbars=yes");
	win.focus();
}

function addBookmark(url, title)
{
	if (!url) url = location.href;
	if (!title) title = document.title;

	//Gecko
	if ((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function")) window.sidebar.addPanel (title, url, "");
	//IE4+
	else if (typeof window.external == "object") window.external.AddFavorite(url, title);
	//Opera7+
	else if (window.opera && document.createElement)
	{
		var a = document.createElement('A');
		if (!a) return false; //IF Opera 6
		a.setAttribute('rel','sidebar');
		a.setAttribute('href',url);
		a.setAttribute('title',title);
		a.click();
	}
	else return false;
	return true;
}

function check()
{
 	var err = 0; var msg = "";
	var form = document.forms.contacts.elements;
	if (form.name.value == "" || form.name.value == "Ваше имя") { err++; msg="Укажите имя!"; field="name"; }
	if (err == 0 && (form.email.value == "" || form.email.value == "Ваш e-mail")) { err++; msg="Укажите Ваш обратный адрес!"; field="email"; }
	if (err == 0 && (form.country.value == "" || form.country.value == "Страна")) { err++; msg="Укажите Вашу страну!"; field="country"; }
	if (err == 0 && (form.city.value == "" || form.city.value == "Ваш город")) { err++; msg="Укажите Ваш город!"; field="city"; }
	if (err == 0 && (form.subject.value == "" || form.subject.value == "Тема письма")) { err++; msg="Укажите тему письма!"; field="subject"; }
 	if (err == 0) { document.forms.contacts.submit(); }
	else { alert(msg); document.getElementsByName(field)[0].focus(); }
}

function EditCity(cityvalue, citytext)
{
    city = document.forms.inputform.elements.cid;
    clength= city.length;
    ccurrent = clength-1;
    document.forms.inputform.elements.cid[ccurrent].selected = true;
    city.options[ccurrent].text= citytext;
    city.options[ccurrent].value= cityvalue;
    city.options[clength] = new Option("Другой город...", "-2");
}

function selectGeo(obj, prefix)
{

	sindex = obj.selectedIndex;
  	if (obj[sindex].value == "-2")
	{
    	openwindow('/purecms/cities.php?field='+prefix, 'selectcity', 350, 240);
    	obj[selform.length-1].selected = true;
	}
}
