//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//mapscroll//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function map_options(func_id)
{
	switch(func_id) 
	{
		case 'left':
				document.getElementById("x").value = parseFloat(document.getElementById("x").value) - 80 ;
				break ;
		case 'centre':
				document.getElementById("x").value = 0 ;
				document.getElementById("y").value = 0 ;
				break ;
		case 'right':
				document.getElementById("x").value = parseFloat(document.getElementById("x").value) + 80 ;
				break ;
		case 'up':
				document.getElementById("y").value = parseFloat(document.getElementById("y").value) - 80 ;
				break ;
		case 'down':
				document.getElementById("y").value = parseFloat(document.getElementById("y").value) + 80 ;
				break ;
		case 'in':
			if (parseFloat(document.getElementById("zoom").value) > 100)
				document.getElementById("zoom").value = parseFloat(document.getElementById("zoom").value) - 100 ;
				break ;
		case 'out':
			if (parseFloat(document.getElementById("zoom").value) < 400)
				document.getElementById("zoom").value = parseFloat(document.getElementById("zoom").value) + 100 ;
				break ;
		case 'change_map':
				if (document.getElementById("mapstyle").value == 'road')
					document.getElementById("mapstyle").value = 'county' ;
				else
					document.getElementById("mapstyle").value = 'road' ;
				break ;
		case 'change_page':
				if (document.getElementById("page").value == 'console')
					document.getElementById("page").value = 'multiactivity' ;
				else
					document.getElementById("page").value = 'console' ;
				break ;
	}
	document.map_hidden_form.submit();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//jquery window//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$(document).ready(
	function()
	{
		$('#windowOpen').bind(
			'click',
			function() {
				if($('#window').css('display') == 'none') {
					$(this).TransferTo(
						{
							to:'window',
							className:'transferer2', 
							duration: 400,
							complete: function()
							{
								$('#window').show();
							}
						}
					);
				}
				this.blur();
				return false;
			}
		);
		$('#windowClose').bind(
			'click',
			function()
			{
				$('#window').TransferTo(
					{
						to:'windowOpen',
						className:'transferer2', 
						duration: 400
					}
				).hide();
			}
		);
		$('#windowMin').bind(
			'click',
			function()
			{
				$('#windowContent').SlideToggleUp(300);
				$('#windowBottom, #windowBottomContent').animate({height: 10}, 300);
				$('#window').animate({height:40},300).get(0).isMinimized = true;
				$(this).hide();
				$('#windowResize').hide();
				$('#windowMax').show();
			}
		);
		$('#windowMax').bind(
			'click',
			function()
			{
				var windowSize = $.iUtil.getSize(document.getElementById('windowContent'));
				$('#windowContent').SlideToggleUp(300);
				$('#windowBottom, #windowBottomContent').animate({height: windowSize.hb + 13}, 300);
				$('#window').animate({height:windowSize.hb+43}, 300).get(0).isMinimized = false;
				$(this).hide();
				$('#windowMin, #windowResize').show();
			}
		);
		$('#window').Resizable(
			{
				minWidth: 200,
				minHeight: 60,
				maxWidth: 700,
				maxHeight: 400,
				dragHandle: '#windowTop',
				handlers: {
					se: '#windowResize'
				},
				onResize : function(size, position) {
					$('#windowBottom, #windowBottomContent').css('height', size.height-33 + 'px');
					var windowContentEl = $('#windowContent').css('width', size.width - 25 + 'px');
					if (!document.getElementById('window').isMinimized) {
						windowContentEl.css('height', size.height - 48 + 'px');
					}
				}
			}
		);
	}
);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//innerfade//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$(function(){
$('#intro').innerfade({ speed: 'slow', timeout: 4000, type: 'sequence', containerheight: '37px' });
} ); 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//popup//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (window.self != window.top) window.top.location = window.self.location;

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
	var win=null;
	
	function NewWindow(mypage,myname,w,h,scroll,pos){
	
		if(pos=="random")
			{LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;
			TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}

		if(pos=="center")
			{LeftPosition=(screen.width)?(screen.width-w)/2:100;
			TopPosition=(screen.height)?(screen.height-h)/2:100;}
	
		else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
	
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes';

	win=window.open(mypage,myname,settings);}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//clear-form-input
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = ""
} 
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//jq-innerfade//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$.fn.innerfade = function(options) {
return this.each(function(){ 
						   
var settings = {
speed: 'normal',
timeout: 2000,
type: 'sequence',
containerheight: 'auto'
}

if(options)
$.extend(settings, options);

var elements = $(this).children().get();

if (elements.length > 1) {

$(this).parent().css('position', 'relative');

$(this).css('height', settings.containerheight);

for ( var i = 0; i < elements.length; i++ ) {
$(elements[i]).css('z-index', elements.length - i).css('position', 'absolute');
$(elements[i]).hide();
}

if ( settings.type == 'sequence' ) {
setTimeout(function(){
$.innerfade.next(elements, settings, 1, 0);
}, settings.timeout);
$(elements[0]).show();
}
else if ( settings.type == 'random' ) {
setTimeout(function(){
do { current = Math.floor ( Math.random ( ) * ( elements.length ) ); } while ( current == 0 )
$.innerfade.next(elements, settings, current, 0);
}, settings.timeout);
$(elements[0]).show();
}
else {
alert('type must either be \'sequence\' or \'random\'');
}

}

});
};

$.innerfade = function() {}
$.innerfade.next = function (elements, settings, current, last) {

$(elements[last]).fadeOut(settings.speed);
$(elements[current]).fadeIn(settings.speed);

if ( settings.type == 'sequence' ) {
if ( ( current + 1 ) < elements.length ) {
current = current + 1;
last = current - 1;
}
else {
current = 0;
last = elements.length - 1;
}
}
else if ( settings.type == 'random' ) {
last = current;
while (current == last ) {
current = Math.floor ( Math.random ( ) * ( elements.length ) );
}
}
else {
alert('type must either be \'sequence\' or \'random\'');
}
setTimeout((function(){$.innerfade.next(elements, settings, current, last);}), settings.timeout);
};