WinAppearance="toolbar=no,location=no,directories=no,scrollbars=no,status=yes,resizable=yes,copyhistory=no";

function zoom(url,name,breite,hoehe) 
{
  var neu = window.open(url,name,WinAppearance+',top=100,width='+breite+',height='+hoehe);
  if (!neu.opener) neu.opener = window;
  neu.focus();
}

function closeWindow() 
{
	self.close();
}

function openTarget (form, features, windowName) {
	var win = open ('', windowName, features);
	win.focus();
	var ref = document.getElementById("storeFinder");
	ref.submit();		
}

function openMap24() {
	var ref = document.getElementById("storeFinder");
	var zip_val = ref.ZIP0.value;
	var city_val = ref.CITY0.value;
	var street_ref = ref.STREET0;
	if (zip_val) {
		street_ref.value = zip_val;
		if (city_val) {
			street_ref.value = street_ref.value + " " + city_val;
		}
	} else {
		if (city_val) {
			street_ref.value = city_val;
		}	
	}
	if (street_ref.value) {
		street_ref.value = street_ref.value + " Deutschland";
	} else {
		street_ref.value = street_ref.value + "Deutschland";	
	}
	openTarget(ref,'width=800,height=600,resizable=1,scrollbars=1','map24');
}

function openGoogleMaps() {
	var ref = document.getElementById("storeFinder");
	var zip_val = ref.ZIP0.value;
	var city_val = ref.CITY0.value;
	var q_ref = ref.q;	
	q_ref.value = "SMS+Shop";
	if (zip_val) {
		q_ref.value = q_ref.value + "+" + zip_val;
		if (city_val) {
			q_ref.value = q_ref.value + "+" + city_val;
		}
	} else {
		if (city_val) {
			q_ref.value = q_ref.value + "+" + city_val;
		}
	}
	openTarget(ref,'width=800,height=600,resizable=1,scrollbars=1','googleMaps');
}

function preloadImages() {
  var d=document; if(d.images){ if(!d.p) d.p=new Array();
    var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
}

toggle=false;

function swapImage(name, image1, image2) {
	if (document.images) {
		document.images[name].src=(toggle)?image1:image2;
		document.images["icon"].src=(toggle)?"/img/icon_detail.gif":"/img/icon_overview.gif";
		toggle=!toggle; 
	}
}

function backToTop() {
    var x1 = x2 = x3 = 0;
    var y1 = y2 = y3 = 0;

    if (document.documentElement) {
        x1 = document.documentElement.scrollLeft || 0;
        y1 = document.documentElement.scrollTop || 0;
    }

    if (document.body) {
        x2 = document.body.scrollLeft || 0;
        y2 = document.body.scrollTop || 0;
    }

    x3 = window.scrollX || 0;
    y3 = window.scrollY || 0;

    var x = Math.max(x1, Math.max(x2, x3));
    var y = Math.max(y1, Math.max(y2, y3));

    window.scrollTo(Math.floor(x / 2), Math.floor(y / 2));

    if (x > 0 || y > 0) {
        window.setTimeout("backToTop()", 25);
    }
}
