function fenster(url,breite,hoehe,options)
{
	posleft=screen.width/2-breite/2;
	postop=screen.height/2-hoehe/2-10;
	window.open(url,'_blank','width='+breite+',height='+hoehe+',left='+posleft+',top='+postop+','+options);
}

function code(field,tag)
{
	if (document.all) sel=document.selection.createRange();
    else              document.getSelection();
  	oldText=sel.text;
	if (sel.text.length>0)
  	{
		if (oldText.charAt(oldText.length-1)==" ") oldText=oldText.substr(0,oldText.length-1);
		if (tag=="a")
		{
			if (oldText.substr(0,7)=="http://") newText="<a href=\""+oldText+"\" target=\"_blank\" class=\"blau\">"+oldText+"</a>";
			else								newText="<a href=\"http://"+oldText+"\" target=\"_blank\" class=\"blau\">"+oldText+"</a>";
		}
		else if (tag=="red")
		{
			newText="<font style='color:red'>"+oldText+"</font>";
		}
		else if (tag=="blue")
		{
			newText="<font style='color:blue'>"+oldText+"</font>";
		}
		else if (tag=="center")
		{
			newText="<center>"+oldText+"</center>";
		}
		else
		{
			newText="<"+tag+">"+oldText+"</"+tag+">";
		}
		if (sel.text.charAt(sel.text.length-1)==" ") sel.text=newText+" ";
  		else                                         sel.text=newText;
  	}
}
	   
function updateState(countryList,stateList,selectedEntry)
{
	germany=new Array("Baden-Württemberg","Bayern","Berlin","Brandenburg","Bremen","Hessen","Hamburg","Mecklenburg-Vorpommern","Niedersachsen","Nordrhein-Westfalen","Rheinland-Pfalz","Saarland","Sachsen","Sachsen-Anhalt","Schleswig-Holstein","Thüringen");
	austria=new Array("Burgenland","Kärnten","Niederösterreich","Oberösterreich","Salzburg","Steiermark","Tirol","Vorarlberg","Wien");
	switzerland=new Array("Aargau","Appenzell-Ausserhoden","Appenzell-Innerhoden","Basel-Stadt","Basel-Landschaft","Bern","Freiburg","Genf","Glarus","Jura","Luzern","Neuenburg","Niderwalden","Oberwalden","Schwyz","Schaffhausen","Solothurn","St. Gallen","Tessin","Thurgau","Uri","Waadt","Wallis","Zug","Zürich");
	switch (countryList.selectedIndex)
	{
		case 1: stateList.options.length=austria.length;
				for (i=0;i<austria.length;i++)
				{
					stateList.options[i].text=austria[i];
					if (selectedEntry==austria[i]) stateList.options[i].selected=true;
				}
				break;
		case 2: stateList.options.length=switzerland.length;
				for (i=0;i<switzerland.length;i++)
				{
					stateList.options[i].text=switzerland[i];
					if (selectedEntry==switzerland[i]) stateList.options[i].selected=true;
				}
				break;
		default:stateList.options.length=germany.length;
				for (i=0;i<germany.length;i++)
				{
					stateList.options[i].text=germany[i];
					if (selectedEntry==germany[i]) stateList.options[i].selected=true;
				}
				break;
	}
}

function changeItem()
{
	if (document.data.title.value=="") 
		{alert("Geben Sie bitte eine Bezeichnung an!");document.data.title.focus();return false};
	id=document.data.id.value;		
	opener.document.data.elements["item_item_id"+id].value=document.data.item_id.value;
	opener.document.data.elements["item_title"+id].value=document.data.title.value;
	opener.document.data.elements["item_price"+id].value=isNaN(Number(document.data.price.value.replace(",","."))) ? "0.00" : Number(document.data.price.value.replace(",","."));
	opener.document.data.elements["item_quantity"+id].value=isNaN(Number(document.data.quantity.value)) ? "0" : Number(document.data.quantity.value);
	opener.document.data.elements["item_delivery_time"+id].value=document.data.delivery_time.value;
	opener.document.data.elements["item_lowtax"+id].value=document.data.lowtax.value;
	opener.document.data.elements["item_type"+id].value=document.data.type.value;
	opener.document.data.action.value="UPDATE";
	opener.document.data.submit();
	window.close();
}

function loadItem()
{
	a=document.data.temp.options[document.data.temp.selectedIndex].value.split("|");
	document.data.item_id.value=a[0];
	document.data.title.value=a[1];
	document.data.price.value=a[2];
	document.data.delivery_time.value=a[3];
	document.data.lowtax.value=a[4];
}

function checkContact()
{
	if (document.mail.field_vorname.value=="") 
		{alert("Bitte geben Sie ihren Vornamen an!");document.mail.field_vorname.focus();return false}
	if (document.mail.field_name.value=="") 
		{alert("Bitte geben Sie ihren Namen an!");document.mail.field_name.focus();return false}
	if (document.mail.field_tel.value=="") 
		{alert("Bitte geben Sie ihre Telefonnummer an!");document.mail.field_tel.focus();return false}
	if (document.mail.field_email.value=="") 
		{alert("Bitte geben Sie ihre E-Mail-Adresse an!");document.mail.field_email.focus();return false}
	if (document.mail.field_betreff.value=="") 
		{alert("Bitte geben Sie einen Betreff an!");document.mail.field_betreff.focus();return false}
	if (document.mail.field_text.value=="") 
		{alert("Bitte formulieren Sie eine Anfrage!");document.mail.field_text.focus();return false}
	return true;
}

function bookmarkPage() {
	if (window.sidebar) {
		window.sidebar.addPanel('Poolshop online - der Poolshop',"http://www.poolshop-online.de","");
	} else if (window.external) {
		window.external.addFavorite("http://www.poolshop-online.de", 'Poolshop online - der Poolshop');
	} 
	void(0);
}

function checkCountry() {
	if (document.reg.country_temp.selectedIndex==0) {
		document.reg.country.style.display="none";
		document.reg.country.value="Deutschland";
	} else {
		document.reg.country.style.display="";
		if (document.reg.country.value=="Deutschland")
			document.reg.country.value="";
	}
}
function checkDeliveryCountry() {
	if (document.reg.delivery_country_temp.selectedIndex==0) {
		document.reg.delivery_country.style.display="none";
		document.reg.delivery_country.value="";
	} else if (document.reg.delivery_country_temp.selectedIndex==1) {
		document.reg.delivery_country.style.display="none";
		document.reg.delivery_country.value="Deutschland";
	} else {
		document.reg.delivery_country.style.display="";
		if (document.reg.delivery_country.value=="Deutschland")
			document.reg.delivery_country.value="";
	}
}
