// JavaScript Document
var seriesName,shortSeriesName,allowAnimations,myCartContent;
var nextpageurl="";
var binbussy=true;
var shortNamesArray = new Array('attaccahome', 'ladder', 'special', 'ensembles', 'composers', 'friends', 'attacca_shop');

currentselect = 1;
var canscroll=true;
function InitScroll(){
 ScrollDiv('divWorks,div1', 'bottomhashz',  300);
}

function centerDiv() {
	availHeight = parseInt(this.window.innerHeight);
	availWidth = parseInt(this.window.innerWidth);
	if(ied) {
		availHeight = parseInt(document.body.clientHeight);
		availWidth = parseInt(document.body.clientWidth);
	}
	restVert = (availHeight-623)/2;
	if(restVert < 0) {
		restVert=0;
		myBody.style.overflow="auto";
	}else{
		myBody.style.overflow="hidden";
	}
	restHor = (availWidth-1024)/2;
	if(restHor < 0) {
		restHor=0;
	}
	restVert=Math.round(restVert);
	restHor=Math.round(restHor);
	marcoTop.style.height = restVert+"px";
	marcoBottom.style.height = restVert+"px";
	marcoBottom.style.top = (restVert+623)+"px";
	marcoLeft.style.width = restHor+"px";
	marcoLeft.style.top = restVert+"px";
	marcoRight.style.width = restHor+"px"; //"100%";
	marcoRight.style.top = restVert+"px";
	marcoRight.style.left = (restHor+1024)+"px";
	contentContainer.style.top = restVert+"px";
	contentContainer.style.left = restHor+"px";
	//if(scrolltimer) {clearTimeout(scrolltimer);}
	//eval('scrolltimer = setTimeout("hideAbdeck()",300)');
	setTimeout("hideAbdeck()",300);
	//divAbdeck.style.display="none";
}	
function hideAbdeck() {
	//alert("here");
	divAbdeck.style.display="none";
}
//script für menu

var scrolltimer=0;
var swapping;

function swapButton(thisButton) {
	//alert(currentButton.id);
	//eval('thisButton.src="images/menu/'+thisButton.id+'_ani.gif"'); // change img to big button
	binbussy==true;
	swapping=true;
	buttonsImgs = new Array(ladder, composers, special, attaccahome, ensembles, contact, friends);
	buttonsDivs = new Array(divbuttonladder, divbuttoncomposers, divbuttonspecial, divbuttonattaccahome, divbuttonensembles, divbuttoncontact, divbuttonfriends);
	buttonsTop = new Array(51, 22, 70, 97, 126, 171, 143);
	buttonsLeft = new Array(32, 101, 159, 91, 23, 82, 150);
	for (var i = 0; i < buttonsDivs.length; i++) {
		eval('buttonsImgs[i].src="images/menu/'+buttonsImgs[i].id+'.gif"'); // reset all buttons
		buttonsDivs[i].style.left=buttonsLeft[i]+"px"; // to normal
		buttonsDivs[i].style.top=buttonsTop[i]+"px"; // positions
		buttonsDivs[i].style.zIndex=245; //change z index to low
	}
	eval('thisButton.src="images/menu/'+thisButton.id+'_ani.gif"'); // change img to big button
	eval('thisButtonStyle=divbutton'+thisButton.id+'.style'); // choosen button
	thisButtonStyle.left=(parseInt(thisButtonStyle.left) - 20)+"px"; // change new big button
	thisButtonStyle.top=(parseInt(thisButtonStyle.top) - 20)+"px"; // to new position
	//thisButtonStyle.width="120px"; // change new big button
	//thisButtonStyle.height="120px"; // change new big button
	//alert(thisButtonStyle.height);
	thisButtonStyle. zIndex=255;
	binbussy=false;
}

function swapBack() {
	if(binbussy==false){
		swapButton(currentButton);
	}
}


//---------------//---------------//---------------//---------------//---------------//
// BESTELLUNG // BESTELLUNG // BESTELLUNG // BESTELLUNG // BESTELLUNG // BESTELLUNG 
//---------------//---------------//---------------//---------------//---------------//

function addToCart(thisCD){ // agregar cd al cookie
	if(!(thisCD==0)){
//---------------//---------------//---------------//---------------//---------------//
// check cookie  // check cookie  // check cookie  // check cookie  // check cookie  
//---------------//---------------//---------------//---------------//---------------//
		var cookieName2 = "einkauf";
		var keks = document.cookie;
		//alert("cookie: "+keks);
		var posName2 = keks.indexOf("; " + cookieName2 + "=");
		if (posName2 == -1) {
		  if (keks.indexOf(cookieName2 + "=") == 0){ posName2 = 0};//else return null;
		}	
		var wertAnfang2 = keks.indexOf("=", posName2)+1;
		var wertEnde2 = keks.indexOf(";", posName2+1);
		if (wertEnde2 == -1){ wertEnde2 = keks.length };
		myCartContent = keks.substring(wertAnfang2, wertEnde2); //esta es la lista de cds para comprar.
		//alert("myCartContent: "+myCartContent);
		if(!(myCartContent=="false")){
			checkDubbel = myCartContent; /*evitar mehrfachbestellung */
			for(i=0;checkDubbel.indexOf("a")>-1;i++){
				var d=checkDubbel.substring(0,checkDubbel.indexOf("a")); //bis zum Trennstrich auslesen
	//alert("thisCD: "+thisCD+" d: "+d);
				if(d==thisCD){
				alert("You have already selected this CD. If you want to add more of the same, please use the selector by the order form");
				return;
				}
				checkDubbel=checkDubbel.substr(checkDubbel.indexOf("|")+1,checkDubbel.length); /*  gelesenes  wegschneiden*/
	//alert("checkDubbel: "+checkDubbel);
			}
		}
		var wert="";
		wert += thisCD+"a1|";
		//alert("wert: "+wert);
		var schonBestellt=myCartContent;
		//alert("schonBestellt: "+schonBestellt);
		if(schonBestellt==""){
			document.cookie = "allowAnimated="+allowAnimations+";";
			document.cookie = "einkauf="+wert+";";
			//alert("A: "+document.cookie);
		}else{
			document.cookie = "allowAnimated="+allowAnimations+";";
			document.cookie = "einkauf="+schonBestellt+wert+";";
			//alert("B: "+document.cookie);
		}
	alert("This CD is now in your Shopping Cart.");
	//alert(document.cookie);
	}
}
