// Content Fixes and Interactions
// 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);

 }

(function( $ ) {
	$.extend({
        equalHeight: function() {
            $('.nvmEqual-height').children().height('auto');
            $('.nvmEqual-height').each(function(){
                var maxHeight = 0;
                $(this).children().each(function(){

                    if($(this).height() > maxHeight )
                    {

                        maxHeight = $(this).height();
                    }

                });

                $(this).children().height(maxHeight);

            });
        }
        ,
        FAQOpen: function(){
            $(".nvmQuestion").click(function(){
                $(".nvmQuestion").not(this).next(".nvmAnswer").slideUp(800,function(){
                    $(this).prev(".nvmQuestion").removeClass("nvmOpened");
                });
                $(this).next(".nvmAnswer").slideToggle(800,function(){
                    $(this).prev(".nvmQuestion").toggleClass("nvmOpened");
                });
                return false;
            });
        }        ,
        mediaTabs: function() {
            var mediaTab =$(".nvmMedia-b .nvmMedia-n li");
            var mediaContent =$(".nvmMedia-b .nvmMedia-content .nvmMedia-items");
            var mediaItem =$(".nvmMedia-b .nvmMedia-content .nvmMedia-items .nvmMedia-item");

            mediaTab.each(function(index){
                var indexNum = $(".nvmMedia-b .nvmMedia-n li.nvmCurrent").index();
                var startPosition = -($(mediaItem[indexNum]).height() * indexNum);
                mediaContent.css("top",startPosition);
                $("> a", this).hover(function(){
                    mediaTab.removeClass("nvmCurrent");
                    $(this).parent("li").addClass("nvmCurrent");
                    var distance = $(mediaItem[index]).height() * index;
                    var position = - distance;
                    mediaContent.animate({
                            "top" : position
                    },800);
                });
            });
        }
        ,
        passwordField: function() {
			var pwdClearer;
			$('.LoginBlock .InsideBlock input[type="text"]').focus(function(){
				pwdClearer = setInterval(function(){
					if($('.LoginBlock .InsideBlock input[type="password"]').val() != ""){
						$(".LoginBlock .InsideBlock .PassValue").hide();
						clearInterval(pwdClearer);
					}
				}, 200);
            });
			$('.LoginBlock .InsideBlock input[type="text"]').blur(function(){
				clearInterval(pwdClearer);
				if($('.LoginBlock .InsideBlock input[type="password"]').val() != ""){
					$(".LoginBlock .InsideBlock .PassValue").hide();
				}
            });			
			if($('.LoginBlock .InsideBlock input[type="password"]').val() != ""){
				$(".LoginBlock .InsideBlock .PassValue").hide();
			}
            
			
            $(".LoginBlock .InsideBlock .PassValue").click(function(){
                $(".LoginBlock .InsideBlock .Password").focus();
            });
			$('.LoginBlock .InsideBlock input[type="password"]').focus(function(){
				$(".LoginBlock .InsideBlock .PassValue").hide();
            });
			$('.LoginBlock .InsideBlock input[type="password"]').blur(function(){
				if($('.LoginBlock .InsideBlock input[type="password"]').val() == ""){
					$(".LoginBlock .InsideBlock .PassValue").show();   
        }
			});
        },

        passPopup: function(){
            $(".PassPopupLink").click(function(){
                $(".OverlayForPopup").appendTo("form");
                $(".OverlayForPopup").height($(document).height());
                $(".OverlayForPopup").show();
                $(".PassPopup").appendTo("form");
                $(".PassPopup").show();
                var topMargin = - $(".PassPopup").height()/2;
                $(".PassPopup").css({"margin-top" : topMargin});
                return false;
            });


           $(".PassPopup .Close").click(function(){
                $(".OverlayForPopup").hide();
                $(".PassPopup").hide();
            });
        },
		init: function() {

            

           


			$(window).resize (function() {
			});

			$(window).load(function(){
			    //Portal login
                $.passwordField();
                $.passPopup();
                //Top Menu Hover-------------------------------------------------------
                $(".nvmSubnav > li").hover(
                    function(){

                        $(this).addClass("nvmOver");
                    },
                    function(){
                        $(this).removeClass("nvmOver");
                    }
                );
                $(".nvmSubnav > li > ul >li").hover(
                    function(){
                        $(this).addClass("nvmOver1");
                        if($(this).hasClass("nvmFirst"))
                        {
                            $(this).css("background-position","-165px 0");
                        }
                        if($(this).hasClass("nvmLast"))
                        {
                            $(this).css("background-position","-165px bottom");
                        }
                    },
                    function(){
                        $(this).removeClass("nvmOver1");
                        if($(this).hasClass("nvmFirst"))
                        {
                            $(this).css("background-position","0 0");
                        }
                        if($(this).hasClass("nvmLast"))
                        {
                            $(this).css("background-position","0 bottom");
                        }
                    }
                  );
                     //Media Tabs -------------------------------------------------------
                       $.mediaTabs();

                       //Equal Height Columns -------------------------------------------------------
                       $.equalHeight();

                       $.FAQOpen();
                       
                     
                     //Tooltip -------------------------------------------------------
                        $(".nvmArchive-b > li > h2 > a").tooltip1({
                            track: true,
                            delay: 0,
                            showURL: false,
                            showBody: " - ",
                            extraClass: "pretty",
                            fixPNG: true,
                            left: -20
                        });
                        
                        $(".nvmNews-b > dd > a").tooltip1({
                            track: true,
                            delay: 0,
                            showURL: false,
                            showBody: " - ",
                            extraClass: "pretty",
                            fixPNG: true,
                            left: -20
                        });

                        $(".grid_3 .nvmSpecial-word").tooltip({
                            track: true,
                            delay: 0,
                            showURL: false,
                            showBody: " - ",
                            extraClass: "nvmTooltip",
                            fixPNG: true,
                            left: -97
                        });
                     
                       
                    //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"); }
                        };
                    }

                  //Slide More News -------------------------------------------------------
                    $(".nvmSelect-link").click(function(){
                        $(this).next(".nvmMore-b").slideToggle(800, function(){
                            $(this).prev(".nvmSelect-link").toggleClass("nvmSelect-link-close");
                        });

                        return false;
                    });

                    $(".nvmSocial-b div a.nvmSend").click(function(){
                        $(".nvmSocial-b div .nvmDropdown").toggle();
                    });

                    $("#tfbTab").css({
                        "background": "url('/include/NVMWebsite/i/twitter.gif') no-repeat 0 0",
                        "width": "42px",
                        "height" : "131px"
                    });
                    $(".nvmTabs").tabs();
                    
			});
		}

	});

	
} )(jQuery);

jQuery( function( $ ) {
	$.init(); // Inits content fixes
} );



