/**
* @var object oJSONHoroskop JSON-Objekt der Wetterdaten
*/
var oJSONHoroskop = null;

/**
* @var object oJSONMessage JSON-Objekt der Topmeldung
*/
var oJSONMessage = null;

/**
* @var array aConfig Konfigurations Array
*/
var aConfig = new Array();

/**
* @var string sView Um welche Anzeige handelt es sich? (Vista, iGoogle, Netvibes, HTML)
*/
var sView = "";

/**
* @var object oHoroskopInterval Interval Objekt für die Wetteraktualisierung
*/
var oHoroskopInterval = "";

/**
* @var object oMessageInterval Interval Objekt für die Topmeldungs Aktualisierung
*/
var oMessageInterval = "";


/**
* Initialisieren des Konfigurationsarrays
*
*/
function mInitConfig() {
	this.sView = "";
	
	//Konfigurations Array bestücken
	
	//versionsnummer
	this.aConfig["sVersionsnummer"] = "v1.00";
	
	// this.aConfig["sServerURL"] = String(this.location).substr(0,String(this.location).indexOf("/horoskop/"))+"/horoskop";
	this.aConfig["sServerURL"] = "http://wiga.t-online.de/horoskop";
	
	this.aConfig["lHoroskopIntervalTime"] = 3600000; //1 Stunde Intervall (Format Millisekunden) 
	this.aConfig["lMessageIntervalTime"] = 900000; // 15*60*1000 = 15 Minuten Intervall (Format Millisekunden) 
	
	this.aConfig["sGetTopMessageFile"] = "gettopmessage.php";
	this.aConfig["sGetPersonalHoroskop"] = "getpersonalhoroskop.php?name={name}&date={date}&time={time}&sex={sex}&city={city}";
	this.aConfig["sGetHoroskop"] = "gethoroskop.php";
	this.aConfig["sSearchLocation"] = "searchlocation.php?city=";
	this.aConfig["sSettingsStandardHoroskop"] = "Widder"; //Widder
	this.aConfig["sSettingsStandardView"] = "daily"; //daily | weekly | personal

	this.aConfig["sSettingsErrorMessage1"] = "Um einen Ort auszuwählen klicken Sie auf den Suche-Button.";
	this.aConfig["sSettingsErrorMessage2"] = "Für ein persönliches Horoskop müssen Sie bitte alle Felder ausfüllen.";
	this.aConfig["sSettingsErrorMessage3"] = "Das Geburtsdatum ist nicht im richtigen Format. Beispiel: 09.06.1972";
	this.aConfig["sSettingsErrorMessage4"] = "Die Geburtszeit ist nicht im richtigen Format. Beispiel: 12.00";
	
	this.aConfig["sSettingsErrorNoAjax"] = "Verbindung zum Server fehlgeschlagen. Bitte Versuchen Sie es zu einem späteren Zeitpunkt wieder.";
	
	this.aConfig["sSettingsErrorCookies"] = "Um die Einstellungen zu speichern müssen Cookies akzeptiert werden.";
	this.aConfig["sSettingsErrorFremdCookies"] = "Um die Einstellungen zu speichern müssen Third-Party (Drittanbieter) Cookies akzeptiert werden.";
	
	this.aConfig["sCookieName"] = "T-OnlineHoroskopWidget"
	
	this.aConfig["sPixelURL"] = "http://intern.passul.t-online.de/cgi-bin/CP/00000000;/CPM/Gadget/iGoogle-Horoskop/index.html";
	this.aConfig["sPixelURL2"] = "http://intern.passul.t-online.de/cgi-bin/CP/00000000;/CPM/Gadget/iGoogle-Horoskop/Schnittstelle/index.html";
	
	this.mInitGadgetConfig();
}

/**
* Standard Settings
*
*/
function mStandardSettings() {
	this.aSettings["sHoroskop"] = this.aConfig["sSettingsStandardHoroskop"];
	this.aSettings["sHoroskopPartner"] = this.aConfig["sSettingsStandardHoroskop"];
	this.aSettings["sShowPartnerHoroskop"] = "false";
	
	this.aSettings["sName"] = ""
	this.aSettings["sDate"] = "";
	this.aSettings["sTime"] = "";
	this.aSettings["sSex"] = "M";  // "W"
	this.aSettings["sCity"] = "";
	
}

/**
* Settings (cookies) laden
*
*/
function mLoadSettings() {
	if(document.cookie != "") {
		var sTrennung = " || ";
		aInfos = document.cookie.split("; ");
		if(aInfos != "") {
			for (var i=0; i<aInfos.length; i++) {
				aInfo = aInfos[i].split("=");
				if (aInfo[0] == this.aConfig["sCookieName"]) {
					aInf = aInfo[1].split(sTrennung);
					//Settings holen
					for (var i in aInf) {
						if (typeof(aInf[i]) != "function") {
							aValue = aInf[i].split("|");
							this.aSettings[aValue[0]] = aValue[1];
						}
					}
					return true;
				}
			}
		} 
	}
	this.mStandardSettings();
	return false;
}

/**
* Per Ajax eine Anfrage an den Server stellen
*
* @param string sFile übergabe des Dateinamens
* @param object oNextMethod Eine Referenz zum Aufruf der nächsten Methode
*/
function mGetDataFromServer(sFile, oNextMethod) {
  
	// Element.replace("Lifestyle", '<div id="Lifestyle">'+sFile+'</div>');
  	
	this.oRequest = new Ajax.Request(this.aConfig["sServerURL"] + "/" + sFile,
	  {
	    method:'get',
	    onSuccess: function(transport){
		  	oNextMethod(transport.responseText);
	    },
	    onFailure: function(){ alert(this.aConfig["sSettingsErrorNoAjax"]) }
	  });
	
}


/**
* Aufruf einer externen URL und schreiben eines Pixels
*
* @param string sContent Übergabe des Contents
*/
function mURLExtern(sURL) {
	sText = '<div id="Pixel">';
	//sText += '<img src="' + this.aConfig["sPixelURL"] + sURL + '" width="1" height="1" border="0" />';
	sText += '<img src="' + this.aConfig["sPixelURL"] + '?d=' + Date.parse(new Date())  + '" width="1" height="1" border="0" />';
	sText += '</div>';
	Element.replace("Pixel", sText);
	
	window.open(sURL, "_blank");
	// location.href = sURL;
}



/**
* show versionsnummer
*
*/
function showVersion() {
  sText = '<div id="Versionnum" class="Versionsnr" onclick="hideVersion();">' + this.aConfig["sVersionsnummer"] + '</div>';
  Element.replace("Versionnum", sText);
  setTimeout("hideVersion()", 5000);
}


/**
* hide versionsnummer
*
*/
function hideVersion() {
  sText = '<div id="Versionnum" class="Versionsnr" onclick="showVersion();">&nbsp;&nbsp;&nbsp;</div>';
  Element.replace("Versionnum", sText);
}

