function popup(link)
{
	window.open(link.href);
	return false;
}

function openCalendar(elementToPopulate)
{
	var win = window.open("/bmi/Src/Pages/IbeCalendar.aspx?formid=" + uniqueId + "&direction=" + elementToPopulate , "bmiCal", "height=220,width=300");
	return false;
}

function showTopNavMenu(obj)
{
	if (document.all && document.getElementById)
	{
		obj.className = "over";
	}
}

function hideTopNavMenu(obj)
{
	if (document.all && document.getElementById)
	{
		obj.className = "";
	}
}

function showHide(element, idPrefix,id){
	// Get a collection of elements
	var objElement = document.getElementsByTagName(element);
	// loop through each element
	for (i=0;i<objElement.length;i++){
		if (objElement[i].id.indexOf(idPrefix) >= 0){
			// if the element is hidden, show it, otherwise hide it
			if (objElement[i].style.display == 'none' && objElement[i].id == id){objElement[i].style.display = 'block';} else {objElement[i].style.display = 'none';}
		}						
	}
}

function Confirm(message)
{
    // Show the confirm screen
    var blnResult = window.confirm(message);
    // Check for response
    if(blnResult)
    {
        // Positive response, return true
        return true;
    } 
    else 
    {
        // Negative response, return false
        return false;
    }   
}
   
// Variables to hold reference to country and language lists
var countryList;
var languageList;

function LoadLanguages(res)
{    
    // Clear language list
    languageList.options.length = 0;
    // Check for errors
    if (res.error == null)
    {   
        var languages = res.value;
        // Add the default option
        languageList.options[languageList.options.length] = new Option("-- select language --","0");        
        // Loop through adding languages to list
        for(var i = 0; i < languages.length; i++)
        {
            languageList.options[languageList.options.length] = new Option(languages[i].split('|')[0], languages[i].split('|')[1]);
        }     
    }
    else
    {
        // raise error
        alert(res.error);
    }        
}  

function CountryChanged(country)
{   
    // Check we can get to the country and language lists
    if (countryList!=null && languageList!=null)
    {
        // Check if user has seleted top option and redirect back to splash
        if(countryList.options[countryList.selectedIndex].value=='0') 
        { 
            window.location.href="/bmi/splash.aspx"; 
            return;
        }
        else
        {
            // Clear the language list
            languageList.options.length = 0;
            // Add a temp item to tell the user to wait
            languageList.options[languageList.options.length] = new Option('please wait...','0');
            // Call the GetLanguaes method on the server and Asynchronously call the LoadLanguages function to populate the list        
            bmi.GetLanguages(country, LoadLanguages); 
        }
    }    
} 

function GoToSite()
{
    // Check we can get to the list
    if(languageList!=null)
    {
        // If we have a valid language selected, go to thr site
        if(languageList.options[languageList.selectedIndex].value!='0')
        {
                window.location.href="/bmi/" + languageList.options[languageList.selectedIndex].value + "/index.aspx";
        }
    }
    return false;
} 
