function checkAnno(){
    if(document.addform.anno_cena.value == ""){
        alert("Ошибка: Вы не ввели цену автомобиля !");
        $("#anno_cena").html("<b class=errora>Цена (в рублях):</b><br/>");
        return false;
    }
    if(document.addform.s0.value == 0){
        alert("Ошибка: Вы не выбрали марку автомобиля !");
        $("#s0").html("<b class=errora>Марка автомобиля:</b><br/>");
        return false;
    }
    if(document.addform.s1.value == 0){
        alert("Ошибка: Вы не выбрали модель автомобиля !");
        $("#s12").html("<b class=errora>Модель автомобиля:</b><br/>");
        return false;
    }
    if(document.addform.anno_year.value == 0){
        alert("Ошибка: Вы не выбрали год выпуска автомобиля !");
        return false;
    }
    return true;

}
function clearSelect(oListbox)
{
  for (var i=document.addform.s1.options.length-1; i >= 0; i--)
  {
      document.addform.s1.remove(i);
  }
};
function subscribe(val){
    var s0,s1,email;
    //$("#loading").show();
    s0 = document.getElementById('s0').value;
    s1 = document.getElementById('s1').value;
    email = document.getElementById('email').value;
    $("#standarForm").load("/subscribe",{act: 'subscribe',s0: s0,s1: s1,useremail: email}, onAjaxSuccess );
}
function addOptions(){
    if($("#options").css("display") == "block"){
        $("#options").slideUp();
    } else {
        $("#options").slideDown();
    }
    $("#opttext").html("скрыть опции");
}
function confirmDelete(delUrl) {
  if (confirm("Вы действительно хотите удалить ?")) {
    document.location = delUrl;
  }
}
function confirmDone(delUrl,message) {
  if (confirm(message)) {
    document.location = delUrl;
  }
}
function closeWin(obj){
    $("#loading").fadeOut(500);
    $("#blackwrap").fadeOut(500);
    $("#loadData").html('');
}
function loginForm(obj){
    obj.href = '#';
    $("#loading").show();
    $("#blackwrap").show();
    $("#loadData").load("/loginform",{act: 'loginform'}, onAjaxSuccess );
    return false;
}
function regForm(obj){
    obj.href = '#';
    $("#loading").show();
    $("#blackwrap").show();
    $("#loadData").load("/regform",{act: 'regform'}, onAjaxSuccess );
    return false;
}
function onAjaxSuccess(){
    $("#loading").fadeOut(500);
}
function addmark(val){
    $("#loading").show();
    $("#s1").load("/loadmark",{act: 'loadmark',mark: val}, onAjaxSuccess );
}
function addfind(val){
    if(val == 2){
        $("#loading").show();
        $("#addfind").load("/loadoptions",{act: 'loadoptions'}, onAjaxSuccess );
    } else {
        $("#addfind").html('<span><a href="#" onClick="addfind(2)" class="findadd">расширенный поиск</a></span>');
    }
}
function getTag(tagOpen,tagClose){
    var selectedText = getSelect();
    if(selectedText){
    var newsText = document.getElementById("newsarea").value;
    newsText = newsText.replace(selectedText,tagOpen+selectedText+tagClose);
    document.getElementById("newsarea").value = newsText;
    } else {
        alert("Вы не выбрали текст");
    }
}
function getSelect(){
    txtarea = document.getElementById("newsarea");
    return (txtarea.value).substring(txtarea.selectionStart,txtarea.selectionEnd);
}
function addTag(tag){
    var newsText = document.getElementById("newsarea").value;
    cursorStart = document.getElementById("newsarea").selectionStart;
    newsTextStart = newsText.substr(0,cursorStart);
    newsTextEnd = newsText.substr(cursorStart,newsText.length);
    newsText = newsTextStart + tag + newsTextEnd;
    document.getElementById("newsarea").value = newsText;
}
function bookmark(title, url) {
	// если название страницы не было чётко указано, возьмём заголовок текущей страницы
	if (title == undefined)
		title = document.title;

	// то же самое и с URL-ом
	if (url == undefined)
		url = top.location.href;

	if (window.sidebar) {
		// Firefox
		window.sidebar.addPanel(title, url, '');
	} else if (window.opera && window.print) {
		// Opera
		var t = document.createElement('a');
		t.setAttribute('rel', 'sidebar');
		t.setAttribute('href', url);
		t.setAttribute('title', title);
		t.click();
	} else {
		// IE
		window.external.AddFavorite(url, title);
	}
	return false;
        }

