function getChannels(url,regionID,fieldName){
	var XMLhttpObj = false;
    if (typeof XMLHttpRequest != 'undefined'){
        XMLhttpObj = new XMLHttpRequest();
    } else if (window.ActiveXObject){
        	try{
            	XMLhttpObj = new ActiveXObject('Msxml2.XMLHTTP');
        	} catch(e) {
            		try{
                		XMLhttpObj = new ActiveXObject('Microsoft.XMLHTTP');
            		} catch(e) {}
        	}
    }
    if (!XMLhttpObj) return;
	
	XMLhttpObj.onreadystatechange = function() {
    	if (XMLhttpObj.readyState == 4) { // when request is complete
			var elmChannel = document.getElementById("showChannels");
			elmChannel.innerHTML = "";
			
			elmChannel.innerHTML = XMLhttpObj.responseText;
        }
    };
    url = url+"?regionID="+regionID+"&fieldName="+fieldName+"&sid="+Math.random();
	//alert(url);
    XMLhttpObj.open('GET', url, true);
    XMLhttpObj.send(null);
}

function getInitChannels(url){
	var XMLhttpObj = false;
    if (typeof XMLHttpRequest != 'undefined'){
        XMLhttpObj = new XMLHttpRequest();
    } else if (window.ActiveXObject){
        	try{
            	XMLhttpObj = new ActiveXObject('Msxml2.XMLHTTP');
        	} catch(e) {
            		try{
                		XMLhttpObj = new ActiveXObject('Microsoft.XMLHTTP');
            		} catch(e) {}
        	}
    }
    if (!XMLhttpObj) return;
	
	XMLhttpObj.onreadystatechange = function() {
    	if (XMLhttpObj.readyState == 4) { // when request is complete
			var elmChannel = document.getElementById("showChannels");
			elmChannel.innerHTML = "";
			elmChannel.innerHTML = XMLhttpObj.responseText;
        }
    };
    url = url; //+ "&sid="+Math.random();
	//alert(url);
    XMLhttpObj.open('GET', url, true);
    XMLhttpObj.send(null);
}

function showChannel(url){
	var XMLhttpObj = false;
    if (typeof XMLHttpRequest != 'undefined'){
        XMLhttpObj = new XMLHttpRequest();
    } else if (window.ActiveXObject){
        	try{
            	XMLhttpObj = new ActiveXObject('Msxml2.XMLHTTP');
        	} catch(e) {
            		try{
                		XMLhttpObj = new ActiveXObject('Microsoft.XMLHTTP');
            		} catch(e) {}
        	}
    }
    if (!XMLhttpObj) return;
	
	XMLhttpObj.onreadystatechange = function() {
    	if (XMLhttpObj.readyState == 4) { // when request is complete
			var elmChannel = document.getElementById("MovieClip");
			elmChannel.innerHTML = "";
			elmChannel.innerHTML = XMLhttpObj.responseText;
        }
    };
    //url = url+"?regionID="+regionID+"&fieldName="+fieldName+"&sid="+Math.random();
	//alert(url);
    XMLhttpObj.open('GET', url, true);
    XMLhttpObj.send(null);
}

function fillSelect(outputText) {
    var elmChannel = document.getElementById("showChannels");
   
    // clear out existing DIV data
    elmChannel.innerHTML = "";
    // fill out existing DIV data
	elmChannel.innerHTML = outputText;
}

function getCountries(url,regionID,fieldName){
	var XMLhttpObj = false;
    if (typeof XMLHttpRequest != 'undefined'){
        XMLhttpObj = new XMLHttpRequest();
    } else if (window.ActiveXObject){
        	try{
            	XMLhttpObj = new ActiveXObject('Msxml2.XMLHTTP');
        	} catch(e) {
            		try{
                		XMLhttpObj = new ActiveXObject('Microsoft.XMLHTTP');
            		} catch(e) {}
        	}
    }
    if (!XMLhttpObj) return;
	
	XMLhttpObj.onreadystatechange = function() {
    	if (XMLhttpObj.readyState == 4) { // when request is complete
            fillSelectCountries(XMLhttpObj.responseText);
        }
    };
    url = url+"?regionID="+regionID+"&fieldName="+fieldName+"&sid="+Math.random();
    XMLhttpObj.open('GET', url, true);
    XMLhttpObj.send(null);
}

function fillSelectCountries(outputText) {
    var elmChannel = document.getElementById("lyr2");
    
    // clear out existing DIV data
    elmChannel.innerHTML = "";
    // fill out existing DIV data
	elmChannel.innerHTML = outputText;
	initScrollLayerCountries();
}

function setBackgroundColor(elmID){
	var type = checkElmType(elmID);
	switch(type){
		case "r":
			setOthersBGColor(type);
			//setOthersBGColor('g');
			document.getElementById(elmID).style.background = '#ffffff';
			getChildNode(document.getElementById(elmID),'A','#323B97');
			break;
		case "c":
			setOthersBGColor(type);
			//setOthersBGColor('g');
			document.getElementById(elmID).style.background = '#ffffff';
			getChildNode(document.getElementById(elmID),'A','#323B97');
			break;
		case "g":
			setOthersBGColor(type);
			//setOthersBGColor('r');
			//setOthersBGColor('c');
			document.getElementById(elmID).style.background = '#ffffff';
			getChildNode(document.getElementById(elmID),'A','#323B97');
			break;
	}
}

function setBackgroundColor_onClick(elmID){
	var type = checkElmType(elmID);
	switch(type){
		case "r":
			setOthersBGColor(type);
			setOthersBGColor('g');
			document.getElementById(elmID).style.background = '#ffffff';
			getChildNode(document.getElementById(elmID),'A','#323B97');
			break;
		case "c":
			setOthersBGColor(type);
			setOthersBGColor('g');
			document.getElementById(elmID).style.background = '#ffffff';
			getChildNode(document.getElementById(elmID),'A','#323B97');
			break;
		case "g":
			setOthersBGColor(type);
			setOthersBGColor('r');
			setOthersBGColor('c');
			document.getElementById(elmID).style.background = '#ffffff';
			getChildNode(document.getElementById(elmID),'A','#323B97');
			break;
	}
}

function setBackgroundColor_td(elmID){
	var type = checkElmType(elmID);
	switch(type){
		case "r":
			setOthersBGColor(type);
			setOthersBGColor('g');
			document.getElementById(elmID).style.background = '#ffffff';
			getChildNode(document.getElementById(elmID),'A','#323B97');
			break;
		case "c":
			//setOthersBGColor(type);
			//setOthersBGColor('g');
			document.getElementById(elmID).style.background = '#ffffff';
			getChildNode(document.getElementById(elmID),'A','#323B97');
			break;
		case "g":
			setOthersBGColor(type);
			//setOthersBGColor('r');
			//setOthersBGColor('c');
			document.getElementById(elmID).style.background = '#ffffff';
			getChildNode(document.getElementById(elmID),'A','#323B97');
			break;
	}
}

function checkElmType(elmID){
	var temparr = elmID.split("_");
	return temparr[0];
}

function setOthersBGColor(type){
	var col = document.getElementsByTagName("tr");
	var newtype;
	for(var i=0; i<col.length; i++){
		newtype = col[i].id;
		if(type == checkElmType(newtype)){
			col[i].style.background = "transparent";
			getChildNode(col[i],'A','#323B97');
		}
	}
}

function getChildNode(elmID,nodeType,fontColorType){
	var col = elmID.childNodes;
	for(var i=0; i<col.length; i++){
		if(col[i].childNodes){
			for(var j=0; j<col[i].childNodes.length; j++){
				if(col[i].childNodes[j].nodeName == nodeType){
					col[i].childNodes[j].style.color = 	fontColorType;				
				}
			}
		}
	}
}
