// ------ Centering function ------function fadeToCenter(el, thisEl) { 	var winH = $(window).height();	var winW = $(window).width();		if (!thisEl) {		$(el).css('top',  winH/2-$($(el)).height()/2 + $(window).scrollTop() + "px");		$(el).css('left', winW/2-$($(el)).width()/2);		var maskHeight = $(document).height();		var maskWidth = $(window).width();		$('#mask').css({'width':maskWidth,'height':maskHeight});		$(el).fadeTo("fast", 1);		$('#mask').fadeTo("fast",0.5, function() {$(el).fadeTo("fast", 1);});	}	else { /* This version centers and fades in the lunch div */		posX = winW/2-$(thisEl.next(el)).width()/2 -10;		posY = winH/2-$(thisEl.next(el)).height()/2 + $(window).scrollTop();				/*if (ie7) {			posY += $(thisEl).next(el).height()/4;			posX -= 170;		}		/*if (ie8) {			posY += $(thisEl).next(el).height()/4;			posX -= 20;		}*/				thisEl.next(el).css('top',  posY + "px");		thisEl.next(el).css('left', posX + "px");				var maskHeight = $(document).height();		var maskWidth = $(window).width();		$('#mask').css({'width':maskWidth,'height':maskHeight});		thisEl.next(el).fadeTo("fast", 1);		var maskHeight = $(document).height();		var maskWidth = $(window).width();		$('#mask').css({'width':maskWidth,'height':maskHeight});		$('#mask').fadeTo("fast",0.5);	}}// ------ formFader function ------function formFader(el) {	$(el).focus(function() {		$(this).val(($(this).val() == $(this)[0].title)?"":$(this).val());	});	$(el).blur(function() {		$(this).val(($(this).val() == "")?$(this)[0].title:$(this).val());	}); 	$(el).blur();	}// ------ Table reservation ------ 	$('.reserve_table_link').click(function() {	if ($(this).hasClass('restaurant_reserve_table')) {		var restaurantArr = $(this).next('.restaurant_name_fetch').text().split('Martina ');		if (restaurantArr[1]) {			var name1 = restaurantArr[1];					var name2 = name1.split(' ')[1] + ' ' + name1.split(' ')[0];		}		else {			name1 = restaurantArr[0];name2 = restaurantArr[0];		}		$("#reservations_restaurantSelect option").each(function() {			$(this).removeAttr('selected');			if ($(this).text() == name1 || $(this).text() == name2) {				$(this).attr('selected', true);			}		});		updateReservation(); reservations.updateDateSelect();	}	fadeToCenter('#reservation_layer2');});// ------ Reklanet restaurant chooser ------	if (!$.trim($('#chosen_restaurant').text()) == "") {	chosenR = $('#chosen_restaurant').text().split('Martina ');	cr1 = chosenR[1];	cr2 = chosenR[1].split(' ')[1]+" "+chosenR[1].split(' ')[0];	$("#tmp1 option").each(function() {			$(this).removeAttr('selected');			if ($(this).text() == cr1 || $(this).text() == cr2) {				$(this).attr('selected', true);				e = document.getElementById("tmp1");				reklanetForm.updateSelects(e);			}		});}	// ------ Weekday highliter ------ var d=new Date();var weekday = '.timetable_' + d.getDay();$(weekday).css('background-color', '#cccccc');	// ------ Lunch pass ------ 	$('#info_right_image_hidden img').mouseover(function () {	$(this).stop().fadeTo(300, 1);});$('#info_right_image_hidden img').mouseout(function () {	$(this).stop().fadeTo(300, 0);}); // ------ Lunch pop-up ------ $('.restaurant_show_lunches').click(function() {		fadeToCenter('.restaurant_lunch_list_outer', $(this));});	// ------ Restaurant list things ------ 	$('.big_lunch_list span').each(function() { 	if($.trim($(this).text()) == "") {		$(this).remove() 	}});$('#main_content .add3').each(function() { 	if ($(this).text().indexOf('fax') >= 0) {		removeFax = $(this).text().split(', fax:');		$(this).text(removeFax[0]);	}});	$('#main_content_inner > .restaurant_list_item:odd').css('background-position','100% 100%'); //$('#main_content_inner > .restaurant_list_item:even').css('clear','left');var restaurants = $(".restaurant_list_item").length;$('.restaurant_list_item').last().css({'background': 'none', 'margin-bottom': '0px'});if (restaurants%2 == 0) {	$('div.restaurant_list_item').last().prev('div.restaurant_list_item').css({'background': 'none', 'margin-bottom': '0px'});}	// ------ News ------ 	$('.news_item').last().css('background', 'none');	// ------ Restaurant Menu ------ $('.item_description_2').each(function() { 	if($.trim($(this).text()) == "")         $(this).parent().remove(); });$('.item_description_1').each(function() {     if($.trim($(this).text()) == "")         $(this).parent().remove() });if ($("#main_content").hasClass("main_menu")) {	$('.menu_category').last().css('margin-bottom', '0px');}else {	$('.menu_category').last().css('margin-bottom', '0px');	$('.menu_category').last().css('background', 'none');}	$('.menu_container .single_menu_item:last-child').css({'margin-bottom': '5px', 'background': 'none'});$('.single_menu_item').last().css({'background':'none', 'margin-bottom':'0px'});	// ------ Max-width IE fix ------ $('.menu_item_table').each(function() {	if ( $(this).width() > 650 ) {		$(this).css({'width': 650});	}});// ------ Show offers or lunchlist on single restaurant page? ------ if($("#content_right_inner").children().length > 0) {    $("#content_right_inner_2").remove();}else {	$("#content_right_inner").remove();}// ------ Mask ------ function fadeHide(el) {	$(el).fadeTo("fast", 0, function(){$(el).hide();});}function fadeHide2(el, el2) {	$(el).click(function () {		$("#mask").fadeTo("fast",0, function(){ $("#mask").hide(); });		$(el2).fadeTo("fast", 0, function(){$(el2).hide();});	});  }$('#mask').click(function () {	$("#mask").fadeTo("fast",0, function(){ $("#mask").hide(); });	$('#map_canvas_outer').hide();	fadeHide('.restaurant_lunch_list_outer');	fadeHide('#reservation_layer2');});  $('#map_close').click(function () {	$("#mask").fadeTo("fast",0, function(){ $("#mask").hide(); });	$('#map_canvas_outer').hide();});fadeHide2('.restaurant_lunch_list_close', '.restaurant_lunch_list_outer');fadeHide2('#reservation_close', '#reservation_layer2');// ------ Maps ------formFader('#directions_text');// ------ News item excerpts (old version) ------ 	/*$('.news_item .news_content').each(function() {	var newsContent = $.trim($(this).text());	if (newsContent.length > 200) {		var visibleText = $.trim($(this).text().substring(0, 200));		var v = visibleText.split(/\.$/);		$(this).html(v[0] + ' ...');	}	else $(this).html(newsContent);});*///------ News item excerpts ------ $('.news_item').each(function() {	newsLink = $(this).find('.news_item_link').attr('href');	console.log(newsLink);	newsContentRaw = $(this).find('.news_content').html();	newsContent = newsContentRaw.replace(/\<\/*a.*?\>/g, '');	if (newsContent.length > 200) {		var visibleText = $(newsContent).html().substring(0, 200);		console.log(visibleText);		$(this).find('.news_content').html('<a href="'+newsLink+'">'+visibleText + ' ...</a>');	}	else $(this).find('.news_content').html('<a href="'+newsLink+'">'+newsContent + '</a>');});// ------ Reservations forms ------formFader('#reserver_name');formFader('#reserver_email');formFader('#reserver_phone');		// ------ Tooltip ------$('.add3').each(function() { 	if ($(this).text().indexOf('020 799') >= 0) {		$(this).css({'cursor': 'help', 'margin-right':'-15px', 'padding-right': '15px', 'background':'url(/stc/martina/2011/images/question_mark.png) 100% 3px no-repeat'});		$(this).hover(function(e) {							  			$("#tooltip").css({"top":(e.pageY - 10) + "px", "left":(e.pageX + 10) + "px"}).fadeIn("fast");				},		function(){				$("#tooltip").delay(200).fadeOut("fast");		});			$(this).mousemove(function(e){			$("#tooltip")			.css("top",(e.pageY - 10) + "px")			.css("left",(e.pageX + 10) + "px");		});				}});		// ------ Lunch table ------if ($('.u4_lunch_table').length) {	$('.u4_lunch_table tr td:nth-child(1)').each(function() {		if ($.trim($(this).text()) != "") $(this).addClass('u4-table-noheader-paiva');	});	$('.u4_lunch_table tr td:nth-child(2)').addClass('u4-table-noheader-kategoria');	$('.u4_lunch_table tr td:nth-child(3)').addClass('u4-table-noheader-ruoka');	$('.u4_lunch_table tr td:nth-child(4)').addClass('u4-table-noheader-hinta');}var sepTr = '<tr class="sep_tr"><td colspan="10">&nbsp;</td></tr>';$('.u4-table-noheader-paiva').each(function() {	$(sepTr).insertBefore($(this).parent());});$('.sep_tr:first-child').remove();
