/**************************************/
/*Springfield-Shopper.de Scripts      */
/**************************************/


// Zufallsgenerator -------------------------------------------------------------------------------

while (true) {
s = Math.random();
s = s*11;
t = Math.round(s);
if (t < 12) break; 
             }

while (true) {
c = Math.random();
c = c*11;
d = Math.round(c);
if (d < 12 && d != t) break; 
             }

while (true) {
e = Math.random();
e = e*11;
f = Math.round(e);
if (f < 12 && f != t && f != d) break; 
             }

while (true) {
g = Math.random();
g = g*11;
h = Math.round(g);
if (h < 12 && h != t && h != d && h != f) break; 
             }	
				
while (true) {
i = Math.random();
i = i*11;
j = Math.round(i);
if (j < 12 && j != t && j != d && j != f && j != h) break; 
             }

// Datum ------------------------------------------------------------------------------------------
function Datum(n) {
			this.length = n
			return this
			}

		monthNames = new Datum(12)
		monthNames[1] = "Januar"
		monthNames[2] = "Februar"
		monthNames[3] = "M&auml;rz"
		monthNames[4] = "April"
		monthNames[5] = "Mai"
		monthNames[6] = "Juni"
		monthNames[7] = "Juli"
		monthNames[8] = "August"
		monthNames[9] = "September"
		monthNames[10] = "Oktober"
		monthNames[11] = "November"
		monthNames[12] = "Dezember"

		dayNames = new Datum(7)
		dayNames[1] = "Sonntag"
		dayNames[2] = "Montag"
		dayNames[3] = "Dienstag"
		dayNames[4] = "Mittwoch"
		dayNames[5] = "Donnerstag"
		dayNames[6] = "Freitag"
		dayNames[7] = "Samstag"


		function customDateString(oneDate) {

			var theDay = dayNames[oneDate.getDay() + 1]
			var theMonth = monthNames[oneDate.getMonth() + 1]
			var theYear = oneDate.getYear() 

			if(theYear<1000) theYear+=1900
 return theDay + ", " + oneDate.getDate() + "." + theMonth + " " + theYear
		}

//Banner Rotation ----------------------------------------------------------------------------------

Anzahl = "3";

while (true) {
y = Math.random();
y = y*10;
z = Math.round(y);
if (z < Anzahl) break;
             }
 
	Banner    = new Array;
	//-----
	
	Banner[0] = "<a href='http://www.emp.de/link/?id=194' target='_blank'><img src='http://www.emp.de/download/banner/simpsons_side_120x240.gif' border='0' width='120' height='240'></a>";
	Banner[1] = "<a href='http://www.emp.de/link/?id=194' target='_blank'><img src='http://www.emp.de/download/banner/simpsons_side_120x240_2.gif' border='0' width='120' height='240'></a>";
	Banner[2] = "<a href='http://www.emp.de/link/?id=194' target='_blank'><img src='http://www.emp.de/download/banner/simpsons_side_120x240_3.gif' border='0' width='120' height='240'></a>";

	//Banner[0] =  "<a href='http://www.comicstore24.de' target='_blank'><img src='http://springfield-shopper.de/cs24/cs24.gif' border='0' alt='ComicStore24.de pr&auml;sentiert die coolsten Merchandising-Artikel / Fanartikel, die es zu den Simpsons gibt.'></a>";
  //Banner[1] =  "<a href='http://www.shirt66.de' target='_blank'><img src='http://springfield-shopper.de/cs24/shirt-66.gif' border='0' alt='Riesen Auswahl mit über 1.500 T-Shirts ! Ob kultige Logos, witzige Sprüche oder trendige Styles - hier findet jeder sein Shirt. '></a>";
  	
// Buddie Rotation
Buddiesource = "http://springfield-shopper.de/Main/Buddies/"


Buddie    = new Array;
Buddie[0] = "<a href='http://www.planearium2.de' target='_blank'><img src='" + Buddiesource + "18.gif' alt='Planearium2.de' border=0 height=31 width=88></a>";  
Buddie[1] = "<a href='http://www.lisasimpson-net.de' target='_blank'><img src='" + Buddiesource + "2.gif' alt='Kleine Miss Springfield' border=0 height=31 width=88></a>"; 
Buddie[2] = "<a href='http://www.spongebob.de' target='_blank'><img src='" + Buddiesource + "14.gif' alt='des Schwammkopfes eigene Fansite' border=0 height=31 width=88></a>"; 
/*was soll der?*/ Buddie[3] = "<a href='http://www.newspringfield.com/' target='_blank'><img src='" + Buddiesource + "4.gif' alt='Die USA lassen grüßen' border=0 height=31 width=88></a>"; 
Buddie[4] = "<a href='http://simpsonssource.de' target='_blank'><img src='" + Buddiesource + "5.gif' alt='Some ench@nted Evening' border=0 height=31 width=88></a>"; 
/*weg bzw homer-simpson.de */ Buddie[5] = "<a href='http://www.homers-area.de.vu/' target='_blank'><img src='" + Buddiesource + "17.gif' alt='the Land of Homer' border=0 height=31 width=88></a>"; 
Buddie[6] = "<a href='http://www.simpsons-blog.de/' target='_blank'><img src='" + Buddiesource + "7.gif' alt='simpsons-blog.de' border=0 height=31 width=88></a>";
Buddie[7] = "<a href='http://www.simpsonsline.com' target='_blank'><img src='" + Buddiesource + "8.gif' alt='cots COTS cots' border=0 height=31 width=88></a>";
/* geht nicht */ Buddie[8] = "<a href='http://home.intergga.ch/osl' target='_blank'><img src='" + Buddiesource + "9.gif' alt=Old Springfield Library' border=0 height=31 width=88></a>";
Buddie[9] = "<a href='http://www.simpsonsweb.de/'target='_blank'><img src='" + Buddiesource + "15.gif' alt='Simpsonsweb.de' border=0 height=31 width=88></a>";
Buddie[10] = "<a href='http://www.futu-rama.de' target='_blank'><img src='" + Buddiesource + "13.gif' alt='http://www.futu-rama.de' border=0 height=31 width=88></a>";
Buddie[11] = "<a href=http://www.bartcity.com/ target=_blank><img src='" + Buddiesource + "12.gif' Border='0'></a>";

FullEps="<br><a href='http://iexploiter.com/episodes/enter1.asp?id=Sshopper' target='_blank'><img src='" + Buddiesource + "tvdownloads.jpg' height='31' width='88' border='0'alt='Top TV Downloads'></a><br>";




// Sonstige Funktionen

// Mail Crypt ----------------------------------------------------------------------------------------

function uncrypt(s) {	//
	var n=0;
	var r="";
	for(var i=0; i < s.length; i++) {
		n=s.charCodeAt(i);
		if (n>=8364) {n = 128;}
		r += String.fromCharCode(n-(5));
	}
	return r;
}



// uncrypt email and linkTo
  
function uncryptMail(s)	{	//
	location.href="mailto:"+uncrypt(s);
}

//Newsletter Mail Checker ----------------------------------------------------------------------------

function check() {
	var mail = document.form.email.value;
    	var status=true;
    	if(mail == "" || mail=="E-Mail" ) {
	  alert("Gib bitte deine email-Adresse an!");
      	  status=false;
  } 	else 	{
      	  at=mail.indexOf("@");
      	  if(mail.indexOf(".", at) < 0){
	    alert("Bitte gültige e-mail Addresse angeben!");
            status=false;
   					}		
   }
   return status;
}

if(top.frames.length > 0)
top.location.href=self.location;

function info(who)	{ //Impressum
window.open("http://www.springfield-shopper.de/Misc/Impressum"+ who +".htm","","width=300, height=300, scrollbars=0, location=0");
			}

//Adventskalender

function history() {
	 window.open("http://www.springfield-shopper.de/Special/History/index.htm","","width=800, height=600, location=0, resizable=1, scrollbars=1, menubar=1");
	}
	
function profil(user){
window.open("http://springfield-shopper.de/profil.php?username="+user,"","width=310, height=260");
}


function hitnrun(){
	 window.open("http://springfield-shopper.de/hitrun/hitrun.htm","","width=620, height=525, scrollbars=1");
	}
	
// Epiguide

function register_help(){
window.open("register_help.htm","","width=400 height=260 menubar=1");
}

function wiki_add(code,cat){
window.open("http://springfield-shopper.de/php/epiguide/wiki_add.php?code="+code+"&catid="+cat,"","width=640, height=520, menubar=1");
}

function wiki_showPic(id,width,height,type){
	
	win = window.open("http://springfield-shopper.de/php/epiguide/wiki_pic.php?id="+id+"&type="+type,"wiki_pic","status=yes,menubar=no,location=no,toolbar=no");
	win.resizeTo(width+16,height+91)
	win.location = "http://springfield-shopper.de/php/epiguide/wiki_pic.php?id="+id+"&type="+type;
	win.focus();

}

function vote(code){
win=window.open("templates/vote_form.php?voteCode="+code,"vote","width=410, height=270");
win.focus();
}


// ------
servicePath = "http://springfield-shopper.de/php/service/";

working = new Image();
working.src = servicePath+"working.gif";

var afiliObj=null;
var quoteObj=null;

function newXObject(){
	var X=null;
	try{
		X=new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				X=new ActiveXObject("Microsoft.XMLHTTP");
			}catch(sc){
					X=null;
			}
		}
	if(!X&&typeof XMLHttpRequest!="undefined"){
			X=new XMLHttpRequest();
			}
return X;
}

function randomQuote(){

	if(quoteObj&&quoteObj.readyState!=0){quoteObj.abort()}
	
	quoteObj = newXObject();
	quoteObj.open("GET","php/service/getQuote.php?t="+new Date().getTime(),true);
	quoteObj.onreadystatechange = quoteHandler;
	quoteObj.send(null);
	
}

function quoteHandler(){

	if(quoteObj.readyState == 4){
		if(quoteObj.status == 200){
			quote = quoteObj.responseText.split("|");
			document.getElementById("quote_text").innerHTML = quote[0];
			document.getElementById("quote_link").innerHTML = "<i>Aus <a href=\"http://springfield-shopper.de/php/epiguide/epiguide.php?show="+quote[2]+"\">"+quote[1]+"</a></i>";
			}
		else{
			document.getElementById("quote_text").innerHTML = "Es ist ein Fehler aufgetreten!";
			document.getElementById("quote_link").innerHTML = "";
			}
	}

}

// -----


var page;
var pages = 99;//null;

function initAfiliTeaser(){

	page = Math.random();
	page = j*100;
	page = Math.round(page);
	afiliTeaser(1);


}

function afiliTeaser(dir){

	if(afiliObj&&afiliObj.readyState!=0){afiliObj.abort()}
	
	
	if(dir == 0) page--;
	else page++;
	
	page = page%pages;
	
	if(page==0) page=pages;
	

	afiliObj = newXObject();
	afiliObj.open("GET",servicePath+"getAfiliTeaserProduct.php?pnr="+page+"&t="+new Date().getTime(),true);
	document.getElementById("afiliTeaserImg").src = working.src;
	afiliObj.onreadystatechange = afiliTeaserHandler;
	afiliObj.send(null);
	
}

function afiliTeaserHandler(){

	if(afiliObj.readyState == 4){
		if(afiliObj.status == 200){
			afiliElements = afiliObj.responseText.split("|");
			//alert(afiliObj.responseText);
			//alert(afiliElements[3]);
			//pages = afiliElements[0];
			document.getElementById("afiliTeaserDescription").innerHTML = afiliElements[1];
			document.getElementById("afiliTeaserImg").src = afiliElements[2];
			document.getElementById("afiliTeaserLink").href = "http://springfield-shopper.de/shop/?aid="+afiliElements[4];
			document.getElementById("afiliTeaserPrice").innerHTML = afiliElements[5];
			}
		else{
			document.getElementById("afiliTeaser").innerHTML = "Es ist ein Fehler aufgetreten!";
			}
	}

}



// -----


function login_window(){
win=window.open("login_windowed.php","login","width=300, height=170");
win.focus();
}

function promocard(filename){
	
	promocard_win = window.open("http://springfield-shopper.de/Pictures/Promocards/picture.php?img="+filename,"promocard","width=640, height=580, scrollbars=1, resizable=1");
	promocard_win.focus();
	
	}
	
function showShopImg(filepath){

	shopImg_win = window.open("http://springfield-shopper.de/shop/showImg.php?img="+filepath,"shopImg","width=640, height=580");
	shopImg_win.focus();
	
	}

function xmas(){
	
	xmaswin = window.open("http://springfield-shopper.de/xmasmarket/index.htm","xmas","width=507, height=800, scrollbars=1");
	xmaswin.focus();
	}
	
