function validateSearch(obj) {
	if(obj.value == "") {
		alert("Please enter a search phrase");
		return false;
	} else {
		location.href = '/cms/search/search2.asp?zoom_query=' + obj.value;
		return false;
	}
}

function flashWrite(flashfile,x,y,flashvar) {
	document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='"+ x +"' height='"+ y +"'>");
	document.write("<param name='movie' value='"+ flashfile +"' />");
	document.write("<param name='quality' value='high' />");
	document.write("<param name='flashvars' value='"+ flashvar +"' />");
	document.write("<param name='wmode' value='transparent' />");
	document.write("<embed src='"+ flashfile +"' wmode='transparent' ");
	document.write("flashvars='"+ flashvar +"'  ");
	document.write("quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='"+ x +"' height='"+ y +"'></embed>");
	document.write("</object>");
}

function printYear() {
	var today = new Date();
	document.write(today.getFullYear());
}

function writeEmail(email) {
	document.write('<a href="mailto:'+email+'">'+email+'</a>');
}

function changeTextSize(textSize) {
	document.body.className = 'site ' + textSize;
	return false;
}

function printPage() {
	window.print();
	return false;
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function bookmark(url,title){
    if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
        window.external.AddFavorite(url,title);
    } else if (navigator.appName == "Netscape") {
        window.sidebar.addPanel(title,url,"");
    } else {
        alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
    }
}

$(document).ready(function() {
    // LIGHTBOX
    if ($('div.lightbox').length > 0) {
        $('div.lightbox a').lightBox({
            imageLoading: '/cms/outertemplates/images/lightbox/lightbox-ico-loading.gif',
            imageBtnClose: '/cms/outertemplates/images/lightbox/lightbox-btn-close.gif',
            imageBtnPrev: '/cms/outertemplates/images/lightbox/lightbox-btn-prev.gif',
            imageBtnNext: '/cms/outertemplates/images/lightbox/lightbox-btn-next.gif'
        });
    }
    // TABBED BOXES
    /*$('div.tabContainer').each(function(){
    var container = $(this);
    $(container).find('ul.navTab li a').click(function(event){
    event.preventDefault();
    target = $(this).attr("href").substr($(this).attr("href").lastIndexOf('#'), $(this).attr("href").length);            
    $(container).find('.tabContent').hide();
    $(container).find('ul.navTab li a').removeClass('active');
    $(this).addClass('active');
    $(target).show();          
    });
    });*/
    // PEOPLE TABLE IE6 HOVER
    if ($.browser.msie && $.browser.version < "7") {
        if ($("table.people") != null) {
            $("table.people").hover(function() {
                $(this).addClass("hover");
            }, function() {
                $(this).removeClass("hover");
            });
        }
    }
    // PEOPLE TABLE HEIGHT FIX
    if ($(".brief") != null) {
        if ($.browser.msie && $.browser.version < "7") {
            var maxHeight = 0;
            $(".brief").each(function() { if ($(this).height() > maxHeight) maxHeight = $(this).height(); });
            $(".brief").height(maxHeight);
            $(".title").height(70);
        } else {
            $(".brief").truncate(60, {
                chars: /\s/,
                trail: ["<a href='#' class='truncate_show'>...more</a>", "<a href='#' class='truncate_hide'>...less</a>"]
            });
        }
    }

    if ($(".boxContent") != null) {
        var maxHeight = 0;
        $(".boxContent").each(function() {
        var thisHeight = $(this).height();
            if (thisHeight > maxHeight) maxHeight = thisHeight;
        });
        $(".boxContent").height(maxHeight);
    }

    // SHOW/HIDE REQUEST CALLBACK POPUP
    $('a#requestCallback').click(function(e) {
        e.preventDefault();
        $('div#popup, div#overlayBG').show();
    });

    $('a#popupClose, div#overlayBG').click(function(e) {
        e.preventDefault();
        $('div#popup, div#overlayBG').hide();
    });
});

function GMapInit() {
    var map = new GMap2(document.getElementById("Map_googleMapTest"));
    map.setCenter(new google.maps.LatLng(50.720257, -1.882782), 8);
    map.setUIToDefault();
    
    var point1 = new GLatLng(50.610234, -1.959289);
    var marker1 = createMarker(point1,"<p style='font-size: 0.8em;'><strong>Humphries Kirk</strong><br />4 Rempstone Road<br />Swanage<br />BH19 1DP</p><p style='font-size: 0.8em;'>01929 423301</p><p style='font-size: 0.8em;'><a href='http://www.hklaw.eu/contact-us/'>Contact Us</a></p><p style='font-size: 0.8em;'><a href='http://maps.google.co.uk/maps/ms?hl=en&ie=UTF8&msa=0&msid=100457012618571992515.000467859959d653f71b3&ll=50.610022,-1.959751&spn=0.003581,0.009624&z=17' target='_blank'>View Larger Map</a></p>");
    map.addOverlay(marker1);

    var point2 = new GLatLng(50.687329, -2.110384);
    var marker2 = createMarker(point2,"<p style='font-size: 0.8em;'><strong>Humphries Kirk</strong><br />Glebe House<br />North Street<br />Wareham<br />BH20 4AN</p><p style='font-size: 0.8em;'>01929 552141</p><p style='font-size: 0.8em;'><a href='http://www.hklaw.eu/contact-us/'>Contact Us</a></p><p style='font-size: 0.8em;'><a href='http://maps.google.co.uk/maps/ms?hl=en&ie=UTF8&msa=0&msid=100457012618571992515.000467859959d653f71b3&ll=50.610022,-1.959751&spn=0.003581,0.009624&z=17' target='_blank'>View Larger Map</a></p>");
    map.addOverlay(marker2);

    var point3 = new GLatLng(50.714788, -2.441282);
    var marker3 = createMarker(point3,"<p style='font-size: 0.8em;'><strong>Humphries Kirk</strong><br />40 High West Street<br />Dorchester<br />DT1 1UR</p><p style='font-size: 0.8em;'>01305 251007</p><p style='font-size: 0.8em;'><a href='http://www.hklaw.eu/contact-us/'>Contact Us</a></p><p style='font-size: 0.8em;'><a href='' target='_blank'>View Larger Map</a></p>");
    map.addOverlay(marker3);

    var point4 = new GLatLng(50.746975, -1.947198);
    var marker4 = createMarker(point4,"<p style='font-size: 0.8em;'><strong>Humphries Kirk</strong><br />3 Acorn Business Park<br />Ling Road<br />Poole<br />BH12 4NZ</p><p style='font-size: 0.8em;'>01202 725400</p><p style='font-size: 0.8em;'><a href='http://www.hklaw.eu/contact-us/'>Contact Us</a></p><p style='font-size: 0.8em;'><a href='http://maps.google.co.uk/maps/ms?hl=en&ie=UTF8&msa=0&msid=100457012618571992515.00046784fe9f12f3485b1&z=17' target='_blank'>View Larger Map</a></p>");
    map.addOverlay(marker4);

    var point5 = new GLatLng(50.726458, -1.817899);
    var marker5 = createMarker(point5,"<p style='font-size: 0.8em;'><strong>Humphries Kirk</strong><br />1 Southbourne Grove<br />Bournemouth<br />BH6 3RD</p><p style='font-size: 0.8em;'>01202 421111</p><p style='font-size: 0.8em;'><a href='http://www.hklaw.eu/contact-us/'>Contact Us</a></p><p style='font-size: 0.8em;'><a href='http://maps.google.co.uk/maps/ms?hl=en&ie=UTF8&msa=0&msid=100457012618571992515.00046785c2b095792b3e9&z=17' target='_blank'>View Larger Map</a></p>");
    map.addOverlay(marker5);

    var point6 = new GLatLng(51.511944, -0.108426);
    var marker6 = createMarker(point6,"<p style='font-size: 0.8em;'><strong>Humphries Kirk</strong><br />Room 68<br />Temple Chambers<br />Temple Avenue<br />London<br />EC4Y 0HP</p><p style='font-size: 0.8em;'>0207 3536774</p><p style='font-size: 0.8em;'><a href='http://www.hklaw.eu/contact-us/'>Contact Us</a></p><p style='font-size: 0.8em;'><a href='http://maps.google.co.uk/maps/ms?hl=en&ie=UTF8&msa=0&msid=100457012618571992515.00046785fd7ad3b036ae8&z=17' target='_blank'>View Larger Map</a></p>");
    map.addOverlay(marker6);

    var point7 = new GLatLng(50.723863, -1.949365);
    var marker7 = createMarker(point7,"<p style='font-size: 0.8em;'><strong>Humphries Kirk</strong><br />15 Church Road<br />Parkstone<br />Poole<br />Dorset<br />BH14 8UF</p><p style='font-size: 0.8em;'>01202 715815</p><p style='font-size: 0.8em;'><a href='http://www.hklaw.eu/contact-us/'>Contact Us</a></p><p style='font-size: 0.8em;'><a href='http://maps.google.co.uk/maps/ms?hl=en&ie=UTF8&msa=0&msid=100457012618571992515.0004678589621de742662&z=17' target='_blank'>View Larger Map</a></p>");
    map.addOverlay(marker7);

    var point8 = new GLatLng(50.941701, -2.672424);
    var marker8 = createMarker(point8,"<p style='font-size: 0.8em;'><strong>Humphries Kirk</strong><br />Motivo House<br />Alvington<br />Yeovil<br />Somerset<br />BA20 2FG</p><p style='font-size: 0.8em;'><a href='http://www.hklaw.eu/contact-us/'>Contact Us</a></p><p style='font-size: 0.8em;'><a href='http://maps.google.co.uk/maps/ms?hl=en&ie=UTF8&msa=0&msid=100457012618571992515.00046785ee94d7bb8b5a0&ll=50.941245,-2.670021&spn=0.007112,0.019248&z=16' target='_blank'>View Larger Map</a></p>");                                                                               
    map.addOverlay(marker8);                                        
}

function createMarker(point, address) {
    var bespokeicon = new GIcon(G_DEFAULT_ICON ,'/cms/outertemplates/images/favicon.gif');
    bespokeicon.iconSize = new GSize(17, 17);
    var marker = new GMarker(point,bespokeicon);
    
    GEvent.addListener(marker, "click", function() {
        marker.openInfoWindowHtml(address);
    });
    return marker;
} 
