jQuery.noConflict();

jQuery(document).ready(function(){

// устраняем flickering в ие6
try {
if(navigator.userAgent.indexOf('MSIE'))
document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}

/*------замена ыелектов------------*/
// Temporary commented while select's css doesn't work with jquery which generates dynamic country-city lists
changeSelects();

/*------смена цвета фона ----------*/

jQuery("div.headerChooseColor > div").mousedown(
function()
{
	jQuery("body").removeClass().addClass(jQuery(this).attr("id"));
	jQuery.cookie("site_color", jQuery(this).attr("id"), {
                                    path: "/"
                                    }
        );
	return true;
});

/*---------- показать вкладку детальный поиск---------*/

jQuery('#search_detail_but').click(
function()
{
	if(jQuery('#search').css("display")!='none')
	{
	jQuery('#search').css("display","none");
	jQuery('#search_detail').fadeIn(300);
	document.getElementById("search_but").className="search_but2";
	document.getElementById("search_detail_but").className="search_detail_but2";
	if(jQuery.browser.msie) {
		jQuery('.formSubmit').css("bottom","30px");
		}
	jQuery('#search_but').removeClass();
	jQuery(this).addClass("leftcolActive");
	}
	
	
});

/*---------- показать вкладку детальный поиск---------*/

jQuery('#search_but').click(
function()
{
	if(jQuery('#search').css("display")=='none')
	{
	jQuery('#search_detail').css("display","none");
	jQuery('#search').fadeIn(300);
	document.getElementById("search_but").className="search_but";
	document.getElementById("search_detail_but").className="search_detail_but";
	if(jQuery.browser.msie) {
		var top = document.getElementById('search').offsetHeight+27;
		jQuery('#search > .but').css("top",top);
		}
	jQuery('#search_detail_but').removeClass();
	jQuery(this).addClass("leftcolActive");
	}
	
});

/*---логин / pass ---*/
jQuery("form.headerLoginForm > div > input").focus(
function()
{
	if((jQuery(this).val()=="" && jQuery(this).attr("id")=="login") || (jQuery(this).val()=="" && jQuery(this).attr("id")=="password"))
	jQuery(this).prev().text("").css("background","none");
	return true;
});

jQuery("form.headerLoginForm > div > input").blur(
function()
{
	if(jQuery(this).val()=="" && jQuery(this).attr("id")=="login")
		jQuery(this).prev().text("Login").css("background","url(images/header/blackArrow.gif) right 9px no-repeat");
	else
	if(jQuery(this).val()=="" && jQuery(this).attr("id")=="password")
		jQuery(this).prev().text("Password").css("background","url(images/header/blackArrow.gif) right 9px no-repeat");
	return true;
});
/*----клик по кнопкам-----*/
jQuery('input').click(
function()
{
	if(jQuery(this).attr("typebut")=="click")
	{
		var posBack = this.offsetHeight;
		jQuery(this).css("background-position","bottom left");
		var thisEl = jQuery(this);
		setTimeout(function(){
							thisEl.css("background-position","top left");
							if(thisEl.is("input[type=submit]"))
                                                        {
                                                                if(thisEl.is("input[presubmit=yes]"))
                                                                   PreSubmit();
								else if (thisEl.is("input[action=customjq]"))
								{
								   //return false;
								}
								else thisEl.parents("form").submit();
                                                        }
							return true;
							},150);
		return false;
	}
	
});

jQuery('a').click(
function()
{
	if(jQuery(this).attr("typebut")=="click")
	{
		var posBack = this.offsetHeight;
		jQuery(this).css("background-position","bottom left");
		var thisEl = jQuery(this);
		setTimeout(function(){
							thisEl.css("background-position","top left");
							if(thisEl.is("a[action=submit]")) // Alena, по ссылке сабмитится форма
							{
							  thisEl.parents("form").submit();
							}
							else if(thisEl.is("a[action=presubmit]")) // Alena, по ссылке сабмитится форма, перед этим должна выполнится функция PreSubmit
							{
							  PreSubmit(thisEl);
							}
                                                        else if(thisEl.is("a[action=customjq]")) // Alena, переход по ссылке не нужен, будет выполнен некий jq-скрипт
                                                        {
                                                          // nothing to do
                                                        }
							else
							{
							  window.location=thisEl.attr("href");
							}
							return true;
							},150);
		return false;
	}
	
});

jQuery('div').click(
function()
{
	if(jQuery(this).attr("typebut")=="click")
	{
		var posBack = this.offsetHeight;
		jQuery(this).css("background-position","bottom left");
		var thisEl = jQuery(this);
		setTimeout(function(){
							thisEl.css("background-position","top left");
							return true;
							},150);
		return false;
	}
	
});

jQuery('span[@typebut=click]').click(
function()
{
                var posBack = this.offsetHeight;
                jQuery(this).css("background-position","bottom left");
                var thisEl = jQuery(this);
                setTimeout(function(){
                                                        thisEl.css("background-position","top left");
                                                        return true;
                                                        },150);
                return false;

});


							   });
