// global JS-Variables
var imgDaemon = "http://images2.amica.de";
var CustomShCut = 'ami';
var imgPath = "/"+CustomShCut+"/images";
var urlAjaxRequ = '/'+CustomShCut+'/nofrawo/ajax_requests/';
var CustCtfDaemon = 'http://member.amica.de';
var CustCtfApplId = 53;

// for channelizer
var list_mediacredits = '';

// for Stats
var StatsClickCount = 1;

// for Rating
var img_star_on = new Image();
img_star_on.src = imgDaemon + imgPath + "/stars/star_on_16x17.gif";
var img_star_off = new Image();
img_star_off.src = imgDaemon + imgPath + "/stars/star_off_16x17.gif";
var img_star_over = new Image();
img_star_over.src = imgDaemon + imgPath + "/stars/star_over_16x17.gif";
var MaxStars = 5;

// for ThumbnavigationBox with CircleEffects
var ThumbOnChanged = false;

// for Login Status Header
var CTFCookie = {
	set: function(name, value, daysToExpire, path, domain) {
		var expire = '';
		if (daysToExpire != undefined) {
			var d = new Date();
			d.setTime(d.getTime() + (86400000 * parseFloat(daysToExpire)));
			expire = '; expires=' + d.toGMTString();
		}
		return (document.cookie = escape(name) + '=' + escape(value || '') + expire + ((path)?';path=' + path:'') + ((domain)?';domain=' + domain:''));
	},
	get: function(name) {
		var cookie = document.cookie.match(new RegExp('(^|;)\\s*' + escape(name) + '=([^;\\s]*)'));
		return (cookie ? unescape(cookie[2]) : null);
	},
	erase: function(name) {
		var cookie = CTFCookie.get(name) || true;
		CTFCookie.set(name, '', -1);
		return cookie;
	},
	accept: function() {
		if (typeof navigator.cookieEnabled == 'boolean') {
			return navigator.cookieEnabled;
		}
		CTFCookie.set('_test', '1');
		return (CTFCookie.erase('_test') === '1');
	}
};

// std error to null (only for livedaemons)
function CiDevStdout() {
	window.onerror = devStdout;
	function devStdout() {
	return true;
	}
}

// for Login Status Header (channelizer!)
// get ctf-referrer(windowLocationHref) urlencodet:
function get_urlenc_uri() {
	if(window.location.href=="") {
		return encodeURIComponent('www.amica.de');
	} else {
		teh_script=window.location.href;
		tmp_pos=teh_script.indexOf("://");
		script_len=teh_script.length;
		teh_script_no_prot=teh_script.substr(tmp_pos+3, script_len);
		teh_script_no_hash = teh_script_no_prot.replace(/#.*/g,"");
		return encodeURIComponent(teh_script_no_hash);
	}
}
// header - channelizer logout
function logout_ctf() {
	ctf_logout_url = CustCtfDaemon+'/logout/'+CustCtfApplId+'.html?ref=' + get_urlenc_uri();
	window.location.href = ctf_logout_url;
}
// header - channelizer login
function my_ctf_login() {
	var MyLogin = CustCtfDaemon+'/login/'+CustCtfApplId+'.html?ref='+get_urlenc_uri();
	openWinIdent(MyLogin,'820','650',CustomShCut+'Ctf');
}
// header - channelizer register
function my_ctf_register() {
	var MyLogin = CustCtfDaemon+'/register/'+CustCtfApplId+'.html?ref='+get_urlenc_uri();
	openWinIdent(MyLogin,'820','650',CustomShCut+'Ctf');
}

// for logged user: prints nickname, profilanchor
function my_header_logged(urlProfile) {
	var ctf_nickname = CTFCookie.get('ctf_nickname');
	if(ctf_nickname=='' || ctf_nickname=='0' || ctf_nickname==null) {
		document.write('Sie sind eingeloggt');
	} else {
		document.write('Hallo <a href="'+urlProfile+'/'+ctf_nickname+'/profil.html" title="Profil '+ctf_nickname+'">' + ctf_nickname + '</a>');
	}
}

// switch header due to loginStatus
function displ_my_header() {
	var ctf_status = CTFCookie.get('ctf_status');
	if(ctf_status==1) {
		$('ctf_loginform').style.display = 'none';
		$('ctf_logged_in').style.display = '';

	} else {
		$('ctf_logged_in').style.display = 'none';
		$('ctf_loginform').style.display = '';
	}
}
// /for Login Status Header


// global_ctf_login(adjusted ctf-referrer) (CTF Login in Appl. and Coop.)
function global_ctf_login(uri) {
	var urlenc_uri = encodeURIComponent(uri);
	var MyLogin = CustCtfDaemon+'/login/'+CustCtfApplId+'.html?ref='+urlenc_uri;
	openWinIdent(MyLogin,'820','650',CustomShCut+'Ctf');
}

// global_ctf_register(adjusted ctf-referrer) (CTF Register in Appl. and Coop.)
function global_ctf_register(uri) {
	var urlenc_uri = encodeURIComponent(uri);
	var MyLogin = CustCtfDaemon+'/register/'+CustCtfApplId+'.html?ref='+urlenc_uri;
	openWinIdent(MyLogin,'820','650',CustomShCut+'Ctf');
}

// SocialBookmarks (Bookmarks)
function createSocialBookmarks(){
	var obj = $('MerkenIcon');
	var MerkenIconPos = Element.cumulativeOffset(obj);
	var SocialBookmarks = new Array();
	SocialBookmarks[0] = new Object()
	SocialBookmarks[0]["class"] = "delicious";
	SocialBookmarks[0]["href"] = "http://del.icio.us/post?url="+location.href;
	SocialBookmarks[0]["name"] = "del.icio.us";
	SocialBookmarks[1] = new Object()
	SocialBookmarks[1]["class"] = "google";
	SocialBookmarks[1]["href"] = "http://www.google.com/bookmarks/mark?op=add&hl=de&bkmk="+location.href;
	SocialBookmarks[1]["name"] = "Google Bookmarks";
	SocialBookmarks[2] = new Object()
	SocialBookmarks[2]["class"] = "wong";
	SocialBookmarks[2]["href"] = "http://www.mister-wong.de/index.php?action=addurl&bm_url="+location.href;
	SocialBookmarks[2]["name"] = "Mister Wong";
	SocialBookmarks[3] = new Object()
	SocialBookmarks[3]["class"] = "facebook";
	SocialBookmarks[3]["href"] = "http://www.facebook.com/sharer.php?u="+location.href;
	SocialBookmarks[3]["name"] = "Facebook";
	SocialBookmarks[4] = new Object()
	SocialBookmarks[4]["class"] = "furl";
	SocialBookmarks[4]["href"] = "http://www.furl.net/storeIt.jsp?u="+location.href;
	SocialBookmarks[4]["name"] = "Furl";
	SocialBookmarks[5] = new Object()
	SocialBookmarks[5]["class"] = "webnews";
	SocialBookmarks[5]["href"] = "http://www.webnews.de/einstellen?url="+encodeURIComponent(document.location)+"&title="+encodeURIComponent(document.title);
	SocialBookmarks[5]["name"] = "Webnews";
	SocialBookmarks[6] = new Object()
	SocialBookmarks[6]["class"] = "yigg";
	SocialBookmarks[6]["href"] = "http://www.yigg.de/neu?exturl="+location.href;
	SocialBookmarks[6]["name"] = "YiGG";

	var BookmarkList = "";
	for(var i=0; i <SocialBookmarks.length; i++) {
		BookmarkList = BookmarkList + "<li><a class=\""+SocialBookmarks[i]['class']+"\" href=\""+SocialBookmarks[i]['href']+"\" title=\"Diesen Artikel bei "+SocialBookmarks[i]['name']+" bookmarken\" target=\"_blank\">"+SocialBookmarks[i]['name']+"</a>";
	}
	$('SCList').innerHTML = BookmarkList;

	if($('SocialBookmarks').style.display=="none"){
		toggleFlyout('SocialBookmarks','JSFlyout1','appear','','200','',MerkenIconPos.left,MerkenIconPos.top+20);
	}else{
		$('SocialBookmarks').hide();
	}
	toggleClass('book_button','content_book','content_booked');
	getomni('service','');

}

// bookThis (Bookmarks)
function bookThis(AjaxFile,contOid,contType) {
	var urlBook = urlAjaxRequ + AjaxFile;
	var parsCont = 'contOid='+contOid+'&contType='+contType;
	var myAjax = new Ajax.Request(
		urlBook,
			{
			Method: 'post',
			parameters: parsCont,
			onSuccess: ContentBooked
			}
		);
}
// ContentBooked (Bookmarks)
function ContentBooked() {
	var MyStyleNavigation = $('header_zones');
	var MyStyleLink = $('SCMyStyleLink');
	var YPos = Element.cumulativeOffset(MyStyleNavigation).top + 27;

	$('SCMyStyleText').innerHTML = "<a href=\"http://dev2.amica.de/my_style/interessen.html\" title=\"Diese Seite unter My Style abrufen.\">My Style</a>";
	$('SCMyStyleCheck').style.display = "block";

	toggleFlyout('MyBookedMsg','JSFlyout2','appear','','202','68','387',YPos);
}

// changeUrls (Horoskop)
function changeUrls(item) {
	if (item != "") {
		urlLoveNeu = urlLove+horoskopURL[parseInt(item)-1];
		urlSingleNeu = urlSingle+horoskopURL[parseInt(item)-1];
	}
	else {
		urlLoveNeu = urlLove;
		urlSingleNeu = urlSingle;
	}
	$('loveLink').href = urlLoveNeu;
	$('singleLink').href = urlSingleNeu;
}

// storeHoroskop (Horoskop)
function storeHoroskop(field){
	if(field.checked) {
		if ($F('horoskopItem') == "") {
			$("horoskopMsg").innerHTML = '<span class="c-red1">Bitte wählen Sie Ihr Sternzeichen aus.</span>';
			field.checked = false;
		}
		else {

			var horoskop_userdomain = escape('${global.customer.cookiedomain}');
			var horoskop_expDays = 365;
			var horoskop_exp = new Date();
			horoskop_exp.setTime(horoskop_exp.getTime()+(horoskop_expDays*24*60*60*1000));
			SetCookie ('ami_horoskop', $F('horoskopItem'), horoskop_exp, '/', horoskop_userdomain);
		}
	}
	else {
		if(GetCookie("ami_horoskop") != "noc") {
			DeleteCookie("ami_horoskop")
		}
	}
}

// changeHoroskop (Horoskop)
function changeHoroskop() {
	$("horoskop2").style.display = "none";
	$("horoskop1").style.display = "block";
	$("horoskopMsg").innerHTML = "Sternzeichen";
}

// showHoroskop (Horoskop)
function showHoroskop(horoskopId){
	if (horoskopId == "") {
		$("horoskopMsg").innerHTML = '<span class="c-red1">Bitte wählen Sie Ihr Sternzeichen aus.</span>';
	}else{
		$("horoskop1").style.display = "none";
		$("horoskop2").style.display = "block";
		$("horoskopName").innerHTML = horoskopNames[parseInt(horoskopId)-1];
		for (var i=1; i<=12; i++)	{
			if ($('horoskopText_'+i).style.display == "block")	{
				$('horoskopText_'+i).style.display = "none";
			}
		}
		$('horoskopText_'+parseInt(horoskopId)).style.display = "block";
		getomni('','');
	}
}

// getCity (Friseur Modul rechte Spalte)
function getCity(select_id) {
	city = document.getElementById(select_id).value;
	return city;
}

// getBarbers (Friseur Modul rechte Spalte)
function getBarbers(sendparams,file) {
	var urlScript = urlAjaxRequ+file;
	var params = sendparams;

	var myAjax = new Ajax.Request(
		urlScript,
			{
			Method: 'post',
			parameters: params,
			onSuccess: showBarbers
			}
		);
	}

// showBarbers (Friseur Modul rechte Spalte)
function showBarbers(originalRequest) {
	var display = originalRequest.responseText;
	$('barber').innerHTML = display;
	new TabsNaviClass('tabs_friseur','best','');
}

// toggleFlyout (allgemeine Funktion zur Darstellung von JS-Flyouts)
function toggleFlyout(BoxID,BoxClass,BoxEffect,EffectArgs,BoxWidth,BoxHeight,XPos,YPos){
  var theBox = $(BoxID);
	var Screen = document.viewport.getDimensions();
	var Offset = document.viewport.getScrollOffsets();
	var BoxWidth = BoxWidth;
	var BoxHeight = BoxHeight;

				// Effekt zuweisen fuer show/hide
				switch (BoxEffect) {
					case "appear":
						var EffectShow = 'Appear';
						var EffectHide = 'Fade';
					break;
					case "puff":
						var EffectShow = 'Grow';
						var EffectHide = 'Shrink';
					break;
					default:
						var EffectShow = 'show';
						var EffectHide = 'hide';
					break;
				}
				EffectArgs = "{afterFinish:function(){theBox.removeClassName(BoxClass);}}";

				// layouttyp zuweisen

				theBox.addClassName(BoxClass);

				var FlyoutElements = $A(theBox.getElementsByTagName('div')).each(
    function(e){
      if(Element.hasAttribute(e,'flyout')){
							// ermittelt den eigentlich content bereich und ?bergibt BoxHeight + BoxWidth
							if(e.attributes['flyout'].value == "content")
								if(BoxHeight != "")
									e.style.height=BoxHeight+'px';
								if(BoxWidth != "")
									e.style.width=BoxWidth+'px';
        }
      }
    );

  // falls keine koordinaten gesetzt sind, wird die box zentriert dargestellt
  if((XPos == "") || (YPos == "")){
					var XPos = ((Screen.width-theBox.getWidth())/2)+Offset.left;
					var YPos = ((Screen.height-theBox.getHeight())/2)+Offset.top;
  }

  theBox.style.top=YPos+'px';
  theBox.style.left=XPos+'px';

  if (EffectShow == 'show') {
    theBox.show();
  }else{
  	eval('new Effect.'+EffectShow+'(theBox);');
  }

  var FlyoutLinks = $A(theBox.getElementsByTagName('a')).each(
    function(e){
      if(Element.hasAttribute(e,'flyout')){
        e.title="Dieses Fenster schlie?en";
        Event.observe(e, 'click',
          function(){
            if (EffectHide == 'hide') {
		                theBox.hide();
		                theBox.removeClassName(BoxClass);
		              }else{
		              	eval('new Effect.'+EffectHide+'(theBox,'+EffectArgs+');');
		              }

          },false);
        }
      }
    );
}

// initRotator (Promoteaser Homepage)
function initRotator(){
	Event.observe('PromoTeaser', 'mouseover', stopRotator, false);
	Event.observe('PromoTeaser', 'mouseout', startRotator, false);
	startRotator();
}

// startRotator (Promoteaser Homepage)
function startRotator() {
	PTRotator = new PeriodicalExecuter(function(PTRotator) {
			 rotatePromoTeaser(PTSlide[PTNext]);
		 }, 10);
}

// stopRotator (Promoteaser Homepage)
function stopRotator() {
	PTRotator.stop();
	PTRotator=null;
}

// rotatePromoTeaser (Promoteaser Homepage)
function rotatePromoTeaser(theID){

		if(PTNext == PTSlide.length-1) {
			PTNext = 0;
		} else {
			PTNext++;
		}

		var newBIGTeaser = PTPosition[theID];
		var newBIGTeaserContent = PTContent[newBIGTeaser];
		var newSMLTeaser = PTPosition[0];
		var newSMLTeaserContent = PTContent[newSMLTeaser];
		PTPosition[0] = newBIGTeaser;
		PTPosition[theID] = newSMLTeaser;

	new Effect.Fade('PT0', {
				duration:0.6,
				from:1.0,
				to:0,
				afterFinish:function(){
					$('PT0Image').innerHTML = newBIGTeaserContent.BigImage;
					$('PT0Header').innerHTML = newBIGTeaserContent.Header;
					$('PT0Text').innerHTML = newBIGTeaserContent.Text;
					new Effect.Appear('PT0',{duration:0.6,from:0.0,to:1.0}); }
				});


	new Effect.Fade('PT'+theID, {
				duration:0.6,
				from:1.0,
				to:0,
				afterFinish:function() {
					$('PT'+theID+'Image').innerHTML = newSMLTeaserContent.BigImage;
					$('PT'+theID+'Header').innerHTML = newSMLTeaserContent.Header;
					new Effect.Appear('PT'+theID,{duration:0.6,from:0.0,to:1.0}); }
				});

		return PTPosition;
}

// toggleMAP (Google-Map für Friseurfinder)
function toggleMAP(Container, Button, map){
	var Element = $(Container);
	var Button = $(Button);

	if(Element.style.height == "110px") {
		Element.style.height = 460+"px";
    Button.title = "Zuklappen";
    Button.innerHTML = "Zuklappen";
    map.maximize(460);
	} else {
    Element.style.height = 110+"px";
    Button.innerHTML = "Ausklappen";
    Button.title = "Ausklappen";
    map.minimize(110);
	}
	toggleClass(Button,'d_light','close_light');
}

// LoadABCResults (Friseurfinder ABC-Navigation auf Suchseite)
function LoadABCResults(Character,Application) {

	var Character = Character;
	var CharacterContainer = $('FGAbcNavLetter');
	var ButtonID = 'Button'+Character;
	var Button = $(ButtonID);
	var ListID = 'FGAbcList'+Character;
	var List = $(ListID);

	$A($('FGAbcNavLetters').getElementsByTagName('a')).each ( function(element) { Element.removeClassName(element,'active') } );
	$A($('FGAbcNavLists').getElementsByTagName('ul')).each ( function(element) { Element.removeClassName(element,'block') } );
	$A($('FGAbcNavLists').getElementsByTagName('ul')).each ( function(element) { Element.addClassName(element,'none') } );

	$(Button).addClassName('active');
	$(List).removeClassName('none');
	$(List).addClassName('block');

	CharacterContainer.innerHTML = Character;
}

// getMousePos (ermittelt die aktuelle Cursor Position)
function getMousePos(e) {
	xPosBook = Event.pointerX(e);
	yPosBook = Event.pointerY(e);
}

// toggleClass (allgemeine Funktion zum toggeln 2er Klassen für eine ID)
function toggleClass(theElement,Class1,Class2) {
	if(Element.hasClassName(theElement,Class1)) {
		Element.removeClassName(theElement,Class1);
		$(theElement).addClassName(Class2);
	} else if(Element.hasClassName(theElement,Class2)) {
		Element.removeClassName(theElement,Class2);
		$(theElement).addClassName(Class1);
	}
}

// toggleFolder (allgemeine Funktion für Folder)
function toggleFolder(theElement,theToggle,Class1,Class2) {
	Element.toggle(theElement);
	toggleClass(theToggle,Class1,Class2);
}

// toggleFolderandText (allgemeine Funktion für Folder + Text)
function toggleFolderAndText(theElement,theToggle,Class1,Class2,Text1,Text2) {
	Element.toggle(theElement);
	toggleClass(theToggle,Class1,Class2);
	theToggle = $(theToggle);
	if(theToggle.title == Text1){
		theToggle.title = Text2;
		theToggle.innerHTML = Text2;
	}else{
		theToggle.title = Text1;
		theToggle.innerHTML = Text1;
	}
}

// changeOpenerLocation (ändert URL in einem bereits geöffnetem Popup)
function changeOpenerLocation(aURL){
	// exists opener window AND is not closed?
	if(window.opener!=null && !window.opener.closed){
		// YES: change location
		window.opener.location.href=aURL;
	}
	else{
		// NO: open new window and set location
		window.open(aURL);
	}
}

// addCredits (fügt weitere Fotocredits an)
function addCredits(credit) {
	if ($('credits') != undefined) {
		var ObjCredits = $('credits');
		var CreditsYet = ObjCredits.innerHTML;
		var Credits2Add = (credit.charAt(0) == ',') ? credit.substring(1,credit.length-1) : credit;
		var CreditsNew = (CreditsYet != '') ? CreditsYet + ', ' + Credits2Add : Credits2Add;
		ObjCredits.innerHTML = CreditsNew;
		if ($('credits_button').style.display == 'none') {
			$('credits_button').style.display = 'block';
			$('credits').style.display = 'block';
		}
	}
}

// CharCount (allgemeine Funktion zur Zählung von einem Input Feld / Textarea mit Counter)
function CharCount(FieldID,CounterID,MaxLimit) {
	var theField = $(FieldID);
	if (theField.value.length > MaxLimit)
		theField.value = theField.value.substring(0, MaxLimit);
	else {
		theValue = MaxLimit - theField.value.length;
		$(CounterID).innerHTML = theValue.toString();
	}
}

// checkEmail (allgemeine Funktion zur Prüfung einer EMail Adresse)
function checkEmail(email) {
	var pattern = "^([a-zA-Z0-9\\-\\.\\_]+)(\\@)([a-zA-Z0-9\\-\\.]+)(\\.)([a-zA-Z]{2,4})$";
	if (email.search(pattern) == -1) 	{	return 0;	}
	else { return 1; }
}

// switchStyles (allgemeine Funktion zum Ändern eines Styleattributes für mehrere IDs gleichzeitig)
function switchStyles(IDs,styleName,styleValue) {
	for (var i = 0;i<IDs.length;i++)
	{
	eval('$(\''+IDs[i]+'\').style.'+styleName+'="'+styleValue+'"');
	}
}

// ads_get_sad (Werbung)
function ads_get_sad() {
	if ($('adsd_topbanner') != undefined) {
		var topbanner=$('adsd_topbanner').innerHTML;
		$('adsd_topbanner').innerHTML = topbanner;
	}
}

// ads_get_cad (Werbung)
function ads_get_cad() {
	if ($('adsd_contentad_c1') != undefined) {
		var headYPos = Element.getHeight('adsd_contentad_c1');
		try {
      var contentad_c1='<iframe src="' + adsc_darturl_contentad + '?' + adsc_transid + '" width="300" height="268" frameborder="0" scrolling="no"></iframe>';
    } catch (e) {
    	var contentad_c1=$('adsd_contentad_c1').innerHTML;
    }
		$('adsd_contentad_c1').innerHTML = contentad_c1;
	}
}

// ads_get_sky (Werbung)
function ads_get_sky() {
	if ($('adsd_skyscraper') != undefined) {
		var skyscraper=$('adsd_skyscraper').innerHTML;
		$('adsd_skyscraper').innerHTML = skyscraper;
	}
}

// ads_get_mad (Werbung)
function ads_get_mad() {
	if ($('adsd_contentbox') != undefined) {
		var contentbox=$('adsd_contentbox').innerHTML;
		$('adsd_contentbox').innerHTML = contentbox;
	}
}

// ads_get_cad2 (Werbung)
function ads_get_cad2() {
	if ($('adsd_contentad_c2') != undefined) {
		var contentad_c2=$('adsd_contentad_c2').innerHTML;
		$('adsd_contentad_c2').innerHTML = contentad_c2;
	}
}

// ads_get_cad3 (Werbung)
function ads_get_cad3() {
	if ($('adsd_contentad_c3') != undefined) {
		var contentad_c3=$('adsd_contentad_c3').innerHTML;
		$('adsd_contentad_c3').innerHTML = contentad_c3;
	}
}

// adsd_slideDown (Werbung)
function adsd_slideDown(adsd_id,adsd_sp_id) {
	var headYPos = Element.getHeight(adsd_id);
	if (headYPos > 40) {
		Effect.SlideDown(adsd_sp_id,{duration:2});
	}
}

// ads_get_all (Werbung nachziehen)
function ads_get_all() {
	if (adsc_sadpercent > -1) {
		//ads_get_sad();
	}
	if (adsc_skyscraperpercent > -1) {
		//ads_get_sky();
	}
	if (adsc_cadpercent > -1) {
		ads_get_cad();
	}
	if (adsc_cad2percent > -1) {
		//ads_get_cad2();
	}
	if (adsc_cad3percent > -1) {
		//ads_get_cad3();
	}
	if (adsc_madpercent > -1) {
		//ads_get_mad();
	}
}

// refreshStatsAds (Werbung und Stats)
function refreshStatsAds(statCat,agofId,countPix) {
	getomni(statCat,agofId);
	if (countPix == 'true') {
		if (StatsClickCount == adsc_click_adrenew) {
			ads_get_all();
			StatsClickCount=0;
		}
		StatsClickCount++;
	}
}

// sendPageEvent (Event tracken für Statistik/Ads)
function sendPageEvent(trackingString) {
	try {
      var sentEventChannelOid = ThisIdentChannel;
    } catch (e) {
    	return;
    }
   // exclude invalid events:
   var ExclArrIdent = 'TrackgStrLevel1ExclArr'+ThisIdentChannel;
   var ExclArrLen = eval(ExclArrIdent+'.length');
   for (var i=0;i<ExclArrLen;i++) {
   	var invalidTrackStr = eval(ExclArrIdent+'['+i+']');
   	if (trackingString == invalidTrackStr) return;
   }
   // valid events:
   var sentEventArrIdent = 'TrackgStrLevel1Arr'+ThisIdentChannel;
   var sentEventArrLen = eval(sentEventArrIdent+'.length');
   var EventVerified = false;
   var IndexLevel1 = 0;
   for (var i=0;i<sentEventArrLen;i++) {
   	var validTrackStr = eval(sentEventArrIdent+'['+i+']');
   	var EventVerified = (trackingString.indexOf(validTrackStr) == 0) ? true : EventVerified;
   	var IndexLevel1 = (trackingString.indexOf(validTrackStr) == 0) ? i : IndexLevel1;
   }
   if (!EventVerified) return;
   var StatsFlagLevel1 = eval('StatsFlagLevel1Arr'+ThisIdentChannel+'['+IndexLevel1+']');
   if (StatsFlagLevel1 == 'f') return;
   var StatsCatLevel1 = eval('StatsCatLevel1Arr'+ThisIdentChannel+'['+IndexLevel1+']');
   var StatsAgofLevel1 = eval('StatsAgofLevel1Arr'+ThisIdentChannel+'['+IndexLevel1+']');
   var StatsCountLevel1 = eval('StatsCountLevel1Arr'+ThisIdentChannel+'['+IndexLevel1+']');
   refreshStatsAds(StatsCatLevel1,StatsAgofLevel1,StatsCountLevel1);
}

// getCookieVal (Wert eines Cookies auslesen)
function getCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
		endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

// GetCookie (Cookie lesen)
function GetCookie (name) {
	if (!navigator.cookieEnabled || !document.cookie) {return 'noc'}
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
	var j = i + alen;
	if (document.cookie.substring(i, j) == arg)
		return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return 'noc';
}

// SetCookie (Cookie schreiben)
function SetCookie (name, value) {
	if (!navigator.cookieEnabled) {return null;}
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	document.cookie = name+ "=" + escape (value) +
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
	((path == null) ? "" : ("; path=" + path)) +
	((domain == null) ? "" : ("; domain=" + domain)) +
	((secure == true) ? "; secure" : "");
}

// DeleteCookie (Cookie löschen)
function DeleteCookie (name) {
	var exp = new Date();
	exp.setTime (exp.getTime() - 1);
	var cval = GetCookie (name);
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

/* begin: video stats */
/* info player old:
function get_video_stat_pixel(uniqueid, mediaid,npi) {
	eval('count_video'+uniqueid+'()');
}
function get_video_npi_pixel(uniqueid, mediaid) {
	eval('count_video_npi'+uniqueid+'()');
}*/
/* available statistics for new and old player: */
function get_video_npi_pixel(uniqueid, mediaid) {
	// triggered by old player - obsolet later
	try {
			// old player
      eval('count_video_npi'+uniqueid+'()');
    } catch (e) {
    	// new statistics
    }
}
function get_video_stat_pixel(uniqueid, mediaid,npi) {
	// triggered by old player - later just:
	// get_vplayer_stat_pixel(uniqueid);
	try {
			// old player
      eval('count_video'+uniqueid+'()');
    } catch (e) {
    	// new statistics
    	//get_vplayer_stat_pixel(uniqueid);
    }
}

/* EventPlay */
function get_vplayer_stat_pixel(uniqueid) {
	var statsReset = eval('statsvars'+uniqueid+'PropReset');
	var category = 'video';
	var npi = 1;
	trig_video_stat_pixel(uniqueid,category,statsReset,npi);
}
/* EventVideoNotAvailable ==> only at LandingPage */
function get_vlpage_stat_pixel(uniqueid) {
	try {
      var StatsDest = eval('statsvars'+uniqueid+'StatsDest');
    } catch (e) {
    	var StatsDest = 'x';
    }
  try {
      var StatsDestHome = eval('statsvars'+uniqueid+'StatsDestHome');
    } catch (e) {
    	var StatsDestHome = 'y';
    }
	if (StatsDest == StatsDestHome) {
		var statsReset = 0;
		var category = '';
		var dummyid = '0000000';
		var npi = 0;
		trig_video_stat_pixel(dummyid,category,statsReset,npi);
	}
}
/* EventPlaylist */
function get_vplaylist_stat_pixel(uniqueid) {
	var statsReset = 0;
	var category = 'playlist';
	var dummyid = '0000000';
	var npi = 0;
	trig_video_stat_pixel(dummyid,category,statsReset,npi);
}
/* set and trigger pixel */
function trig_video_stat_pixel(uniqueid, category, statsReset,npi) {
	var defProp = 'defProp';
	var curr_x6 = category;
	if (statsReset == 1) {
		/* reset properties */
		var video_pagename = eval('flashvars'+uniqueid+'.landingPageUrl');
		var video_parts = video_pagename.split('%2F');
		var curr_x17 = category+':'+ video_parts[video_parts.length-1];
		/* trigger adupted pixel */
		setomni(defProp,curr_x6,defProp,defProp,defProp,defProp,defProp,defProp,defProp,defProp,defProp,defProp,curr_x17,defProp);
	} else {
		/* trigger default pixel */
		setomni(defProp,curr_x6,defProp,defProp,defProp,defProp,defProp,defProp,defProp,defProp,defProp,defProp,defProp,defProp);
	}
	/* npi unique */
	if (npi == 1) {
		var curr_npi = eval('statsNpiVars'+uniqueid+'.npi_flag');
		if (curr_npi == 1) {
			var tft_news_type = 'Video';
			var tft_id = eval('statsNpiVars'+uniqueid+'.tft_id');
			var tft_ti = eval('statsNpiVars'+uniqueid+'.tft_ti');
			var npi_daemon = eval('statsNpiVars'+uniqueid+'.npi_daemon');
			var npi_pixel = eval('statsNpiVars'+uniqueid+'.npi_pixel');
			getnpi_videoPlayer(uniqueid,tft_news_type,tft_id,tft_ti,npi_daemon,npi_pixel);
		}
	}
}
function getnpi_videoPlayer(uniqueid,tft_news,tft_id,tft_ti,tft_dea,npi_pixel) {
	var expDays = 365;
	var exp = new Date();
	exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
	var ra = new Date().getTime();
	var tft_ra = escape(ra);
	var querystr = "?";
	querystr +=   "type=" + tft_news;
	querystr +=   "&id="  + tft_id;
	querystr +=   "&title="  + escape(tft_ti);
	querystr +=   "&dea="  + escape(tft_dea);
	querystr +=   "&ra="  + tft_ra;
	var das_npi_pixel = npi_pixel+querystr;
	var rndm = (Math.random()*3)+0.5;
	var rnd = Math.round(rndm);
	if (rnd==1) {
		try {
      $('npipixel').src = das_npi_pixel;
    } catch (e) {
    	// no unique npi imgId
    }
	}
}
/* event registrator for video */
function addTFTEventListener( swfName, eventName, methodName ) {
	$(swfName).addTFTEventListener( eventName, methodName );
}
/* events videoplayer */
function doRegisterVideoplayerEvents( id ) {
	//addTFTEventListener( id, 'medAdVideoPlay', 'onAdVideoPlay' );
	//addTFTEventListener( id, 'medVideoPlay', 'OnVideoPlay' );
	//addTFTEventListener( id, 'medVideoAvailable', 'get_vplayer_stat_pixel' );
	addTFTEventListener( id, 'medVideoNotAvailable', 'get_vlpage_stat_pixel' );
	//addTFTEventListener( id, 'medError', 'onError' );
	addTFTEventListener( id, 'medOpenLandingPage', 'open_video_browser' );
}
/* events videoplaylist */
function doRegisterVideoplaylistEvents( id ) {
	//addTFTEventListener( id, 'medCountPixel', 'get_vplaylist_stat_pixel' );
}
/* end: video stats */
function removePlayers() {
	if (typeof flashVer != 'undefined' && flashVer.major < 6) {
								 				
		window.open('http://www.amica.de/ami/video-flash/video-flash.htm?themaname=&picfile=http://images2.amica.de/ami/images/logo/amica_249_64.gif&url=&bigMovie=http://videos.amica.de/test/test.flv','videoBrowser','width=645,height=452');
		return false;
	}
	var embObj = new Array();
	embObj = document.getElementsByTagName('object');
	var d = document.createElement("div");
	for (var i=0; i<embObj.length; i++) {
		if (embObj[i].id.substring(0, 9) == "playerswf") {
			divId = embObj[i].parentNode.id;
			$(divId).innerHTML = eval("backup"+embObj[i].id);
		}
	}
}
/* opens the video landingpage */
function open_video_browser(video_time_frame,vid,landingPageUrl) {
	if (typeof landingPageUrl != 'undefined') window.location.href = landingPageUrl;
	else {
		var lPapeTopic = (vid.substring(0, 2) == "rt") ? '/politik/videos/nachrichten-ueberblick' : '/intern';
		window.location.href = "http://"+window.location.hostname+lPapeTopic+"/video_vid_"+vid+".html";
	}
}

// openWinIdent (Popup erzeugen)
function openWinIdent(myWin, breite, hoehe, winname) {
	fenster = open(myWin, winname, "scrollbars=yes,resizable=yes,status=no,toolbar=no,menubar=no,width="+breite+",height="+hoehe);
	fenster.focus();
}

// createPopup (nochmal ein Popup erzeugen)
function createPopup(URL, Title, Width, Height, optParams) {
	if(optParams == "") {
		var optParams = "scrollbars=yes,resizable=yes,status=no,toolbar=no,menubar=no";
	}
	var Params = 'width='+Width+',height='+Height+','+optParams;
	newWindow = open(URL, Title, eval('"'+Params+'"'));
	newWindow.focus();
}





var RateMsg = {
	init: function(RatedVotes,RatedFlt,RatedInt,mode){

		var StrPoints = (RatedInt > 1)?" Punkte":" Punkt";
		var StrVotes = (RatedVotes > 1)?" Stimmen":" Stimme";

		if (mode == 'alt') {
			var StrRateMsgAlt = RatedFlt+StrPoints+' bei '+RatedVotes+StrVotes;
		} else if (mode == 'rateMsg') {
			var StrRateMsgAlt = '<strong>'+RatedFlt+'</strong>'+StrPoints+' bei '+'<strong>'+RatedVotes+'</strong>'+StrVotes;
		} else if (mode == 'ranking') {
			var StrRateMsgAlt = '<strong>'+RatedFlt+'</strong>'+StrPoints+'<br />'+'<strong>'+RatedVotes+'</strong>'+StrVotes;
		}
		if (RatedVotes == 0) {
			var StrRateMsgAlt = '';
		}
		return StrRateMsgAlt;
	}
}

// sendRate (Bewertung abschicken)
function sendRate(iStar,ctId,parentId,ctType,parentType,imgSequ,iImg,myUrlAjax,myScript) {
	var urlRate = myUrlAjax + myScript;
	var parsRate = '?ajax=true&stars='+iStar+'&ctId='+ctId+'&parentId='+parentId+'&ctType='+ctType+'&parentType='+parentType;
	var MyUrl = urlRate + parsRate;

	new Ajax.Request(MyUrl, {
		method: 'get',
		onSuccess: function(originalRequest) {
			var jsonHBVers = originalRequest.responseText;
			var json = jsonHBVers.replace(/<!-- Generated by.*/g,"");
			// parse json-response
			var obj = json.evalJSON();
			var RespError = obj.RespSet.RateError;
			var RespErrMessg = obj.RespSet.RateErrMessg;
			var RespAvg = obj.RespSet.RateAvg;
			var RespFlt = obj.RespSet.RateFlt;
			var RespVotes = obj.RespSet.RateVotes;
			var RespMessg = obj.RespSet.RateMessg;
			if (RespError == "false") {
				// upd arrays
				ImgRatedMyArray[iImg] = iStar;
				ImgRatedAvgArray[iImg] = RespAvg;
				ImgRatedAvgFltArray[iImg] = RespFlt;
				ImgRatedVotesArray[iImg] = RespVotes;
				// displ MyRating
				$('ct_rate_act_'+iImg).innerHTML = "";
				$('ct_rate_msg_'+iImg).innerHTML = RespMessg;
				ic_passive(iStar,MaxStars,imgSequ,iImg);
				// update eventhandler onmouseout
				ImgRatedTmpArray[iImg] = iStar;
				// switch to displ. Average
				var ThisRespMsg2 = RateMsg.init(ImgRatedVotesArray[iImg],ImgRatedAvgFltArray[iImg],ImgRatedAvgArray[iImg],'rateMsg');
				var CallTimeFunc = "switchRated("+RespAvg+",'"+imgSequ+"',"+iImg+",'"+ThisRespMsg2+"','avg')";
				active = setTimeout(CallTimeFunc, 1200);
			} else {
				$('ct_rate_msg_'+iImg).innerHTML = RespErrMessg;
				$('ct_rate_act_'+iImg).innerHTML = "";
				var CallTimeFunc = "switchRated(ImgRatedMyArray["+iImg+"],'"+imgSequ+"',"+iImg+",'So war Ihre Bewertung','my')";
				active = setTimeout(CallTimeFunc, 1200);

			}
		}
	});
}

// switchRated (Bewertung ändern)
function switchRated(ratedAvg,imgSequ,iImg,SrcCtMsg,SwitchMode) {
	ic_passive(ratedAvg,MaxStars,imgSequ,iImg);
	ImgRatedTmpArray[iImg] = ratedAvg;
	$('ct_rate_msg_'+iImg).innerHTML = SrcCtMsg;
	if (SwitchMode == "avg") {
		var MsgSrc = "<a href=\"javascript: switchRated(ImgRatedMyArray["+iImg+"],'"+imgSequ+"',"+iImg+",'','my');\" title=\"meine Bewertung zeigen\" onmouseover=\"window.status='';return true;\" onmouseout=\"window.status='';return true;\">meine Bewertung zeigen</a>";
	} else {
		var MsgSrc = "<a href=\"javascript: switchRated(ImgRatedAvgArray["+iImg+"],'"+imgSequ+"',"+iImg+",'"+RateMsg.init(ImgRatedVotesArray[iImg],ImgRatedAvgFltArray[iImg],ImgRatedAvgArray[iImg],'rateMsg')+"','avg');\" title=\"Gesamtbewertung zeigen\" onmouseover=\"window.status='';return true;\" onmouseout=\"window.status='';return true;\">Gesamtbewertung zeigen</a>";
	}
	$('ct_rate_act_'+iImg).innerHTML = MsgSrc;
}

// ic_active (aktives Icon)
function ic_active(iStar,imgSequ,iImg) {
	for (var i = 1; i <= iStar; i++) {
		var imgname = imgSequ + '_' + i + '_' + iImg;
		$(imgname).src = img_star_over.src;
	}
}

// ic_passice (passives Icon)
function ic_passive(ratedAvg,stars,imgSequ,iImg) {
	for (var i = 1; i <= stars; i++) {
		var imgname = imgSequ + '_' + i + '_' + iImg;
		if (i <= ratedAvg) {
			$(imgname).src = img_star_on.src;
		} else {
			$(imgname).src = img_star_off.src;
		}
	}
}

// toggleTitle (wechselt das Title Attribut einer ID)
function toggleTitle(ID,text1,text2) {
	$(ID).title = ($(ID).title == text1)?text2:text1;
}

// findTopPos (findet die Top-Position eines Elements)
function findTopPos(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curtop += obj.offsetTop
		}
	}
	return curtop;
}

// counter_txt
var thelen = 0;
var thelencount = 0;
var thestr = '';

function counter_txt(attr,maxlen,thestrall,blockid) {
	$(blockid).style.display = 'block';

	var thestr = thestrall;
	var thelen = thestr.length;
	var thelencount = maxlen - thelen;
	var warntxt = '';

	if (thelencount < 0) {
		var thetxtCut = thestr.substring(0,maxlen);
		document.write_comment[attr].value = thetxtCut;
		var thelencount = 0;
	}

	if (thelencount <= 0) {
		warntxt = 'Die maximale Zeichenl&auml;nge wurde &uuml;berschritten.';
	} else {
		warntxt = '';
	}

	thecountnote = 'Sie k&ouml;nnen noch <strong>'+thelencount+'</strong> Zeichen eingeben.';
	$(blockid).innerHTML = thecountnote;
	show_warning_txt(warntxt,blockid+"w");
}

// show_warning_txt
function show_warning_txt(warntxt,blockid) {
	if ($(blockid)) {
		$(blockid).innerHTML = warntxt;
		if ((warntxt.length) > 0)
			$(blockid).style.display = '';
		else
			$(blockid).style.display = 'none';
	}
}

// showMessage
function showMessage(rowNoa1,rowNoa2) {
   if(document.getElementById || document.all)
   {
    $(rowNoa1).style.display = 'none';
    $(rowNoa2).style.display = 'block';
    if ($('link_writecomment_a0') != undefined)
    	$('link_writecomment_a0').style.display = 'none';
   }
}

// showImgComment
function showImgComment(txtLengthMax,thisDomain,insCtPath,insCtOh,insCtHd) {
	 var HeaderCut = document.write_comment.head.value;
   var NameCut = document.write_comment.name.value;
   var TxtCut = document.write_comment.txt.value;
   // cut strlength
   var HeaderCut = HeaderCut.substring(0,50);
   var NameCut = NameCut.substring(0,25);
   var TxtCut = TxtCut.substring(0,txtLengthMax);

   // string ok?
   var HeaderCut = replaceSecChar(HeaderCut);
   var NameCut = replaceSecChar(NameCut);
   var TxtCut = replaceSecChar(TxtCut);

	 var insHeader = encodeURIComponent(HeaderCut);
   var insName = encodeURIComponent(NameCut);
   var insTxt = encodeURIComponent(TxtCut);

   var insOid = document.write_comment.oid.value;
   var insType = encodeURIComponent(document.write_comment.type.value);
   var insIp = encodeURIComponent(document.write_comment.ip.value);

   if (document.write_comment.mg5)
   {
   	var insMg5 = document.write_comment.mg5.checked;
   }
   else var insMg5 = 'false';
   urlIns = '/'+CustomShCut+'/comment/comment_div.htm'
   var insContentData = '&ctpth=' + insCtPath + '&ctoh=' + insCtOh + '&cthd=' + insCtHd
   var insAll = 'this_domain=' + thisDomain + '&mg5=' + insMg5 + '&head=' + insHeader + '&name=' + insName + '&txt=' + insTxt + '&oid=' + insOid + '&type=' + insType + '&ip=' + insIp;

   // load insert (neu)- no errorPrint here ==> no oncomplete:
	var insSrc = insAll + insContentData;
	var myAjax = new Ajax.Request(
		urlIns,
		{
		Method: 'post',
		parameters: insSrc
		}
	);
}

// replaceSecChar
function replaceSecChar(attr_str) {
	// dann stringcheck auf zugelassene zeichen
	 var Dblquot = '"'
   var StrOk = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzÄÖÜäöüß0123456789().-_',!?€$%/§&:"+Dblquot;
	 for(CountI = 0 ; CountI < attr_str.length ; CountI++)
	  {
	  	var SubStrCheck = attr_str.charAt(CountI);
	  	if (StrOk.indexOf(SubStrCheck) == -1)
	  	{
	  		var attr_str = attr_str.replace(SubStrCheck," ");
	  	}
    }
    return attr_str;
}

// check attribut != ""
function check_attr(attr_id,attr_str) {
	var errfound = false;
	error_txt = '';
	var thestr = document.write_comment[attr_id].value;
	if (thestr == '')
	{
		error_txt = 'Bitte füllen Sie das Feld für ' + attr_str + ' aus.<br />';
		var errfound = true;
	}
	else var errfound = false;
	return !errfound;
}

// check all attributes with event onsubmit
function validFormStr() {
	var errfound = false;
	var error_txt_all = '';
	if(!check_attr('head','die Überschrift'))
		{
		var error_txt_all = error_txt_all + error_txt;
		}
	if(!check_attr('name','Ihren Namen'))
		{
		var error_txt_all = error_txt_all + error_txt;
		}
	if(!check_attr('txt','Ihren Kommentartext'))
		{
		var error_txt_all = error_txt_all + error_txt;
		}
	if (error_txt_all != '')
		{
		$('ctErrMsg').innerHTML=error_txt_all;
		$('ctErrMsgCt').style.display='block';
		var errfound = true;
		}
	else
		{
		var errfound = false;
		}
	return !errfound;
}

// valid form
function validFormComs(TxtLenMax,thisDomain,insCtPath,insCtOh,insCtHd) {
	var noerrfound = false;
	if(!validFormStr())	{
		var noerrfound = false;
	}
	else
	{
		var noerrfound = true;
		showMessage('submitted_comment_a1','submitted_comment_a2');
		showImgComment(TxtLenMax,thisDomain,insCtPath,insCtOh,insCtHd);
		getomni('kommentare','');
	}
}

var flagGetComments = 1;

// getComments
function getComments() {
	if (flagGetComments == 0) {
		// just toggle
		toggleFolder('more_comments','fold_chng','folder_close','folder_open');
		statsComment();
	} else {
		// ajax
		Element.toggle('comments_loading');
		var urlGetCommts = '/'+CustomShCut+'/comment/proxy_comments.hbs';
		var parsCont = ReadCommentsParsCont;
		var myAjax = new Ajax.Request(
			urlGetCommts,
			{
			Method: 'post',
			parameters: parsCont,
			onSuccess: displComments
			}
		);
	}
}

// displComments
function displComments(originalRequest) {
	$('more_comments').innerHTML = originalRequest.responseText;
	Element.toggle('comments_loading');
	toggleFolder('more_comments','fold_chng','folder_close','folder_open');
	flagGetComments = 0;
	statsComment();
}

// statsComment
function statsComment() {
	getomni('kommentare','');
}

var sendMode = 'ini';
function machzu() {
	new Effect.BlindUp('content_senden');
	if(Element.hasClassName('sendmail_a','sent')) {
		Element.removeClassName('sendmail_a','sent');
		$('sendmail_a').addClassName('send');
	}
	sendMode = 'ini';
	}

// cms_content_senden
function cms_content_senden(email1,email2,text) {
	if (sendMode == 'sent' && email1=='' && email2=='' && text=='') {
		machzu();
	} else {
		if(Element.hasClassName('sendmail_a','send')) {
			Element.removeClassName('sendmail_a','send');
			$('sendmail_a').addClassName('sent');
		}
		if (sendMode == 'ini') {
			new Effect.BlindDown('content_senden');
			sendMode = 'sent';
		}
		var url = urlAjaxRequ+'versenden.hbs';
		var parsSendForm = "email1="+email1+"&email2="+email2+"&text="+encodeURIComponent(text);
		var pars = parsSendForm + PrintSendParsCont;
		var myAjax = new Ajax.Updater(
					{success: 'content_senden'},
					url,
					{
						method: 'get',
						parameters: pars,
						onFailure: reportError,
						evalScripts: true
					});
		getomni('service','');
	}
}

// reportError
function reportError(request) {
	alert('Sorry. There was an error.');
}

// cms_senden_check
function cms_senden_check(){
	if (document.der_formname.email1.value!='' && document.der_formname.email2.value!='') {
		cms_content_senden(document.der_formname.email1.value,document.der_formname.email2.value,document.der_formname.text.value);
	}
}


// fireEvent
function fireEvent (eventType, o) {
	if (document.createEvent) { 				// Mozilla like eventhandling
		var evt = document.createEvent("MouseEvents");
		evt.initEvent(eventType, true, true, window);
		o.dispatchEvent(evt);
	} else if (document.createEventObject) { 	// IE like eventhandling
		var evt = document.createEventObject();
		o.fireEvent('on' + eventType, evt);
	}
}

// init_form_field
function init_form_field(element,visibility) {
	if (visibility == 1)
	{
		if (element.value == element.defaultValue)
			element.value='';
	}
	else if (visibility == 0)
	{
		if (element.value.replace(/\s/g, '') == '' )
		element.value = element.defaultValue;
	}
	return false;
}

// galTeaserActivateTab
function galTeaserActivateTab(tabRef,tabCtRef,tabIndex,LinkPrefix) {
	var TabObj = $(tabCtRef+tabRef);
	if(!Element.hasClassName(TabObj,'loading')) { return; }
	var GTsrc = '';
	var GTmaxImg = (tabCtRef == 'GTL') ? 12 : 8;
	var urlProxy = urlAjaxRequ + 'get_gallery_ranking_tabs.hbs';
	var parsRankg = '?rankingType='+tabRef+'&rankingMaxImgs='+GTmaxImg;
	var getRankgUrl = urlProxy + parsRankg;

	new Ajax.Request(getRankgUrl, {
		method: 'get',
		onSuccess: function(originalRequest) {
			var jsonHBVers = originalRequest.responseText;
			var json = jsonHBVers.replace(/<!-- Generated by.*/g,"");
			var obj = json.evalJSON();
			var RespError = obj.RespSet.RankError;
			var RespImgLink = obj.RespSet.ImgLink;
			var RespImgSrc = obj.RespSet.ImgSrc;
			var RespImgAlt = obj.RespSet.ImgAlt;
			var RespImgCredit = obj.RespSet.ImgCredit;
			if (RespError == "false") {
				eval(RespImgLink);
				eval(RespImgSrc);
				eval(RespImgAlt);
				var j = 0;
				for (var i = 0; i < ImgLinkArr.length; ++i) {
					++j;
					var GTImgMdir = (tabCtRef == 'GTL') ? GTLmdir[i] : GTRmdir[i];
					var GTImgStil = (tabCtRef == 'GTL') ? GTLstil[i] : GTRstil[i];
					GTsrc += '<a href="'+LinkPrefix+ImgLinkArr[i]+'" title="'+ImgAltArr[i]+'"><img id="Thb.'+tabCtRef+'.OID'+tabIndex+j+'" mdir="'+GTImgMdir+'" class="pic-63-94 absolute" style="'+GTImgStil+'" src="'+ImgSrcArr[i]+'" alt="'+ImgAltArr[i]+'" title="'+ImgAltArr[i]+'" /></a>';
				}
				Element.removeClassName(TabObj,'loading');
				TabObj.innerHTML = GTsrc;
				new GalleryThumbScaleClass(tabCtRef+tabRef,1,tabIndex);
				if (RespImgCredit != '') {
					addCredits(RespImgCredit);
				}
			}
		}
	});
}

// TodayRightNaviClass
TodayRightNaviClass = Class.create();
TodayRightNaviClass.prototype = {
	initialize: function(nav,init) {
		this.ces=new Array();
		this.nes=new Array('look','horoskop');
		for (var i=0;i<this.nes.length;i++) {
			this.ces.push($$("div."+$(this.nes[i]).className));
			$(this.nes[i]).onmouseover=this.hover.bind(this);
			if ($(this.nes[i]).className==init) {
				this.ces[i].each(function(item){item.style.display="block"});
				$(this.nes[i]).style.backgroundPosition="0px 0px";
			}
			else
				this.ces[i].each(function(item){item.style.display="none"});
		}
	},
	hover: function(e) {
		var ee=Event.element(e || window.event);
		for (var i=0;i<this.nes.length;i++) {
			$(this.nes[i]).style.backgroundPosition="0px -21px";
			if ($(this.nes[i]).className==ee.className)
				this.ces[i].each(function(item){item.style.display="block"});
			else
				this.ces[i].each(function(item){item.style.display="none"});
		}
		ee.style.backgroundPosition="0px 0px";
	}
}

/* Scale Effect aus Scryptaculous mit direction erweitert */
Effect.ExtScale = function(element, percent) {
		element = $(element);
		var options = Object.extend({
		direction: 'bottom-right',
		moveTransition: Effect.Transitions.sinoidal,
		scaleTransition: Effect.Transitions.sinoidal
	}, arguments[2] || { });

	// abort if one other Effect is playing
	if (isPlaying) return false;

	var moveX, moveY;
	var offsetX = element.width*percent/100-element.width;
	var offsetY = element.height*percent/100-element.height;

	switch (options.direction) {
		case 'top-left':
		  moveX = -(offsetX);
		  moveY = -(offsetY);
		  break;
		case 'top-right':
		  moveX = 0;
		  moveY = -(offsetY);
		  break;
		case 'bottom-left':
		  moveX = -(offsetX);
		  moveY = 0;
		  break;
		case 'bottom-right':
		  moveX = moveY = 0;
		  break;
		case 'center':
		  moveX = element.width / 2;
		  moveY = element.height / 2;
		  break;
	  }
	  return new Effect.Parallel(
		[ new Effect.Scale(element, percent, { sync: true, transition: options.scaleTransition, scaleMode:{originalWidth:63, originalHeight: 94}}),
		  new Effect.Move(element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition })
		], Object.extend({
			 beforeStartInternal: function(effect) {
			   isPlaying = true;
			   effect.effects[0].element.makePositioned().makeClipping();
			 },
			 afterFinishInternal: function(effect) {
			   isPlaying = false;
			 }
		  }, options)
	  );
};

var isPlaying = false;
GalleryThumbScaleClass = Class.create();
GalleryThumbScaleClass.prototype = {
	initialize: function(nav,init,tabref) {
		this.tabref = tabref;
		this.direction = new Object();
		this.direction['bl']='bottom-left';
		this.direction['br']='bottom-right';
		this.direction['tl']='top-left';
		this.direction['tr']='top-right';
		this.timeOutDuration = 6000;

		// save the original position of all elements and bind mouseover and mouseout events to the hover and hout functions
		this.nes = $A($(nav).getElementsByTagName('img'));
		for (var i=0;i<this.nes.length;i++)	{
			mdir = this.nes[i].attributes['mdir'].value;
			this.nes[i].origLeft = this.nes[i].style.left;
			this.nes[i].origTop = this.nes[i].style.top;
			$(this.nes[i]).onmouseover=this.hover.bind(this,mdir);
			$(this.nes[i]).onmouseout=this.hout.bind(this);
		}
		this.timerId1 = setTimeout(this.scaleRndImg.bind(this), this.timeOutDuration);
	},
	hover: function(mdir,e) {
		// timeout handling
		clearTimeout(this.timerId1);

		if (isPlaying) return false;
		var ee=Event.element(e || window.event);
		for (var i=0;i<this.nes.length;i++)	{
			// set back the original size and position of all elements
			if (ee.id != this.nes[i]) {
				$(this.nes[i]).style.width = '63px';
				$(this.nes[i]).style.height= '94px';
				$(this.nes[i]).style.left  = this.nes[i].origLeft;
				$(this.nes[i]).style.top   = this.nes[i].origTop;
			}
			$(this.nes[i]).style.zIndex = 10;
		}
		if (ee.width <= 63) {
			// bring element in front and scale it
			ee.style.zIndex = 100;
			new Effect.ExtScale( ee.id, 226, {duration:0.5, direction:this.direction[mdir], scaleX:true, scaleY:true, scaleMode:{originalWidth:63, originalHeight: 94}});
		}
	},
	hout: function(e) {
		var ee=Event.element(e || window.event);
		ee.style.width = '63px';
		ee.style.height= '94px';
		ee.style.left  = ee.origLeft;
		ee.style.top   = ee.origTop;
		this.timerId1 = setTimeout(this.scaleRndImg.bind(this), this.timeOutDuration);
	},
	scaleRndImg: function(maxId) {
		// get the current tab
		tabNr = this.tabref;
		maxId = this.nes.length;
		var rndId = Math.ceil(Math.random()*(maxId));
		fireEvent('mouseover',this.nes[rndId-1]);
		this.timeOutDuration = 6000;
		this.timerId1 = setTimeout(this.scaleRndImg.bind(this), this.timeOutDuration);
	}
}

TabsNaviClassClck = Class.create();
TabsNaviClassClck.prototype = {
	initialize: function(nav,init,galpref) {
		this.ces = new Array();
		this.nes = $A($(nav).getElementsByTagName('a'));
		this.actTabNr = 1;
		for (var i=0;i<this.nes.length;i++) {
			this.ces.push($$("div."+galpref+$(this.nes[i]).className));
			$(this.nes[i]).onclick=this.onclck.bind(this);
			if ($(this.nes[i]).className==init) {
				this.ces[i].each(function(item){item.style.display="block"});
				$(this.nes[i]).style.backgroundPosition="0px 0px";
				this.actTabNr = i+1;
			}
			else
				this.ces[i].each(function(item){item.style.display="none"});
		}
	},
	onclck: function(e) {
		var ee=Event.element(e || window.event);
		for (var i=0;i<this.nes.length;i++) {
			$(this.nes[i]).style.backgroundPosition="0px -21px";
			if ($(this.nes[i]).className==ee.className) {
				this.ces[i].each(function(item){item.style.display="block"});
				this.actTabNr = i+1;
			} else
				this.ces[i].each(function(item){item.style.display="none"});
		}
		ee.style.backgroundPosition="0px 0px";
	},
	getActTabNr: function() {
		return this.actTabNr;
	}
}

TabsNaviClass = Class.create();
TabsNaviClass.prototype = {
	initialize: function(nav,init,galpref) {
		this.ces = new Array();
		this.nes = $A($(nav).getElementsByTagName('a'));
		this.actTabNr = 1;
		for (var i=0;i<this.nes.length;i++) {
			this.ces.push($$("div."+galpref+$(this.nes[i]).className));
			$(this.nes[i]).onmouseover=this.hover.bind(this);
			if ($(this.nes[i]).className==init) {
				this.ces[i].each(function(item){item.style.display="block"});
				$(this.nes[i]).style.backgroundPosition="0px 0px";
				this.actTabNr = i+1;
			}
			else
				this.ces[i].each(function(item){item.style.display="none"});
		}
	},
	hover: function(e) {
		var ee=Event.element(e || window.event);
		for (var i=0;i<this.nes.length;i++) {
			$(this.nes[i]).style.backgroundPosition="0px -21px";
			if ($(this.nes[i]).className==ee.className) {
				this.ces[i].each(function(item){item.style.display="block"});
				this.actTabNr = i+1;
			} else
				this.ces[i].each(function(item){item.style.display="none"});
		}
		ee.style.backgroundPosition="0px 0px";
	},
	getActTabNr: function() {
		return this.actTabNr;
	}
}

// getDateStrWithTime
function getDateStrWithTime(){
	var DayArray = new Array("Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag");
	var today = new Date();
	//alert(today+" "+today.getMonth());
	var year = today.getYear();
	var mon = today.getMonth()+1;
	var day = today.getDate();
	if(year<1000) year+=1900
	mon = ((mon < 10) ? "0" : "") + mon;
	day = ((day < 10) ? "0" : "") + day;
	var todayStr = DayArray[today.getDay()] + " ";
	todayStr += day+"."+mon+"."+year;
	var h = today.getHours();
	var m = today.getMinutes();
	//var s = today.getSeconds();
	var timeStr = h;
	timeStr += ((m < 10) ? ":0" : ":") + m;
	//timeStr += ((s < 10) ? ":0" : ":") + s;
	return todayStr+", "+timeStr+" Uhr";
}


// openPopup
newwindow=false;
function openPopup(myWin, breite, hoehe, winname) {
  if(newwindow&&newwindow.closed==false)
    newwindow.close()
    var l = (screen.availWidth - breite) / 2;
    var t = (screen.availHeight - hoehe) / 2;
    newwindow = open(myWin, winname, "scrollbars=yes,resizable=yes,status=no,toolbar=no,menubar=no,width="+breite+",height="+ hoehe+ ",left=" + l + ",top=" + t + ";");
  	newwindow.focus();
}

// for ThumbnavigationBox with CircleEffects
function ThumbsNavCircle(activeRow,circleMode,MaxPics,MaxPicsOfRow,circlObj,widthMove) {
	var numberOfRows = Math.ceil(MaxPics/MaxPicsOfRow);
	var ActRowId = (!ThumbOnChanged) ? activeRow : ThumbCircleRow2App;
	var FollowRowId = (ActRowId == numberOfRows-1) ? 0 : ActRowId+1;
	var PrevRowId = (ActRowId == 0) ? numberOfRows-1 : ActRowId-1;
	ThumbCircleRow2App = (circleMode == 'right') ? FollowRowId : PrevRowId;

	var objDisapp = $(circlObj+ActRowId);
	var objApp = $(circlObj+ThumbCircleRow2App);

	if (circleMode == 'right') {
		objApp.style.left=widthMove+"px";
		objApp.style.display = "block";
		new Effect.Parallel(
			[
				new Effect.Move(objDisapp,{ x: -465, y: 0, mode:'relative'}),
				new Effect.Move(objApp,{ x: -465, y: 0, mode:'relative'})
			],
			{
				beforeStartInternal: function(effect) { ActCircleInternal(circleMode,circlObj); },
			 	afterFinishInternal: function(effect) { ActCircleInternal(circleMode,circlObj); }
			}
		);
	} else if (circleMode == 'left') {
		objApp.style.left="-"+widthMove+"px";
		objApp.style.display = "block";
		new Effect.Parallel(
			[
				new Effect.Move(objDisapp,{ x: 465, y: 0, mode:'relative'}),
				new Effect.Move(objApp,{ x: 465, y: 0, mode:'relative'})
			],
			{
				beforeStartInternal: function(effect) { ActCircleInternal(circleMode,circlObj); },
			 	afterFinishInternal: function(effect) { ActCircleInternal(circleMode,circlObj); }
			}
		);
	}
	ThumbOnChanged = true;
}
function ActCircleInternal(circleMode,circlObj) {
	var direction = (circleMode == 'right') ? 'r' : 'l';
	Element.toggle($(circlObj+'a_'+direction+'_actv'));
	Element.toggle($(circlObj+'a_'+direction+'_pasv'));
	//Element.toggle(circlObj+'overlay');
}


// SwitchMyLayer (wird von Accelsis verwendet)
function SwitchMyLayer(myEffect,layerId,duration,arg2,arg3) {
	var obj = layerId;
	if (myEffect == 'BlindUp') {
		new Effect.BlindUp(obj);
	}
	else if (myEffect == 'Puff') {
		new Effect.Puff(obj);
	}
	else if (myEffect == 'Shrink') {
		new Effect.Shrink(obj);
	}
	else if (myEffect == 'SwitchOff') {
		new Effect.SwitchOff(obj);
	}
	else if (myEffect == 'Fold') {
		new Effect.Fold(obj);
	}
	else if (myEffect == 'Fade') {
		new Effect.Fade(obj);
	}
	else if (myEffect == 'BlindDown') {
		new Effect.BlindDown(obj);
	}
	else if (myEffect == 'Appear') {
		new Effect.Appear(obj);
	}
}



// displMSProfile (Profil bearbeiten Mystyle)
function displMSProfile(){

	// hidden adsd_skyscraper
		if ($('adsd_skyscraper') != undefined) {
			var d = $('adsd_skyscraper');
			d.style.display = 'none';
		}
		if ($('adsd_contentad_c1') != undefined) {
			var e = $('adsd_contentad_c1');
			e.style.display = 'none';
		}
		if ($('adsd_contentad_c2') != undefined) {
			var f = $('adsd_contentad_c2');
			f.style.display = 'none';
		}
		if ($('adsd_topbanner') != undefined) {
			var g = $('adsd_topbanner');
			g.style.display = 'none';
		}
		if ($('adsd_contentad_c3') != undefined) {
			var h = $('adsd_contentad_c3');
			h.style.display = 'none';
		}
		if ($('adsd_contentbox') != undefined) {
			var i = $('adsd_contentbox');
			i.style.display = 'none';
		}

	var arrayPageSize = getPageSize();
	Element.setWidth('MSOverlay', arrayPageSize[0]);
	Element.setHeight('MSOverlay', arrayPageSize[1]);
	new Effect.Appear('MSOverlay', { duration: 0.5, from: 0.0, to: 0.7 });
	$('MSProfile').show();
}
// for all teaser kind of 'neu auf amica'
function changeTeaser(next,teasCount,teasCt) {
	var allTeaser = teasCount;
	for (var i=1; i<=allTeaser; i++) {
		if ($(teasCt+i).style.display == "block") {
			var nextTeaserId = i + next;
			if (nextTeaserId < 1)
				nextTeaserId = allTeaser;
			else if (nextTeaserId > allTeaser)
				nextTeaserId = 1;
			var hideTeaser = teasCt + i;
			var showTeaser = teasCt + nextTeaserId;
		}
	}
	$(hideTeaser).style.display = "none";
	$(showTeaser).style.display = "block";
	getomni('','');
}

/**
 * Method retrieving Omniture configuration variable(s)
 *
 * @param property Name of variable to retrieve values for (optional)
 */
function getOmnitureData( property ) {
	
	// Check if we need to retrieve all Omniture configuration
	// variables or only the value of a specific one
	if( property == undefined ) 
	{
		var objectArray = new Array();
		
		// Set account variable explicitly
		objectArray.push( new Array( "account", s_account ) );			
		
		// Loop all variables of s_code object and get its values
		for( var attribute in s )
		{
			// Filter out functions and objects
			if( ( typeof s[attribute] != "function" ) && 
				( typeof s[attribute] != "object" ) )
			{
				objectArray.push( new Array( attribute, s[attribute] ) );				
			}
		}
		return objectArray;
	}
	else 
	{
		// Retrieve value of a specific variable
		return s[property];
	}
}