function bookmark (a) {
    if (window.opera && window.print) {
        var mbm = a;
        mbm.setAttribute("rel", "sidebar");
        mbm.setAttribute("title", document.title);
        mbm.setAttribute("href", window.location.href);
        mbm.click();
    } else if (window.sidebar) {
        window.sidebar.addPanel(document.title, window.location.href, "");
    } else if (window.external) {
        window.external.AddFavorite(window.location.href, document.title);
    }
	xajax_click_on_favorites(window.location.href);
}

function ShowWin(url,x,y,name,isscrollbars) {
    cx=screen.width / 2 - (x / 2);
    cy=(screen.height/2-(y/2));
    isscrollbars=(isscrollbars=="no")?"no":"yes";
    window.open(url,name,"toolbar=no,status=no,directories=no,menubar=no,resizable=no,width="+x+",height="+y+",scrollbars="+isscrollbars+",top="+cy+",left="+cx);
}  

function ShowImg(ImgPath, x, y) {
    cx=screen.width / 2 - (x / 2);
    cy=(screen.height/2-(y/2));
    if (ImgPath == '/images/map.gif')
        var w = window.open("", "map1", "toolbar=no,status=no,directories=no,menubar=no,resizable=yes,width="+x+",height="+y+",scrollbars=yes,top="+cy+",left="+cx);
    if (ImgPath == '/images/map2.gif')
        var w = window.open("", "map2", "toolbar=no,status=no,directories=no,menubar=no,resizable=yes,width="+x+",height="+y+",scrollbars=yes,top="+cy+",left="+cx);

    var d = w.document;
    d.open();
    d.write('<html><head><title></title></head><link rel="stylesheet" type="text/css" href="/css/style.css">');
    d.write('<body style="margin: 0px; padding: 0px;"><img src = "' + ImgPath + '"</body></html>');
    d.close();
}

function show_tab(number) {
      if (number == 1) {
            document.getElementById('tab1t').className = 'tab_sel';          
            document.getElementById('tab2t').className = 'tab';
            document.getElementById('tab3t').className = 'tab';
            document.getElementById('tab4t').className = 'tab';

            document.getElementById('tab1c').style.display = 'block';
            document.getElementById('tab2c').style.display = 'none';
            document.getElementById('tab3c').style.display = 'none';
            document.getElementById('tab4c').style.display = 'none';
      }

      if (number == 2) {
            document.getElementById('tab2t').className = 'tab_sel';            
            document.getElementById('tab1t').className = 'tab';
            document.getElementById('tab3t').className = 'tab';
            document.getElementById('tab4t').className = 'tab';

            document.getElementById('tab2c').style.display = 'block';
            document.getElementById('tab1c').style.display = 'none';
            document.getElementById('tab3c').style.display = 'none';
            document.getElementById('tab4c').style.display = 'none';
      }

      if (number == 3) {
            document.getElementById('tab3t').className = 'tab_sel';            
            document.getElementById('tab1t').className = 'tab';
            document.getElementById('tab2t').className = 'tab';
            document.getElementById('tab4t').className = 'tab';

            document.getElementById('tab3c').style.display = 'block';
            document.getElementById('tab1c').style.display = 'none';
            document.getElementById('tab2c').style.display = 'none';
            document.getElementById('tab4c').style.display = 'none';
      }

      if (number == 4) {
            document.getElementById('tab4t').className = 'tab_sel';            
            document.getElementById('tab1t').className = 'tab';
            document.getElementById('tab2t').className = 'tab';
            document.getElementById('tab3t').className = 'tab';

            document.getElementById('tab4c').style.display = 'block';
            document.getElementById('tab1c').style.display = 'none';
            document.getElementById('tab2c').style.display = 'none';
            document.getElementById('tab3c').style.display = 'none';
      }
    
}

var searchResElem = []; 	// Для навигации по результатам поиска при помощи клавиатуры - массив елементов
var searchResElemSelected = -1; // Для навигации по результатам поиска при помощи клавиатуры - текущий элемент
var searchResElemHref = ''; // Для навигации по результатам поиска при помощи клавиатуры - url выбранного элемента

//mouseover на результат поиска
function sel_result(el) {
    //$(el).removeClass('result_value');
    $(el).addClass('result_value_selected');
}

//mouseout на результат поиска
function unsel_result(el) {
    $(el).removeClass('result_value_selected');
    //$(el).addClass('result_value');
}


function pr(url) {
    x = 900;
    y = 550;
    cx = screen.width/2 - x/2;
    cy = screen.height/2 - y/2;
    window.open(
                    url,
                    '',
                    "toolbar=no, status=no, directories=no, menubar=no, resizable=no, width="+x+", height="+y+", scrollbars=yes, top="+cy+", left="+cx
                );
}


function recall() {
		var name = $('#fancy_div #form-callback #callback input[name=name]').val();
		var phone = $('#fancy_div #form-callback #callback input[name=phone]').val();
		var head = $('#fancy_div #form-callback #callback input[name=head]').val();
		
		if(name == 'Ваше имя *' ||
			   name == '' ||
			   phone == 'Телефон *' ||
			   phone == '' ||
			   head == 'Тема сообщения *' ||
			   head == '') alert('Пожалуйста, заполните обязательные поля формы');	
		else
			xajax_callback(name, phone, head);
		return false;
}


function send_poll(poll_id) {
	//Получаем параметры
	var data = $('#poll').serialize();
	// Отсылаем паметры
		   $.ajax({
					type: "POST",
					url: "http://www.shop-stroitel.ru/modules/vote.processor.php",
					data: data,
					success: function(){
						xajax_vote_result(poll_id);
					}
				});
	return false;
}

function validateForm (form) {
	// Проверка телефона
	var flag = true;
	if($('#main_phone input[name=phone]').attr('type') == 'text') {
		if($('#main_phone input[name=phone]').val() == '' || $('#main_phone input[name=phone]').hasClass('example_phone')) {
			flag = false;
		}
	}else if($('#main_phone input[name=phone]').attr('type') == 'checkbox') {
		if($('#main_phone input:checked').length == 0) {
			flag = false;
			$('.extra_phone input[name*=extra_phone]').each(function() {
				if($(this).val() != '' && !$(this).hasClass('example_phone'))
					flag = true;
			});
		}			
	}else{
		flag = false;
	}
	
	if(flag) {
		$('#form input.example_phone').val('');
		return true; 
	}else {
		alert('Не укзан телефон!'); 
		return false;
	}
}

