// This script was supplied free by Hypergurl
// http://www.hypergurl.com
// JavaScript to interpolate random images into a page.
var ic = 22;     // Number of alternative images
var xoxo = new Array(ic);  // Array to hold filenames
xoxo[0] = "http://www.schreiberundleser.de/_elemente/top-strip1.jpg";

// Write out an IMG tag, using a randomly-chosen image name.
//var choice = pickTopstrip(ic);
var stripchoice ='http://www.schreiberundleser.de/_elemente/top-strip'+String((getDoy() % ic)+1)+'.jpg';

function pickTopstrip(range) {
	//var now = new Date();	
    //return (now.getDate() % range);
	return (getDoy() % range);
}

function getDoy()
{
        //get day of the year 1-365
		var today = new Date();
        Year = takeYear(today);
        Month = today.getMonth();
        Day = today.getDate();
        now = Date.UTC(Year,Month,Day+1,0,0,0);
        var Firstday = new Date();
        Firstday.setYear(Year);
        Firstday.setMonth(0);
        Firstday.setDate(1);
        then = Date.UTC(Year,0,1,0,0,0);
        var Compensation = Firstday.getDay();
        if (Compensation > 3) Compensation -= 4;
        else Compensation += 3;
        doy = Math.round((((now-then)/86400000)+Compensation));
		return doy;
}

function takeYear(theDate)
{
        x = theDate.getYear();
        var y = x % 100;
        y += (y < 38) ? 2000 : 1900;
        return y;
}
function popCover(coverFile, bodyColor) {


if (!document.getElementById) {  //If you don't get it, don't do it...
	var seitenTitel="";
}
 else {
	 var seitenTitel=document.getElementById(coverFile).title;	 
 }
 
top.consoleRef=window.open('',coverFile+'cover','width=400,height=630,top=30,menubar=0,toolbar=0,status=0,scrollbars=0,resizable=1');
seitenTitel = replaceSonderZ(seitenTitel);
//top.consoleRef.document.open("text/html","replace");
top.consoleRef.document.writeln('<html><head><title>Titelbild: '+seitenTitel+'</title>'+
								'<link href="http://www.schreiberundleser.de/_elemente/sl.css" rel="stylesheet" type="text/css">'+
								'<style type="text/css"> body {background-color: #'+bodyColor+'};</style></head>'+
								'<body onLoad="self.focus()"><table width="100%" border="0" cellpadding="0" cellspacing="10">'+
								'<tr><td width="100%" valign="middle"><p class="p_'+bodyColor+'">Titelbild: '+seitenTitel+'</p></td></tr>'+
								'<tr><td width="100%" align="center" valign="top"><img src="_titel_gross/'+coverFile+'.jpg" class="img_pop-cover"></td></tr></table></body></html>');
top.consoleRef.document.close();
}

function replaceSonderZ(stringVar) {

 while (stringVar.indexOf("&")>=0){
	 stringVar = stringVar.replace("&","ampersand"); // This one first and in two steps!!
	  }
while (stringVar.indexOf("ampersand")>=0){
	 stringVar = stringVar.replace("ampersand","&amp;"); // Step two of "&"
	 }

 while (stringVar.indexOf("?")>=0){
	 stringVar = stringVar.replace("?","&auml;");
	  }
while (stringVar.indexOf("?")>=0){
	 stringVar = stringVar.replace("?","&ouml;");
	  }
while (stringVar.indexOf("?")>=0){
	 stringVar = stringVar.replace("?","&uuml;");
	  }
while (stringVar.indexOf("?")>=0){
	 stringVar = stringVar.replace("?","&Auml;");
	  }
while (stringVar.indexOf("?")>=0){
	 stringVar = stringVar.replace("?","&Ouml;");
	  }
while (stringVar.indexOf("?")>=0){
	 stringVar = stringVar.replace("?","&Uuml;");
	  }	

while (stringVar.indexOf("?")>=0){
	 stringVar = stringVar.replace("?","&szlig;");
	  }	
//while (stringVar.indexOf("\?")>=0){
//	 stringVar = stringVar.replace("?","&agrave;"); 
//	  }	
//while (stringVar.indexOf("?")>=0){
//	 stringVar = stringVar.replace("?","&icirc;"); 
//	  }	
while (stringVar.indexOf('\"')>=0){
	 stringVar = stringVar.replace('"',"&quot;");
	  }	
while (stringVar.indexOf('?')>=0){
	 stringVar = stringVar.replace('?',"&ndash;");
	  }	
	
	return stringVar;
}
function popLeseprobeSingle(currUrl, seitenFile, bodyColor) {

if (!document.getElementById) {  //If you don't get it, don't do it...
	var seitenTitel="";
}
 else {
	 var seitenTitel=document.getElementById(seitenFile).title;
 }
top.consoleRef=window.open('',seitenFile+'seite','width=700,height='+(screen.availHeight-50)+',top=30,menubar=0,toolbar=0,status=0,scrollbars=1,resizable=1');
	seitenTitel = replaceSonderZ(seitenTitel);

var currPath = new String (currUrl);
var slashPos = currPath.lastIndexOf("/");
currPath = currPath.substr(0,slashPos);

//top.consoleRef.document.open("text/html","replace");
top.consoleRef.document.writeln('<html><head>'+'<title>Leseprobe: '+seitenTitel+
								'</title><link href="http://www.schreiberundleser.de/_elemente/sl.css" rel="stylesheet" type="text/css">'+
								'<script language="javascript" type="text/javascript" src="http://www.schreiberundleser.de/_elemente/sl.js"></script>'+
								'</head><body class="body_'+bodyColor+'" onLoad="self.focus()">'+'<table width="100%" border="0" cellpadding="0" cellspacing="0">'+
								'<tr><td width="100%" height="40" align="center" valign="middle">'+
								'<p class="p_'+bodyColor+'">Leseprobe: '+seitenTitel+'</p></td></tr>'+
								'<tr><td align="center"><img src="'+currPath+'/_lesen/'+seitenFile+'-1.jpg" class="img_pop-cover"></td></tr>'+
								'<tr><td height="30"></td></tr></table>'+'</body></html>');
//top.consoleRef.document.close();
}


function popLeseprobe(currUrl, seitenFile, bodyColor) {

if (!document.getElementById) {  //If you don't get it, don't do it...
	var seitenTitel="";
}
 else {
	 var seitenTitel=document.getElementById(seitenFile).title;
 }
top.consoleRef=window.open('',seitenFile+'seite','width=700,height='+(screen.availHeight-50)+',top=30,menubar=0,toolbar=0,status=0,scrollbars=1,resizable=1');
	seitenTitel = replaceSonderZ(seitenTitel);

var currPath = new String (currUrl);
var slashPos = currPath.lastIndexOf("/");
currPath = currPath.substr(0,slashPos);

//top.consoleRef.document.open("text/html","replace");
top.consoleRef.document.writeln('<html><head>'+'<title>Leseprobe: '+seitenTitel+
								'</title><link href="http://www.schreiberundleser.de/_elemente/sl.css" rel="stylesheet" type="text/css">'+
								'<script language="javascript" type="text/javascript" src="http://www.schreiberundleser.de/_elemente/sl.js"></script>'+
								'</head><body class="body_'+bodyColor+'" onLoad="self.focus()">'+'<table width="100%" border="0" cellpadding="0" cellspacing="0">'+
								'<tr><td width="100%" height="40" align="center" valign="middle">'+
								'<p class="p_'+bodyColor+'">Leseprobe: '+seitenTitel+' - erste Seite</p></td></tr>'+
								'<tr><td align="center">'+
								'<a href="javascript:void(0)" onClick="popLeseprobe2(\''+currUrl+'\',\''+seitenFile+'\',\''+bodyColor+'\'); window.close();" title="'+seitenTitel+'" id="'+seitenFile+'2" class="a_'+bodyColor+'">'+
								'<img src="'+currPath+'/_lesen/'+seitenFile+'-1.jpg" class="img_pop-cover">'+
								'<br><br>zweite Seite &gt;</a></td></tr>'+
								'<tr><td height="30"></td></tr></table>'+'</body></html>');
//top.consoleRef.document.close();
}

function popLeseprobe2(currUrl,seitenFile, bodyColor) {

var zweitseitenFile = seitenFile+'2';
if (!document.getElementById) {  //If you don't get it, don't do it...
	var seitenTitel="";
}
 else {
	 var seitenTitel=document.getElementById(zweitseitenFile).title;
 }
top.console2Ref=window.open('',seitenFile+'2seite','width=700,height='+(screen.availHeight-50)+',top=30,menubar=0,toolbar=0,status=0,scrollbars=1,resizable=1');
	 seitenTitel = replaceSonderZ(seitenTitel);

var currPath = new String (currUrl);
var slashPos = currPath.lastIndexOf("/");
currPath = currPath.substr(0,slashPos);

//top.console2Ref.document.open("text/html","replace");
top.console2Ref.document.writeln('<html><head>'+
								 '<title>Leseprobe: '+seitenTitel+'</title>'+
								 '<script language="javascript" type="text/javascript" src="http://www.schreiberundleser.de/_elemente/sl.js"></script>'+
								 '<link href="http://www.schreiberundleser.de/_elemente/sl.css" rel="stylesheet" type="text/css">'+
								 '</head>'+
								 '<body class="body_'+bodyColor+'" onLoad="self.focus()">'+
								 '<table width="100%" border="0" cellpadding="0" cellspacing="0">'+
								 '<tr><td width="100%" height="40" align="center" valign="middle">'+
								 '<p class="p_'+bodyColor+'">Leseprobe: '+seitenTitel+' - zweite Seite</p></td></tr>'+
								 '<tr><td align="center">'+
								 '<a href="javascript:void(0)" onClick="popLeseprobe(\''+currUrl+'\',\''+seitenFile+'\',\''+bodyColor+'\'); window.close();" title="'+seitenTitel+'" id="'+seitenFile+'" class="a_'+bodyColor+'">'+
								 '<img src="'+currPath+'/_lesen/'+seitenFile+'-2.jpg" class="img_pop-cover">'+
								 '<br><br>&lt; erste Seite</a></td></tr>'+
								 '<tr><td height="30"></td></tr></table></body></html>');
//top.console2Ref.document.close();
}

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 MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

