
// ab- und anstellen ------------------------------
function imgon(who){
	document.getElementById(who).style.visibility = "visible";
}
function imgof(who){
	document.getElementById(who).style.visibility = "hidden";
}

function isValidEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}
function validateNewsletterForm(fillAll, validEmail) {
    if (document.forms.form["mb-name"].value.length > 1 && isValidEmail(document.forms.form["mb-tljry-tljry"].value))
    {
        document.forms.form.submit();
    }
    else
    {
        if (!isValidEmail(document.forms.form["mb-tljry-tljry"].value))
        {
            alert(validEmail);
        }
        else
        {
            alert(fillAll);
        }
    }
}

// 
function allOffWithout(containerId, thumbContainerId, onId){
    // big
    var cont = document.getElementById(containerId);
    var children = cont.getElementsByTagName("div");
    for (i=0; i<children.length; i++)
    {
        if (children[i].id != onId && children[i].id > 0)
        {
            imgof(children[i].id); 
        }
    }
    imgon(onId);
    // thumb
    var cont = document.getElementById(thumbContainerId);
    var children = cont.getElementsByTagName("div");
    for (i=0; i<children.length; i++)
    {
        if (children[i].id.indexOf("thumb") != -1 && children[i].id != "thumb"+onId && children[i].id.length > 0)
        { 
            imgof(children[i].id); 
        }
        if (children[i].id.indexOf("plus") != -1 && children[i].id != "plus"+onId && children[i].id.length > 0)
        { 
            imgon(children[i].id); 
        }
    }
    imgon("thumb"+onId);
    imgof("plus"+onId);
}

/* safemail func */
function safemail(name, domain, display, linkclass) {
	displayed=(display.length)<1 ? name+"@"+domain : display;
	document.write('<a class="'+linkclass+'" href="mailto:' + name + '@' + domain + '">' + displayed + '</a>');
}

/* very nice function from die-gestalten.de. thx */
function popup(url, w, h, f, x, y){
	if(navigator.userAgent.indexOf("Safari") != -1){
		w = w - 2;
	}
	var day = new Date();
	var id = day.getTime();
	var name = "ilovefu" + id;
	
	if(x == null){
		x = Math.round((screen.availWidth-w)/2);
	}
	if(y == null){
		y = Math.round((screen.availHeight-h)/2);
	}
	var features = "width="+w+",height="+h+",left="+x+",top="+y+",screenX="+x+",screenY="+y+",toolbar=no,location=no,status=no,menubar=no,history=no,titlebar=no,alwaysRaised";

	if(f != null){
		features += "," + f;
	}

	eval("var win"+id+" = window.open('"+url+"', '"+name+"', '"+features+"');");
	eval("win"+id+".moveTo("+x+","+y+");");
	eval("win"+id+".focus();");
}

function open_example_win(url, width, height) {
	popup(url,width,height, 'resizable=no,scrollbars=no')
}

function redirect_to (url) {
	location.href=url;
	return true;
}


function countryChange(select) {
	var code = select.options[select.selectedIndex].value;
	var howtopay = document.forms.addressForm.howtopay;
	if (code != "CH" && code != "CH-")
	{
		//alert(document.forms.addressForm.howtopay.value);
		disableOption(howtopay[1]);
		disableOption(howtopay[2]);
		disableOption(howtopay[3]);
		simulateDisabled(howtopay, 0);
	}
	else
	{
		enableOption(howtopay[1]);
		enableOption(howtopay[2]);
		enableOption(howtopay[3]);
	}
}

function disableOption(option) {
	option.disabled = true;
	option.className = "disabled";
	//option.style.display = 'none';
}
function enableOption(option) {
	option.disabled = false;
	option.className = "";
	//option.style.display = '';
}
function simulateDisable(select, defaultIndex) {
	if(select.options[select.selectedIndex].disabled ){
		select.selectedIndex = defaultIndex;
	}
}