// ------------------------------
//        input_default
// ------------------------------

function input_default(elm)
{
  if (!elm.base) elm.base = elm.value
  if (elm.value == elm.base) elm.value = "";
  else if (elm.value == "") elm.value = elm.base;
}

//------------------------------
//			close_box
//------------------------------

function close_box()
{
	$("#lb_box").html("");
	hideLightbox();
}

//------------------------------
//				map hover
//------------------------------

function map_hover()
{
	$("div.map a.map").hover(function () 
	{
		 $('div.map a.map').animate({backgroundPosition: '0px 0px'}, "slow");
	}, 
	function () 
	{
		$('div.map a.map').animate({backgroundPosition: '0px 6px'}, "slow");
	});
}

//------------------------------
//				open map
//------------------------------

function open_map()
{
	showLightbox();
	$("div.map a.map").blur();
	$("div.map_modal_box").show();
	mapInitialize("map");	
	
	$.get("/ajax.php", { section: "pins"}, 
	function(data) 
	{
		$("#pins").html(data);
	});		

}

//------------------------------
//			close_map
//------------------------------

function close_map()
{
	hideLightbox();
	$("div.map_modal_box").hide();
}

//------------------------------
//				preloading
//------------------------------

(function ($) {
$.preLoadImages = function(imageList,callback) {
var pic = [], i, total, loaded = 0;
if (typeof imageList != 'undefined') {
  if ($.isArray(imageList)) {
      total = imageList.length;
          for (i=0; i < total; i++) {
              pic[i] = new Image();
              pic[i].onload = function() {
                  loaded++;
                  if (loaded == total) {
                      if ($.isFunction(callback)) {
                          callback();
                      }
                  }
              };
              pic[i].src = imageList[i];
          }
  }
  else {
  	  pic[0] = new Image();
      pic[0].onload = function() {
          if ($.isFunction(callback)) {
              callback();
          }
      }
      pic[0].src = imageList;
  }
}
pic = undefined;
};
})(jQuery);

//------------------------------
//					fb open
//------------------------------

$(function()
{
	$('div#facebook').click(function()
	{
		window.open("http://www.facebook.com/zubrbojovnik");
		return false;
	});
});

//------------------------------
//				bottles_hover
//------------------------------

function bottles_hover()
{
	$('a[id*="bottle_"]').hover(function () 
	{
		
		var id = ($(this).attr("id"));
		$("a#"+id).parent().addClass("selected");
		$('li#'+id+'_hover div div').css("display", "block");
	}, 
	function () 
	{
		var id = ($(this).attr("id"));
		$("a#"+id).parent().removeClass();		
		$('li#'+id+'_hover div div').css("display", "none");
	});
}

//------------------------------
//	  bottles_hover_products
//------------------------------

function bottles_hover_products()
{
	$('a[id*="bottle_"]').hover(function () 
	{
		var id = ($(this).attr("id"));
		$("a#"+id).parent().addClass("selected");
		$('li#'+id+'_hover div div').css("background-position", "bottom");
		$('li#'+id+'_hover div div span').css("color", "#022e62");
	}, 
	function () 
	{
		var id = ($(this).attr("id"));
		$("a#"+id).parent().removeClass();
		$('li#'+id+'_hover div div').css("background-position", "top");
		$('li#'+id+'_hover div div span').css("color", "#ffc600");
	});
}


//------------------------------
//			  background
//------------------------------

function background(id)
{
	$("#all_100").css("background-image", "url(../images/web/layout/backgr_"+id+".jpg)");
}

//------------------------------
//				him_hover
//------------------------------

function him_hover()
{
	$('div.him div.info p').hover(function () 
	{
		$(this).attr("class", "hover");
	}, 
	function () 
	{
		$(this).removeClass();
	});
}

//------------------------------
//				people
//------------------------------

function people()
{
	var position = $("#span_pref_people").offset();
	$("#select_people").css("left", (position.left)+"px")
	$("#select_people").css("top", ((position.top)+31)+"px")  	

	$("#select_people").toggle();
}

//------------------------------
//				select_people
//------------------------------

function select_people(value)
{
	$("#span_pref_people").html(value);
	$("#pref_people").attr("value", value);
	$("#select_people").hide();
}


//------------------------------
//				submenu
//------------------------------

function submenu(type)
{
// ak vojde na menu 

$("#menu_"+type).mouseenter(function()
{
	var test_class = $("#li_menu_"+type).attr("class");
	if(test_class != "selected")
	{
		$("#li_menu_"+type).attr("class", "hover");
	}
	var position = $("#menu_"+type).offset();
//	alert(position.left+' - '+position.top);
	var top_minus = 0;
	if (jQuery.browser.msie) 
	{
		var version = parseInt(jQuery.browser.version);
		
		if(version >= 8)
		{
			// var top_minus = 16;
			var top_minus = 0;
		}
	}

	$("#div_submenu_"+type).css("left", (position.left)+"px")
	$("#div_submenu_"+type).css("top", (position.top-8-top_minus)+"px")  	
	$("#div_submenu_"+type).show();
});

// ak vyjde z menu

$("#div_submenu_"+type).mouseleave(function() 
{
	var test_class = $("#li_menu_"+type).attr("class");
	if(test_class != "selected")
	{
		$("#li_menu_"+type).removeClass();
	}
 	$("#div_submenu_"+type).hide();
});

// ak vojde na close plochu

$("#close_"+type).mouseenter(function()
{
	var test_class = $("#li_menu_"+type).attr("class");
	if(test_class != "selected")
	{
		$("#li_menu_"+type).removeClass();
	}
	$("#div_submenu_"+type).hide();
});
}

//------------------------------
//			change_language
//------------------------------

function change_language()
{
	var offset = $("div.selected_lang").offset();
	$("ul#langs").css("top", offset.top+"px");
	$("ul#langs").css("left", offset.left+"px");
	
	$("#langs").toggle();
	$("div.selected_lang a").blur();
}

//------------------------------
//			input_hovers
//------------------------------

function input_hovers()
{
	$("div.center_box input.submit").hover(function () 
	{
		 $(this).css("background-position", "bottom right")
		 $(this).css("text-shadow", "#fdf003 0px 1px 0px")
	}, 
	function () 
	{
		$(this).css("background-position", "top right")
		$(this).css("text-shadow", "#5eb6da 0px 1px 0px")
	});
}

