function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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

function MM_findObj(n, d) { //v4.01
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
   	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function imageLoaded(obj, b_color, b_width, b_style){
  var doc = obj;
  var b_color = b_color;
  var b_width = b_width;
  var b_style = b_style;
  
  doc.style.borderWidth=b_width;	 
  doc.style.borderColor=b_color;
  doc.style.borderStyle=b_style;
 }//-----------------------------------//
 
 function SendForm(Formname, Formaction, FieldName, FieldValue) {
			
			document.forms[Formname].formaction.value = Formaction;
			
			if (FieldName) {
				document.forms[Formname].elements[FieldName].value = FieldValue;
			}
			
			document.forms[Formname].submit();
	
		}

		
function checkKey(form, e){
	
	if(!e)	e = window.event.keyCode;
  	
	if(e == 13) {
		
		form.submit();	
	}
}

function showColor(val,obj) {
	 
	var TempObj = document.forms["form_designdaten"][obj].value;
	 
	if(!TempObj) alert('kein Objekt für den Farbauswahl gefunden!\nKlcken Sie auf das Feld, in den Sie Farbwert einfügen möchten');
	
	
	document.forms["form_designdaten"][TempObj].value = val;
	document.forms["form_designdaten"][TempObj].style.color = val;
	
 }//-----------------------------------//

/*
function showColor(val) {
	 alert(val);
	 
	 var TempObj = document.forms["form_designdaten"].hexvalTemp.value;
	 
	document.forms["form_designdaten"][TempObj].value = val;
	document.forms["form_designdaten"][TempObj].style.color = val;
	
 }//-----------------------------------//
*/

function showProfileFoto(imgId, url) {
	var image = document.getElementById(imgId);
	if(image) {
		image.src = url;
	}
}//-----------------------------------//


function showImage(id) {
		
	var element = document.getElementById(id);
	
	if(element) {
		
				
		if(element.Tempid != id) {
			hideImage(element.Tempid);
			element.Tempid = id;
		}
		//alert(id);
		element.style.display = "block";
	}
}//-----------------------------------//

function hideImage(id) {
	//alert("hide " + id);
	var element = document.getElementById(id);
	
	if(element) {
		element.style.display = "none";
	}
}//-----------------------------------//

		
function SetDisplay(id, obj) { 

	var display = document.getElementById(id);
	
	if(obj.tempid==id && display.style.display=="block"){
		display.style.display="none";
		obj.style.fontWeight = '';	
	}else{
		
		display.style.display="block";
		obj.style.fontWeight = 'bold';
		
	}
	
	obj.tempid = id;
	
	
}

 
function farbe(obj) { 
	
	if(obj.tempobj){
		obj.tempobj.style.fontWeight = 'normal';
	}
	
	obj.tempobj = obj;
	obj.style.fontWeight = 'bold';
	
} 


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");
	fenster.focus();
	changeColor();
}

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 chgBg1(obj){
	
	if (document.all || document.getElementById)
		obj.style.backgroundColor = obj.TempColor;
	else if (document.layers)
 		obj.bgColor=obj.TempColor;
		
}


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


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


function chgTxtColor(obj,color){
	if (document.all || document.getElementById){
		obj.Txtcolor = obj.style.color;
		obj.style.color=color;
	}else if (document.layers){
		obj.Txtcolor = obj.color;
		obj.color=color;
	}
}

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


/****************************************************************************
*												Editor fuer Formulardaten														*
****************************************************************************/

function LineBreak(Formname,TxtEintrag){
	
  Markierung = document.selection.createRange().text
  TextArea   =  document.getElementById(Formname);
  
 TextArea[TxtEintrag].value =  TextArea[TxtEintrag].value + '<BR>'
}


function Fett(Formname,TxtEintrag){
	
  Markierung = document.selection.createRange().text
  TextArea   =  document.getElementById(Formname);
  
  if(Markierung==""){
   	TextArea[TxtEintrag].value =  TextArea[TxtEintrag].value + '<b>text</b>'
  } else {
	Markierung = '<b>'+Markierung+'</b>'
	document.selection.createRange().text = Markierung
  }      
}

function Kursiv(Formname,TxtEintrag){
	
  Markierung = document.selection.createRange().text
  TextArea   =  document.getElementById(Formname);
          
  if(Markierung=="")  {
 	 TextArea[TxtEintrag].value =  TextArea[TxtEintrag].value + '<i>text</i>'
  }  else  {
	 Markierung = '<i>'+Markierung+'</i>'
	document.selection.createRange().text = Markierung
  }       
}


function Unterstreichen(Formname,TxtEintrag)
{
  Markierung = document.selection.createRange().text
  TextArea   =  document.getElementById(Formname);
          
  if(Markierung=="")
  {
  TextArea[TxtEintrag].value =  TextArea[TxtEintrag].value + '<u>text</u>'
  }
  else
  {
	 Markierung = '<u>'+Markierung+'</u>'
	document.selection.createRange().text = Markierung
  }      
}

function Aufzaehlung(Formname,TxtEintrag){
	
  Markierung = document.selection.createRange().text
  TextArea   =  document.getElementById(Formname);
          
  if(Markierung==""){
  	TextArea[TxtEintrag].value =  TextArea[TxtEintrag].value + '<ul type="disc"><li>text</li></ul>'
  } else {
	 Markierung = '<ul type="disc"><li>'+Markierung+'</li></ul>'
	document.selection.createRange().text = Markierung
  }      
}

function Headline(Formname,TxtEintrag, Head){
	
  Markierung = document.selection.createRange().text
  TextArea   =  document.getElementById(Formname);
          
  if(Markierung==""){
  	TextArea[TxtEintrag].value =  TextArea[TxtEintrag].value + '<'+ Head + '>text</' + Head + '>'
  } else {
	 Markierung = '<'+ Head + '>'+Markierung+'</' + Head + '>'
	document.selection.createRange().text = Markierung
  }      
}


function Pfad(Formname,TxtEintrag , Url){
  Markierung = document.selection.createRange().text
  TextArea   =  document.getElementById(Formname);
          
  if(Markierung=="") {
	TextArea[TxtEintrag].value =  TextArea[TxtEintrag].value + '<a href="' + Url + '(URL)" target="blank">TEXT</a>'
  } else  {
	Markierung = '<a href="' + Url + '(URL)" target="blank">' + Markierung + '</a>'
	document.selection.createRange().text = Markierung
  }  
}

function GetColor(Val,Formname,TxtEintrag){
	
  Markierung = document.selection.createRange().text
  TextArea   =  document.getElementById(Formname);
          
  if(Markierung==""){
	alert('Makieren Sie den Text, den Sie ändern wollen.!!')  
  	TextArea[TxtEintrag].value =  TextArea[TxtEintrag].value + '<font color="' + Val + '">text</font>';
  } else {
	Markierung = '<font color="' + Val + '">' + Markierung + '</font>';
	document.selection.createRange().text = Markierung
  }      
}

function SetAniGif(Formname,TxtEintrag, Label){
	
  Markierung = document.selection.createRange().text
  TextArea   =  document.getElementById(Formname);
          
  //TextArea[TxtEintrag].value =  TextArea[TxtEintrag].value + '<img src=' + Url + '>';
  TextArea[TxtEintrag].value =  TextArea[TxtEintrag].value + '{:' + Label + ':}';
    
}

function CreateImageInText(Formname,TxtEintrag, Urlimage){
 
 	Markierung = document.selection.createRange().text
  	TextArea   =  document.getElementById(Formname);
          
  	TextArea[TxtEintrag].value =  TextArea[TxtEintrag].value + Urlimage;
	
	
    
}

function SetImage11(Formname,TxtEintrag, Url){
  Markierung = document.selection.createRange().text
  TextArea   =  document.getElementById(Formname);
          
  TextArea[TxtEintrag].value =  TextArea[TxtEintrag].value + '<img src=' + Url + '(Image) >';
    
}


function SwapImage(AreaObj,imgId,BewertungNr){
	
	
	var Image=document.getElementById(imgId);
	if(Image.disabled) 	return;
	
	Image.src=AreaObj.attributes["i"].value;
}
// ------------------------------------------------------- //

function ImgRestore(imgId){
	var Image=document.getElementById(imgId);
	if(Image.disabled) return;
	
	var originalImg=Image.attributes["originalImg"].value;
	
	Image.src=originalImg;
}
// ------------------------------------------------------- //

function SetImage(urlPfad, imgPfad, imgId, response, value, BewertungNr, AreaObj){
	
	var map=document.getElementsByName(imgId+"Map")[0];
	
	if(map){
		
		var rtxt=(map.attributes["rtxt"]?map.attributes["rtxt"].value.replace(/%value%/gi,AreaObj.attributes["v"].value):null);
		
		var Image=document.getElementById(imgId);
		
		if(Image.disabled) return;
		
		if(Image){
			Image.attributes["originalImg"].value=imgPfad;
			Image.src=imgPfad;
			
			document.getElementById(response).value = BewertungNr;
			
			
		
		}
		
		//openFenster(urlPfad + '/themes/kategorie/bewertung.php?artId=' + ArtikelID + '&bewertung=' + BewertungNr,680,600); return true;
	
	}
	
	//Disable(imgId,rtxt,null);
	
	return false;
		
}

// ------------------------------------------------------- //
function Disable(imgId,rtxt,dval){
	
	var Image=document.getElementById(imgId);
	if(Image){
		
		Image.disabled=true;
		Image.style.cursor="default";
		var map=document.getElementsByName(imgId+"Map")[0];
		if(map){
			for(i=0;i<map.childNodes.length;i++){
				var area=map.childNodes[i];
				if(area.nodeName=="AREA"){
					if(rtxt!=null) area.setAttribute("alt",rtxt.replace(/%value%/gi,dval));
					area.removeAttribute("href");
				}
			}
		}
		
	}
}

// ------------------------------------------------------- //
function ShowTable(SelecObj, TableID){
	
	var Table=document.getElementById(TableID);
	var SelecObj=document.getElementById(SelecObj);
	
	if(Table){
		if(SelecObj.value == 'Ohne'){
			Table.style.visibility = 'hidden';
		}else{
			Table.style.visibility = 'visible';
		}
	}
}

function ZweiFrames(URI1,F1,URI2,F2) {
  Frame1=eval("parent."+F1);
  Frame2=eval("parent."+F2);
  Frame1.location.href = URI1;
  Frame2.location.href = URI2;
}
function ZweiFramesBack(F1,F2) {
  Frame1=eval("parent."+F1);
  Frame2=eval("parent."+F2);
  Frame1.history.back();
  if (!window.opera) window.setTimeout("Frame2.history.back()",10);
}
function ZweiFramesForward(F1,F2) {
  Frame1=eval("parent."+F1);
  Frame2=eval("parent."+F2);
  Frame1.history.forward();
  if (!window.opera) window.setTimeout("Frame2.history.forward()",10);
}

function high(which2) {
  theobject=which2
  	highlighting=setInterval("highlightit(theobject)",10)
}

function low(which2){
  clearInterval(highlighting)
  if (which2.style.MozOpacity){
    which2.style.MozOpacity=0.9
  }else if (which2.filters){
    which2.filters.alpha.opacity=40
    }
  }

function highlightit(cur2){
  if (cur2.style.MozOpacity<1){
    cur2.style.MozOpacity=parseFloat(cur2.style.MozOpacity)+0.1
  }else if (cur2.filters&&cur2.filters.alpha.opacity<100){
    cur2.filters.alpha.opacity+=6
  }else if (window.highlighting){
    clearInterval(highlighting)
    }
  }
  
function PageXPos (ID, With) { 
	
	var doc = document.getElementById(ID);
	
	if(navigator.appName.indexOf('Microsoft')!=-1){
		var innerWidth  = window.document.documentElement.offsetWidth;
		var innerHeight = window.document.documentElement.offsetHeight;
	}else{
		var innerWidth  = window.innerWidth;
		var innerHeight = window.innerHeight;
	}
	
	X = (innerWidth - With ) / 2;
	
	doc.style.margin = X + 'px auto';
	
	
}

function PageYPos(ID, Height) {  
  	
	var doc = document.getElementById(ID);
	
	if(navigator.appName.indexOf('Microsoft')!=-1){
		var innerWidth  = window.document.documentElement.offsetWidth;
		var innerHeight = window.document.documentElement.offsetHeight;
	}else{
		var innerWidth  = window.innerWidth;
		var innerHeight = window.innerHeight;
	}
	
	Y = (innerHeight - Height) / 2;
	
	doc.style.margin = Y + 'px auto';
	
}  

function GetPageScaleFaktor(ID, Width, Height) { 
	
	var docfla = document.getElementById(ID);
	
	if(navigator.appName.indexOf('Microsoft')!=-1){
		var innerWidth  = window.document.documentElement.offsetWidth;
		var innerHeight = window.document.documentElement.offsetHeight;
	}else{
		var innerWidth  = window.innerWidth;
		var innerHeight = window.innerHeight;
	}

	
	if(innerWidth < Width ){
		
		//document.body.style.overflow = "scroll";
		
		XFaktor = innerWidth / Width  ;
		YFaktor = innerHeight / Height;
		
		XScaleFaktor = 1 + ( 1 - XFaktor);
		YScaleFaktor = 1 + ( 1 - YFaktor);
		
		NewPageWidth = Math.round(innerWidth * XScaleFaktor);
		NewPageHeight = Math.round(innerHeight * YScaleFaktor);

		//NewPageWidth = 1024;
		//NewPageHeight = 600	
		
		document.body.style.width = NewPageWidth + 'px';
		document.body.style.height = NewPageHeight + 'px'; 

			
		if((innerWidth - NewPageWidth) > 0) {
			X = (innerWidth - NewPageWidth ) / 2;
			X1 = (innerWidth - NewPageWidth );
		}else{
			X = (NewPageWidth - innerWidth ) / 2;	
			X1 = (NewPageWidth - innerWidth );	
		}
		
		if((innerHeight - NewPageHeight) > 0) {
			Y = (innerHeight - NewPageHeight ) / 2;
			Y1 = (innerHeight - NewPageHeight );
		}else{
			Y = (NewPageHeight - innerHeight ) / 2;
			Y1 = (NewPageHeight - innerHeight );
		}
		
		document.body.style.margin = Y + 'px ' + X + 'px';
		
		jumpScroll(X1,Y1);
		
		
		//alert('Browser -:' + innerWidth + 'px\nParameter -:' +  Width + 'px\n\nSkaliert auf -:' + NewPageWidth + 'px');
		
	}else{
		
		
		
		document.body.style.overflow = "hidden";
		document.body.style.height = '100%';
		document.body.style.widht = '100%';

		document.body.style.width = innerWidth + 'px';
		document.body.style.height = innerHeight + 'px'; 

		//alert('Browser -:' + innerWidth + 'px\nParameter -:' +  Width + 'px\n\n:::NICHT SKALIERT:::');

		
	}
  	
}

function jumpScroll(X,Y) {

	//self.scrollbars.visible = false;

	//alert(X + ", " + Y);
   	window.scrollTo(X,Y); // horizontal and vertical scroll targets
}



