var fl=false;
var f2=false;
var lastSel= '';
var main = {
    init: function()
    {
    	 $('.region-titles a').mouseover(

    	 function(){main.lightRegion(this.id);},function(){main.hideRegion(this.id);}    

        );

        $('#region-map area').mouseover(

        function(){main.lightRegion('emb_'+this.id);},function(){main.hideRegion('emb_'+this.id);},function(){main.clickRegion(this.id);}

        );
/*
    	$('.region-titles a').hover(
            function(){main.lightRegion(this.id);},function(){main.hideRegion(this.id);}
        );

        $('#region-map area').hover(
            function(){main.lightRegion('emb_'+this.id);},function(){main.hideRegion('emb_'+this.id);}
        );

        $('.region-titles a').click(
            function(){main.clickRegion(this.id);}
        );
*/
		$('#region-map area').click(
            function(){window.open(site[this.id]);}
        );

	},
    
    lightRegion: function(region) {
		fl=false;

		if (region && document.getElementById(region)) {
			main.clickRegion(region); // document.getElementById(region).style.color ='black';                        
		}
		if (region) {document.getElementById('region_image').style.backgroundImage = 'url(/themes/default/images/' + region + '.png)';}
	},
    
    hideRegion: function(region) {
		if (!fl && region && document.getElementById(region)) {
			document.getElementById(region).style.color ='';
		}
		if (!$.browser.opera && !fl){
			document.getElementById('region_image').style.backgroundImage = 'url(/themes/default/images/images/blank.gif)';
		}
	},
	
	clickRegion: function(region) {
		if (region) {fl=true; 
				if (lastSel != region && lastSel !='') {
					document.getElementById(lastSel + '_li').className = '';
					$('#' + lastSel + '_ul').hide();					
				};
				// $('#' + region + '_a').hide();
				document.getElementById(region + '_li').className = 'Sel';
				$('#' + region + '_ul').show();
				lastSel = region;
				// alert(region+' '+fl);
		}
	}
    
}

$(document).ready(function(){main.init()});
