// JavaScript Document for Flash and Html control

var coIds = "";


function initFlashMap(){
	var items = document.getElementById("wg_maplist");
	var listItems = items.getElementsByTagName("a");
	
	for (var i=0; i < listItems.length; i++) {
		listItems[i].onmouseover = fHighlightById;
		listItems[i].onmouseout = fUnhighlightById;
	}
}


function getCountryIDFromPage(){
	var items = document.getElementById("wg_maplist");
	var listItems = items.getElementsByTagName("a");
	var listStr = "";
	for (var i=0; i < listItems.length; i++) {
			listStr += listItems[i].id 
			listStr += (i<listItems.length-1)?  "|" : "";
	}
	return listStr;
}
function getTargetNameById(id){
	var target = document.getElementById(id);
	var targetName = "";
	targetName = target.innerHTML;
	return targetName;
	//alert(targetName);
}
function getTargetURLById(id){
	var target = document.getElementById(id);
	var targetURL = "";
	targetURL = target.href;
	return targetURL
	//alert(targetURL);
}

function openURLById(id){

	    var targetURL = getTargetURLById(id).toLowerCase();	
	    // AAA Code: regions we're not subscribed are
	    //identified as '#'
	    if (targetURL.indexOf('#') < 0)
	    {
	        var items = document.getElementById(id);
    	    //
	        items.className = "";		
	        window.open(targetURL, '_top');
	    }
}

function fHighlightById(){
	var targetName = getTargetNameById(this.id);
	var targetID = this.id;
	getMovieName("flashMap").callHighlight(targetID, targetName);
}

function fUnhighlightById(){
	var targetName = getTargetNameById(this.id);
	var targetID = this.id;
	getMovieName("flashMap").callUnhighlight(targetID, targetName);
}


function getMovieName(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName]
   }
   else {
       return document[movieName]
   }
}

function fCallHighlightById(id){
	var targetName = getTargetNameById(id);
	//AAA Code: try...catch added
try {
	document.getElementById(id).className = "active";
}
catch (e){}	
	return targetName;

}

function fCallUnhighlightById(id){
    //AAA Code: try...catch added
    try {
	var targetName = getTargetNameById(id);
	
	document.getElementById(id).className = "";
	} catch(e) {}
	return targetName;
	
}


function fCallOpenURLById(id){
	//alert( "Flash call Open URL");
	openURLById(id);
}

