﻿﻿/*
======================================================================
google map
======================================================================
*/

 

/*
======================================================================
load in flash slideshow using SWFobject
======================================================================
*/

// Permalinks option
function flashPutHref(href) { location.href = href; }

// SWFObject embed
var flashvars = {
    paramXMLPath: "param.xml",
	initialURL: escape(document.location)
}
var params = { 
	base: ".",
	quality: "best",
	bgcolor: "#121212",
	allowfullscreen: "true"
}                
var attributes = {}
swfobject.embedSWF("/extension/nmdesigntroms/design/troms/flash/slideshowpro.swf", "flash_gallery", "360", "258", "9.0.0", "/extension/nmdesigntroms/design/troms/javascript/expressInstall.swf", flashvars, params, attributes);

function load()
{
	var e=document.getElementById("refreshed");
	if(e.value=="no")e.value="yes";
	else{e.value="no";location.reload();}

}

/*
=====================
jQuery DOM is ready
=====================
*/

$(document).ready(function() {


    /*
    =================================
    Language selector
    =================================
    */
    $("#branding ul#links li.last > a").click(function() {
        $("#language_selector").slideToggle("slow");
    });

});


/*
=============================================
fix caching for background images for IE6 
=============================================
*/

/*@cc_on
@if (@_win32)
try {
    document.execCommand("BackgroundImageCache", false, true);
} catch (err) { };
@end@*/

/*
==============================================
Lightbox code
==============================================
*/
var myTimeout = null;
var sel = 0;
var items = null;
var tabContainers = null;
var lightboxLinks = null;
var tabs = null;
var startTimeout = 10000;
var timeout = 4000;
var debug = null;

var isOpen = false;

function showGoogleLightbox(id) {
	updateGoogleOverlay();
	//if box is not set to open then don't do anything
	if( isOpen == false ) return;
	// set the properties of the overlay box, the left and top positions
	jQuery("#bluecover").before(jQuery(id).get());
	jQuery(id + " a.lukk").click(doGoogleOverlayClose);
	//
	//bind('click', function() {
	//alert(jQuery(id).contents().find("a").eq(0));  Math.round((wh-494)/2)
	
	jQuery(id).css({
		display:'block',
		top: Math.round((jQuery(window).height() - jQuery(id).height() )/2) + jQuery(window).scrollTop()
	});
	 if (GBrowserIsCompatible()) {
        var bigmap = new GMap2(document.getElementById("bigmap"));
        var bigbounds = new GLatLngBounds();
        var zoom = 6;
		var bigpoint;
		var marker;
        for (var i=0; i < cords.length; i++) {
        	bigpoint = new GLatLng(cords[i]['lat'],cords[i]['lng']);
			marker = new GMarker(bigpoint);
			bigmap.addOverlay(marker);
			bigbounds.extend(marker.getPoint());
			//markers[i] = marker;
        }
        bigmap.setCenter(bigpoint, zoom);
        if ( cords.length > 1 )
        {
	        bigmap.setZoom(bigmap.getBoundsZoomLevel(bigbounds));
	        bigmap.setCenter(bigbounds.getCenter());
        }
        else
        {
        	bigmap.setZoom(zoom);
        }
	    bigmap.addControl(new GSmallMapControl());

      }	
}
function updateGoogleOverlay() {
	if( isOpen == false ) return;
	// set the window background for the overlay. i.e the body becomes darker
	jQuery('#bluecover').css({"position":"absolute", "display":"block", width:jQuery(document).width(), height:jQuery(document).height(), top:jQuery(window).scrollTop(), left:jQuery(window).scrollLeft()});
}
function doGoogleMapOverlayOpen() {
	isOpen = true;
	showGoogleLightbox(jQuery(this).attr("href"));
	jQuery('#bluecover').css({opacity:0}).animate( {opacity:0.9}, 100 );
	jQuery(window).bind('resize',updateGoogleOverlay);
	return false;
}

function doGoogleOverlayClose() {
	isOpen = false;
	jQuery('#googlemap_lightbox').css( 'display', 'none' );
	jQuery("#bluecover").unbind('resize', updateGoogleOverlay);
	// now animate the background to fade out to opacity 0
	// and then hide it after the animation is complete.
	jQuery("#bluecover").animate( {opacity:0.1}, 600 ).hide();
	return false;
}


jQuery(document).ready(function() {
	
	googlemapLightboxLinks = jQuery('a.googlemap_lightbox'); 
	//alert(lightboxLinks.size());
	googlemapLightboxLinks.each(function(i) { 
		//alert(this);
		//jQuery(this).click(doOverlayOpen);
		jQuery(this).bind('click', doGoogleMapOverlayOpen);
	});
	
});
