function trim(text) {
 while(text.charAt(0)==" ") { text=text.substring(1,text.length); }
 while(text.charAt(text.length-1)==" ") { text=text.substring(0,text.length-1); }
 return text;
}



function Shop800psb(jumpto) {
  location.href= jumpto;
  return false;
}

function AJaXwork(command,object) {
   document.title=object;
  if ( command=='open' )
  {
    document.title=object;
    mousedownJob='open';
    mousedownURL=object;
//    AWopen( 160,560,640,480,"http://linuxwin.de/wallpaper/atari/97-pong-2-0.html?AJaXE=4");
  }
  return false;
}

function AJaXwindow(object,command) {
    div = document.getElementById(object);
//  div.innerHTML = content;
  if ( command=='null' )
  {
    document.getElementById(object).style.width =0;
    document.getElementById(object).style.height=0;
  }
  if ( command=='icon' )
  {
    document.getElementById(object        ).style.height=document.getElementById(object+'TL').style.height;
    document.getElementById(object+'Paper').style.height= 0;
  }
  if ( command=='full' )
  {
    document.getElementById(object).style.width =640;
    document.getElementById(object).style.height=480;
   AWopen( 160,560,640,480,"http://linuxwin.de/wallpaper/atari/97-pong-2-0.html?AJaXE=4");
  }
  if ( command=='load' )
  {
    document.getElementById(object).style.width =640;
    document.getElementById(object).style.height=480;
  }
  return false;
}



function AWcontentappend (object,content) {
    div = document.getElementById(object);
    div.innerHTML = div.innerHTML+content;
}
function AWcontentappendleft (object,content) {
    div = document.getElementById(object);
    div.innerHTML = content+div.innerHTML;
}

function pushContent(object,content) {
    div = document.getElementById(object);
    div.innerHTML = content;
}
function pushValue(object,content) {
    div = document.getElementById(object);
    div.value = content;
}
// find out if ie runs in quirks mode
//
var docEl = (
             typeof document.compatMode != "undefined" && 
             document.compatMode        != "BackCompat"
            )? "documentElement" : "body";
// register event
// capture it for nc 4x (ok it's a dino)
//
var mousebutton='up';
var mousedownJob='*';
var mousedownOn=0;
var mousedownx=0;
var mousedowny=0;
var mousepos_x=0;
var mousepos_y=0;
var mousemovex=0;
var mousemovey=0;
function mouseclick(mousebuttonnow) {
    mousebutton=mousebuttonnow;
    if ( mousebutton=='down' )
    {
      mousedownx=mousepos_x;
      mousedowny=mousepos_y;
      for( var i=1; i<=AWcounter; i++ )
      {
        if ( mousedownx >= AWindow[i]['x']
          && mousedownx <  AWindow[i]['x'] + AWindow[i]['w']
          && mousedowny >= AWindow[i]['y']
          && mousedowny <  AWindow[i]['y'] + AWindow[i]['h'] )
        {
          mousedownOn  = i;
          mousedownJob = 'Touche';
          if ( mousedownx >= AWindow[i]['x'] + AWindow[i]['w'] -th
            && mousedowny >= AWindow[i]['y'] + AWindow[i]['h'] -th )
          {
            mousedownJob = 'Sizer';
          }
          if ( mousedowny <  AWindow[i]['y'] + th )
          {
            mousedownJob = 'Title';
          }
        }
      }
    }
    else
    {
      AWid     ='AWid'+mousedownOn;
      document.title += ' MouseDown ';
      if ( mousedownJob )
      {
        if ( mousemovex || mousemovey )
        {
          if ( mousedownJob=='Title' )
          {
            AWindow[mousedownOn]['x']=AWindow[mousedownOn]['x2'];
            AWindow[mousedownOn]['y']=AWindow[mousedownOn]['y2'];
          }
          if ( mousedownJob=='Sizer' )
          {
            AWindow[mousedownOn]['w']=AWindow[mousedownOn]['x2'];
            AWindow[mousedownOn]['h']=AWindow[mousedownOn]['y2'];
          }
        }
        else AWup(AWid);
        mousedownJob = '';
      }
      //pushContent(AWid+'Paper','MOUSE<br>' + AWindow[mousedownOn]['x'] +':'+ AWindow[mousedownOn]['y'] +'<br>'+ AWindow[mousedownOn]['w'] +':'+ AWindow[mousedownOn]['h']);
      mousedownx=mousedowny=0; 
    }
    pushContent('MausPos','MOUSE' + mousebutton);
    mousemovex=mousemovey=0;
  }
function init_mousemove() {
    if(document.layers) document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove =	dpl_mouse_pos;
}
function dpl_mouse_pos(e) {

    // position where mousemove fired
    //
    var xPos    =  e? e.pageX : window.event.x;
	var yPos    =  e? e.pageY : window.event.y;

	
	// for ie add scroll position
	//
	if (document.all && !document.captureEvents) {
	    xPos    += document[docEl].scrollLeft;
	    yPos    += document[docEl].scrollTop;
    }
    
    // display position
    //
    mousepos_x=xPos;
    mousepos_y=yPos;
    mousemovex=xDown=xPos-mousedownx;
    mousemovey=yDown=yPos-mousedowny;
    if ( mousebutton=='up' )
    pushContent('MausPos'," " + xPos + " : " + yPos + " " + mousebutton + ' ··· '+mousedownJob);
    else
    {
      pushContent('MausPos','MOUSE down' + xDown + " : " + yDown + ' ··· '+mousedownJob);
      if ( mousedownJob=='Title' )
      {
        AWid     ='AWid'+mousedownOn;
        AWindow[mousedownOn]['x2']=AWindow[mousedownOn]['x']+xDown;
        AWindow[mousedownOn]['y2']=AWindow[mousedownOn]['y']+yDown;
        document.getElementById(AWid).style.left=AWindow[mousedownOn]['x2'];
        document.getElementById(AWid).style.top =AWindow[mousedownOn]['y2'];
      }
      if ( mousedownJob=='Sizer' )
      {
        AWid     ='AWid'+mousedownOn;
        AWindow[mousedownOn]['x2']=AWindow[mousedownOn]['w']+xDown;
        AWindow[mousedownOn]['y2']=AWindow[mousedownOn]['h']+yDown;
        //document.getElementById(AWid).style.width =AWindow[mousedownOn]['x2'];
        //document.getElementById(AWid).style.height=AWindow[mousedownOn]['y2'];
        AWsize(AWid,AWindow[mousedownOn]['x'],AWindow[mousedownOn]['y'],AWindow[mousedownOn]['x2'],AWindow[mousedownOn]['y2']);
      }
    }
    //document.feld.ausg.value    =  "Left = " + xPos + " : Top = " + yPos;
    // for the dino pass event
    //
    if (document.layers) routeEvent(e);
}

















































function AJaXdoIt(object,url){ AJaXEcho=object;
  
//pushContent('readMeta','content pushing');
//pushValue('readDes','Beschreibung');

      //erstellen des requests
      var req = null;

    try{
        req = new XMLHttpRequest();
    }
    catch (ms){
        try{
            req = new ActiveXObject("Msxml2.XMLHTTP");
        } 
        catch (nonms){
            try{
                req = new ActiveXObject("Microsoft.XMLHTTP");
            } 
            catch (failed){
                req = null;
            }
        }  
    }

    if (req == null)
          alert("Error creating request object!");
      
pushContent('readMeta','öffnen: '+ decodeURI(url) );
      //anfrage erstellen (GET, url ist localhost,
      //request ist asynchron      
      //req.open("GET", 'http://linuxwin.de/wallpaper/linux/', true);
      //req.open("GET", url, true);
pushContent('readMeta','öffnen: geöffnet');

    //Beim abschliessen des request wird diese Funktion ausgeführt
    req.onreadystatechange = function(){            
        switch(req.readyState) {
                case 4:
                if(req.status!=200) {
                    alert("Fehler:"+req.status); 
                }else{    
                    //alert(req.responseText);
                    //schreibe die antwort in den div container mit der id content 

                    pushContent(AJaXEcho,req.responseText);
                    //document.getElementById('eins').innerHTML = '<strong>'+req.responseText+'</strong>';
                    //AJaXEcho=req.responseText;
                }
                break;
        
                default:
                    return false;
                break;     
            }
        };

      req.setRequestHeader("Content-Type",
                          "application/x-www-form-urlencoded");
    req.send(null);
    return false;
}














function AWgoto(AWurl)
{
  location.href=AWurl;
}



var AWcounter=0;
var AWindow = new Array();
var lb= 4; // left   Border
var rb= 4; // right  Border
var bb= 4; // bottom Border
var bw=32; // Button width
var th=32;
var dh=bb;

function AWopen(x,y,w,h,AWtitle) {
  if ( !AWcounter )
  {
    winCode ='';
    winCode += '<div id="AW0"> ';
    winCode += '<div id="AW0Paper"> AWdesktop 0.9 .... ';
    winCode += '</div>';
    winCode += '</div>';
    document.write(winCode);
  }
  AWcounter=AWcounter+1;
  AWid     ='AWid'+AWcounter;
  
  AWindow[AWcounter] = new Object();
  AWindow[AWcounter]['x']=x;
  AWindow[AWcounter]['y']=y;
  AWindow[AWcounter]['w']=w;
  AWindow[AWcounter]['h']=h;
  
  winContent=AWcounter+' Praesent nisi sem, bibendum in, ultrices sit amet, euismod sit amet, dui. Donec varius tincidunt nisi. Ut ut sapien. Integer porta. Fusce nibh. Curabitur pellentesque, lectus at volutpat interdum, sem justo placerat elit, eget feugiat est leo tempor quam. Ut quis neque convallis magna consequat molestie. Nullam semper massa eget ligula. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Pellentesque a nibh quis nunc volutpat aliquam';
  ph=h-th-dh;
  pw=w-lb-rb;
  winCode ='';
  winCode += '<div id="' + AWid + '" ';
  winCode += 'style="border: solid 1px; border-color:black; color:yellow; padding:0px;margin:0px;cursor:move;">';
  
  winCode += '<div id="' + AWid + 'TL" ';
  winCode += 'style="background-color:blue;color:yellow;width:100%;height:'+th+'px;overflow:hidden;cursor:move;">';
  winCode += '<span style="float:right;">';
  var infoer = 'onclick="AJaXwindow(\''+AWid+'\',\'info\');"';
  var iconer = 'onclick="AJaXwindow(\''+AWid+'\',\'icon\');"';
  var fuller = 'onclick="AJaXwindow(\''+AWid+'\',\'full\');"';
  var nuller = 'onclick="AJaXwindow(\''+AWid+'\',\'null\');"';
  var icoINI = '<img src="';
  var icoEND = '" border="0" width="32" height="32">';
  var infICO = icoINI+'http://mit-oder-ohne-www.de/img/DuckTownBlog/ANIwin18.gif'+icoEND;
  var icoICO = icoINI+'http://mit-oder-ohne-www.de/img/DuckTownBlog/miscB55.gif'+icoEND;
  var fulICO = icoINI+'http://mit-oder-ohne-www.de/img/DuckTownBlog/miscB59.gif'+icoEND;
  var nulICO = icoINI+'http://mit-oder-ohne-www.de/img/DuckTownBlog/miscB2.gif'+icoEND;
  
  var infICO = icoINI+'http://mit-oder-ohne-www.de/img/DuckTownBlog/ANIwin18.gif'+icoEND;
  var icoICO = icoINI+'http://mit-oder-ohne-www.de/img/DuckTownBlog/ANIwin11.gif'+icoEND;
  var fulICO = icoINI+'http://mit-oder-ohne-www.de/img/DuckTownBlog/COrec40.gif'+icoEND;
  var nulICO = icoINI+'http://mit-oder-ohne-www.de/img/DuckTownBlog/ANIwin12.gif'+icoEND;
  
  winCode += '<a href="#" '+iconer+'>'+icoICO+'</a>';
  winCode += '<a href="#" '+fuller+'>'+fulICO+'</a>';
  winCode += '<a href="#" '+nuller+'>'+nulICO+'</a>';
  winCode += '</span>';
  winCode += '<span style="float:left;">';
  winCode += '<a href="#" '+infoer+'>'+infICO+'</a>';
  winCode += '</span>';
  winCode += '<div id="' + AWid + 'Title" style="text-align:middle;width:'+(w-4*bw-8)+';height:'+th+'px;overflow:hidden;">';
  winCode += ' '+AWtitle;
  winCode += '</div>';
  winCode += '</div>';
  
  winCode += '<div id="' + AWid + 'Paper" ';
  winCode += 'style="margin-left:'+lb+'px;width:'+pw+'px;height:'+ph+'px;overflow:auto;cursor:default;">';
  winCode += AWtitle+'<hr>'+winContent;
  winCode += '</div>';
  winCode += '</div>';
  //document.write(winCode);
  AWcontentappend ('AW0Paper',winCode);
  document.getElementById(AWid).style.backgroundColor='silver';
  document.getElementById(AWid).style.color='blue';
  document.getElementById(AWid).style.width=w;
  document.getElementById(AWid).style.height=h;
  document.getElementById(AWid).style.position='absolute';
  document.getElementById(AWid).style.left=x;
  document.getElementById(AWid).style.top=y;
  document.getElementById(AWid).style.zIndex=AWcounter;
  AWsize(AWid,x,y,w,h);
  //if ( AWcounter==5 ) AJaXdoIt('AWid5Paper',AWtitle);
  if ( h==480 ) AJaXdoIt(AWid+'Paper',AWtitle);
  //pushContent(AWid,'Window'+document.getElementById(AWid).style.zIndex);
  return false;
}
function AWup(AWid) 
{
  now = document.getElementById(AWid).style.zIndex;
  var i = 0;
  while ( ++i <= AWcounter )
  {
    AWid2watch ='AWid'+i;
    if ( now <= document.getElementById(AWid2watch).style.zIndex )
    document.getElementById(AWid2watch).style.zIndex--;

  } document.getElementById(AWid      ).style.zIndex=AWcounter;
  //pushContent(AWid+'Paper','onTOP'+document.getElementById(AWid).style.zIndex);
}
function AWsize(AWid,x,y,w,h) 
{
  document.getElementById(AWid).style.left  =x;
  document.getElementById(AWid).style.top   =y;
  document.getElementById(AWid).style.width =w;
  document.getElementById(AWid).style.height=h;
  
  ph=h-th-dh;
  pw=w-lb-rb;
  document.getElementById(AWid+'Paper').style.width =pw;
  document.getElementById(AWid+'Paper').style.height=ph;
  
  document.getElementById(AWid+'Title').style.width =(w-4*bw-8);
}








