var isIE7  = (navigator.appVersion.indexOf("MSIE 7") != -1) ? true : false;

//check for flash
var flashversionMin = 8;
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;

if (plugin) {
	for (f = 0; f < 20; f++) {
		var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
		if (plugin.description.indexOf(f+".")>=0){
			flashversion = f;
			
			if (flashversion >= flashversionMin){
				plugin = true;
				break;
			}
		}
	}
}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.userAgent.indexOf("Windows 95")>=0 || navigator.userAgent.indexOf("Windows 98")>=0 || navigator.userAgent.indexOf("Windows NT")>=0)) {
	document.write('<SCRIPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('plugin = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.'+flashversionMin+'")))\n');
	document.write('</SCRIPT\> \n'); 
}

function check_flash(filename) {
	var requiredMajorVersion = 8;
	var requiredMinorVersion = 0;
	var requiredRevision = 0;

	var hasProductInstall = DetectFlashVer(6, 0, 65);

	var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);

	if ( hasProductInstall && !hasReqestedVersion ) {
		var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
		var MMredirectURL = window.location;
		document.title = document.title.slice(0, 47) + " - Flash Player Installation";
		var MMdoctitle = document.title;

		AC_FL_RunContent(
			"src", "image/flash_install/playerProductInstall",
			"FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"",
			"width", "550",
			"height", "300",
			"align", "middle",
			"id", "detectionExample",
			"quality", "high",
			"bgcolor", "#3A6EA5",
			"name", "detectionExample",
			"wmode", "transparent",
			"allowScriptAccess","sameDomain",
			"type", "application/x-shockwave-flash",
			"pluginspage", "http://www.adobe.com/go/getflashplayer"
		);
	}
}

function play_flash(filename, w, h, o) {
	var requiredMajorVersion = 8;
	var requiredMinorVersion = 0;
	var requiredRevision = 0;

	var hasProductInstall = DetectFlashVer(6, 0, 65);

	var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);

	if (hasReqestedVersion) {
		AC_FL_RunContent(
				"src", filename,
				"width", w,
				"height", h,
				"align", "middle",
				"id", "detectionExample",
				"quality", "high",
				"bgcolor", "",
				"name", "detectionExample",
				"wmode", "transparent",
				"allowScriptAccess","sameDomain",
				"type", "application/x-shockwave-flash",
				'codebase', 'http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab',
				"pluginspage", "http://www.adobe.com/go/getflashplayer"
		);
	} else {
		document.write(o);
	}
}

/* functions are depending on prototype ! */
function extend_tab() {
	var my_div = $("features");
	if (my_div) {
		my_div.style.display = "block";
		fx_extend_tab.custom(135, 549);
	}
}
function shrink_tab() {
	var my_div = $("features");
	if (my_div) {
		fx_shrink_tab.custom(549, 135);
	}
}
function hide_tab() {
	hide_div("features");
}
function hide_div(e1) {
	var my_div = $(e1);
	if (my_div) my_div.style.display = "none";
}
function show_div(e1) {
	var my_div = $(e1);
	if (my_div) my_div.style.display = "block";
}
function toggle_news(n) {
	o = activenews;
	activenews = n;
	for (var x = 1; x <= 5; x++) {
		if (x != n) {
	    		hide_div("start_topthema"+x);
			fx_newsbox[x].setOpacity(0.5);
		}
	}
	fx_newsbox[n].setOpacity(1);
	show_div("start_topthema"+n);
}
/* Align y position from e2 to e1 */
function overlay12y(e1, e2) {
	var my_e1 = $(e1);
	var my_e2 = $(e2);
	if (my_e1) {
		var ypos = Position.cumulativeOffset(my_e1)[1];
		if ((isIE) && (!isIE7)) ypos = ypos-210; /* Depends on ac_oetags.js */
		if (my_e2) my_e2.style.top = ypos+"px";
	}
}
/* copy content from e1 to e2 */
function copy12(e1, e2) {
	var my_e1 = $(e1);
	var my_e2 = $(e2);
	if ((my_e1) && (my_e2)) {
		my_e2.innerHTML = my_e1.innerHTML;
	}
}
var ohbehave = {
	'img#ext_tabs_drag' : function(el) { el.onclick = function() { extend_tab(); }},
	'img#ext_tab_drag' : function(el) { el.onclick = function() { shrink_tab(); }}
};

var ohbehave_home = {
	'div#start_topthema_list1' : function(el) { el.onmouseover = function() { toggle_news(1); }},
	'div#start_topthema_list2' : function(el) { el.onmouseover = function() { toggle_news(2); }},
	'div#start_topthema_list3' : function(el) { el.onmouseover = function() { toggle_news(3); }},
	'div#start_topthema_list4' : function(el) { el.onmouseover = function() { toggle_news(4); }},
	'div#start_topthema_list5' : function(el) { el.onmouseover = function() { toggle_news(5); }}
};

var activenews = 1;
var fx_news = new Array("");
var fx_newsbox = new Array("");

window.onload = function() {
	if ($("ext_cut")) {
		fx_extend_tab = new fx.Width("ext_scale", {duration: 300});
		fx_shrink_tab = new fx.Width("ext_scale", {duration: 300, onComplete: function() { hide_tab(); }});
		overlay12y("ext_tabs", "features");
		copy12("ext_cut", "ext_scale");
		shrink_tab();
		Behaviour.register(ohbehave);
	}
	if ($("start_topthema_news")) {
		for (var x = 1; x <= 5; x++) {
			fx_newsbox[x] = new fx.Opacity("start_topthema_list"+x, {duration: 300});
			fx_news[x] = new fx.Opacity("start_topthema"+x, {duration: 300});
			if (x != activenews) {
				fx_newsbox[x].setOpacity(0.5);
				// fx_news[x].hide();
			}
		}
		Behaviour.register(ohbehave_home);
	}
	Behaviour.apply();
}

function getobject(id) {
	var elmID;

	if(document.getElementById) {elmID = document.getElementById(id);}
    else if(document.all) {elmID = document.all[id];}
    else if(document.layers) {elmID = this._getLayer(id);}
    else if(document.forms) {
        if(document.forms[id]) {elmID = document.forms[id];}
        else {
            for(var i=0; i<document.forms.length; i++) {
                if(document.forms[i][id]) {
                    elmID = document.forms[i][id];
                    break;
                }
            }
        }
    }
    else {elmID = null;}

    return elmID;
}

