var currentABCSelectedLink;
var currentSelectedLink;
var currenctSelectedContactWorldwide;
var currentSelectedContactTrainingTopic;

function fireEvent (eventType, elementID) 
{ 
    var o = document.getElementById(elementID); 
    if (document.createEvent) 
    { 
        var evt = document.createEvent("Events"); 
        evt.initEvent(eventType, true, true);
         o.dispatchEvent(evt); 
    } 
    else if (document.createEventObject) 
    { 
        var evt = document.createEventObject(); 
        o.fireEvent('on' + eventType, evt); 
    } 
}

function GetCountriesByABCSelect(link, abc)
{
    if( currentABCSelectedLink )
    {
        link.style.lineHeight = "";
        currentABCSelectedLink.style.fontSize = "";
        currentABCSelectedLink.style.fontWeight = "";
        currentABCSelectedLink.style.color = "";
        /*currentABCSelectedLink.style.textDecoration = "";*/
    }

    if ( link )
    {
        link.style.fontSize = "16px";
        link.style.fontWeight = "bold";
        link.style.color = "#900";
        /*link.style.textDecoration = "underline";*/
        currentABCSelectedLink = link;
    }  
    
    SiTrainWorldApplication.WebServices.GlobalContent.FillContactWordwideLayerFiltered(abc, GetCountriesByABCSelectCallback);  
}


function GetWorldwideContactDetail(link, country)
{
    if( currentSelectedLink )
    {
        currentSelectedLink.style.fontSize = "";
        currentSelectedLink.style.fontWeight = "";
        currentSelectedLink.style.color = "";
        currentSelectedLink.style.textDecoration = "";
    }

    if ( link )
    {
        link.style.fontSize = "13px";
        link.style.fontWeight = "bold";
        link.style.color = "#900";
        link.style.textDecoration = "underline";
        currentSelectedLink = link;
    }  
        
    SiTrainWorldApplication.WebServices.GlobalContent.GetWorldContactsLayerDetailContent(country, GetWorldwideContactDetailCallback);
    
    currenctSelectedContactWorldwide = country;    
    
    if(toolbarLayerSitrainContactsWorldwide !== null) 
    {    
        toolbarLayerSitrainContactsWorldwide.set_SelectedCountry(country);	
    }    
}

function GetCountriesByABCSelectCallback(result)
{
    currenctSelectedContactWorldwide = null;    
    
    if(toolbarLayerSitrainContactsWorldwide !== null) 
    {    
        toolbarLayerSitrainContactsWorldwide.set_SelectedCountry(currenctSelectedContactWorldwide);	
    } 

    var control = $get("ContactLayerCountryList");
    var controlRight = $get("DetailWorldwideContact");
    if ( control !== null )
    {
        control.innerHTML = result;
        control.style.width = '';
        AjaxControlToolkit.Animation.FadeInAnimation.play(control, 1.0, 24);  
        
        if (controlRight !== null )
        {
            if ( controlRight.innerHTML !== "")
            {
                 controlRight.innerHTML = "";
            }
        }
    }
}

function GetWorldwideContactDetailCallback(result)
{
    var controlRight = $get("DetailWorldwideContact");
    if (controlRight !== null )
    {
        controlRight.style.visiblity = "hidden";            
        controlRight.innerHTML = result;
        AjaxControlToolkit.Animation.FadeInAnimation.play(controlRight, 1.0, 24, 0.01 );            
    }
}

function highlightLinkByImageMap(link)
	{
	    if ( link )
	    {
	        link.style.fontSize = "13px";
            link.style.fontWeight = "bold";
            link.style.color = "#900";
        }
	}
	
	function unhighlightLinkByImageMap(link)
	{
	    if ( link )
	    {
	        link.style.fontSize = "";
            link.style.fontWeight = "";
            link.style.color = "";
        }
	}
	
	function GetSelectedValue(dropDownElement)
    {
        var selectedIndex = dropDownElement.selectedIndex;
        var optionCollection = dropDownElement.options;
        var returnText = new String();
        
//        if (selectedIndex > 0)
        {
            var option = optionCollection[selectedIndex];
            returnText = option.value;
        }
        
        return returnText;
    }
	
	function disableLinkListWithFading()
	{
	    //link_list_world.childNodes..getElementsByTagName("ul")[0].
	}
	
	function switch_worldimagemap(type)
	{

	
	    $get("backtoworldmap").style.display = "none";		
	    $get("link_list_world").style.display = "none";
	    $get("link_list_afrika").style.display = "none";
	    $get("link_list_asien").style.display = "none";
	    $get("link_list_australien").style.display = "none";
	    $get("link_list_europa").style.display = "none";
	    $get("link_list_nordamerika").style.display = "none";
	    $get("link_list_suedamerika").style.display = "none";
	
	    $get("container_imagemap_world").style.display = "none";
	    $get("container_imagemap_afrika").style.display = "none";
	    $get("container_imagemap_asien").style.display = "none";
	    $get("container_imagemap_australien").style.display = "none";
	    $get("container_imagemap_nordamerika").style.display = "none";
	    $get("container_imagemap_suedamerika").style.display = "none";
	    $get("container_imagemap_europa").style.display = "none";
	    
	    switch(type)
	    {
	        case "world": 
	            $get("container_imagemap_world").style.display = "block"; 
	            $get("link_list_world").style.display = "block";
	            break;
	        case "europa": 
	            $get("container_imagemap_europa").style.display = "block"; 
	            $get("backtoworldmap").style.display = "block";
	            $get("link_list_europa").style.display = "block"; 	            
	            break;
	        case "nordamerika": 
	            $get("container_imagemap_nordamerika").style.display = "block";
	            $get("backtoworldmap").style.display = "block"; 
	            $get("link_list_nordamerika").style.display = "block"; 
	            break;
	        case "suedamerika": 
	            $get("container_imagemap_suedamerika").style.display = "block"; 
	            $get("backtoworldmap").style.display = "block";
	            $get("link_list_suedamerika").style.display = "block"; 
	            break;
	        case "asien": 
	            $get("container_imagemap_asien").style.display = "block"; 
	            $get("backtoworldmap").style.display = "block";
	            $get("link_list_asien").style.display = "block"; 
	            break;
	        case "afrika": 
	            $get("container_imagemap_afrika").style.display = "block"; 
	            $get("backtoworldmap").style.display = "block";
	            $get("link_list_afrika").style.display = "block"; 
	            break;
	        case "australien": 
	            $get("container_imagemap_australien").style.display = "block"; 
	            $get("backtoworldmap").style.display = "block";
	            $get("link_list_australien").style.display = "block"; 
	            break;
	    } 
	}
	
		
	function openPrintDialog(url)
	{
	    window.open(url, "", "scrollbars=auto,width=600,height=800,menubar=yes,locationbar=no,status=no,resizable=yes,dependent=yes"); 
	}
	
	function printCurrentContactWorldwide()
	{
	    if(currenctSelectedContactWorldwide)
	    {
	        var url = "./printcontactworldwide.aspx?country=" + currenctSelectedContactWorldwide;
	        openPrintDialog(url);	        
	    }
	}
	
	function printWhyTraining( )
	{
	    openPrintDialog("./printwhytraining.aspx");
	}


function setImageMapLayer( type, image )
{
   $get("imagemap_" + type).src = image;
   //setTimeout("setLayer('" + image + "');" 100);
}

function setLayer(image)
{
    
}

function clickButton(e, buttonid)
{
    var evt = e ? e : window.event;   
    if (evt.keyCode == 13)
    {  
        fireEvent("click", buttonid);
        return false; 
    }    
}

function removeImageMapLayer( type )
{
    var worldimage = 'Images/World/welt.gif';
    var europaimage = 'Images/World/Europa/europa.gif';
    var asienimage = 'Images/World/Asien/asien_pazifik.gif';
    var afrikaimage = 'Images/World/Afrika/afrika.gif';
    var australienimage = 'Images/World/Australien/australien_neuseeland.gif';
    var nordamerikaimage = 'Images/World/Nordamerika/nordamerika.gif';
    var suedamerikaimage = 'Images/World/Suedamerika/suedamerika.gif';

    switch( type )
    {
        case "world":           $get("imagemap_world").src = worldimage;     break;
        case "europa":          $get("imagemap_europa").src = europaimage;   break;
        case "asien":           $get("imagemap_asien").src = asienimage;     break;
        case "afrika":          $get("imagemap_afrika").src = afrikaimage;   break;
        case "australien":      $get("imagemap_australien").src = australienimage;       break;
        case "nordamerika":     $get("imagemap_nordamerika").src = nordamerikaimage;     break;
        case "suedamerika":     $get("imagemap_suedamerika").src = suedamerikaimage;     break;
    }    
}
