/// <reference path="../../../Scripts/jquery-vsdoc.js" />
/**
* SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
*
* SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
* http://www.opensource.org/licenses/mit-license.php
*
*/
if (typeof deconcept == "undefined") { var deconcept = new Object(); } if (typeof deconcept.util == "undefined") { deconcept.util = new Object(); } if (typeof deconcept.SWFObjectUtil == "undefined") { deconcept.SWFObjectUtil = new Object(); } deconcept.SWFObject = function (_1, id, w, h, _5, c, _7, _8, _9, _a) { if (!document.getElementById) { return; } this.DETECT_KEY = _a ? _a : "detectflash"; this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY); this.params = new Object(); this.variables = new Object(); this.attributes = new Array(); if (_1) { this.setAttribute("swf", _1); } if (id) { this.setAttribute("id", id); } if (w) { this.setAttribute("width", w); } if (h) { this.setAttribute("height", h); } if (_5) { this.setAttribute("version", new deconcept.PlayerVersion(_5.toString().split("."))); } this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion(); if (!window.opera && document.all && this.installedVer.major > 7) { deconcept.SWFObject.doPrepUnload = true; } if (c) { this.addParam("bgcolor", c); } var q = _7 ? _7 : "high"; this.addParam("quality", q); this.setAttribute("useExpressInstall", false); this.setAttribute("doExpressInstall", false); var _c = (_8) ? _8 : window.location; this.setAttribute("xiRedirectUrl", _c); this.setAttribute("redirectUrl", ""); if (_9) { this.setAttribute("redirectUrl", _9); } }; deconcept.SWFObject.prototype = { useExpressInstall: function (_d) { this.xiSWFPath = !_d ? "expressinstall.swf" : _d; this.setAttribute("useExpressInstall", true); }, setAttribute: function (_e, _f) { this.attributes[_e] = _f; }, getAttribute: function (_10) { return this.attributes[_10]; }, addParam: function (_11, _12) { this.params[_11] = _12; }, getParams: function () { return this.params; }, addVariable: function (_13, _14) { this.variables[_13] = _14; }, getVariable: function (_15) { return this.variables[_15]; }, getVariables: function () { return this.variables; }, getVariablePairs: function () { var _16 = new Array(); var key; var _18 = this.getVariables(); for (key in _18) { _16[_16.length] = key + "=" + _18[key]; } return _16; }, getSWFHTML: function () { var _19 = ""; if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { if (this.getAttribute("doExpressInstall")) { this.addVariable("MMplayerType", "PlugIn"); this.setAttribute("swf", this.xiSWFPath); } _19 = "<embed type=\"application/x-shockwave-flash\" src=\"" + this.getAttribute("swf") + "\" width=\"" + this.getAttribute("width") + "\" height=\"" + this.getAttribute("height") + "\" style=\"" + this.getAttribute("style") + "\""; _19 += " id=\"" + this.getAttribute("id") + "\" name=\"" + this.getAttribute("id") + "\" "; var _1a = this.getParams(); for (var key in _1a) { _19 += [key] + "=\"" + _1a[key] + "\" "; } var _1c = this.getVariablePairs().join("&"); if (_1c.length > 0) { _19 += "flashvars=\"" + _1c + "\""; } _19 += "/>"; } else { if (this.getAttribute("doExpressInstall")) { this.addVariable("MMplayerType", "ActiveX"); this.setAttribute("swf", this.xiSWFPath); } _19 = "<object id=\"" + this.getAttribute("id") + "\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"" + this.getAttribute("width") + "\" height=\"" + this.getAttribute("height") + "\" style=\"" + this.getAttribute("style") + "\">"; _19 += "<param name=\"movie\" value=\"" + this.getAttribute("swf") + "\" />"; var _1d = this.getParams(); for (var key in _1d) { _19 += "<param name=\"" + key + "\" value=\"" + _1d[key] + "\" />"; } var _1f = this.getVariablePairs().join("&"); if (_1f.length > 0) { _19 += "<param name=\"flashvars\" value=\"" + _1f + "\" />"; } _19 += "</object>"; } return _19; }, write: function (_20) { if (this.getAttribute("useExpressInstall")) { var _21 = new deconcept.PlayerVersion([6, 0, 65]); if (this.installedVer.versionIsValid(_21) && !this.installedVer.versionIsValid(this.getAttribute("version"))) { this.setAttribute("doExpressInstall", true); this.addVariable("MMredirectURL", escape(this.getAttribute("xiRedirectUrl"))); document.title = document.title.slice(0, 47) + " - Flash Player Installation"; this.addVariable("MMdoctitle", document.title); } } if (this.skipDetect || this.getAttribute("doExpressInstall") || this.installedVer.versionIsValid(this.getAttribute("version"))) { var n = (typeof _20 == "string") ? document.getElementById(_20) : _20; n.innerHTML = this.getSWFHTML(); if (!(navigator.plugins && navigator.mimeTypes.length)) window[this.getAttribute('id')] = document.getElementById(this.getAttribute('id')); return true; } else { if (this.getAttribute("redirectUrl") != "") { document.location.replace(this.getAttribute("redirectUrl")); } } return false; } }; deconcept.SWFObjectUtil.getPlayerVersion = function () { var _23 = new deconcept.PlayerVersion([0, 0, 0]); if (navigator.plugins && navigator.mimeTypes.length) { var x = navigator.plugins["Shockwave Flash"]; if (x && x.description) { _23 = new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split(".")); } } else { if (navigator.userAgent && navigator.userAgent.indexOf("Windows CE") >= 0) { var axo = 1; var _26 = 3; while (axo) { try { _26++; axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + _26); _23 = new deconcept.PlayerVersion([_26, 0, 0]); } catch (e) { axo = null; } } } else { try { var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"); } catch (e) { try { var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"); _23 = new deconcept.PlayerVersion([6, 0, 21]); axo.AllowScriptAccess = "always"; } catch (e) { if (_23.major == 6) { return _23; } } try { axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); } catch (e) { } } if (axo != null) { _23 = new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(",")); } } } return _23; }; deconcept.PlayerVersion = function (_29) { this.major = _29[0] != null ? parseInt(_29[0]) : 0; this.minor = _29[1] != null ? parseInt(_29[1]) : 0; this.rev = _29[2] != null ? parseInt(_29[2]) : 0; }; deconcept.PlayerVersion.prototype.versionIsValid = function (fv) { if (this.major < fv.major) { return false; } if (this.major > fv.major) { return true; } if (this.minor < fv.minor) { return false; } if (this.minor > fv.minor) { return true; } if (this.rev < fv.rev) { return false; } return true; }; deconcept.util = { getRequestParameter: function (_2b) { var q = document.location.search || document.location.hash; if (_2b == null) { return q; } if (q) { var _2d = q.substring(1).split("&"); for (var i = 0; i < _2d.length; i++) { if (_2d[i].substring(0, _2d[i].indexOf("=")) == _2b) { return _2d[i].substring((_2d[i].indexOf("=") + 1)); } } } return ""; } }; deconcept.SWFObjectUtil.cleanupSWFs = function () { var _2f = document.getElementsByTagName("OBJECT"); for (var i = _2f.length - 1; i >= 0; i--) { _2f[i].style.display = "none"; for (var x in _2f[i]) { if (typeof _2f[i][x] == "function") { _2f[i][x] = function () { }; } } } }; if (deconcept.SWFObject.doPrepUnload) { if (!deconcept.unloadSet) { deconcept.SWFObjectUtil.prepUnload = function () { __flash_unloadHandler = function () { }; __flash_savedUnloadHandler = function () { }; window.attachEvent("onunload", deconcept.SWFObjectUtil.cleanupSWFs); }; window.attachEvent("onbeforeunload", deconcept.SWFObjectUtil.prepUnload); deconcept.unloadSet = true; } } if (!document.getElementById && document.all) { document.getElementById = function (id) { return document.all[id]; }; } var getQueryParamValue = deconcept.util.getRequestParameter; var FlashObject = deconcept.SWFObject; var SWFObject = deconcept.SWFObject;


//Sperre dass bei einem Click auf ein Mediaprofile die Tabelle und die landauswahl verändert wird
var m_bLockCountry = false; //Endloos Loop verhindern
var m_iToggleSpeed = 0;
var m_iMinStringLenSearch = 1; //minimale Stringlänge zum suchen

//////////////////////////////////////////////////////////////////////////////////////////
// Functions that control the map ////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
// EXPORT AS IMAGE ///////////////////////////////////////////////////////////////////////
// flashMovie.exportImage([file_name]) 
// This function will start the process of exporting the chart as an image. The file_name
// is a name of a file to which image data will be posted (files provided in the download 
// package are export.php and export.aspx). The file_name is optional and can be set in 
// the <export_as_image><file> setting.
function exportImage() {
	flashMovie.exportImage('export.aspx');
}

// PRINT /////////////////////////////////////////////////////////////////////////////////
// flashMovie.print()
// This function will print the chart. 
function print() {
	flashMovie.print();
}

// PRINT AS BITMAP ///////////////////////////////////////////////////////////////////////
// flashMovie.printAsBitmap()
function printAsBitmap() {
	flashMovie.printAsBitmap();
}

//////////////////////////////////////////////////////////////////////////////////////////
// Functions that are called by the chart ////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////  

// MAP COMPLETED /////////////////////////////////////////////////////////////////////////   
// amMapCompleted(chart_id)
// This function is called when the map is fully loaded and initialized.
function amMapCompleted(map_id) {
	// get the flash object into "flashMovie" variable   
	flashMovie = document.getElementById(map_id);
	// tell the field with id "mapfinished" that this chart was initialized
	document.getElementById("mapfinished").value = map_id;
}

// ERROR /////////////////////////////////////////////////////////////////////////////////
// amError(map_id, message)
// This function is called when an error occurs, such as no data, or file not found.
function amError(map_id, message) {
	//alert(message);
}

// RELOAD DATA ///////////////////////////////////////////////////////////////////////////
// flashMove.reloadData([file_name])
// This function will reload the data. The file_name variable is optional, if you do not
// set it here, data from the original file will be reloaded.       
function reloadData() {
	flashMovie.reloadData();
}

// RELOAD ALL ////////////////////////////////////////////////////////////////////////////
// flashMovie.reloadAll([data_file_name][,settings_file_name])
// This function will reload both data and settings. The names of the files are optional. 
// If you do not set them, the original file names will be used.
function reloadAll() {
	flashMovie.reloadAll();
}

// REGISTER MOUSE CLICK ON AN OBJECT
// amRegisterClick(map_id, object_id, title, value)
// This function is called when user clicks on some object - area, movie or label.
function amRegisterClick(map_id, object_id, title, value) {
	if (object_id == "homeworldmap") {
		ResetForm();
		goToByScroll("news-worldmap");
		SendWebAnalyticInfo("homeworldmap", "");
	}
	else if (object_id.substring(0, 6) == "movie_") {
		goToByScroll("news-worldmap");
		$.uiTableFilterDetail($("#mediaprofiles"), object_id.substring(6, 100));
	}

	else {
		if (m_bLockCountry) {
			m_bLockCountry = false;
		} else {
			$("#cboCountry").val(object_id);
			RefreshTable();
			goToByScroll("news-worldmap");
			//var strCountry = $("#cboCountry option:selected").text();
			var strCountry = $("#country_en_" + object_id.substring(1, 37)).text();
			SendWebAnalyticInfo("countryworldmap", strCountry);
		}
	}
}

// REGISTER ROLL-OVER THE OBJECT
// amRegisterHover(map_id, object_id, title, value)
// This function is called when user rolls-over on some object - area, movie or label.
//function amRegisterHover(map_id, object_id, title, value) {
////	if (object_id == "{1025EA47-60D1-4F0A-B7C3-292BF99A2088}") {
////		$.uiTableFilterDetail($("#mediaprofiles"), object_id);
////	}
//}


/* FormularEvent -------------------------------------------------- */
$(document).ready(function () {
	SetCountProfiles(-1);
	$("#txtSearch").val($("#txtSearch2").val());
	$("#cboCountry").val('');
	$("#cboCategorie").val('');
	$("#cboMedium").val('');
	$("#cboSector").val('');
	$("#cboLanguages").val('');
});

function SetCountProfiles(iAnzahl) {
	//IE8 kann dies leider nicht...
	//var iAnzHidden = $("#mediaprofiles").find("tr.trtitle:hidden").size();
	//...somit ein umweg über classen "trshow"
	//var iAnzHidden = $("#mediaprofiles").find("tr.trshow").size();
	//		$('#mediaprofiles').find("tbody > tr.trtitle").each(function() {
	//			if (!jQuery(this).hasClass("trshow")) {	iAnzHidden++;}
	//		});
	//		var iAnzAll = $("#mediaprofiles").find("tr.trtitle").size();	

	var strText = "";
	if (iAnzahl == -1) {
		var iAnz = $("#mediaprofiles").find("tbody > tr.trshow").size();
		strText = $("#countProfilesLabel").text().replace("{0}", iAnz);
	}
	else { strText = $("#countProfilesLabel").text().replace("{0}", iAnzahl); }
	$("#countProfiles").text(strText);
}

function blurInputSearch() {
	RefreshTable();

	var strTextSearchValue = $("#txtSearch").val();
	if (strTextSearchValue == "") {
		$("#txtSearch").val($("#txtSearch2").val());
		$("#txtSearch").attr("class", "worldmapSearchEmpty");
	}
	else {
		$("#txtSearch").attr("class", "worldmapSearchNotEmpty");
		SendWebAnalyticInfo("textfilter", strTextSearchValue);
	}
}
function focusInputSearch() {
	if ($("#txtSearch").val() == $("#txtSearch2").val()) {
		$("#txtSearch").val("");
		$("#txtSearch").attr("class", "worldmapSearchNotEmpty");
	}
}
function changeCountry() {
	m_bLockCountry = true;
	strCountryId = $("#cboCountry").val();
	if (typeof flashMovie != "undefined") {
		flashMovie.clickObject(strCountryId);
	}
	RefreshTable();
	//var strValue = $("#cboCountry option:selected").text();
	var strValue = $("#country_en_" + strCountryId.substring(1, 37)).text();
	SendWebAnalyticInfo("countryfilter", strValue);
}
function changeCategorie() {
	RefreshTable();
	var strValue = $("#cboCategorie option:selected").text();
	SendWebAnalyticInfo("categoriefilter", strValue);
}
function changeMedium() {
	RefreshTable();
	var strValue = $("#cboMedium option:selected").text();
	SendWebAnalyticInfo("mediumfilter", strValue);
}
function changeSector() {
	RefreshTable();
}
function changeLanguage() {
	RefreshTable();
	var strValue = $("#cboLanguages option:selected").text();
	SendWebAnalyticInfo("languagefilter", strValue);
}
function clickAnkerShowList() {
	SendWebAnalyticInfo("AnkerShowList", "");
}
function clickWWW(strId) {
	var strTitelMedium = GetTitleMedium(strId);
	if (strTitelMedium != "") {
		SendWebAnalyticInfo("www", strTitelMedium);
	}
}
function clickEMail(strId) {
	var strTitelMedium = GetTitleMedium(strId);
	if (strTitelMedium != "") {
		SendWebAnalyticInfo("email", strTitelMedium);
	}
}
function clickEpaper(strId) {
	var strTitelMedium = GetTitleMedium(strId) + ", " + GetEPaperTitle(strId);
	if (strTitelMedium != "") {
		SendWebAnalyticInfo("downloadEPaper", strTitelMedium);
	}
}
function clickPdf(strId) {
	var strTitelMedium = GetTitleMedium(strId) + ", " + GetEPaperTitle(strId);
	if (strTitelMedium != "") {
		SendWebAnalyticInfo("downloadPdf", strTitelMedium);
	}
}

function GetTitleMedium(strId) {
	if (strId != "") {
		return $("#" + strId).find("td > a").text();
	}
}
function GetEPaperTitle(strId) {
	if (strId != "") {
		return $("#" + strId).next().find("td > div > div > span.mediaprofilesDetailsTitle").text();
	}
}


//reset Worldmap
function ResetFlashMap() {
	if (typeof flashMovie != "undefined") {
		flashMovie.clickObject('homeworldmap');
	}
	else {
		ResetForm();
	}
}

//Debug-Mode
function SetDebugMode(bDebugMode) {
	if (bDebugMode) {
		flashMovie.setParam("developer_mode", "true");
		flashMovie.setParam("background.color", "0xd0d0d0");
		flashMovie.setParam("area.color_light", "0xa0a0a0");
		flashMovie.setParam("area.color_hover", "0xb0b0b0");
		flashMovie.setParam("area.color_selected", "0xb7b7b7");
		flashMovie.reloadData();
	}
	else {
		flashMovie.reloadSettings();
	}
}

//Alle Elemente zurücksetzen
function ResetForm() {
	$("#txtSearch").val($("#txtSearch2").val());
	$("#cboCountry").val('');
	$("#cboCategorie").val('');
	$("#cboMedium").val('');
	$("#cboSector").val('');
	$("#cboLanguages").val('');
	RefreshTable();
}
function RefreshTable() {
	$.uiTableFilter($("#mediaprofiles"), $("#txtSearch").val(), false);
}


/* Scrollen ein Html-Element */
function goToByScroll(id) {
	$('html,body').animate({ scrollTop: $("#" + id).offset().top }, 'slow');
}


//Daten für Google-Analytics und Webtrekk senden
function SendWebAnalyticInfo(strAction, strValue) {
	SendWebtrekkInfo(strAction + "/" + strValue);
	SendGoogleAnalyticInfo(strAction, strValue);
}


/* //Detail eines Medienprofile > Tabellenfilter -------------------------------------- */
jQuery.uiTableFilterDetail = function (jQueryTable, strMediaprofileId) {
	jQueryTable.find("tbody > tr").hide();
	jQueryTable.find("tbody > tr > td").hide();

	var row = $("#id_" + strMediaprofileId.substring(1, 37));
	var anker = row.find("td > a");
	if (anker.attr("class").indexOf("open") < 0) {
		anker.toggleClass('open')
		row.next('tr').find('td > div.collapse').toggle(m_iToggleSpeed);
	}
	row.show();
	row.find('td').show();
	row.next('tr').show();
	row.next('tr').find('td').show();
	SetCountProfiles(1);
	SendWebAnalyticInfo("worldmap", anker.text());
};


/* Liste > Tabellenfilter -------------------------------------------------- */
var m_iLengthOldSearchTxt = 0;
jQuery.uiTableFilter = function (jQueryTable, strSearchTxt, btxtSearch) {

	if (strSearchTxt == $("#txtSearch2").val() || iSearchTxtLength < m_iMinStringLenSearch) {
		strSearchTxt = "";
	}

	var iSearchTxtLength = strSearchTxt.length;
	//bei wenigen Zeichen keine Änderung
	if (btxtSearch && iSearchTxtLength < m_iMinStringLenSearch && m_iLengthOldSearchTxt < m_iMinStringLenSearch) {
		return false;
	}

	var strCountry = ""
	if ($("#cboCountry").val() != 0) {
		strCountry = $('#cboCountry option:selected').text();
	}
	var strCategorie = ""
	if ($("#cboCategorie").val() != 0) {
		strCategorie = $('#cboCategorie option:selected').text();
	}
	var strMedium = ""
	if ($("#cboMedium").val() != 0) {
		strMedium = $("#cboMedium option:selected").text();
	}
	var strLanguages = ""
	if ($("#cboLanguages").val() != 0) {
		strLanguages = $("#cboLanguages option:selected").text();
	}

	var arySearchWords = strSearchTxt.toLowerCase().split(" ");
	var iLengthArySearchWords = arySearchWords.length;

	if (iLengthArySearchWords > 1) {
		if (arySearchWords[iLengthArySearchWords - 1] == "") {
			return false;
		}
	}

	var elems = jQueryTable.find("tbody > tr")
	var i = 0;
	var bShow = true;

	elems.each(function () {
		var elem = jQuery(this);
		i = i + 1;
		if ((i % 2) != 0) {
			bShow = true;
			//Suche in Dropdown
			if ((strCountry) && jQuery(elem.find("td:eq(1)")).text() != strCountry) {
				bShow = false;
			}
			else if (bShow && (strCategorie) && jQuery(elem.find("td:eq(2)")).text() != strCategorie) {
				bShow = false;
			}
			else if (bShow && (strMedium) && jQuery(elem.find("td:eq(3)")).text() != strMedium) {
				bShow = false;
			}
			else if (bShow && (strLanguages) &&
				(jQuery(elems[i]).find('td > div >  div.mediaprofilesDetails > p.mediaprofilesLanguages').text().indexOf(strLanguages) < 0)) {
				bShow = false;
			}

			//Volltextsuche: Suchbegriff ist vorhanden
			else if (bShow && iSearchTxtLength > 0) {
				var bfind = false;
				//Suche im Adressblock
				if (jQuery.uiTableFilter.hasWords(jQuery(elems[i]).text().toLowerCase(), arySearchWords))
					bfind = true;
				//Suche in Titelzeile
				else if (bfind == false && jQuery.uiTableFilter.hasWords(elem.text().toLowerCase(), arySearchWords))
					bfind = true;

				if (bfind == false)
					bShow = false;
			}

			if (bShow == true) {
				elem.show();
				elem.find("td").show();
				elem.addClass("trshow");
			}
			else {
				elem.hide();
				elem.find("td").hide();
				elem.removeClass("trshow");
			}
		}
		else {
			//Detailsichten ein-/ausblenden
			if (bShow == true) {
				elem.show();
				elem.find("td").show();
			}
			else {
				elem.hide();
				elem.find("td").hide();
			}
		}
	});

	m_iLengthOldSearchTxt = iSearchTxtLength;
	SetCountProfiles(-1);
};

jQuery.uiTableFilter.hasWords = function (strElement, arySearchWords) {
	for (var i = 0; i < arySearchWords.length; i++) {
		if (strElement.indexOf(arySearchWords[i]) == -1) return false;
	}
	return true;
}
/* ************************************************ */
$(document).ready((function () {
	var theTable = $('#mediaprofiles')

	$("#txtSearch").keyup(function (e) {
		code = (e.keyCode ? e.keyCode : e.which);
		if (code == 13) {
			$.uiTableFilter(theTable, this.value, true);
		}
		else if ( this.value.length > 2)
		{
			$.uiTableFilter(theTable, this.value, true);
		}
		else if (this.value.length == 0) {
			$.uiTableFilter(theTable, "", true);
		}
		//Developer-Mode setzen
		else if (this.value == "dbg=1") {
			SetDebugMode(true);
		}
		else if (this.value == "dbg=0") {
			SetDebugMode(false);
		}
	})
}));

/* Tabellensortierung -------------------------------------------------- */
/*.tablesorter({
headers: { 4: { sorter: false} },
sortList: [], widthFixed: true, widgets: ['zebra']
});
*/
//$(document).ready(function() {
//	$("#mediaprofiles")
//	.tablesorter({
//	sortList: [], widthFixed: true, widgets: ['zebra']
//	});
//});
$(document).ready(function () {
	$("#mediaprofiles")
	.collapsible("td.collapsible", {
		collapse: true
	})

	.tablesorter({
		sortList: [], widthFixed: true
	});
});

/* Funktionen für Expander -------------------------------------------------- */
(function ($) {
	$.fn.orphans = function () {
		var txt = [];
		this.each(function () {
			$.each(this.childNodes, function () {
				if (this.nodeType == 3 && $.trim(this.nodeValue)) txt.push(this)
			})
		});
		return $(txt);
	};

	$.fn.expandAll = function (options) {
		var defaults = {
			txtExpand: $("#expandAllLabel").text(),
			txtCollapse: $("#collapseAllLabel").text(),
			showMethod: 'show',
			hideMethod: 'hide'
		};
		options = $.extend(defaults, options);
		return this.each(function () {
			//$(options.a + options.txtExpand + options.b).insertBefore(options.cont + options.ref);

			$('#mediaprofilesExpandAll a').click(function () {
				var $cllps = $(this).closest('div').find('.collapse'), $exp = $(this).closest('div').find('.expand');
				if ($(this).text() == options.txtExpand) {
					SendWebAnalyticInfo("expandall", "");
					$(this).text(options.txtCollapse);
					$exp.addClass('open');
					$cllps[options.showMethod](m_iToggleSpeed);
					//Alle Titelzeilen tr Klassen tauschen
					$(this).closest('div').find('tr.trtitleclose').addClass('trtitleopen');
					$(this).closest('div').find('tr.trtitleclose').removeClass('trtitleclose');
				} else {
					SendWebAnalyticInfo("collapseall", "");
					$(this).text(options.txtExpand);
					$exp.removeClass('open');
					$cllps[options.hideMethod](m_iToggleSpeed);
					//Alle Titelzeilen tr Klassen tauschen
					$(this).closest('div').find('tr.trtitleopen').addClass('trtitleclose');
					$(this).closest('div').find('tr.trtitleopen').removeClass('trtitleopen');
				}
			});
		});
	};
})(jQuery);

$(function () {
	if ($('#mediaprofiles') != null) {
		$('#mediaprofiles').expandAll().find('div.collapse').hide().end()
    .find('.expand').css('cursor', 'pointer').orphans().wrap('<a style="display:block" href="#expand/collapse" title="'
    + g_objResource.GetStringFromResource("ExpandCollapse") + '"></a>');

		$('#mediaprofiles .expander .expand').click(function () {
			//$(this).parent().parent().find('td.expander a.expand').toggleClass('open');

			//Titelzeile alle td.Zellen
			if ($(this).parent().parent().hasClass('trtitleclose')) {


				$(this).parent().parent().addClass('trtitleopen');
				$(this).parent().parent().removeClass('trtitleclose');

				$(this).parent().parent().find('td.expander a.expand').addClass('open');
				$(this).parent().parent().next('tr').find('td > div.collapse')['show'](m_iToggleSpeed)

				//Zoom auf das Land
				m_bLockCountry = true;
				if (typeof flashMovie != "undefined") {
					flashMovie.clickObject("{" + $(this).parent().parent().find("td").attr("id").substring(8, 44) + "}");
				}
				SendWebAnalyticInfo("listdetail", $(this).text());

			} else {
				$(this).parent().parent().addClass('trtitleclose');
				$(this).parent().parent().removeClass('trtitleopen');

				$(this).parent().parent().find('td.expander a.expand').removeClass('open');
				$(this).parent().parent().next('tr').find('td > div.collapse')['hide'](m_iToggleSpeed)
			}
		});
	}
});
