// Beware of Fake Code: Fake Google Map Insertion 

function initialize() {

        var latlng = new google.maps.LatLng(53.92, 27.65);
		var myOptions = {      zoom: 12,      center: latlng,      mapTypeId: google.maps.MapTypeId.ROADMAP    };
        var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
        var contentString = '<div id="content"><img src="bullit_red.gif"/><b>Uluru</b>, sandstone rock formation in the southern part of the Northern Territory, central Australia. It lies 335 km (208 mi)</div>';
var infowindow = new google.maps.InfoWindow({    content: contentString});
var image = new google.maps.MarkerImage('bullit_red.gif',
                                                                 new google.maps.Size(20, 32),
				new google.maps.Point(0,0),
				 new google.maps.Point(0, 32));
 var shadow = new google.maps.MarkerImage('ico_plus.gif',
				      new google.maps.Size(37, 32),
					new google.maps.Point(0,0),
					 new google.maps.Point(0, 32));
var marker = new google.maps.Marker({      position: latlng,       map: map,   shadow: shadow,        icon: image,     title:"Hello World!"});
var latlng2 = new google.maps.LatLng(55, 29);
var marker2= new google.maps.Marker({      position: latlng2,       map: map,      title:"2"});
var latlng3 = new google.maps.LatLng(52, 6);

google.maps.event.addListener(marker, 'click', function() {  infowindow.open(map,marker);});


//alert("0");
var bounds=new google.maps.LatLngBounds(latlng, latlng);
//alert(bounds);

bounds.extend(latlng3);
bounds.extend(latlng2);
var marker= new google.maps.Marker({      position: latlng3,       map: map,      title:"3"});
google.maps.event.addListener(marker, 'click', function() { alert('3');});
map.fitBounds(bounds);

 }

// Content Fixes and Interactions (not fake)

(function( $ ) {
	$.extend({
		setFooter: function() {
				// Stick the footer
				var footer = $(".ndcFooter");
				var delta = $(document).height() - ($(footer).offset().top + $(footer).height());
				//alert(delta);
				if (delta > 0) $(footer).css({marginTop: delta + 1 + "px"});
			},
		init: function() {
			if (!$.font.test("'Trebuchet MS'")) {
				//Cufon	goes here
			};
			
			$(window).resize (function() {
				var chequeWrapper = $(".ndcChequeWrapper");
				var cheque = $(".ndcCheque");
				if (chequeWrapper && cheque) {
					//alert($(chequeWrapper).offset().top + " " +$(chequeWrapper).offset().left);
					$(cheque).css({left: $(chequeWrapper).offset().left + "px", top: $(chequeWrapper).offset().top + "px"});
				}
				var ndcSearch = $(".ndcSearch");
				var helpBox = $(".ndcSuggestions");
				if(ndcSearch && helpBox) {
				    $(helpBox).css({left: $(ndcSearch).offset().left + 326 +"px", top: $(ndcSearch).offset().top + 51 + "px"});
				}
			});

			$(window).load(function(){
				// Clear inputs on focus
				var inputs = $("input[type='text']");
				//alert(inputs.length);
				for (var i=0; i < inputs.length; i++) {
					inputs[i].onfocus = function () {
						if ($(this).attr("alt") && this.value.indexOf($(this).attr("alt")) == 0) { this.value = ''; }
					}
					inputs[i].onblur = function () {
						if (this.value == '') { this.value = $(this).attr("alt"); }
					}
				}

				
				// Make shadows over images
				$(".ndcShadowWrapper").dropShadow();
				
				// Modal
				$(".eftDetails").click(function (e) {
					e.preventDefault();
					$(".eftModal").modal();
					$(".modalCloseImg").html(closeText);
				});
				
				$(".eftFakeModalCall").click(function (e) {
					e.preventDefault();
					$(".eftModal").modal();
					$(".modalCloseImg").html(closeText);
				});
				
				// Footer
				$.setFooter();
				
				// Fake googlemap load
				
				//initialize();
				
				// Shifting secondary blocks in a grid columns
				var boxes = $(".box");
				for (var i=0; i < boxes.length; i++) {
					$(boxes[i]).addClass("shifted");
				}
				$(".row .column .row .column .box:first-child").each(function () {
					$(this).removeClass("shifted");															   
				});
				
				// Pointers tuning
				/*var pointers = $(".ndcPointer");
				for (var i=0; i < pointers.length; i++) {
					if (pointers[i].innerHTML.length > 1) {
						$(pointers[i]).addClass("ndcPointer" + pointers[i].innerHTML.length + "Digits");
					}
				}*/
				
                // IE 6 selectors natural width

                var kitchenSelectIE6 = $(".ie6 .ndcSearch select");
                //alert(kitchenSelect.length);
                $(kitchenSelectIE6).css("width", "auto");

				// Push intro block
				var shiftedRow = $(".ndcShiftedRow");
				
				if (shiftedRow && $(".ndcShiftedRow .ndcIntro").length) {
					shiftedRow.css("marginBottom", "20px");
				}
				
				// Playing with suggestions and search controls
				var placesControl = $(".ndcPlacesControl");
				var kitchensControl = $(".ndcKitchensControl");
				var placesList = $(".ndcPopularLocationsList");
				var kitchensList = $(".ndcPopularKitchensList");
					
				if (placesControl && kitchensControl && placesList && kitchensList) {

					//	Places:
						var locations = $(".ndcPopularLocationsList > li > a");
						for (var i=0; i < locations.length; i++) {
							locations[i].onclick = function () {
								//alert(this.innerHTML);	
								$(".ndcPlacesControl").attr("value", this.innerHTML);
								/*]]]]]ACHTUNG[[[[[*/
								//$(".ndcSuggestions").hide(); // Closing help box (suggestions)
							}
						}
						
					//	Kitchens:
						var kitchens = $(".ndcPopularKitchensList > li > a");
						for (var i=0; i < kitchens.length; i++) {
							kitchens[i].onclick = function () {
								var chosenOption = this.innerHTML;
								var valuesInKitchensControl = $(".ndcKitchensControl > option");
								for (var j=1; j < valuesInKitchensControl.length; j++) {
									if (valuesInKitchensControl[j].innerHTML.indexOf(chosenOption) > -1) {
										//alert("got in list");	
										$(".ndcKitchensControl").attr("selectedIndex", j);
										/*]]]]]ACHTUNG[[[[[*/
										//$(".ndcSuggestions").hide(); // Closing help box (suggestions)
										break;
									}	
								}
							}
						}
				}
				

			
				// Set Suggestions Section
				/*if ($(".ndcSuggestions").length) {
					$(".ndcSuggestions").hide();
				}*/
				
				if ($(".ndcSuggestions").length && $(".ndcSuggestionsClose").length) {
					$(".ndcSuggestionsClose").click(function () {
						$(".ndcSuggestions").hide();										  
					});
				}
				
				// FAQ Question Opener
				var openers = $(".ndcFAQopener");
				//alert(openers.length);
				for (var i=0; i <openers.length; i++) {
					openers[i].onclick = function () {
						$.cookie('ndcFAQparticularQuestion', $(this).attr("href"));
					}	
				}
				
				// Set Suggestions Section
				if ($(".ndcSuggestions").length && $(".ndcSuggestionsTrigger").length) {
					$(".ndcSuggestionsTrigger").click(function () {
						$(".ndcSuggestions").show();										  
					});
				}
				
				// Put cheque into unique position
				var chequeWrapper = $(".ndcChequeWrapper");
				var cheque = $(".ndcCheque");
				if (chequeWrapper && cheque) {
					//alert($(chequeWrapper).offset().top + " " +$(chequeWrapper).offset().left);
					$(cheque).css({left: $(chequeWrapper).offset().left + "px", top: $(chequeWrapper).offset().top + "px"});
				}
				
				// Put helpbox into proper place
				var ndcSearch = $(".ndcSearch");
				var helpBox = $(".ndcSuggestions");
				if(ndcSearch && helpBox) {
				    $(helpBox).css({left: $(ndcSearch).offset().left + 326 +"px", top: $(ndcSearch).offset().top + 51 + "px"});
				}
				
				// Clickable Plugin fires
				if ($(".ndcOverviewList li").length) $(".ndcOverviewList li").clickable();
				//$(".box3 p").clickable();
				
				// Lightbox fires
				if ($(".lightbox").length) $(".lightbox").lightBox();
				
				// Thumbnails fires
				
				var thumbLinks = $(".ndcThumbnails li a");
				var step = 207; // height of big thumbnail
				for (var i=0; i < thumbLinks.length; i++) {
					if (thumbLinks[i].parentNode.className.indexOf('noimage') < 0) {
						thumbLinks[i].onclick = function () {
							var lis = this.parentNode.parentNode.getElementsByTagName("li");
							//alert(lis.length);
							for (var j=0; j < lis.length; j++) {
								if (lis[j] == this.parentNode) {
									$(".ndcBigTumbnails").css("top", (-1)*(j)*step+"px");	
									return false;
								}	
							}
							
						}	
					}	
				}
				
				
				// FAQ
				
				$(".ndcFAQBigList > li > p").each(function() {
					$(this).hide();										   
				});
				
			
				//$.setFooter();
				var timeout = setTimeout($.setFooter, 250);
				
				// Check Cookie
				//alert($.cookie('ndcFAQparticularQuestion'));
				var cookieValue = $.cookie('ndcFAQparticularQuestion');
				if (cookieValue) {
					var filteredQuestion = (cookieValue.substring(cookieValue.indexOf('#')+1, cookieValue.length));	
					//alert(filteredQuestion);
					var faqLinks = $(".ndcFAQBigList > li > a");
					for (var i=0; i < faqLinks.length; i++) {
						if (faqLinks[i].name == filteredQuestion) {
							//alert(faqLinks[i].name);
							$(faqLinks[i].parentNode).addClass("ndcCurrent");
							$(faqLinks[i].parentNode.getElementsByTagName('p')[0]).show();
							break;
						}	
					}
					
				}
				
				var faqQuestions = $(".ndcFAQBigList > li > a");
				for (var i=0; i < faqQuestions.length; i++) {
					faqQuestions[i].onclick = function() {
						if (this.parentNode.className.indexOf("ndcCurrent") > -1) {
							$(this.parentNode).removeClass("ndcCurrent");
							$(this.parentNode.getElementsByTagName('p')[0]).hide();
							$.cookie('ndcFAQparticularQuestion', null);
							//$.setFooter();
						} else {
							$(".ndcFAQBigList > li > p").each(function() {$(this).hide();});			
							$(".ndcFAQBigList > li.ndcCurrent").removeClass("ndcCurrent");
							$(this.parentNode).addClass("ndcCurrent");
							$(this.parentNode.getElementsByTagName('p')[0]).show();
							//$.setFooter();
						}
						//$.setFooter();
						$(".ndcFooter").css("visibility", "hidden");
						$(".ndcFooter").css("visibility", "visible");
						var timeout = setTimeout($.setFooter, 300);
						//$.setFooter();
						
					}
				}
				
				// Modal
				

				
				// Star Rating
				  	var ratingClassNames = ['nostar', 'onestar','twostar','threestar','fourstar','fivestar'];
					
					var ratings = $(".rating");
					
					for (var i=0; i<ratings.length; i++) {
						ratings[i].className += " " + ratingClassNames[parseInt(ratings[i].title)];
						
						// Reset on doubleclick
						ratings[i].ondblclick = function () {
							this.className = 'rating nostar';
							this.title = "0";
						}
						
					}
					
					var innerLinks = $(".rating li a");
					
					for (var i=0; i<innerLinks.length; i++) {
						innerLinks[i].onclick = function () {
							this.parentNode.parentNode.title = this.title;	
							//alert(ratingClassNames[parseInt(this.title)]);
							this.parentNode.parentNode.className = 'rating';
							$(this.parentNode.parentNode).addClass(ratingClassNames[parseInt(this.title)]);
							//alert(this.clientWidth)
							   if($("#ratingInput").length) {
								   $("#ratingInput").attr("value",this.title);
							   }
						}
					}

			});			
		}
	});
	
	// Shadowing
	var dropShadowZindex = 1;  //z-index counter

	$.fn.dropShadow = function(options)
	{
		// Default options
		var opt = $.extend({
			left: 2,
			top: 2,
			blur: 3,
			opacity: .25,
			color: "black",
			swap: false
			}, options);
		var jShadows = $([]);  //empty jQuery collection
		
		// Loop through original elements
		this.not(".dropShadow").each(function()
		{
			var jthis = $(this);
			var shadows = [];
			var blur = (opt.blur <= 0) ? 0 : opt.blur;
			var opacity = (blur == 0) ? opt.opacity : opt.opacity / (blur * 8);
			var zOriginal = (opt.swap) ? dropShadowZindex : dropShadowZindex + 1;
			var zShadow = (opt.swap) ? dropShadowZindex + 1 : dropShadowZindex;
			
			// Create ID for shadow
			var shadowId;
			if (this.id) {
				shadowId = this.id + "_dropShadow";
			}
			else {
				shadowId = "ds" + (1 + Math.floor(9999 * Math.random()));
			}

			// Modify original element
			$.data(this, "shadowId", shadowId); //store id in expando
			$.data(this, "shadowOptions", options); //store options in expando
			jthis
				.attr("shadowId", shadowId)
				.css("zIndex", zOriginal);
			if (jthis.css("position") != "absolute") {
				jthis.css({
					position: "relative",
					zoom: 1 //for IE layout
				});
			}

			// Create first shadow layer
			bgColor = jthis.css("backgroundColor");
			if (bgColor == "rgba(0, 0, 0, 0)") bgColor = "transparent";  //Safari
			if (bgColor != "transparent" || jthis.css("backgroundImage") != "none" 
					|| this.nodeName == "SELECT" 
					|| this.nodeName == "INPUT"
					|| this.nodeName == "TEXTAREA") {		
				shadows[0] = $("<div></div>")
					.css("background", opt.color);								
			}
			else {
				shadows[0] = jthis
					.clone()
					.removeAttr("id")
					.removeAttr("name")
					.removeAttr("shadowId")
					.css("color", opt.color);
			}
			shadows[0]
				.addClass("dropShadow")
				.css({
					height: jthis.outerHeight(),
					left: blur,
					opacity: opacity,
					position: "absolute",
					top: blur,
					width: jthis.outerWidth(),
					zIndex: zShadow
				});
				
			// Create other shadow layers
			var layers = (8 * blur) + 1;
			for (i = 1; i < layers; i++) {
				shadows[i] = shadows[0].clone();
			}

			// Position layers
			var i = 1;			
			var j = blur;
			while (j > 0) {
				shadows[i].css({left: j * 2, top: 0});           //top
				shadows[i + 1].css({left: j * 4, top: j * 2});   //right
				shadows[i + 2].css({left: j * 2, top: j * 4});   //bottom
				shadows[i + 3].css({left: 0, top: j * 2});       //left
				shadows[i + 4].css({left: j * 3, top: j});       //top-right
				shadows[i + 5].css({left: j * 3, top: j * 3});   //bottom-right
				shadows[i + 6].css({left: j, top: j * 3});       //bottom-left
				shadows[i + 7].css({left: j, top: j});           //top-left
				i += 8;
				j--;
			}

			// Create container
			var divShadow = $("<div></div>")
				.attr("id", shadowId) 
				.addClass("dropShadow")
				.css({
					left: jthis.position().left + opt.left - blur,
					marginTop: jthis.css("marginTop"),
					marginRight: jthis.css("marginRight"),
					marginBottom: jthis.css("marginBottom"),
					marginLeft: jthis.css("marginLeft"),
					position: "absolute",
					top: jthis.position().top + opt.top - blur,
					zIndex: zShadow
				});

			// Add layers to container	
			for (i = 0; i < layers; i++) {
				divShadow.append(shadows[i]);
			}
			
			// Add container to DOM
			jthis.after(divShadow);

			// Add shadow to return set
			jShadows = jShadows.add(divShadow);

			// Re-align shadow on window resize
			$(window).resize(function()
			{
				try {
					divShadow.css({
						left: jthis.position().left + opt.left - blur,
						top: jthis.position().top + opt.top - blur
					});
				}
				catch(e){}
			});
			
			// Increment z-index counter
			dropShadowZindex += 2;

		});  //end each
		
		return this.pushStack(jShadows);
	};


	$.fn.redrawShadow = function()
	{
		// Remove existing shadows
		this.removeShadow();
		
		// Draw new shadows
		return this.each(function()
		{
			var shadowOptions = $.data(this, "shadowOptions");
			$(this).dropShadow(shadowOptions);
		});
	};


	$.fn.removeShadow = function()
	{
		return this.each(function()
		{
			var shadowId = $(this).shadowId();
			$("div#" + shadowId).remove();
		});
	};


	$.fn.shadowId = function()
	{
		return $.data(this[0], "shadowId");
	};


	$(function()  
	{
		// Suppress printing of shadows
		var noPrint = "<style type='text/css' media='print'>";
		noPrint += ".dropShadow{visibility:hidden;}</style>";
		$("head").append(noPrint);
	});

	
} )(jQuery);

jQuery( function( $ ) {
	$.init(); // Inits content fixes
} );