// *************************************** Funktionen für 5qm ****************************//
//
// In dieser Datei finden sich die Funktionen, die für den 5qm-Auftritt benötigt werden.
// Objektkonstruktor, Popup-Inhalte-Laden, Bildwechsel, Tabellengenerierung, Popup öffnen, Preload
// copyright Antje Diehl, 2002, Diehl@NetzRecherche.de
//****************************************************************************************//



// Objektkonstruktion Tapete
function tapete(nummer,text) {
      this.text = text;
	  this.nummer=nummer;
	  //this.platz=platz;
	  this.name="t"+nummer;
	  this.small="img/"+nummer+"s.jpg";
  	  this.medium="img/"+nummer+"m.jpg";
   	  this.large="img/"+nummer+"l.jpg";
	  	for (i=0;i<tapeten.length;i++)
		{
			tap_compare = tapeten[i];
			if (tap_compare==this.name) 
			{	
			    this.platz=i; //platz = index in tapeten
				if (this.platz==0)	{this.next=tapeten[1]; this.prev=tapeten[tapeten.length-1];}
				if (this.platz==tapeten.length-1){this.next=tapeten[0];this.prev=tapeten[tapeten.length-2];	}
				if (this.platz>0&&this.platz<tapeten.length-1){this.next=tapeten[i+1];this.prev=tapeten[i-1];}
			}
		}
}


// Inhalte für Tapetenpopup laden
function laden(){
		window.focus();
        window.document.images[0].src = window[tap].large;
}
function goto_next(){
        window.location.href="ftpopup.html?"+window[tap].next;
}
function goto_prev(){
        window.location.href="ftpopup.html?"+window[tap].prev;
}

// Funktionen für Bildwechsel (Rollover)
function change(name)
{ var nsdoc= 'document'; 
 var rpath=window[name].medium; 
 var preload= true;
  var img = eval((navigator.appName.indexOf('Netscape', 0) != -1) ? nsdoc+'.'+name : 'document.all.'+name);
  if (name == '')  return;
  if (img) {
    img.altsrc = img.src;
    img.src    = rpath;
  } 
}

function restore(name)
{ var nsdoc='document';
  var img = eval((navigator.appName.indexOf('Netscape', 0) != -1) ? nsdoc+'.'+name : 'document.all.'+name);
  if (name == '')
    return;
  if (img && img.altsrc) {
    img.src    = img.altsrc;
    img.altsrc = null;
  } 
}

// Tapetenpopup
function openPopup(number) { 
	theURL="ftpopup.html"+"?"+number;
	features="toolbar=no,menubar=no,scrollbars=no,location=no,width=650,height=500";
  popupwindow=window.open(theURL,'popup',features);
  if(window.focus) {popupwindow.focus();}
}
 
// allgemeines Popup
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

// Code-Generierung für die einzelnen Tabellenzellen des Index
function make_code(tap){
	bild=("<img src="+window[tap].small+" width='100' height='70' border='0' name='"+tap+"' alt='Fototapete Nr."+window[tap].nummer+"' title='Fototapete Nr. "+window[tap].nummer+"'"+">");
	linkanfang="<a href='#' "+"onMouseOut=restore('"+tap+"'); "+"onMouseOver=change('"+tap+"'); "+"onClick=openPopup('"+tap+"');"+">";
	linkende="</a>";
	code="<p>"+linkanfang+bild+linkende+"</P>";
}


// Preloadfunktion

function na_preload_img()
{    
	img_list=new Array;
	img_list[0]=false;
	for (i=1;i<=tapeten.length;i++){
		tap_item=tapeten[i-1];
		img_list[i]=window[tap_item].medium;
	}
	if (document.preloadlist == null) document.preloadlist = new Array();
  var top = document.preloadlist.length;
  for (var i=0; i < img_list.length; i++) {
    document.preloadlist[top+i] = new Image;
    document.preloadlist[top+i].src = img_list[i+1];
  } 
}
