function URLParam() {
	var iServerTypeLaenge = sServerType.length;
   var sFormName = window.document.GamesForm;

  // uebertragene Parameter ermitteln z.B. ?package=4_6
  // tatsaechliche Slot/Laufzeit-Parameter auslesen
	var sParamIst = window.location.search.substr(9); // ab ?package=
	
	// Wenn Parameter uebergeben werden...
	if (sParamIst != "" ) {
		// aufsplitten des Strings  4_6
		aParamIst = sParamIst.split("_");
		
		var iParamSlot = (aParamIst[0]); // Slot-Anzahl = 4
		var iParamVlz = (aParamIst[1]);  // Vertragslaufzeit in Monate = 6 
      
		// Pruefen ob Cookie gesetzt ist
		// Cookie dient als Pruefelement 
		// In Abhaengigkeit vom Pruefergebnis, darf die Funktion ausgefuehrt werden oder nicht
		if(document.cookie) {
			
		 var sCookieWert = "";
		 var sCookieWertStart = document.cookie.indexOf("=") + 1;
		 var sCookieWertEnde = document.cookie.indexOf(";");
		    // Auslesen des Cookie-Wertes
			 if (sCookieWertEnde == -1) {
			 sCookieWertEnde = document.cookie.length;
			 sCookieWert = document.cookie.substring(sCookieWertStart, sCookieWertEnde);
			 sCookieWert = sCookieWert.substr(iServerTypeLaenge+1); 
			 }
			 // Wenn der Cookie-Wert der Parameter-Uebergabe entspricht
			 // soll Default-Anzeige erfolgen (z.B. bei einem Reload der Seite)
			 if (sCookieWert == sParamIst) {
				// Umsetzen der option/selected darf nicht erfolgen
				// Default-Anzeige erfolgt - wie ohne Parameter-Uebergabe
				var iRunFirst = 1;
			 // Wenn der Cookie-Wert nicht der Parameter-Uebergabe entspricht
			 // wird der aktuelle Cookie-Wert ueberschrieben und die Anzeige entsprechend angepasst	
			 } else {
				document.cookie = "GameServerPackage="+sServerType+"_"+sParamIst;
				// Umsetzen der option/selected darf erfolgen
				var iRunFirst = 0;
			 }
			 
		// Wenn kein Cookie vorhanden und Erstbesuch dann Cookie setzen	 
		} else {
		  document.cookie = "GameServerPackage="+sServerType+"_"+sParamIst;
		  // Umsetzen der option/selected darf erfolgen
		  var iRunFirst = 0;
		}
		
		// Umsetzen der option/selected erfolgt 
		if(iRunFirst == 0) {
		  // Umsetzen der option/selected fuer SLOTS erfolgt	
		  for (iLauf = 0; iLauf < sFormName.slots.length; ++iLauf) {
			 if (sFormName.slots.options[iLauf].value != iParamSlot){ continue; }
				sFormName.slots.options[iLauf].selected = true;
		  }
		  // Umsetzen der option/selected fuer LAUFZEIT erfolgt
		  for (iLauf = 0; iLauf < sFormName.laufzeit.length; ++iLauf) {
			 if (sFormName.laufzeit.options[iLauf].value != iParamVlz){ continue; }
				sFormName.laufzeit.options[iLauf].selected = true;
		  }
		}  
	 }
	
}


function popup(url,name,params) {
    var sizeX = 0;
    var sizeY = 0;
    var winX = screen.availWidth;
    var winY = screen.availHeight;
    var tmpArray = params.split(',');
    for (var i = 0; i < tmpArray.length; i++) {
        if (tmpArray[i].indexOf('width') != -1) {
            var tmpArray2 = tmpArray[i].split('=');
            sizeX = tmpArray2[1];
        }
        if (tmpArray[i].indexOf('height') != -1) {
            var tmpArray2 = tmpArray[i].split('=');
            sizeY = tmpArray2[1];
        }
    }
    var centerX = Math.round(winX / 2 - sizeX / 2);
    var centerY = Math.round(winY / 2 - sizeY / 2);
    params += ',left=' + centerX + ',top=' + centerY;
    var pWindow = open(url,name,params).focus();
}

function openLink(o) {
    var link = o.getElementsByTagName("a")[o.getElementsByTagName("a").length-1];
    if(!link.onclick) location.href=link.href;
    else {link.onclick();}
}


var bError = false; // Error-Meldung on/off

function error(sErrorText) {
  if (bError != true) {return; }
  if (! sErrorText)  { sErrorText = 'unknown error'; }
  alert(sErrorText);
}//error

var aValueListPublic = new Array(
  '4|3|pc_6_99|<input type="hidden" name="Addon" value="SLOT_4_BUNDLE" />|<input type="hidden" name="Product" value="DEDI_GAMEPUBLIC3" />|Einrichtungsgeb&uuml;hr: 9,90 &euro;',
  '8|3|pc_12_99|<input type="hidden" name="Addon" value="SLOT_8_BUNDLE" />|<input type="hidden" name="Product" value="DEDI_GAMEPUBLIC3" />|Einrichtungsgeb&uuml;hr: 9,90 &euro;',
  '12|3|pc_18_99_norm|<input type="hidden" name="Addon" value="SLOT_12_BUNDLE" />|<input type="hidden" name="Product" value="DEDI_GAMEPUBLIC3" />|Einrichtungsgeb&uuml;hr: 9,90 &euro;',
  '16|3|pc_24_99|<input type="hidden" name="Addon" value="SLOT_16_BUNDLE_AKTION201010" />|<input type="hidden" name="Product" value="DEDI_GAMEPUBLIC3_SLOT16" />|Keine Einrichtungsgeb&uuml;hr',
  '20|3|pc_30_99_op|<input type="hidden" name="Addon" value="SLOT_20_BUNDLE" />|<input type="hidden" name="Product" value="DEDI_GAMEPUBLIC3" />|Einrichtungsgeb&uuml;hr: 9,90 &euro;',
  '24|3|pc_36_99_op|<input type="hidden" name="Addon" value="SLOT_24_BUNDLE" />|<input type="hidden" name="Product" value="DEDI_GAMEPUBLIC3" />|Einrichtungsgeb&uuml;hr: 9,90 &euro;',
  '28|3|pc_42_99_op|<input type="hidden" name="Addon" value="SLOT_28_BUNDLE" />|<input type="hidden" name="Product" value="DEDI_GAMEPUBLIC3" />|Einrichtungsgeb&uuml;hr: 9,90 &euro;',
  '32|3|pc_48_99_op|<input type="hidden" name="Addon" value="SLOT_32_BUNDLE" />|<input type="hidden" name="Product" value="DEDI_GAMEPUBLIC3" />|Einrichtungsgeb&uuml;hr: 9,90 &euro;',
  '4|6|pc_6_99|<input type="hidden" name="Addon" value="SLOT_4_BUNDLE" />|<input type="hidden" name="Product" value="DEDI_GAMEPUBLIC6" />|Keine Einrichtungsgeb&uuml;hr',	
  '8|6|pc_12_99|<input type="hidden" name="Addon" value="SLOT_8_BUNDLE" />|<input type="hidden" name="Product" value="DEDI_GAMEPUBLIC6" />|Keine Einrichtungsgeb&uuml;hr',
  '12|6|pc_18_99|<input type="hidden" name="Addon" value="SLOT_12_BUNDLE" />|<input type="hidden" name="Product" value="DEDI_GAMEPUBLIC6" />|Keine Einrichtungsgeb&uuml;hr',	
  '16|6|pc_12_99_aktion|<input type="hidden" name="Addon" value="SLOT_16_BUNDLE_AKTION200907" />|<input type="hidden" name="Product" value="DEDI_GAMEPUBLIC6_SLOT16" />|Keine Einrichtungsgeb&uuml;hr',
  '20|6|pc_30_99|<input type="hidden" name="Addon" value="SLOT_20_BUNDLE" />|<input type="hidden" name="Product" value="DEDI_GAMEPUBLIC6" />|Keine Einrichtungsgeb&uuml;hr',	
  '24|6|pc_36_99|<input type="hidden" name="Addon" value="SLOT_24_BUNDLE" />|<input type="hidden" name="Product" value="DEDI_GAMEPUBLIC6" />|Keine Einrichtungsgeb&uuml;hr',
  '28|6|pc_42_99|<input type="hidden" name="Addon" value="SLOT_28_BUNDLE" />|<input type="hidden" name="Product" value="DEDI_GAMEPUBLIC6" />|Keine Einrichtungsgeb&uuml;hr',
  '32|6|pc_48_99|<input type="hidden" name="Addon" value="SLOT_32_BUNDLE" />|<input type="hidden" name="Product" value="DEDI_GAMEPUBLIC6" />|Keine Einrichtungsgeb&uuml;hr'
);//aValueListPublic

var aValueListClan = new Array(
  '4|3|pc_6_99|<input type="hidden" name="Addon" value="SLOT_4_BUNDLE" />|<input type="hidden" name="Product" value="DEDI_GAMECLAN3" />|Einrichtungsgeb&uuml;hr: 9,90 &euro;',
  '8|3|pc_12_99|<input type="hidden" name="Addon" value="SLOT_8_BUNDLE" />|<input type="hidden" name="Product" value="DEDI_GAMECLAN3" />|Einrichtungsgeb&uuml;hr: 9,90 &euro;',
  '12|3|pc_18_99_clan|<input type="hidden" name="Addon" value="SLOT_12_BUNDLE" />|<input type="hidden" name="Product" value="DEDI_GAMECLAN3" />|Einrichtungsgeb&uuml;hr: 9,90 &euro;',
  '16|3|pc_24_99|<input type="hidden" name="Addon" value="SLOT_16_BUNDLE_AKTION201010" />|<input type="hidden" name="Product" value="DEDI_GAMECLAN3_SLOT16" />|Keine Einrichtungsgeb&uuml;hr',
  '20|3|pc_30_99_clan_2|<input type="hidden" name="Addon" value="SLOT_20_BUNDLE" />|<input type="hidden" name="Product" value="DEDI_GAMECLAN3" />|Einrichtungsgeb&uuml;hr: 9,90 &euro;',
  '24|3|pc_36_99_op|<input type="hidden" name="Addon" value="SLOT_24_BUNDLE" />|<input type="hidden" name="Product" value="DEDI_GAMECLAN3" />|Einrichtungsgeb&uuml;hr: 9,90 &euro;',
  '28|3|pc_42_99_op|<input type="hidden" name="Addon" value="SLOT_28_BUNDLE" />|<input type="hidden" name="Product" value="DEDI_GAMECLAN3" />|Einrichtungsgeb&uuml;hr: 9,90 &euro;',
  '32|3|pc_48_99_op|<input type="hidden" name="Addon" value="SLOT_32_BUNDLE" />|<input type="hidden" name="Product" value="DEDI_GAMECLAN3" />|Einrichtungsgeb&uuml;hr: 9,90 &euro;',
  '4|6|pc_6_99|<input type="hidden" name="Addon" value="SLOT_4_BUNDLE" />|<input type="hidden" name="Product" value="DEDI_GAMECLAN6" />|Keine Einrichtungsgeb&uuml;hr',
   '8|6|pc_12_99 |<input type="hidden" name="Addon" value="SLOT_8_BUNDLE" />|<input type="hidden" name="Product" value="DEDI_GAMECLAN6" />|Keine Einrichtungsgeb&uuml;hr',
	'12|6|pc_18_99|<input type="hidden" name="Addon" value="SLOT_12_BUNDLE" />|<input type="hidden" name="Product" value="DEDI_GAMECLAN6" />|Keine Einrichtungsgeb&uuml;hr',
'16|6|pc_12_99_aktion|<input type="hidden" name="Addon" value="SLOT_16_BUNDLE_GS" />|<input type="hidden" name="Product" value="DEDI_GAMECLAN6_SLOT16" />|Keine Einrichtungsgeb&uuml;hr',
  '20|6|pc_30_99_clan|<input type="hidden" name="Addon" value="SLOT_20_BUNDLE" />|<input type="hidden" name="Product" value="DEDI_GAMECLAN6" />|Keine Einrichtungsgeb&uuml;hr',
  '24|6|pc_36_99|<input type="hidden" name="Addon" value="SLOT_24_BUNDLE" />|<input type="hidden" name="Product" value="DEDI_GAMECLAN6" />|Keine Einrichtungsgeb&uuml;hr',
  '28|6|pc_42_99|<input type="hidden" name="Addon" value="SLOT_28_BUNDLE" />|<input type="hidden" name="Product" value="DEDI_GAMECLAN6" />|Keine Einrichtungsgeb&uuml;hr',
  '32|6|pc_48_99|<input type="hidden" name="Addon" value="SLOT_32_BUNDLE" />|<input type="hidden" name="Product" value="DEDI_GAMECLAN6" />|Keine Einrichtungsgeb&uuml;hr'
);//aValueListClan

function calcFee() {

  if(! window.document.getElementById('laufzeit')) { error("laufzeit not found"); return; }
  if(! window.document.getElementById('slots')) { error("slots not found"); return; }
  if(! window.document.getElementById('sum')) { error("sum not found"); return; }
  if(! window.document.getElementById('hideAddon')) { error("hideAddon not found"); return; }
  if(! window.document.getElementById('hideProduct')) { error("hideProduct not found"); return; }
  if(! window.document.getElementById('SetupTXT')) { error("SetupTXT not found"); return; }
   
  if(isClan==false) {
	  
	URLParam();	
   
	for (var iLauf in aValueListPublic) {
     var aLauf = aValueListPublic[iLauf].split('|');
     if (aLauf[0] != window.document.getElementById('slots').value || 
       aLauf[1] != window.document.getElementById('laufzeit').value) { continue; }
     window.document.getElementById('sum').className = aLauf[2];
     window.document.getElementById('hideAddon').innerHTML = aLauf[3];
	  window.document.getElementById('hideProduct').innerHTML = aLauf[4];
	  window.document.getElementById('SetupTXT').innerHTML = aLauf[5];
     return;
   }
  }
  
  if(isClan==true) {
	  
	URLParam();	 
		
   for (var iLauf in aValueListClan) {
     var aLauf = aValueListClan[iLauf].split('|');
     if (aLauf[0] != window.document.getElementById('slots').value || 
       aLauf[1] != window.document.getElementById('laufzeit').value) { continue; }
     window.document.getElementById('sum').className = aLauf[2];
     window.document.getElementById('hideAddon').innerHTML = aLauf[3];
     window.document.getElementById('hideProduct').innerHTML = aLauf[4];
	  window.document.getElementById('SetupTXT').innerHTML = aLauf[5];
     return;
   }
  }    
  error("no solution found");
}//calcFee

