 var ActualFont= "Arial,Helvetica,sans-serif";
 var ActualColor = '#000000';
 var ActualTextColor = '#000000';
 var ActualBodyColor = '#FFFFFF';
 var ActualBold = 'normal';
 var ActualItaly = 'normal';
 var ActualSize = 12;
 var ActualLine = 0;
 var ActualSpacing = 0;

 var FeldBodyColor1 = '#000000';
 var FeldBodyColor2 = '#000000';
 var FeldBodyColor3 = '#000000';

 var FeldTextColor1 = '#FFFFFF';
 var FeldTextColor2 = '#FFFFFF';
 var FeldTextColor3 = '#FFFFFF';

 var GrundOderColor;
 var MyStart1 = 0;
 var MyStart2 = 0;
 var MyStart3 = 0;
 var myAusgabe = '';
 var FntColorFg = false;
 var FntColorBg = false;

function setText (textfiled) {
	if(textfiled == 'Text1'){MyStart1 = 1; document.getElementById('fnt1').firstChild.nodeValue = ActualFont;}
	if(textfiled == 'Text2'){MyStart2 = 1; document.getElementById('fnt2').firstChild.nodeValue = ActualFont;}
	if(textfiled == 'Text3'){MyStart3 = 1; document.getElementById('fnt3').firstChild.nodeValue = ActualFont;}
  document.getElementById(textfiled).firstChild.nodeValue = document.getElementById("Eingabe").value;
  document.getElementById(textfiled).style.fontFamily = ActualFont;
  document.getElementById(textfiled).style.color = ActualTextColor;
  document.getElementById(textfiled).style.backgroundColor = ActualBodyColor;
  document.getElementById(textfiled).style.fontSize = ActualSize;
  document.getElementById(textfiled).style.fontWeight = ActualBold;
  document.getElementById(textfiled).style.fontStyle = ActualItaly;
  		if(ActualLine == 0){document.getElementById(textfiled).style.lineHeight = 'normal'} else {
  document.getElementById(textfiled).style.lineHeight = ActualLine +'px';}

  		if(ActualSpacing == 0){document.getElementById(textfiled).style.letterSpacing = 'normal'} else {
  document.getElementById(textfiled).style.letterSpacing = ActualSpacing +'px';}
}


function rewrite(whText) {
	ActualFont = whText;

	document.getElementById("vorschuaABC").style.fontFamily = ActualFont;
	document.getElementById("FntName").firstChild.nodeValue = ActualFont;
}


function FarbeNix(){
	if(GrundOderColor == 'color') {FntColorFg = false; ActualColor = '#000000';}
	if(GrundOderColor == 'grund') {FntColorBg = false; ActualColor = '#FFFFFF';}
	document.getElementById('ATGrund').style.backgroundColor  = '#FFFFFF';
	document.getElementById('ATColor').value ='x';

}

function FarbeOver(x){
	if(GrundOderColor == 'color') {FntColorFg = true;}
	if(GrundOderColor == 'grund') {FntColorBg = true;}
	document.getElementById('ATGrund').style.backgroundColor  = x;
	document.getElementById('ATColor').value ='#'+x;
	ActualColor = x;
 }


function add_ValueSize(myObjekt,myValue) {
		ActualSize += myValue;
	if(ActualSize < 1 ) {ActualSize = 1; }
	if(ActualSize > 99 ) {ActualSize = 99; }
	document.getElementById(myObjekt).value = ActualSize;
}

function add_ValueLine(myObjekt,myValue) {
		ActualLine += myValue;
	if(ActualLine < 0 ) {ActualLine = 0; }
	if(ActualLine > 50 ) {ActualLine = 50; }
	document.getElementById(myObjekt).value = ActualLine;
	 if(ActualLine == 0){document.getElementById(myObjekt).value = 'auto';}
}

function add_ValueSpace(myObjekt,myValue) {
		ActualSpacing += myValue;
	if(ActualSpacing < 0 ) {ActualSpacing = 0; }
	if(ActualSpacing > 20 ) {ActualSpacing = 20; }
	document.getElementById(myObjekt).value = ActualSpacing;
	 if(ActualSpacing == 0){document.getElementById(myObjekt).value = 'auto';}
}

function set2Color(was){
	if(GrundOderColor == 'color') {ActualTextColor = ActualColor;}
	if(GrundOderColor == 'grund') {ActualBodyColor = ActualColor;}
	document.getElementById('vorschuaABC').style.color = ActualTextColor;
	document.getElementById('vorschuaABC').style.backgroundColor = ActualBodyColor;
}


function addFromTextfield(textfiled){
	if(textfiled == 'Text1'){if(MyStart1 == 0){return;}}
	if(textfiled == 'Text2'){if(MyStart2 == 0){return;}}
	if(textfiled == 'Text3'){if(MyStart3 == 0){return;}}

 ActualFont = document.getElementById(textfiled).style.fontFamily;
 ActualTextColor = document.getElementById(textfiled).style.color;
 ActualBodyColor = document.getElementById(textfiled).style.backgroundColor;
 ActualSize = document.getElementById(textfiled).style.fontSize;
 ActualBold = document.getElementById(textfiled).style.fontWeight;
 ActualItaly = document.getElementById(textfiled).style.fontStyle;
 ActualLine = document.getElementById(textfiled).style.lineHeight;
 ActualSpacing = document.getElementById(textfiled).style.letterSpacing;


if(ActualSize != 'normal'){ActualSize = parseInt(ActualSize);}
if(ActualLine != 'normal'){ActualLine = parseInt(ActualLine);}
if(ActualSpacing != 'normal'){ActualSpacing = parseInt(ActualSpacing);}


	document.getElementById('vorschuaABC').style.backgroundColor  = ActualBodyColor;
	document.getElementById('vorschuaABC').style.color = ActualTextColor;
	document.getElementById('zahlSize').value = ActualSize;
	document.getElementById('zahlLine').value = ActualLine;
		if(ActualLine == 'normal'){document.getElementById('zahlLine').value = 'auto'; ActualLine = 0;}
	document.getElementById('zahlSpace').value = ActualSpacing;
		if(ActualSpacing == 'normal'){document.getElementById('zahlSpace').value = 'auto'; ActualSpacing = 0;}
	document.getElementById("vorschuaABC").style.fontFamily = ActualFont;
	document.getElementById("FntLister").ActualFont = 'selected';

		if(ActualBold == 'bold') {document.getElementsByName('check_bold')[0].checked = true;}
					else {document.getElementsByName('check_bold')[0].checked = false;}

		if(ActualItaly == 'italic') {document.getElementsByName('check_ital')[0].checked = true;}
					else {document.getElementsByName('check_ital')[0].checked = false;}
						document.getElementById("FntName").firstChild.nodeValue = ActualFont;
}

function onBoldItaly(){
	if(document.getElementsByName('check_bold')[0].checked == true) {ActualBold = 'bold';}  else { ActualBold = 'normal';}
	if(document.getElementsByName('check_ital')[0].checked == true) {ActualItaly = 'italic';} else {ActualItaly = 'normal';}
}

function SHLcolor(layer,stan,was) {
	if(was == 'color'){GrundOderColor = 'color';}
	if(was == 'grund'){GrundOderColor = 'grund';}
	if(was == 'zeige'){set2Color();}
	SHL(layer,stan);
}


function SHL(layer,stan) {
	document.getElementById(layer).style.visibility = stan;
}

function toAusgabe(textfiled){
	if(textfiled == 'Text1'){if(MyStart1 == 0){return;}}
	if(textfiled == 'Text2'){if(MyStart2 == 0){return;}}
	if(textfiled == 'Text3'){if(MyStart3 == 0){return;}}
	myAusgabe = '';
    var temp ='';


 	myAusgabe = 'font-family : '+ document.getElementById(textfiled).style.fontFamily + ';\n';;

	if(FntColorFg == true){myAusgabe += 'color : '+ document.getElementById(textfiled).style.color +';\n';}
	if(FntColorBg == true){myAusgabe += 'background-color : '+ document.getElementById(textfiled).style.backgroundColor + ';\n';}


  	temp = document.getElementById(textfiled).style.fontSize;
  	if(temp != '12px'){ myAusgabe += 'font-size : '+ temp + ';\n';}

  	temp = document.getElementById(textfiled).style.fontWeight;
  	if(temp != 'normal'){ myAusgabe += 'font-weight : '+ temp + ';\n';}

  	temp = document.getElementById(textfiled).style.fontStyle;
  	if(temp != 'normal'){ myAusgabe += 'font-style : '+ temp + ';\n';}

  	temp = document.getElementById(textfiled).style.lineHeight;
  	if(temp != 'normal'){ myAusgabe += 'line-height : '+ temp + ';\n';}

  	temp = document.getElementById(textfiled).style.letterSpacing;
  	if(temp != 'normal'){ myAusgabe += 'letter-spacing : '+ temp + ';\n';}


   document.getElementById('TextAusgabe').value = myAusgabe;
}
///////////////
function goPosition (mylayer,mx,my,min) {

  if (document.getElementById) {
    document.getElementById(mylayer).style.left  = mx + "px";
    document.getElementById(mylayer).style.top = my-min + "px";
  } else if (document.all) {
    document.all.mylayer.style.left = mx;
    document.all.mylayer.style.top = my-min;
  }

}

function getPosition(element){
  var elem=element,tagname="",x=0,y=0;

  while ((typeof(elem)=="object")&&(typeof(elem.tagName)!="undefined"))  {
    y+=elem.offsetTop;
    x+=elem.offsetLeft;
    tagname=elem.tagName.toUpperCase();


    if (tagname=="BODY")
      elem=0;

    if (typeof(elem)=="object")
      if (typeof(elem.offsetParent)=="object")
        elem=elem.offsetParent;
  }

  	position=new Object();
  	position.x=x;
  	position.y=y;
  	return position;
}

function alertPosition(elementId,mylayer,min) {
  var a,element;
  element=document.getElementById(elementId);
  a=getPosition(element);

  goPosition (mylayer,a.x,a.y,min);
}

function resetSizeLine(n){
	document.getElementById(n).value = 'auto';
	if(n == 'zahlLine'){ActualLine = 0;}
	if(n == 'zahlSpace'){ActualSpacing = 0;}
}


function init(){
SHL('Palette','hidden');

}

//// ---=== Tapete ===--- /////

var hh;
var vv;
//var hi;
//var vi;
var HgAt;
var HgRep;
var HGPos;

function TapetenRest(t){

	HgAt = document.getElementById('attachment').value;
	HgRep = document.getElementById('repeat').value;
	hh = document.getElementById('Hposition').value;
	vv = document.getElementById('Vposition').value;
	
		if(document.getElementById('Hvalue').value != 0){ 
			hh =  document.getElementById('Hvalue').value +'px';
		}
		if(document.getElementById('Vvalue').value != 0){ 
			vv =  document.getElementById('Vvalue').value +'px';
		}
	HGPos = hh + ' ' + vv;
	
	if(t==1){
	
	document.getElementById('tabelka').style.backgroundAttachment = HgAt;
	document.getElementById('tabelka').style.backgroundRepeat = HgRep;
	document.getElementById('tabelka').style.backgroundPosition = HGPos;
	}
}

function openTapete(){
	bildHG = document.getElementById('fileFeld').value;
	document.getElementById('tabelka').style.backgroundColor = document.getElementById('ColorFeld').value;

	if (document.all){

	document.getElementById('tabelka').style.backgroundImage = 'url(' + bildHG +')';
		} else {
			for(var x=0; x < bildHG.length; x ++){
				bildHG = bildHG.replace(/\\/, "/");
				bildHG = bildHG.replace(" ", "%20");
				}
			bildHG = 'file:///' + bildHG;

	document.getElementById('tabelka').style.backgroundImage = 'url('+ bildHG +')';
	}
  TapetenRest(1);
}

function openTapeteWin(){

	bildHG = document.getElementById('fileFeld').value;
	ColorHG = document.getElementById('ColorFeld').value;


if (document.all){
 var x;
	} else {
			for(var x=0; x < bildHG.length; x ++){
				bildHG = bildHG.replace(/\\/, "/");
				bildHG = bildHG.replace(" ", "%20");
				}
			bildHG = 'file:///' + bildHG;

	}

  TapetenRest(0);
  
  
  
var burl = "about:blank";
czessi=window.open(burl,'tibfenster','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes');
czessi.focus();

czessi.document.open();
czessi.document.clear();
czessi.document.write("<html><head><title>Tapete</title>\n"

+"<style type=\"text/css\">\n"
+"<!--\n"
+"body {\n"
+"	background-color:" + ColorHG + ";\n"
+"	margin-left: 0px;\n"
+"	margin-top: 0px;\n"
+"	margin-right: 0px;\n"
+"	margin-bottom: 0px;\n"
+"	background-image: url(" + bildHG + ");\n"
+"	background-attachment:" + HgAt + ";\n"
+"	background-repeat:" + HgRep + ";\n"
+"	background-position:" + HGPos + ";\n"
+"}\n"
+"-->\n"
+"</style>\n"
+"</head>\n"
+"<body>\n"
+"</body>\n"
+"</html>"
);
	czessi.document.close();
	czessi.focus();

}
