$(document).ready(function(){
	

	$("#search_word")
		.bind("click", function()
		{
			if($(this).val() == 'Sök på webbplatsen...' || $(this).val() == 'Search the website...')
			{
				$(this).val('');
				$(this).removeClass("display");
				$(this).addClass("write");
			}
		})
		.bind("keyup", function(e)
		{
			if($(this).val() != '' && $(this).val() != 'Sök på webbplatsen...' && $(this).val() != 'Search the website...' )
			{
				$("#search_clear").show();
			}
			
			if($(this).val() != ''&& $(this).val().length > 2)
			{
				/* search_query 
				$("#search_tip .content").empty();
				
				var query_string = 	'search_word='+ escape($("#search_word").val()) + 
									'&site_id='+ tmpl_page.site_id +
									'&site_language='+ tmpl_page.language;
				if($("#search_tip").length < 1)
				{
				  		var pos = $("#search_word").offset();  
				  		var width = $("#search_word").width();
						// search_tip HTML
						var search_tip_html = '<div id="search_tip">'+
							'<div class="header"></div>'+
							'<div class="content"></div>'+
							'<div class="footer"></div></div>';
				  		
				  		$(search_tip_html).insertBefore("#subnav");
				  		$("#search_tip").css( { "left": (pos.left - 142) + "px", "top":pos.top+ 20 + "px" } );
				}
									
									
				$.ajax({
					type: "POST",
					url: "/System/Templates/Sites/166/php/search_results.php",
					data: ""+query_string+"",
					success: function(s)
					{
						if(s == '')
						{
							$("#search_tip").hide();
						}
						else
						{
							$("#search_tip .content").html(s);
				  			$("#search_tip").show();
						}
					}
				});
				*/
			}
			else if($(this).val().length < 3)
			{
				$("#search_tip").hide();
			}
			
		})
		.bind("blur", function() 
		{
			if(typeof(tmpl_page) != 'undefined')
			{
				if($(this).val() == '')
				{
					if(tmpl_page.language == 'EN')
					{
						$(this).val('Search the website...');
					}
					else
					{
						$(this).val('Sök på webbplatsen...');
					}
					$(this).removeClass("write"); 
					$(this).addClass("display");
				}
			}
		});
		
	$("#search_clear")
		.hide()
		.bind("click", function()
		{
			$("#search_word").val(''); 
			$("#search_tip").remove();
			
			return false;
		});

		$('a.contact').each(function()
		{
			var host = window.location.protocol+'//'+window.location.host;
			var b = 'eon-se';
			var a = $(this).attr("href");
			a = a.replace(host,'');
			a = a.replace('/','@');
			b = b.replace('-','.');
			$(this).attr("href",'mailto:'+a+b);
		});
		
		
});
