leftmap_europe_height = 0;

_leftmap_order = new Array('scotland', 'ireland', 'ni', 'southwest', 'south', 'east', 'home', 'northeast', 'northwest', 'wales', 'midlands', 'london');

_leftmap_data = new Array();

_leftmap_data['map'] = new Array();
_leftmap_data['map']['left'] = 43;

_leftmap_data['heading'] = new Array();
_leftmap_data['heading']['left'] = 60;

_leftmap_data['scotland'] = new Array();
_leftmap_data['scotland']['name'] = 'Scotland';
_leftmap_data['scotland']['count'] = 26;
_leftmap_data['scotland']['left'] = 64;

_leftmap_data['ireland'] = new Array();
_leftmap_data['ireland']['name'] = 'Ireland';
_leftmap_data['ireland']['count'] = 3;
_leftmap_data['ireland']['left'] = 43;

_leftmap_data['ni'] = new Array();
_leftmap_data['ni']['name'] = 'Northern Ireland';
_leftmap_data['ni']['count'] = 5;
_leftmap_data['ni']['left'] = 43;

_leftmap_data['southwest'] = new Array();
_leftmap_data['southwest']['name'] = 'South West';
_leftmap_data['southwest']['count'] = 6;
_leftmap_data['southwest']['left'] = 55;

_leftmap_data['south'] = new Array();
_leftmap_data['south']['name'] = 'South';
_leftmap_data['south']['count'] = 3;
_leftmap_data['south']['left'] = 130;

_leftmap_data['east'] = new Array();
_leftmap_data['east']['name'] = 'East Anglia';
_leftmap_data['east']['count'] = 5;
_leftmap_data['east']['left'] = 161;

_leftmap_data['home'] = new Array();
_leftmap_data['home']['name'] = 'Home Counties';
_leftmap_data['home']['count'] = 3;
_leftmap_data['home']['left'] = 138;

_leftmap_data['northeast'] = new Array();
_leftmap_data['northeast']['name'] = 'North East';
_leftmap_data['northeast']['count'] = 7;
_leftmap_data['northeast']['left'] = 132;

_leftmap_data['northwest'] = new Array();
_leftmap_data['northwest']['name'] = 'North West';
_leftmap_data['northwest']['count'] = 9;
_leftmap_data['northwest']['left'] = 116;

_leftmap_data['wales'] = new Array();
_leftmap_data['wales']['name'] = 'Wales';
_leftmap_data['wales']['count'] = 9;
_leftmap_data['wales']['left'] = 73;

_leftmap_data['midlands'] = new Array();
_leftmap_data['midlands']['name'] = 'Midlands';
_leftmap_data['midlands']['count'] = 8;
_leftmap_data['midlands']['left'] = 112;

_leftmap_data['london'] = new Array();
_leftmap_data['london']['name'] = 'London';
_leftmap_data['london']['count'] = 1;
_leftmap_data['london']['left'] = 159;
_leftmap_data['london']['url'] = 'christmas-parties-london';


function leftmap_draw_header () {
	document.write('<div id="leftmap" class="leftmap" onmouseover="leftmap_area_over();" onmouseout="leftmap_area_out();" style="height: '+(351+leftmap_europe_height)+'px;">');
}

function leftmap_draw_footer () {
	var letters = new Array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z');
	document.write('<div id="leftmap_map" class="map"></div>');
	for (var i = 0; i < _leftmap_order.length; i++) {
		document.write('<div id="leftmap_'+_leftmap_order[i]+'" class="'+_leftmap_order[i]+'-over"></div>');
	}
	document.write('<div id="leftmap_heading" class="heading"><table class="set"><tr><td class="set"><table class="content"><tr><td class="text"><nobr id="leftmap_text">Select a region</nobr></td><td class="icon"><div id="leftmap_icon" class="icon"></div></td></tr></table></td></tr></table></div>');
	document.write('<div id="leftmap_container_left" class="container-left" style="height: '+(351+leftmap_europe_height)+'px;"></div><div class="container-topleft"></div><div id="leftmap_container_bottomleft" class="container-bottomleft" style="margin-top: '+(304+leftmap_europe_height)+'px;"></div><div class="container-top"></div><div id="leftmap_container_bottom" class="container-bottom" style="margin-top: '+(341+leftmap_europe_height)+'px;"></div>');
	// document.write('<div id="leftmap_europe_title" class="leftmap-europe-title"></div>');
	document.write('<div id="leftmap_clickarea" class="clickarea">');
	for (var i = 0; i < _leftmap_order.length; i++) {
		for (var c = 0; c < _leftmap_data[_leftmap_order[i]]['count']; c++) {
			document.write('<span class="'+_leftmap_order[i]+'-'+letters[c]+'" onclick="leftmap_click(this);" onmouseover="leftmap_over(this);" onmouseout="leftmap_out();"></span>');
		}
	}
	document.write('</div>');
	document.write('</div><div id="leftmap_whitecover" class="leftmap-whitecover" style="margin-top: '+(0-405-leftmap_europe_height)+'px; height: '+(370+leftmap_europe_height)+'px;"></div>');
}


///////////////////


_leftmap_status = '';
_leftmap_current = '';

function leftmap_over ( obj ) {
	if (_leftmap_status != '') { return; }
	if (_leftmap_current != '') {
		document.getElementById('leftmap_'+_leftmap_current).style.visibility = 'hidden';
	}
	var a = obj.className.split('-');
	document.getElementById('leftmap_'+a[0]).style.visibility = 'visible';
	document.getElementById('leftmap_text').innerHTML = _leftmap_data[a[0]]['name'];
	document.getElementById('leftmap_icon').style.backgroundPosition = '0px -13px';
	_leftmap_current = a[0];
}

function leftmap_out () {
	if (_leftmap_status != '') { return; }
	if (_leftmap_current != '') {
		document.getElementById('leftmap_'+_leftmap_current).style.visibility = 'hidden';
	}
	document.getElementById('leftmap_text').innerHTML = 'Select a region';
	document.getElementById('leftmap_icon').style.backgroundPosition = '0px 0px';
	_leftmap_current = '';
}

function leftmap_click ( obj ) {
	if (_leftmap_status != '') { return; }
	// var a = obj.className.split('-');
	// going to assume _leftmap_current is what was clicked on
	if (_leftmap_data[_leftmap_current]['url']) {
		document.location = basehref()+_leftmap_data[_leftmap_current]['url'];
		return;
	}
	return;
	_leftmap_status = 'mapleft';
	ge('leftmap_clickarea').style.display = 'none';
	ge('leftmap_rb_'+_leftmap_current).style.display = 'block';
	leftmap_opacity('leftmap_rb_'+_leftmap_current, 0);
	leftmap_timer_reset();
	if (!_leftmap_timer) { leftmap_timer(); }
}

function leftmap_backtomap () {
	if (_leftmap_status == 'wait' || _leftmap_status == 'mapleft') {
		_leftmap_status = 'mapright';
		leftmap_timer_reset();
	}
}

//////////////////////

_leftmap_aover = false;

function leftmap_area_over () {
	_leftmap_aover = true;
	if (_leftmap_status == 'wait') {
		leftmap_timer_reset();
	}
}

function leftmap_area_out () {
	_leftmap_aover = false;
	if (_leftmap_status == 'wait') {
		leftmap_timer_reset();
	}
}

//////////////////////

_leftmap_timer = false;
_leftmap_t = 0;

function leftmap_timer_reset () {
	var a = new Date();
	_leftmap_t = a.getTime();
}

function leftmap_timer () {
	_leftmap_timer = true;

	if (_leftmap_status != '') {
		var a = new Date();
		var t = a.getTime() - _leftmap_t;
		var p = t * (170 / 250);
	}

	switch (_leftmap_status) {

		case 'mapleft':
			if (p > 0) { // map
				if (p > 170) {
					leftmap_move_map(170);
				} else {
					// var q = (Math.sin( ((p / 170) * Math.PI) - (Math.PI / 2) ) + 1) / 2 * 170;
					leftmap_move_map(p);
				}
			}
			if (p > 50) { // regionbox
				if (p > 170) {
					leftmap_opacity('leftmap_rb_'+_leftmap_current, 1);
					leftmap_opacity('leftmap_europe_title', 0);
				} else {
					var v = (p - 50) / 170;
					leftmap_opacity('leftmap_rb_'+_leftmap_current, v);
					leftmap_opacity('leftmap_europe_title', 1 - v);
				}
			}
			if (p > 170) {
				_leftmap_status = 'wait';
				leftmap_timer_reset();
				document.getElementById('leftmap_'+_leftmap_current).style.visibility = 'hidden';
			};
			break;

		case 'wait':
			if (_leftmap_aover == false && p > 500) {
				_leftmap_status = 'mapright';
				leftmap_timer_reset();
			}
			break;

		case 'mapright':
			if (p > 0) { // map
				if (p > 170) {
					leftmap_move_map(0);
				} else {
					// var q = (Math.sin( ((p / 170) * Math.PI) - (Math.PI / 2) ) + 1) / 2 * 170;
					leftmap_move_map(170 - p);
				}
			}
			if (p > 0) { // regionbox
				if (p > 120) {
					leftmap_opacity('leftmap_rb_'+_leftmap_current, 0);
					leftmap_opacity('leftmap_europe_title', 1);
				} else {
					var v = 1 - (p / 120);
					leftmap_opacity('leftmap_rb_'+_leftmap_current, v);
					leftmap_opacity('leftmap_europe_title', 1 - v);
				}
			}
			if (p > 170) {
				_leftmap_status = '';
				leftmap_timer_reset();
				ge('leftmap_clickarea').style.display = 'block';
				ge('leftmap_rb_'+_leftmap_current).style.display = 'none';
				leftmap_out();
				_leftmap_timer = false;
			};
			break;

	}

	if (_leftmap_timer) { setTimeout('leftmap_timer();', 10);	}

}

function leftmap_move_map ( p ) {
	ge('leftmap_heading').style.marginLeft = Math.floor(_leftmap_data['heading']['left'] - p) +'px';
	ge('leftmap_map').style.marginLeft = Math.floor(_leftmap_data['map']['left'] - p) +'px';
	ge('leftmap_'+_leftmap_current).style.marginLeft = Math.floor(_leftmap_data[_leftmap_current]['left'] - p) +'px';
	ge('leftmap_europe').style.marginLeft = Math.floor(_leftmap_data['map']['left'] - p) +'px';
}

function leftmap_opacity ( id, opacity ) {
	var s = ge(id).style;
	s.opacity = opacity;
	s.MozOpacity = opacity; 
	s.KhtmlOpacity = opacity;
	s.filter = "alpha(opacity=" + (opacity*100) + ")";
}


////////////////////////////////////

function leftmap_europe_resize () {
	return;
	var height = ge('leftmap_europe_uldiv').scrollHeight
	if (height == leftmap_europe_height) { return; }
	ge('leftmap').style.height = (401+height) +'px';
	ge('leftmap_whitecover').style.marginTop = (0-405-height) +'px';
	ge('leftmap_whitecover').style.height = (420+height) +'px';
	ge('leftmap_container_left').style.height = (401+height) +'px';
	ge('leftmap_container_bottomleft').style.marginTop = (354+height) +'px';
	ge('leftmap_container_bottom').style.marginTop = (391+height) +'px';
	ge('leftmap_europe').style.height = (40+height) +'px';
}

/* window.addEvent('domready', function(){
  leftmap_europe_resize();
});
add_load_event(leftmap_europe_resize); */

