function welcome(target) {
  var httpRequest;
  if (window.XMLHttpRequest) { // Mozilla, Safari, ...
      httpRequest = new XMLHttpRequest();
      if (httpRequest.overrideMimeType) {
          httpRequest.overrideMimeType('text/xml');
      }
  }
  else if (window.ActiveXObject) { // IE
      try {
          httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
          }
          catch (e) {
                     try {
                          httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
                         }
                       catch (e) {}
                    }
                                 }

  if (!httpRequest) {
      alert('Giving up :( Cannot create an XMLHTTP instance');
      return false;
  }
  var url = "start.php?la="+la;
  httpRequest.onreadystatechange = function() { get_welcome(httpRequest,target); };
  httpRequest.open('GET', url, true);
  httpRequest.send('');
}

function get_welcome(httpRequest,target) {
  if (httpRequest.readyState == 4)
  {
    if (httpRequest.status == 200)
    {
      var xml = httpRequest.responseXML;
      target.innerHTML='';
//      th.colSpan="5";

      if (ledit)
      {
        add_edit_link(5,0,-1,150);
      }
      var nopt=xml.getElementsByTagName("opt").length;
      for (iopt=0;iopt<nopt;iopt++)
      {
				bgimage=xml.getElementsByTagName("bgimage")[iopt].firstChild.data;
        opt=xml.getElementsByTagName("optnumber")[iopt].firstChild.data;
        add_title(target,xml.getElementsByTagName("title")[iopt].firstChild.data,"start",opt,0);
        var text=document.createElement("div");
        text.className='info_body';
        text.style.textAlign='center';
        if (bgimage!=0) text.style.backgroundImage='url('+bgimage+')';
        text.style.backgroundRepeat='no-repeat';
//        var htmltext=xml.getElementsByTagName("opt")[iopt];
//        .getElementsByTagName("text")[0].firstChild.data;
//        alert(htmltext);
        text.id="start_text_"+opt;
        text.innerHTML=xml.getElementsByTagName("text")[iopt].firstChild.data;
        target.appendChild(text);
        if (ledit)
        {
          var elem=document.getElementById("start_text_"+opt);
          var yoff=target.offsetTop+elem.offsetTop;
          if (iopt>0) {add_edit_link(3,0,opt,yoff);yoff=yoff+20;}
          add_edit_link(1,0,opt,yoff);yoff=yoff+20;
          add_edit_link(2,0,opt,yoff);yoff=yoff+20;
          if (iopt<(nopt-1)) add_edit_link(4,0,opt,yoff);
        }
      }
    } else
    {
      alert('There was a problem with the request.');
    }
  }
}


function timetable(target) {
  var httpRequest;
  if (window.XMLHttpRequest) { // Mozilla, Safari, ...
      httpRequest = new XMLHttpRequest();
      if (httpRequest.overrideMimeType) {
          httpRequest.overrideMimeType('text/xml');
      }
  }
  else if (window.ActiveXObject) { // IE
      try {
          httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
          }
          catch (e) {
                     try {
                          httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
                         }
                       catch (e) {}
                    }
                                 }

  if (!httpRequest) {
      alert('Giving up :( Cannot create an XMLHTTP instance');
      return false;
  }
  var url = "timetable.php?la="+la;
//  document.getElementById('ac_list').innerHTML=url;

  httpRequest.onreadystatechange = function() { get_timetable(httpRequest,target); };
  httpRequest.open('GET', url, true);
  httpRequest.send('');
}

function get_timetable(httpRequest,target) {
  if (httpRequest.readyState == 4)
  {
    if (httpRequest.status == 200)
    {
      var xml = httpRequest.responseXML;
      target.innerHTML='';
//      th.colSpan="5";
      add_title(target,get_text(2,0),'timetable',1,0);

      for (iday=0;iday<=1;iday++)
      {
        var table = document.createElement("table");
        var tbody = document.createElement("tbody");
        table.className='timetable';
        var date = xml.getElementsByTagName("day")[iday].getElementsByTagName("date")[0].firstChild.data;
        var daynumber = xml.getElementsByTagName("day")[iday].getElementsByTagName("dayofweek")[0].firstChild.data;
        var tr=document.createElement("tr");
        var th=document.createElement("th");
        th.innerHTML=get_text(0,daynumber)+", "+date;
        th.style.fontWeight='bold';
        th.style.borderLeft='0px';
        th.style.width='160px';
        tr.appendChild(th);
        floortext=get_text(2,1);
        for (ifloor=1;ifloor<=4;ifloor++)
        {
          var th=document.createElement("th");
          th.style.fontWeight='normal';
          if (ifloor==4) th.style.borderRight='0px';
          th.style.width='160px';
          th.innerHTML=floortext+' '+ifloor;
          tr.appendChild(th);
        }
        tbody.appendChild(tr);
        table.appendChild(tbody);
        var nblock=xml.getElementsByTagName("day")[iday].getElementsByTagName("block").length;
        for (iblock=0;iblock<nblock;iblock++)
        {
          var time=xml.getElementsByTagName("day")[iday].getElementsByTagName("block")[iblock].getElementsByTagName("time")[0].firstChild.data;
          var floor1=xml.getElementsByTagName("day")[iday].getElementsByTagName("block")[iblock].getElementsByTagName("floor1")[0].firstChild.data;
          var floor2=xml.getElementsByTagName("day")[iday].getElementsByTagName("block")[iblock].getElementsByTagName("floor2")[0].firstChild.data;
          var floor3=xml.getElementsByTagName("day")[iday].getElementsByTagName("block")[iblock].getElementsByTagName("floor3")[0].firstChild.data;
          var floor4=xml.getElementsByTagName("day")[iday].getElementsByTagName("block")[iblock].getElementsByTagName("floor4")[0].firstChild.data;
          var tr=document.createElement("tr");
          tr.className='normal';
          var functext="this.className='highlight';";
          var func1=new Function(functext);
          tr.onmouseover=func1;
          var functext="this.className='normal';";
          var func2=new Function(functext);
          tr.onmouseout=func2;
          var td=document.createElement("td");
          td.innerHTML=time+' Uhr';
          td.style.borderLeft='0px';
          if (iblock==(nblock-1)) td.style.borderBottom='0px';
          tr.appendChild(td);
          var td=document.createElement("td");
          td.innerHTML=check_linebreak(floor1).replace(/#sup#/g,"<sup>").replace(/#\/sup#/g,"</sup>");
          if (iblock==(nblock-1)) td.style.borderBottom='0px';
          tr.appendChild(td);
          var td=document.createElement("td");
          td.innerHTML=check_linebreak(floor2).replace(/#sup#/g,"<sup>").replace(/#\/sup#/g,"</sup>");
          if (iblock==(nblock-1)) td.style.borderBottom='0px';
          tr.appendChild(td);
          var td=document.createElement("td");
          td.innerHTML=check_linebreak(floor3).replace(/#sup#/g,"<sup>").replace(/#\/sup#/g,"</sup>");
          if (iblock==(nblock-1)) td.style.borderBottom='0px';
          tr.appendChild(td);
          var td=document.createElement("td");
          td.innerHTML=check_linebreak(floor4).replace(/#sup#/g,"<sup>").replace(/#\/sup#/g,"</sup>");
          td.style.borderRight='0px';
          if (iblock==(nblock-1)) td.style.borderBottom='0px';
          tr.appendChild(td);
          tbody.appendChild(tr);
          table.appendChild(tbody);
        }
        target.appendChild(table);
      }
			text=document.createElement('div');
			var info=xml.getElementsByTagName("info")[0].firstChild.data.replace(/#sup#/g,"<sup>").replace(/#\/sup#/g,"</sup>");
			text.innerHTML="<div style=\"margin-top:20px;font-size:12px;\">"+info+"</div>";
//			if (la=="de") text.innerHTML=info;
//			"<div style=\"margin-top:20px;font-size:12px;\"><sup>*</sup>Die Aufteilung der Turniere innerhalb der Bl&ouml;cke 1/2 sowie 4/5 kann sich noch &auml;ndern. Die endg&uuml;ltigen Startzeiten werden vor dem Sommepokal hier ver&ouml;ffentlicht.</div>";
//			if (la=="en") text.innerHTML="<div style=\"margin-top:20px;font-size:12px;\"><sup>*</sup>The partitioning of the tournaments inside the time slots 1/2 and 4/5 are subject to possible changes. The final starting times will be published here shortly before the Summertrophy.</div>";
      target.appendChild(text);
    } else
    {
      alert('There was a problem with the request.');
    }
  }
}

function news(target,active_opt) {
  var httpRequest;
  if (window.XMLHttpRequest) { // Mozilla, Safari, ...
      httpRequest = new XMLHttpRequest();
      if (httpRequest.overrideMimeType) {
          httpRequest.overrideMimeType('text/xml');
      }
  }
  else if (window.ActiveXObject) { // IE
      try {
          httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
          }
          catch (e) {
                     try {
                          httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
                         }
                       catch (e) {}
                    }
                                 }

  if (!httpRequest) {
      alert('Giving up :( Cannot create an XMLHTTP instance');
      return false;
  }
  var url = "news.php?la="+la;
//  document.getElementById('ac_list').innerHTML=url;
  httpRequest.onreadystatechange = function() { get_news(httpRequest,target,active_opt); };
  httpRequest.open('GET', url, true);
  httpRequest.send('');
}

function get_news(httpRequest,target,active_opt) {
  if (httpRequest.readyState == 4)
  {
    if (httpRequest.status == 200)
    {
      var xml = httpRequest.responseXML;
      target.innerHTML='';
//      th.colSpan="5";
      var nopt=xml.getElementsByTagName("opt").length;


      for (iopt=0;iopt<nopt;iopt++)
      {
       if (xml.getElementsByTagName("optnumber")[iopt].firstChild.data==active_opt)
       {
        opt=xml.getElementsByTagName("optnumber")[iopt].firstChild.data;
        add_title(target,xml.getElementsByTagName("title")[iopt].firstChild.data,"about",opt,0);
        var text=document.createElement("div");
        text.className='info_body';
        text.id="about_text_"+opt;
        text.innerHTML=xml.getElementsByTagName("text")[iopt].firstChild.data;
        target.appendChild(text);
       } else
       {
        add_title(target,xml.getElementsByTagName("title")[iopt].firstChild.data,"about",xml.getElementsByTagName("optnumber")[iopt].firstChild.data,1);
        var text=document.createElement("div");
        text.className='info_body';
        text.id="about_text_"+xml.getElementsByTagName("optnumber")[iopt].firstChild.data;
        text.innerHTML=xml.getElementsByTagName("text")[iopt].firstChild.data;
        text.style.display='none';
        target.appendChild(text);
       }
      }
    } else
    {
      alert('There was a problem with the request.');
    }
  }
}

function custom_content(target,active_opt) {
  var httpRequest;
  if (window.XMLHttpRequest) { // Mozilla, Safari, ...
      httpRequest = new XMLHttpRequest();
      if (httpRequest.overrideMimeType) {
          httpRequest.overrideMimeType('text/xml');
      }
  }
  else if (window.ActiveXObject) { // IE
      try {
          httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
          }
          catch (e) {
                     try {
                          httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
                         }
                       catch (e) {}
                    }
                                 }

  if (!httpRequest) {
      alert('Giving up :( Cannot create an XMLHTTP instance');
      return false;
  }
  var url = "custom_content.php?la="+la;
//  document.getElementById('ac_list').innerHTML=url;
  httpRequest.onreadystatechange = function() { get_custom_content(httpRequest,target,active_opt); };
  httpRequest.open('GET', url, true);
  httpRequest.send('');
}

function get_custom_content(httpRequest,target,active_opt)
{
  if (httpRequest.readyState == 4)
  {
    if (httpRequest.status == 200)
    {
      var xml = httpRequest.responseXML;
      target.innerHTML='';
//      th.colSpan="5";
      var nopt=xml.getElementsByTagName("opt").length;

      for (iopt=0;iopt<nopt;iopt++)
      {
       if (xml.getElementsByTagName("optnumber")[iopt].firstChild.data==active_opt)
       {
        opt=xml.getElementsByTagName("optnumber")[iopt].firstChild.data;
        add_title(target,xml.getElementsByTagName("title")[iopt].firstChild.data,"about",opt,0);
        var text=document.createElement("div");
        text.className='info_body';
        text.id="about_text_"+opt;
        text.innerHTML=xml.getElementsByTagName("text")[iopt].firstChild.data.replace(/#ka#/g,"<").replace(/#kz#/g,">");
        target.appendChild(text);
       } else
       {
        add_title(target,xml.getElementsByTagName("title")[iopt].firstChild.data,"about",xml.getElementsByTagName("optnumber")[iopt].firstChild.data,1);
        var text=document.createElement("div");
        text.className='info_body';
        text.id="about_text_"+xml.getElementsByTagName("optnumber")[iopt].firstChild.data;
        text.innerHTML=xml.getElementsByTagName("text")[iopt].firstChild.data.replace(/#ka#/g,"<").replace(/#kz#/g,">");
        text.style.display='none';
        target.appendChild(text);
       }
      }
    } else
    {
      alert('There was a problem with the request.');
    }
  }
}

function about(target,active_opt) {
  var httpRequest;
  if (window.XMLHttpRequest) { // Mozilla, Safari, ...
      httpRequest = new XMLHttpRequest();
      if (httpRequest.overrideMimeType) {
          httpRequest.overrideMimeType('text/xml');
      }
  }
  else if (window.ActiveXObject) { // IE
      try {
          httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
          }
          catch (e) {
                     try {
                          httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
                         }
                       catch (e) {}
                    }
                                 }

  if (!httpRequest) {
      alert('Giving up :( Cannot create an XMLHTTP instance');
      return false;
  }
  var url = "about.php?la="+la;
//  document.getElementById('ac_list').innerHTML=url;
  httpRequest.onreadystatechange = function() { get_about(httpRequest,target,active_opt); };
  httpRequest.open('GET', url, true);
  httpRequest.send('');
}

function get_about(httpRequest,target,active_opt) {
  if (httpRequest.readyState == 4)
  {
    if (httpRequest.status == 200)
    {
      var xml = httpRequest.responseXML;
      target.innerHTML='';
//      th.colSpan="5";
      var nopt=xml.getElementsByTagName("opt").length;

      for (iopt=0;iopt<nopt;iopt++)
      {
       if (xml.getElementsByTagName("optnumber")[iopt].firstChild.data==active_opt)
       {
        opt=xml.getElementsByTagName("optnumber")[iopt].firstChild.data;
        add_title(target,xml.getElementsByTagName("title")[iopt].firstChild.data,"about",opt,0);
        var text=document.createElement("div");
        text.id="about_text_"+opt;
        text.innerHTML=xml.getElementsByTagName("text")[iopt].firstChild.data;
        target.appendChild(text);
       } else
       {
        add_title(target,xml.getElementsByTagName("title")[iopt].firstChild.data,"about",xml.getElementsByTagName("optnumber")[iopt].firstChild.data,1);
        var text=document.createElement("div");
        text.id="about_text_"+xml.getElementsByTagName("optnumber")[iopt].firstChild.data;
        text.innerHTML=xml.getElementsByTagName("text")[iopt].firstChild.data;
        text.style.display='none';
        target.appendChild(text);
       }
      }
    } else
    {
      alert('There was a problem with the request.');
    }
  }
}

function directions(target,active_opt) {
  var httpRequest;
  if (window.XMLHttpRequest) { // Mozilla, Safari, ...
      httpRequest = new XMLHttpRequest();
      if (httpRequest.overrideMimeType) {
          httpRequest.overrideMimeType('text/xml');
      }
  }
  else if (window.ActiveXObject) { // IE
      try {
          httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
          }
          catch (e) {
                     try {
                          httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
                         }
                       catch (e) {}
                    }
                                 }

  if (!httpRequest) {
      alert('Giving up :( Cannot create an XMLHTTP instance');
      return false;
  }
  var url = "directions.php?la="+la;
//  document.getElementById('ac_list').innerHTML=url;
  httpRequest.onreadystatechange = function() { get_directions(httpRequest,target,active_opt); };
  httpRequest.open('GET', url, true);
  httpRequest.send('');
}

function get_directions(httpRequest,target,active_opt) {
  if (httpRequest.readyState == 4)
  {
    if (httpRequest.status == 200)
    {
      var xml = httpRequest.responseXML;
      target.innerHTML='';
//      th.colSpan="5";
      var nopt=xml.getElementsByTagName("opt").length;

      for (iopt=0;iopt<nopt;iopt++)
      {
       if (xml.getElementsByTagName("optnumber")[iopt].firstChild.data==active_opt)
       {
        opt=xml.getElementsByTagName("optnumber")[iopt].firstChild.data;
        add_title(target,xml.getElementsByTagName("title")[iopt].firstChild.data,"about",opt,0);
        var text=document.createElement("div");
        text.className="info_body";
        text.id="about_text_"+opt;
        text.innerHTML=xml.getElementsByTagName("text")[iopt].firstChild.data;
        target.appendChild(text);
       } else
       {
        add_title(target,xml.getElementsByTagName("title")[iopt].firstChild.data,"about",xml.getElementsByTagName("optnumber")[iopt].firstChild.data,1);
        var text=document.createElement("div");
        text.id="about_text_"+xml.getElementsByTagName("optnumber")[iopt].firstChild.data;
        text.innerHTML=xml.getElementsByTagName("text")[iopt].firstChild.data;
        text.className="info_body";
        text.style.display='none';
        target.appendChild(text);
       }
      }
    } else
    {
      alert('There was a problem with the request.');
    }
  }
}

function accomodation(target) {
  var httpRequest;
  if (window.XMLHttpRequest) { // Mozilla, Safari, ...
      httpRequest = new XMLHttpRequest();
      if (httpRequest.overrideMimeType) {
          httpRequest.overrideMimeType('text/xml');
      }
  }
  else if (window.ActiveXObject) { // IE
      try {
          httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
          }
          catch (e) {
                     try {
                          httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
                         }
                       catch (e) {}
                    }
                                 }

  if (!httpRequest) {
      alert('Giving up :( Cannot create an XMLHTTP instance');
      return false;
  }
  var url = "accomodation.php?la="+la;
//  document.getElementById('ac_list').innerHTML=url;
  httpRequest.onreadystatechange = function() { get_accomodation(httpRequest,target); };
  httpRequest.open('GET', url, true);
  httpRequest.send('');
}

function get_accomodation(httpRequest,target) {
  if (httpRequest.readyState == 4)
  {
    if (httpRequest.status == 200)
    {
      var xml = httpRequest.responseXML;
      target.innerHTML='';
//      th.colSpan="5";
      var nopt=xml.getElementsByTagName("opt").length;

      var info=document.createElement("div");
      info.className='info_body';

      for (iopt=0;iopt<nopt;iopt++)
      {
        opt=xml.getElementsByTagName("optnumber")[iopt].firstChild.data;
        add_title(target,xml.getElementsByTagName("title")[iopt].firstChild.data,"directions",opt,0);
        var text=document.createElement("div");
        text.id="directions_text_"+opt;
        text.innerHTML=xml.getElementsByTagName("text")[iopt].firstChild.data.replace("#and#",'&');
        info.appendChild(text);
      }
        target.appendChild(info);
    } else
    {
      alert('There was a problem with the request.');
    }
  }
}

function media_overview(target) {
  var httpRequest;
  if (window.XMLHttpRequest) { // Mozilla, Safari, ...
      httpRequest = new XMLHttpRequest();
      if (httpRequest.overrideMimeType) {
          httpRequest.overrideMimeType('text/xml');
      }
  }
  else if (window.ActiveXObject) { // IE
      try {
          httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
          }
          catch (e) {
                     try {
                          httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
                         }
                       catch (e) {}
                    }
                                 }

  if (!httpRequest) {
      alert('Giving up :( Cannot create an XMLHTTP instance');
      return false;
  }

  var url = "media.php?la="+la;
//  document.getElementById('ac_list').innerHTML=url;
  httpRequest.onreadystatechange = function() { get_media_overview(httpRequest,target); };
  httpRequest.open('GET', url, true);
  httpRequest.send('');
}

function get_media_overview(httpRequest,target) {
  if (httpRequest.readyState == 4)
  {
    if (httpRequest.status == 200)
    {
      var xml = httpRequest.responseXML;
      target.innerHTML='';
      data=xml.getElementsByTagName("year");
      title=get_text(20,0);
			
      add_title(target,title,"media",opt,0);
  		singlesubopt=0;
			click=0;
      for (iyear=0;iyear<data.length;iyear++)
      {	
         add_subtitle(target,"Sommerpokal "+data[iyear].getElementsByTagName("yearnumber")[0].firstChild.data,"results",iyear,click,'single');
         var table=document.createElement("table");
	       var tbody = document.createElement("tbody");
				 if (iyear==singlesubopt) document.getElementById("results_subtitle_"+iyear).style.className='subtitle';
         table.className='results_overview';
         table.style.width=(200*data[iyear].getElementsByTagName("cat").length)+'px';
         var tr=document.createElement("tr");
         for (icat=0;icat<data[iyear].getElementsByTagName("cat").length;icat++)
         {
				   var thiscat=data[iyear].getElementsByTagName("cat")[icat].firstChild.data;
				   var linkcat=data[iyear].getElementsByTagName("linkcat")[icat].firstChild.data;
           var th=document.createElement("td");
           th.style.border='0px';
           th.style.height='50px';
           var a=document.createElement("a");
           a.className='result_link';
           a.innerHTML="> "+thiscat;
           a.style.fontSize="14px";
           var functext="media_show('"+target.id+"','"+data[iyear].getElementsByTagName("yearnumber")[0].firstChild.data+"','"+linkcat+"');";
           var func1=new Function(functext);

           th.onclick=func1;
           var functext="this.style.fontWeight='bold';";
           var func2=new Function(functext);
           th.onmouseover=func2;
           var functext="this.style.fontWeight='normal';";
           var func3=new Function(functext);
           th.onmouseout=func3;
           th.appendChild(a);
           tr.appendChild(th);
         }
         tbody.appendChild(tr);
         var div=document.createElement("div");
         table.appendChild(tbody);
				 div.appendChild(table);
         div.id='results_text_'+iyear;
				 if (iyear!=singlesubopt) div.style.display='none';
         target.appendChild(div);
				 table=0;
      }
    } else
    {
      alert('There was a problem with the request.');
    }
  }
}

function media_show(target,year,type) {
	target=document.getElementById(target);
  var httpRequest;
  if (window.XMLHttpRequest) { // Mozilla, Safari, ...
      httpRequest = new XMLHttpRequest();
      if (httpRequest.overrideMimeType) {
          httpRequest.overrideMimeType('text/xml');
      }
  }
  else if (window.ActiveXObject) { // IE
      try {
          httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
          }
          catch (e) {
                     try {
                          httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
                         }
                       catch (e) {}
                    }
                                 }

  if (!httpRequest) {
      alert('Giving up :( Cannot create an XMLHTTP instance');
      return false;
  }

  var url = "media.php?la="+la+"&year="+year+"&type="+type;
	
  httpRequest.onreadystatechange = function() { get_media_show(httpRequest,target,year,type); };
  httpRequest.open('GET', url, true);
	httpRequest.send('');
}

function get_media_show(httpRequest,target,year,type) {
  if (httpRequest.readyState == 4)
  {
    if (httpRequest.status == 200)
    {
      var xml = httpRequest.responseXML;
      target.innerHTML='';
      data=xml.getElementsByTagName("mediaelement");
      title=get_text(20,type)+" "+year;
			
      add_title(target,title,"media",opt,0);

      if (type==2)
			{
				h=300;
				w=800;
				var div=document.createElement("div");
				div.style.position="relative";
				div.style.left="0px";
				div.style.width=w+"px";
				div.style.height=h+"px";
				var button_left=document.createElement("div");
				button_left.id="image_gallery_button_left";
				button_left.style.position="absolute";
				button_left.style.left="0px";
				button_left.style.top=(h/2-25)+"px";
				button_left.style.width="50px";
				button_left.style.height="50px";
				button_left.style.cursor="pointer";
				button_left.style.backgroundImage="url(images/button_left_right.png)";
				button_left.style.backgroundPosition="0px 0px";
        functext="image_gallery('left')";
        var func1=new Function(functext);
        button_left.onclick=func1;
				div.appendChild(button_left);
				var button_right=document.createElement("div");
				button_right.id="image_gallery_button_right";
				button_right.style.position="absolute";
				button_right.style.right="0px";
				button_right.style.top=(h/2-25)+"px";
				button_right.style.width="50px";
				button_right.style.height="50px";
				button_right.style.cursor="pointer";
				button_right.style.backgroundImage="url(images/button_left_right.png)";
				button_right.style.backgroundPosition="50px 0px";
        functext="image_gallery('right')";
        var func1=new Function(functext);
        button_right.onclick=func1;
				button_right.ondblclick="";
				div.appendChild(button_right);

				var imgcontainer=document.createElement("div");
				imgcontainer.style.position="absolute";
				imgcontainer.style.top="0px";
				imgcontainer.style.left="50px";
				w2=w-2*50;
				imgcontainer.style.width=w2+"px";
				imgcontainer.style.height=h+"px";
				div.appendChild(imgcontainer);
				
				activeimage=document.createElement("input");
				activeimage.id="activeimage";
				activeimage.type="hidden"
				activeimage.value="1"
				nimages=document.createElement("input");
				nimages.id="nimages";
				nimages.type="hidden"
				nimages.value=data.length;
				
				div.appendChild(activeimage);
				div.appendChild(nimages);

				for (ielement=0;ielement<data.length;ielement++)
      	{
					var divsub=document.createElement("div");
					divsub.id="cimage"+ielement;
					imname=document.createElement("input");
					imname.type="hidden"
					imname.value=data[ielement].getElementsByTagName("name")[0].firstChild.data;
					imname.id="cimage"+ielement+"name";
					divsub.style.position="absolute";
					divsub.style.left=(ielement*200)+"px";
					divsub.style.display="none";
					var thisimg=document.createElement("img");
					thisimg.id='cimage'+ielement+'img';
					thisimg.src=data[ielement].getElementsByTagName("linkth")[0].firstChild.data;
					thisimg.style.width="100%";
					thisimg.style.height="100%";
					thisimg.style.border="2px solid #e9c785";
					thisimg.style.cursor="pointer"
					functext="this.style.border='2px solid #ab9160';";
        	var func1=new Function(functext);
					thisimg.onmouseover=func1;
					functext="this.style.border='2px solid #e9c785';";
        	var func2=new Function(functext);
					thisimg.onmouseout=func2;
					functext="window.open('"+data[ielement].getElementsByTagName("link")[0].firstChild.data+"','')";
        	var func3=new Function(functext);
					thisimg.onclick=func3;
					
					divsub.appendChild(thisimg);
					imgcontainer.appendChild(divsub);
					imgcontainer.appendChild(imname);
				}
        imagesub=document.createElement("div");
				imagesub.id="imagesub";
				imagesub.style.position="absolute";
				imagesub.style.fontSize="12px";
				imagesub.style.textAlign="center";
				imgcontainer.appendChild(imagesub);

        target.appendChild(div);

				imgw=new Array(75,125,200,125,75)
				gap=15
				center=0;
				
				image_gallery("left");
				
/*				for (i=0;i<nimages;i++) document.getElementById("cimage"+active).style.display="none";
				
				for (i=0;i<5;i++)
				{
					active=center-2+i;
					if (active<0) active+=data.length;
					cw=imgw[i];
					var a2=document.getElementById("cimage"+active);
					var a2img=document.getElementById("cimage"+active+"img");
					ch=cw*parseFloat(a2img.height)/parseFloat(a2img.width);
					a2.style.top=((h/2-(ch/2)))+"px";
					if (i==0) imgl=(w2/2)-imgw[0]/2-imgw[1]-imgw[2]/2-gap*2;
					if (i==1) imgl=(w2/2)-imgw[1]/2-imgw[2]/2-gap;
					if (i==2) imgl=(w2/2);
					if (i==3) imgl=(w2/2)+imgw[3]/2+imgw[2]/2+gap;
					if (i==4) imgl=(w2/2)+imgw[4]/2+imgw[3]+gap*2+imgw[2]/2;
					a2.style.left=(imgl-(cw/2))+"px";
					a2.style.width=cw+"px";
					a2.style.height=ch+"px";
					a2.style.display="block";

					if (i==2)
					{
						var name=document.getElementById("cimage"+active+"name");
						var namediv=document.getElementById("imagesub");
						namediv.innerHTML=name.value;
						namediv.style.top=(a2.offsetHeight+a2.offsetTop+5)+"px";
						namediv.style.left=a2.style.left;
						namediv.style.width=a2.style.width;
					}
				}
*/
				
//				   var thiscat=data[iyear].getElementsByTagName("cat")[icat].firstChild.data;
//				   var linkcat=data[iyear].getElementsByTagName("linkcat")[icat].firstChild.data;
//           var functext="media_show('"+target.id+"','"+linkcat+"');";
//           var func1=new Function(functext);
//           th.onclick=func1;
//           var functext="this.style.fontWeight='bold';";
//           var func2=new Function(functext);
//           th.onmouseover=func2;
//           var functext="this.style.fontWeight='normal';";
//           var func3=new Function(functext);
//           th.onmouseout=func3;
//           th.appendChild(a);
//           tr.appendChild(th);
      }
    } else
    {
      alert('There was a problem with the request.');
    }
  }
}

function image_gallery(dir)
{
  if (document.selection && document.selection.empty)
	{
    document.selection.empty();
  } else if (window.getSelection)
	{
    var sel = window.getSelection();
    sel.removeAllRanges();
  }
	but=document.getElementById("image_gallery_button_"+dir)
	activeimage=parseInt(document.getElementById("activeimage").value);
	nimages=parseInt(document.getElementById("nimages").value);
	if (dir=="right")
	{
//		but.style.backgroundPosition='50px -50px';
		activeimage++;
		if (activeimage>=nimages) activeimage=0;
	} else
	{
//		but.style.backgroundPosition='0px -50px';
		activeimage--;
		if (activeimage<0) activeimage=nimages-1;
	}
	document.getElementById("activeimage").value=activeimage;
	
	imgw=new Array(75,125,200,125,75)
	gap=15
	center=activeimage;

	for (i=0;i<nimages;i++) document.getElementById("cimage"+i).style.display="none";

	for (i=0;i<5;i++)
	{
		active=center-2+i;
		if (active<0) active=nimages+active;
		if (active>=nimages) active=active-nimages;
		cw=imgw[i];
		var a2=document.getElementById("cimage"+active);
		var a2img=document.getElementById("cimage"+active+"img");
		var newImg = new Image();
		newImg.src = a2img.src;
		var theight = newImg.height;
		var twidth = newImg.width;
		ch=cw*parseFloat(theight)/parseFloat(twidth);
		a2.style.top=((h/2-(ch/2)))+"px";
		if (i==0) imgl=(w2/2)-imgw[0]/2-imgw[1]-imgw[2]/2-gap*2;
		if (i==1) imgl=(w2/2)-imgw[1]/2-imgw[2]/2-gap;
		if (i==2) imgl=(w2/2);
		if (i==3) imgl=(w2/2)+imgw[3]/2+imgw[2]/2+gap;
		if (i==4) imgl=(w2/2)+imgw[4]/2+imgw[3]+gap*2+imgw[2]/2;
		a2.style.left=(imgl-(cw/2))+"px";
		a2.style.width=cw+"px";
		a2.style.height=ch+"px";
		a2.style.display="block";

		if (i==2)
		{
			var name=document.getElementById("cimage"+active+"name");
			var namediv=document.getElementById("imagesub");
			namediv.innerHTML=name.value;
			namediv.style.top=(a2.offsetHeight+a2.offsetTop+5)+"px";
			namediv.style.left=a2.style.left;
			namediv.style.width=a2.style.width;
		}
	}
}

