/*
	Collections of javascript functions used in dotbyresound.com
	
	Author :	
	Subsilo ApS
	www.subsilo.dk
	
	Production :
	Wasabi
	www.wasabi.dk
*/

/*
	Create drop down for language choice
	used globally throughout all country domains	
	
	Requirements:
	- A css element parsed to the function
	- Init the array defining the content of the dropdwon
	
	Sets the innerHTML in the css element parsed to the function 
*/

// CONFIGURE ----------------------------------------------------------------------------------------
// Dropdown 
// Content array
var dropdownStructure = []

// CONFIGURE FROM HERE
dropdownStructure.push(["Select a country", "", "SELECTED"])
//dropdownStructure.push(["Australia", "www.dotbyresound.com.au"])
dropdownStructure.push(["Belgique (FR)", "www.dotbyresound.be/FR"])
dropdownStructure.push(["Belgique (NL)", "www.dotbyresound.be/NL"])
//dropdownStructure.push(["Canada", "www.dotbyresound.ca"])
dropdownStructure.push(["Danmark", "www.dotbyresound.dk"])
dropdownStructure.push(["Deutschland", "www.dotbyresound.de"])
dropdownStructure.push(["Espa&ntilde;a", "www.dotbyresound.es"])
dropdownStructure.push(["France", "www.dotbyresound.fr"])
//dropdownStructure.push(["Italia", "www.dotbyresound.it"])
dropdownStructure.push(["&#26085;&#26412", "www.dotbyresound.jp"])
dropdownStructure.push(["Nederland", "www.dotbyresound.nl"])
dropdownStructure.push(["Norge", "www.dotbyresound.no"])
dropdownStructure.push(["New Zealand", "www.dotbyresound.co.nz"])
//dropdownStructure.push(["Sweden", "www.dotbyresound.se"])
dropdownStructure.push(["Schweiz (DE)", "www.dotbyresound.ch/DE"])
dropdownStructure.push(["Suisse (FR)", "www.dotbyresound.ch/FR"])
dropdownStructure.push(["United Kingdom", "http://www.dotbyresound.co.uk"])
//dropdownStructure.push(["&Ouml;sterreich", "www.dotbyresound.at"])
// TO HERE 

// ------------------------------------------------------------------------------------------------------


// BLACK BOX -----------------------------------------------------------------------------------------
// Create HTML for the dropdown 
// Don't touch 
function createLanguageDropdown(cssElement)
{
	// Create HTML for css element
	var str = ""
	str +=	"<form name='form' id='form'>"
    str +=	"Change country: "

    str +=	"<select name=\"jumpMenu\" id=\"jumpMenu\" onchange=\"chooseOption(this)\">"
    
    // Create all options from the structure list
    for(var i=0; i<dropdownStructure.length; i++)
    {
    	var optionTitle = dropdownStructure[i][0]
    	var siteURL = dropdownStructure[i][1]
    	if(dropdownStructure[i][2] != undefined){ var selectedValue = " "+dropdownStructure[i][2] }else{ var selectedValue = "" }

    	str +=	"<option value=\""+siteURL+"\""+selectedValue+">"+optionTitle+"</option>"	
    }

    str +=	"</select>"
    //str +=	"</form>"
	
	// Write the dropdown into the css element
	var obj = document.getElementById(cssElement)
	obj.innerHTML = str	
}

// What to do when an option is chosen
// Don't touch 
function chooseOption(opt)
{
	// Subtract the URL 
	var siteURL = opt.options[opt.selectedIndex].value
	
	// Drop out if there's no URL
	if(siteURL == "")
		return false
	
	// Check for "http://" as beeing the first part of the URL.
	// not pressent then insert the string
	if(siteURL.search(/^http:\/\//) == -1) 
		siteURL = "http://"+siteURL
	
	// Redirect to the new web page	 
	window.location.href = siteURL
}
// ------------------------------------------------------------------------------------------------------

