/** StoreLocator **/
function getCities(lang) {
	if($F('country-select') != "notset") {
	var ajax = new Ajax.Updater(
		'city-select',
		'/' + lang + '/shop/locator.dynamic-yes.html',
		{
			method: 'post',
			parameters: 'countryID=' + $F('country-select') + '&lang=' + lang
		});

	}
};

/** Snowpass Resort **/
function spGetCities(lang,countryID,type) {
	var ajax = new Ajax.Updater(
		'scitybox',
		'/' + lang + '/snowpass/snowpass_wheretouse_ski_ressorts.dynamic-yes.html',
		{
			method: 'post',
			parameters: 'countryID=' + countryID + '&lang=' + lang + '&type=' + type + '&range=city'
		});
	document.getElementById('sresortsbox').innerHTML = '';
	document.getElementById('sprint_link').innerHTML = '<p class="link" style="margin:10px;"><a href="/templates/en/snowpass/print/print.php?language=' + lang + '&amp;country=' + countryID + '&amp;type=' + type + '" target="_blank" title="Print">Print</a></p>';
}

/** Snowpass Resort **/
function spGetResorts(lang,city,countryID,type) {
	var ajax = new Ajax.Updater(
		'sresortsbox',
		'/' + lang + '/snowpass/snowpass_wheretouse_ski_ressorts.dynamic-yes.html',
		{
			method: 'post',
			parameters: 'city=' + city + '&lang=' + lang + '&countryID=' + countryID + '&type=' + type + '&range=resort',
			evalScripts: true
		});
	}

/** Snowpass neu von Michi */
function spGetData(lang,country,type,print) {
	if (!print)
		print = "PRINT";
    var ajax = new Ajax.Updater('scitybox2',
        '/' + lang + '/snowpass/snowpass_wheretouse_ski_ressorts.dynamic-yes.html',
        {
            method: 'post',
            parameters: 'country=' + country + '&lang=' + lang + '&type=' + type,
            evalScripts: true
        });
    $('sprint_link').innerHTML  =   '<p class="link" style="margin:10px;"><a href="' + lang + '/snowpass/print.country-' + country + '.type-' + type + '.html" target="_blank" title="'+print+'">'+print+'</a></p>';
}

/** Newsletterformulare **/
function subscribeNewsletter(action) {
	if(action == 'unsubscribe'){
		$('action').value = 'unsubscribe';
	} else {
		$('action').value = 'subscribe';
	}
    document.getElementById('newsletterform').submit();
}

/** Locale Chooser **/
function select(locale) {
	$('selected-lang').value = locale;
	var tmp = $('submitter').action;
	/*$('submitter').action = tmp.replace(/\/[a-z]{2}_[a-z]{2}\//i,'/' + locale + '/');*/
	tmp = tmp.replace('/sense/','/choose/');
	tmp = tmp.replace('/xx_en/','/choose/');
	$('submitter').action = tmp.replace('/choose/','/' + locale + '/');
	
	//alert($('submitter').action);
	//document.forms[0].submit();
	$('submitter').submit();
}

function getCountriesList(continent,e) {
	$$('.country-choose').invoke('hide');
	var req	=	new Ajax.Updater(
		'response',
		'/libs/ajax/choose-locales.php',
		{
			method: 'get',
			parameters: 'conti=' + continent,
			evalScripts: true
		}
	);
	$$('.linkcontinent').invoke('removeClassName' ,'hover');
	e.addClassName('hover');
}

function get(land,e) {
	$$('.country-choose').invoke('hide');
	$('lang-h3').show();
	$('lang-' + land).show();
	$$('.linkcountry').invoke('removeClassName' ,'hover');
	e.addClassName('hover');
}

function markActiveLanguage(lang) {
	if($('lang-' + lang))
		$('lang-' + lang).show();
}

/* ### Selected Country ### */
function switchLangColor(e,f) {
	if(f == 'continent') {
		$$('.linkcontinent').each(function(el) {
			if(el != e) {
				el.style.color = "#666666";
				el.style.background = "inherit";
			}
		});
		document.getElementById(e).style.color = "#FFFFFF";
		document.getElementById(e).style.background = "#666666;"
		document.getElementById(e).style.textDecoration = "underline";
	} else if(f == 'countrys')  {
		$$('.linkcountry').each(function(el) {
		if(el != e)
			el.style.color = "#666666";
			el.style.background = "inherit";
		});
		document.getElementById(e).style.color = "#FFFFFF";
		document.getElementById(e).style.background = "#666666;"
		document.getElementById(e).style.textDecoration = "underline";
	} else {
		$$('.linklanguage').each(function(el) {
		if(el != e)
			el.style.color = "#666666";
			el.style.background = "inherit";
		});
		document.getElementById(e).style.color = "#FFFFFF";
		document.getElementById(e).style.background = "#666666;"
		document.getElementById(e).style.textDecoration = "underline";
	}
}