$(document).ready(function() {

//Shadowbox init
var options = {
    //assetURL: '../',  
    keysClose: ['c', 27], // c or esc
    displayNav: true

};

Shadowbox.init(options);   

});

function close_module(collapsable_module)
{
    bar_header = collapsable_module.prev('div.bar_header');
    
    bar_header.removeClass('bar_header_current');
    bar_header.find('p span.close').remove();
    bar_header.find('p span').show();
    
    if(collapsable_module.css('display') != 'none'){
        collapsable_module.slideUp('fast');
    }
}



function expandMap() {

    Shadowbox.open({
        player: 'html',
        content: '',
        height: 500,
        width: 700,
        options: {
            onFinish: function(item) {
                if (GBrowserIsCompatible()) {

                    var map = new GMap2(document.getElementById('shadowbox_content'));

                    // geolocation co-ordinates of precise office
                    var precise_loc = new GLatLng(51.509717, -0.071626);
                    var map_centre = new GLatLng(51.511, -0.0717)

                    map.setCenter(map_centre, 16);
                    
                    
                    // custom marker
                    var customIcon = new GIcon(G_DEFAULT_ICON);
                    customIcon.image = "images/map_marker.png";
                    // Set up our GMarkerOptions object
                    markerOptions = { icon: customIcon };
                    var marker = new GMarker(precise_loc, markerOptions);
                    map.addOverlay(marker);       
                    


                    // create balloon information window
                    map.openInfoWindow(precise_loc, "<img src=/images/mapinfo_logo.gif title=Precise logo /><p>The Registry, <br />3 Royal Mint Court, <br />London, <br />EC3N 4QN, <br />United Kingdom</p><p>+44 (0)20 3301 4490</p><p><a class=block href=http://maps.google.com/maps?oe=UTF-8&q=3+Royal+Mint+Ct,+London,+EC3N+4QN&hl=en&ie=UTF8&ll=51.509717,-0.071712&spn=0.009188,0.027895&z=16&iwloc=addr target=blank>View larger map and directions</a></p>");


                    // add some simple controls
                    map.addControl(new GSmallMapControl());
                    map.addControl(new GMapTypeControl());
                }
            }
        }
    });

};




function popupNews(url) {

    Shadowbox.open({
        player: 'iframe',
        content: url,
        height: 500,
        width: 430
    });

};



function popitup(url) {
	newwindow=window.open(url,'name','height=640,width=500');
	if (window.focus) {newwindow.focus()}
	return false;
}


function includeScript(scriptUrl) {
    // Change requests to be sent synchronous
    $.ajaxSetup({ async: false });

    // Loads and executes a local JavaScript file
    $.getScript(scriptUrl);

    // Restore requests to be sent asynchronous
    $.ajaxSetup({ async: true });
} 
