// JavaScript Document for Flash and Html control

var coIds = "";


function initFlashMap(){
	var items = document.getElementById("countries_list");
	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("countries_list");
	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);
	
	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);

	document.getElementById(id).className = "active";

	return targetName;
	
}

function fCallUnhighlightById(id){
	var targetName = getTargetNameById(id);
	
	document.getElementById(id).className = "";
	
	return targetName;
	
}


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