function SubmitForm(Formname, Formaction, Action) {

	if (Formaction) {
		document.forms[Formname].formaction.value = Formaction;
	}
	
	if (Action) {
		document.forms[Formname].action = Action;
	}
	
	document.forms[Formname].submit();

}

function DisableLaenderauswahl() {

    // die Auswahlliste deaktivieren
	if (document.forms["form_land"].elements["laender[]"].disabled) {
	    document.forms["form_land"].elements["laender[]"].disabled = false;
	} else {
        document.forms["form_land"].elements["laender[]"].disabled = true;
    }

}

function DisableKundengruppenVersandarten() {

    // die Auswahlliste deaktivieren
	if (document.forms["edit_form"].elements["versandarten[]"].disabled) {
	    document.forms["edit_form"].elements["versandarten[]"].disabled = false;
	} else {
        document.forms["edit_form"].elements["versandarten[]"].disabled = true;
    }

}

function SetReadOnly(FormName, InputName, Readonly) {
	document.forms[FormName].elements[InputName].readOnly = Readonly;
	
}

function SetRadioButton(FormName, RadioButtonName, RadioButtonValue) {
	if (document.forms[FormName].elements[RadioButtonName][0].checked) {
		document.forms[FormName].elements[RadioButtonName][RadioButtonValue].checked = true;
		SetReadOnly(FormName, 'artikel_nr', 'true');
	}
	
}

function ReloadDetailPage(FormName, FormAction, FormNextSite) {

	if (document.forms[FormName].elements["schemamenue"]) {
		document.forms[FormName].elements["variante1"].value = document.forms[FormName].elements["schemamenue"].value;
	}
	
	if (document.forms[FormName].elements["schemamenue1"]) {
		document.forms[FormName].elements["variante2"].value = document.forms[FormName].elements["schemamenue1"].value;
	}

	if (document.forms[FormName].elements["schemamenue2"]) {
		document.forms[FormName].elements["variante3"].value = document.forms[FormName].elements["schemamenue2"].value;
	}

	if (document.forms[FormName].elements["schemamenue3"]) {
		document.forms[FormName].elements["variante4"].value = document.forms[FormName].elements["schemamenue3"].value;
	}
	
	document.forms[FormName].elements["formaction"].value = FormAction;
	document.forms[FormName].action = FormNextSite;
	document.forms[FormName].submit();
	
}

function GoToDetailPage(FormName, FormAction, FormNextSite) {

	if (document.forms[FormName].elements["schemamenue"]) {
		document.forms[FormName].elements["variante1"].value = document.forms[FormName].elements["schemamenue"].value;
	}

	if (document.forms[FormName].elements["schemamenue1"]) {
		document.forms[FormName].elements["variante2"].value = document.forms[FormName].elements["schemamenue1"].value;
	}

	if (document.forms[FormName].elements["schemamenue2"]) {
		document.forms[FormName].elements["variante3"].value = document.forms[FormName].elements["schemamenue2"].value;
	}

	if (document.forms[FormName].elements["schemamenue3"]) {
		document.forms[FormName].elements["variante4"].value = document.forms[FormName].elements["schemamenue3"].value;
	}

	document.forms[FormName].elements["formaction"].value = FormAction;
	document.forms[FormName].action = FormNextSite;
	document.forms[FormName].submit();

}

function SaveFormAndOpenPreisPopup(FormName, FormAction, RadiobuttonName, RadiobuttonValue1, RadiobuttonValue2, PopupFile1, PopupFile2, PopupWidth, PopupHeight) {

	if (document.forms[FormName].elements[RadiobuttonName][RadiobuttonValue1].checked) {
		SaveFormAndOpenPopup(FormName, FormAction, PopupFile1, PopupWidth, PopupHeight)
	}

	if (document.forms[FormName].elements[RadiobuttonName][RadiobuttonValue2].checked) {
		SaveFormAndOpenPopup(FormName, FormAction, PopupFile2, PopupWidth, PopupHeight)
	}

}

function SaveFormAndOpenPopup(FormName, FormAction, PopupFile, PopupWidth, PopupHeight) {
	document.forms[FormName].action = FormAction;
	document.forms[FormName].elements["popupfile"].value = PopupFile;
	document.forms[FormName].elements["popupwidth"].value = PopupWidth;
	document.forms[FormName].elements["popupheight"].value = PopupHeight;
	document.forms[FormName].submit()

}

function openFenster(datei,breite,hoehe)
{
	fenster = open(datei,"send","width="+breite+",height="+hoehe+",locationbar=no,menubar=no,scrollbars=yes");
	fenster.focus();
}

function openFenster2(datei,breite,hoehe)
{
	fenster = open(datei,"big","width="+breite+",height="+hoehe+",locationbar=no,menubar=no,scrollbars=yes");
	fenster.focus();
}

function fenster_auf(file)
{ 
	fs=window.open(file,"Fenstername","location=no,height=300px,width=250px");
	fs.moveTo(230,100); <!--  Positionierung des Fensters -->
	fs.focus();
}

/* Fuer den Backgroundchange in der Navi */
function chgBg(obj,color)
{
	if (document.all || document.getElementById)
		obj.style.backgroundColor=color;
	else if (document.layers)
 		obj.bgColor=color;
}

/* ============================================== DROP DOWN WEITERLEITUNG ====================================== */
function linkOn(x)
{
	var ziel;
	ziel = document.form_artikel.Gruppenschalter.options[document.form_artikel.Gruppenschalter.options.selectedIndex].value;
	window.location.href = ziel;

}
function checkform(aID,Formname)
{
	if(document.getElementById('aID_'+aID))
	{
		if(document.getElementById('aID_'+aID).value[0] != 0)
		{
			document.forms[Formname].submit();
		}
		else
		{
			alert(unescape('Bitte w%E4hlen Sie eine Austattung aus!'));
		}
	}
	else
	{
		document.forms[Formname].submit();
	}
}
function GoToDetailWithColor(kID,aID)
{
	fName = "aID_"+aID;
	fID = document.getElementById(fName).value;
	Ziel = "detail.php?kategorieid="+kID+"&artikelid="+aID+"&farbe="+fID+"&source=2";
	window.location.href = Ziel;
}
function GoToGruppenmitglied(ArtikelID)
{
	if(window.document.getElementById('Gruppenmitglieder_'+ArtikelID).value != "- Weitere Gr&ouml;&szlig;en und Sonderaustattungen -")
	{
		window.location.href = window.document.getElementById('Gruppenmitglieder_'+ArtikelID).value;
	}
	else
	{
		alert(unescape('Bitte w%E4hlen Sie eine Sonderaustattung aus!'));
	}
}
function ZeigeArtikel(z)
{
	if(document.getElementById)
	{
		scroll(0,0);
		$("#"+z+"").fadeIn(700);
	}
}
function SchliesseArtikel(z)
{
	if(document.getElementById)
	{
		$("#"+z+"").fadeOut(600);
	}
}
function GetScrollPos()
{
	var scrollPos;
	var scrollPosText;
	if (typeof window.pageYOffset != 'undefined')
	{
		scrollPos = window.pageYOffset;
	}
	else if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat')
	{
		scrollPos = document.documentElement.scrollTop;
	}
	else if (typeof document.body != 'undefined')
	{
		scrollPos = document.body.scrollTop;
	}
	scrollPosText = scrollPos+90+"px";
	$('#BildInGross').show("slow");
	$('#BildInGross').css({top:scrollPosText});
}
/****************************************************************************
*												Editor fuer Formulardaten														*
****************************************************************************/
function Fett()
{
  Markierung = document.selection.createRange().text
          
  if(Markierung=="")
  {
  document.getElementById('formular').beschreibung.value = document.getElementById('formular').beschreibung.value + '<b>text</b>'
  }
  else
  {
	 Markierung = '<b>'+Markierung+'</b>'
	document.selection.createRange().text = Markierung
  }      
}

function Kursiv()
{
  Markierung = document.selection.createRange().text
          
  if(Markierung=="")
  {
  document.getElementById('formular').beschreibung.value = document.getElementById('formular').beschreibung.value + '<i>text</i>'
  }
  else
  {
	 Markierung = '<i>'+Markierung+'</i>'
	document.selection.createRange().text = Markierung
  }       
}

function Unterstreichen()
{
  Markierung = document.selection.createRange().text
          
  if(Markierung=="")
  {
  document.getElementById('formular').beschreibung.value = document.getElementById('formular').beschreibung.value + '<u>text</u>'
  }
  else
  {
	 Markierung = '<u>'+Markierung+'</u>'
	document.selection.createRange().text = Markierung
  }      
}

function Pfad()
{
  Markierung = document.selection.createRange().text
          
  if(Markierung=="")
  {
  document.getElementById('formular').beschreibung.value = document.getElementById('formular').beschreibung.value + "<a href='HTTP://URL\' target='blank'>text</a>"
  }
  else
  {
	Markierung = "<a href='HTTP://URL' target='blank'>"+Markierung+"</a>"
	document.selection.createRange().text = Markierung
  }  
}
/*** DIV statt Popup fuer die grossen Schuhbilder   **/
function anzeigen(x)
{
	var MSNR = "m"+x;
	if(document.getElementById)
		document.getElementById(MSNR).style.display = "block";
}
function zumachen(y)
{
	var MSNR = "m"+y;
	if(document.getElementById)
		document.getElementById(MSNR).style.display = "none";
}
