var Feature = Class.create();

Feature.prototype = {
	initialize: function()
	{
		this._featureId = "FlashApplication";
		//this._featureId = "featureLayer";
		
		var version;
		var fVersion = deconcept.SWFObjectUtil.getPlayerVersion()["major"];
		if(fVersion >= 8){			//special resources for flash 8 available
			version = 8;
		}

		else{
			version = 0;			//not supported flash version -> show non-flash/non-javascript version
		}

		if(version != 0){
			this.flashVersion = version;
			this.initFeature();
		}
	},
	initFeature: function()
	{
// ---------- change by publicis ---------- 
		// DELETE for stage/live - Version
/**/
		var FEATURE_NAME = "science_express";

		var rsLang	= "de";
		var rsPath	= encodeURIComponent("http://stage.conrad-caine.com/siemens_com/entry/cc/features/science_express/all2/de/readspeaker/");
		var rsCustomer	= "1003388";
		var rsUrl	= "http://asp.readspeaker.net/cgi-bin/siemensrsone";
/**/

		//  vars for contact/feedbackform
		//var formmailerUrl	= "http://siemens.com/entry/framework/pub/script/formmailer.php";
		var formmailerUrl	= "/science_express/formmailer.php";
		var formmailerReceiver	= "28";
		var feedbackReceiver	= "28";

// ---------- change by ccaine ---------- 
		// vars for flash
		var swfLang	= "de";
		var localPath	= "";
		var globalPath	= "../../../science_express/all/";	
		var flvPath	= "../../../science_express/all/flv/" + this.flashVersion + "/";
		var imgPath	= "../../../science_express/all/img/";
		// 	/science_express/all2/de/
		//	/blatt/d_wz_microsite
		//	/alias/Data_%26_Facts/994278
		var sectionParameter = "";
		var section = getUrlParameter("section");
		if(section != null && (section == "index" || section == "map" )){
			sectionParameter = "&section=" + section;
		}else{
			sectionParameter = "";
		}

// ---------- declared by thieleman/spektrum ---------- 
		var s_account = "siemenscc.de,siemenscc-com-prod";
		var customerId = "";
		
		var isFirefox = navigator.appName == "Netscape" ? true : false;
		var logoUrl = "http://www.siemens.com";

		var app = new SWFObject("../../../science_express/all/swf/main.swf", this._featureId , "987", "393", this.flashVersion + ",0,0,0", "#ffffff");
		app.addParam("quality", "high");
		app.addParam("wmode", "transparent");
		app.addParam("base", "/science_express/all/de/");
		app.addParam("menu", "false");
		app.addParam("swliveconnect", "true");
		app.addParam("allowScriptAccess", "always");
		app.addParam("FlashVars", "s_account=" + s_account + "&slider=false&isFirefox=" + isFirefox +  "&feedbackReceiver=" + feedbackReceiver + "&customerId=" + customerId + "&formmailerUrl=" + formmailerUrl + "&formmailerReceiver=" + formmailerReceiver + "&version=" + this.flashVersion + "&language=" + swfLang + "&localPath=" + localPath + "&globalPath=" + globalPath + "&logoUrl=" + logoUrl + "&imgPath=" + imgPath + "&flvPath=" + flvPath + "&featureName=" + FEATURE_NAME + sectionParameter);
		app.write("headervisual-zone");
	},
	stopVideo: function() { 
		var _flashObj = $(this._featureId); 
	    if(_flashObj) _flashObj.SetVariable('stopVideo','true');
	},
	looseFocus: function() {
		$(this._featureId).blur();
	},
	getFeatureId: function() {
		return this._featureId;
	}
}


// ---------- inserted by thieleman@spektrum.com ---------- 
// ---------- source: http://w1.siemens.com/entry/cc/framework/pub/script/common.js
function getUrlParameter(asName, url){
	var lsURL = ((typeof(url) == 'undefined') || (url.length == 0)) ? window.location.href : url;
	loU = lsURL.split("?");
	if (loU.length>1){
		var loallPm = loU[1].split("&");
		for (var i=0; i<loallPm.length; i++){
			var loPm = loallPm[i].split("=");
			if (loPm[0]==asName){
				if (loPm.length>1){
					return loPm[1];
				}
			}
		}
	}
	else{
		return null;
	}
}
// ---------------------------------------------------------

// ---------- inserted by thieleman@spektrum.com ---------- 
// ---------- source: http://w1.siemens.com/entry/cc/framework/vi/js/script.js
Object.extend(Event, {
  _domReady : function() {
    if (arguments.callee.done) return;
    arguments.callee.done = true;

    if (this._timer)  clearInterval(this._timer);

    this._readyCallbacks.each(function(f) { f() });
    this._readyCallbacks = null;
},
  onDOMReady : function(f) {
    if (!this._readyCallbacks) {
      var domReady = this._domReady.bind(this);

      if (document.addEventListener)
        document.addEventListener("DOMContentLoaded", domReady, false);

        /*@cc_on @*/
        /*@if (@_win32)
            document.write("<script id=__ie_onload defer src=//:><\/script>");
            document.getElementById("__ie_onload").onreadystatechange = function() {
                if (this.readyState == "complete") domReady();
            };
        /*@end @*/

        if (/WebKit/i.test(navigator.userAgent)) {
          this._timer = setInterval(function() {
            if (/loaded|complete/.test(document.readyState)) domReady();
          }, 10);
        }

        Event.observe(window, "load", domReady);
        Event._readyCallbacks =  [];
    }
    Event._readyCallbacks.push(f);
  }
});
// --------------------------------------------------------- 


var featureFlash;
/*
function init() {
	featureFlash = new Feature();
}
window.onload = init;
*/

Event.onDOMReady(function() {
	/// initialize feature
	featureFlash = new Feature();
});
