jQuery.noConflict();

function setHints()
{
    //small icons hints
    jQuery(".forIcons > span").hover(
	function () {
		    jQuery(this).find(".hint").css("display","block");
	},
	function () {
	    jQuery(this).find(".hint").css("display","none");
	}
    );


    jQuery(".itemText h3 > span").hover(
	function () {
		    jQuery(this).find(".hint").css("display","block");
	},
	function () {
	    jQuery(this).find(".hint").css("display","none");
	}
    );
}

jQuery(document).ready(function(){


// addCompany
jQuery("#addCompany").click(function(){
	jQuery("#addCompanyWindow").appendTo("body").fadeIn("fast");
	toggleDarkBack();
	return false;

});


// enterCompany
jQuery("#enterCompany").click(function(){
	jQuery("#enterCompanyWindow").appendTo("body").fadeIn("fast");				  
	toggleDarkBack();
	return false;
});


// otherHighway
jQuery("#otherHighway").click(function(){
	jQuery("#otherHighwayWindow").appendTo("body").fadeIn("fast");								  
	toggleDarkBack();
	return false;
});

var otherDirFlag = true;
// otherDirection
jQuery("#otherDirectionStr").click(function(){
	if(otherDirFlag) {
	jQuery("#otherDirectionWindow").appendTo("body").fadeIn("fast");
	otherDirFlag = false;
	}
	else jQuery("#otherDirectionWindow").fadeIn("fast");
	toggleDarkBack();
	return false;
});

// onlineMailWindow
jQuery("#mailOnline").click(function(){
	jQuery("#onlineMailWindow").appendTo("body").fadeIn("fast");										 
	toggleDarkBack();
	return false;
});

// addFeedbackWindow
jQuery("#addFeedback").click(function(){
	jQuery("#addFeedbackWindow").appendTo("body").fadeIn("fast");											 
					  
	toggleDarkBack();
	return false;
});

// popup recomendations
jQuery("#showRecomendations").click(function(){
	jQuery("#popupRecomendations").appendTo("body").fadeIn("fast");											 
	toggleDarkBack();
	return false;
});

// popup add company
jQuery("#addToOurSearch").click(function(){
	jQuery("#popupAddCompany").appendTo("body").fadeIn("fast");											 
	toggleDarkBack();
	return false;
});

// 
jQuery(".popupClose").click(function(){
	jQuery(this).parent().fadeOut();
	jQuery("#TB_overlay").remove();
	return false;
});


function toggleDarkBack(){

	if(!jQuery("body").find("#TB_overlay").is("div")) 
	{
	   if(!jQuery.browser.msie)
	   jQuery("body").append("<div id='TB_overlay'></div>");
	
	   else {
		
	   jQuery("body").append("<div id='TB_overlay'><iframe scrolling='no' frameborder='0' style='position: absolute; top: 0; left: 0; width: 100%; height: 100%; filter:alpha(opacity=0)'></iframe></div>");
	   }
		 
	}
	else
	{
		jQuery("#TB_overlay").remove();
	}

}



//hints 
jQuery(".bigPercent").hover(
      function () {
		jQuery("#bigPercentHint").css("display","block");
      },
      function () {
        jQuery("#bigPercentHint").css("display","none");
      }
);
jQuery(".bigMedal").hover(
      function () {
        jQuery("#bigMedalHint").css("display","block");
      },
      function () {
        jQuery("#bigMedalHint").css("display","none");
      }
);
jQuery(".bigHand").hover(
      function () {
        jQuery("#bigHandHint").css("display","block");
      },
      function () {
        jQuery("#bigHandHint").css("display","none");
      }
);


setHints();

//    
jQuery("#searchInp").focus(
function () {
    if(jQuery(this).val()=='Iai?eia?, "?anoi?aiu"') jQuery(this).val("");
		 
		 
});
jQuery("#searchInp").blur(
function()
{
	if(jQuery(this).val()=="") jQuery(this).val('Например, "рестораны"');
	return false;
});




//direction Window

jQuery("#clearFilter").click(function(){
	jQuery(".popupDirForm input").attr("checked","");
	jQuery("#otherDirection i").replaceWith("<i>на всем направлении</i>");
	jQuery("#otherDirectionHellip").css("display","none");
	jQuery("#otherDirection").removeClass("noBack");
	return false;
});



//images  

preload([
		'../images/popup.png',
		'../images/popup-body.png',
		'../images/popup-bot.png',
		'../images/popup-top.png',
		'../images/popup400-body.png',
		'../images/popup400-bot.png',
		'../images/popup400-top.png',
		'../images/hint-top.png',
		'../images/good50.png',
		'../images/bad50.png',
		'../images/so-so50.png'

]);

function preload(images) {
    if (typeof document.body == "undefined") return;
    try {

        var div = document.createElement("div");
        var s = div.style;
		    s.position = "absolute";
        s.top = s.left = 0;
        s.visibility = "hidden";
        document.body.appendChild(div);
		div.innerHTML = "<img src=\"" + images.join("\" /><img src=\"") + "\" />";
		var lastImg = div.lastChild;
		lastImg.onload = function() { document.body.removeChild(document.body.lastChild); };
	 }
	 catch(e) {
        // Error. Do nothing.
	}
}

// define directions from request (function from jquery.inner.js OR jquery.main.directions.js !!!)
setDirectionStr();


});




