// Basisdaten
var STR_submenu = 'untermenu';


// Inhalt einer Box verstecken
function foldBox(STR_box_id)
{
	// Inhalt ausblenden
	$('#' + STR_box_id + ' > .' + STR_submenu).slideUp('fast');
	$('#' + STR_box_id + ' div.minimize').hide();
	$('#' + STR_box_id + ' div.maximize').show();
	
} // end function foldBox


// Inhalt einer Box zeigen
function unfoldBox(STR_box_id)
{
	// Inhalt ausblenden
	$('#' + STR_box_id + ' > .' + STR_submenu).slideDown('fast');
	$('#' + STR_box_id + '  div.minimize').show();
	$('#' + STR_box_id + '  div.maximize').hide();
	
} // end function unfoldBox	


//Inhalt einer Box zeigen
function showAll(STR_box_id,morebutton)
{
	// Inhalt ausblenden
	$(morebutton).fadeOut('fast');
	$('#' + STR_box_id).slideDown('fast');
	
} // end function unfoldBox	



/*------------ SlideBox zuerst ausgeklappt -----*/
// Basisdaten
var STR_submenu2 = 'untermenu2';


// Inhalt einer Box verstecken
function foldBox2(STR_box_id)
{
	// Inhalt ausblenden
	$('#' + STR_box_id + ' > .' + STR_submenu2).slideUp('fast');
	$('#' + STR_box_id + ' div.minimize2').hide();
	$('#' + STR_box_id + ' div.maximize2').show();
	
} // end function foldBox


// Inhalt einer Box zeigen
function unfoldBox2(STR_box_id)
{
	// Inhalt ausblenden
	$('#' + STR_box_id + ' > .' + STR_submenu2).slideDown('fast');
	$('#' + STR_box_id + '  div.minimize2').show();
	$('#' + STR_box_id + '  div.maximize2').hide();
	
} // end function unfoldBox	


/*---------------- Subsubmenu ---------------*/

$(function(){
$('ul.jd_menu').jdMenu({	onShow: loadMenu
						//onHideCheck: onHideCheckMenu,
						//onHide: onHideMenu, 
						//onClick: onClickMenu, 
						//onAnimate: onAnimate
											});
$('ul.jd_menu_vertical').jdMenu({onShow: loadMenu, onHide: unloadMenu, offset: 1, onAnimate: onAnimate});
});

function onAnimate(show) {
				//$(this).fadeIn('slow').show();
		if (show) {
			$(this)
				.css('visibility', 'hidden').show()
					.css('width', $(this).innerWidth())
				.hide().css('visibility', 'visible')
			.fadeIn('normal');
		} else {
			$(this).fadeOut('fast');
		}
	}

		var MENU_COUNTER = 1;
		function loadMenu() {
			if (this.id == 'dynamicMenu') {
				$('> ul > li', this).remove();
			
				var ul = $('<ul></ul>');
				var t = MENU_COUNTER + 10;
				for (; MENU_COUNTER < t; MENU_COUNTER++) {
					$('> ul', this).append('<li>Item ' + MENU_COUNTER + '</li>');
				}
			}
		}

function unloadMenu() {
	if (MENU_COUNTER >= 30) {
			MENU_COUNTER = 1;
		}
}

// We're passed a UL
function onHideCheckMenu() {
	return !$(this).parent().is('.LOCKED');
}

// We're passed a LI
function onClickMenu() {
	$(this).toggleClass('LOCKED');
	return true;
}


function openPopUp(url,sTmpWidth)
{
	if ((typeof sTmpWidth) == 'undefined') {sTmpWidth = 500;}
		newWindow = window.open(url,"popup","width=" + sTmpWidth + ",scrollbars=yes,resizable=yes");
}


function toggleDiv(id,flagit) 
					{
						if (flagit=="1")
							{
						if (document.layers) document.layers[''+id+''].visibility = "show"
						else if (document.all) document.all[''+id+''].style.visibility = "visible"
						else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "visible"
							}
						else
						if (flagit=="0")
							{
						if (document.layers) document.layers[''+id+''].visibility = "hide"
						else if (document.all) document.all[''+id+''].style.visibility = "hidden"
						else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "hidden"
							}
					}

function removeBanner(myid)
{
	var src = $(myid).attr("src");
	// da nicht immer ein Bild geliefert wird bei Flashbannern
	if (typeof(src) != 'undefined'){
		if (src.search(/817-grey.gif/) >= 0 )
		{
			$(myid).parent().parent().remove();
		}
		else if ( src == "http://m1.emea.2mdn.net/2005024/1x1.gif" || src == "http://s0.2mdn.net/2005024/1x1.gif") {
			$(myid).parent().remove();
		}
	}
}


/* 
START: Slottracking fuer die BEPs
@desc: 21.09.2009 / alle Divs der Seite werden gesucht, die diese (Slot-)Klasse haben (wird als Parameter uebergeben)
@param: Klasse des Divs (= Name des Slots, aus dem der Link aufgerufen wird)
*/
function sc_slotTracking(item)
	{
		// alle (Div-) Classes ermitteln, die einen Slotnamen haben
		$("." + item + " a").each(function(i){
			// Objekteigenschaft href auslesen
			var STR_url = this.href;
			
			// Slotbezeichnung suchen
			var INT_result_slot = STR_url.search(/slot=|javascript:/);

			// nach Anchorn suchen
			var INT_result_anchor_exists = STR_url.search(/#/);
			var STR_url_anchor = '';

			// URL aufsplitten (evtl. vorhanden Anchor-Tag zwischenspeichern)
			if (INT_result_anchor_exists != -1) 
			{
				var STR_url_anchor = STR_url.substring(INT_result_anchor_exists, STR_url.length);
				var STR_url = STR_url.substring(0, INT_result_anchor_exists);
			}

			// kein Slottracking bei einem Ad-Link
			var INT_result_adlink = STR_url.search(/(doubleclick)/);
			
			
			var BOO_slottracking = 1;
			
			if ($(this).hasClass("noslottracking")) 
			{
				var BOO_slottracking = 0;
			}
			
			
			// Slotbezeichnung vorhanden? Ad-Link?
			if (INT_result_slot == -1 && INT_result_adlink == -1 && BOO_slottracking == 1)
			{
				var INT_result = STR_url.search(/(%3f)/);
				var INT_result2 = STR_url.search(/\?/);
				/* Slot-Parameter werden jetzt hier ersetzt! */
				if (INT_result > -1 || INT_result2 > -1)
				{
					STR_url += "&slot=" + item + "_pos" + i;
				}
				else
				{
					STR_url += "?slot=" + item + "_pos" + i;
				}
				// URL wieder zusammenbauen
				var STR_url = STR_url + STR_url_anchor;
				
				$(this).attr('href', STR_url);
			}	
		});
		
		return false;
	}
/* 
ENDE: Slottracking fuer die BEPs
*/


/*
 * Get URL Parameter: Übergabe eines URL-Parameters.
 * @param {String} name
 */
function gup( name )
{
	name = name.replace(/[[]/,"\[").replace(/[]]/,"\]");
	var regexS = "[\?&]"+name+"=([^&##]*)";
	var regex = new RegExp( regexS );
	var results = regex.exec( window.location.href );
	if( results == null )
		return "0";
	else
		return results[1];
}
/* 
ENDE: Get URL Parameter
*/

/*
 * Steuerung ob Video bzw. Leadfragen angezeigt werden sollen.
 * @param {Object} data
 * @param {Object} hasQuestion
 */
function FNC_startVideo(STR_div,data, BOO_hasQuestion, BOO_isliveEvent){
    try {
		var STR_opv = gup('opv');
		
    	if (typeof(BOO_hasQuestion) == 'undefined') 
		{
        	BOO_hasQuestion = 0;
        }
		if (typeof(BOO_isliveEvent) == 'undefined') 
		{
        	BOO_isliveEvent = 0;
        }
		if (typeof(STR_div) == 'undefined')
		{
			STR_div = 'video_content';
		}
		$.extend(data, { liveEvent: BOO_isliveEvent});
		if (BOO_isliveEvent == 1) {
			STR_targetUrl = '/shared/vogelonline/_ajax/webcasts/_joinLiveWebcast.cfm';
			$("#"+STR_div).css("background-image","");
		}
		else {
			STR_targetUrl = '/shared/vogelonline/_ajax/webcasts/_showVideo.cfm';
			if (STR_opv != '3'){
				$.ajax({ url: '/templates/globalrelaunch/_dyn_ssi/_dyn_ssi_tracking.cfm', 
					data:data, 
					dataType: 'script', 
					cache: false
	 			});
			}
			$("#"+STR_div).css("background-image","");
		}
        if (!BOO_hasQuestion) {
            $.ajax({
                type: "POST",
                url: STR_targetUrl,
                data: data,
                success: function(responseText){
                    if (responseText.search(/error:0/) == -1) {
						$("#"+STR_div).html(responseText);
						$("#"+STR_div).fadeIn('slow');
                    }
                    else {
                        alert("Fehler beim Starten");
                    }
                    
                }
            });
        }
		else{
			$.ajax({
                type: "POST",
                url: '/shared/vogelonline/_ajax/webcasts/_showQuestions.cfm',
                data: data,
                success: function(responseText){
                    if (responseText.search(/error:0/) == -1) {
						$("#"+STR_div).html(responseText);
						$("#"+STR_div).fadeIn('slow');
                    }
                    else {
                        alert("Fehler beim Starten");
                    }
                    
                }
            });
			
		}
    } 
    catch (e) {
    }
}

function FNC_Questions(STR_div,STR_form,INT_userid,INT_downloadid,INT_pageid,BOO_isliveEvent,INT_companyid){
    try {
			$('#'+STR_form).ajaxSubmit({
                type: "POST",
                url: '/shared/vogelonline/_ajax/webcasts/_showQuestions.cfm',
                success: function(responseText){
                    if (responseText.search(/error/) == -1) {
						if (responseText.search(/success/) == -1) {
							$("#"+STR_div).html(responseText);
							$("#"+STR_div).fadeIn('slow');
						}
						else {
							FNC_startVideo(STR_div,{userid: INT_userid, pk: INT_downloadid, pid: INT_pageid, ct: 65, op: 'dwn', BOO_isajax: true, haslead:'1', companyid: INT_companyid},0,BOO_isliveEvent);
						}				
					
						
                    }
                    else {
                        alert("Fehler beim Starten");
                    }
                    
                }
            });
        }
    catch (e) {
    }
}


/**
  * Funktion: linkTracking()
  * setzt cookies mit der clickmapid und der autonomyid
  * Parameter: clickmapid, autonomyid
  * Rückgabewert: true/false
  **/
      
function linkTracking(STR_linkid, STR_autonomyid)
{
    if (typeof(STR_linkid) != 'undefined')
        {
			// Cookie fuer Slottracking setzen
            setCookie('sc_slot',STR_linkid);
        }
        
    if (typeof(STR_autonomyid) != 'undefined')
        {
			// Cookie fuer Autonomytracking setzen
            setCookie('sc_prof',STR_autonomyid);
        }

	return false;
}

 
/**
  * Funktion: setCookie()
  * setzt cookie
  * Parameter: cookie-Name,cookie-Wert
  * Rückgabewert: true/false
  **/

function setCookie(STR_name,STR_value)
{
	document.cookie = STR_name + "=" + escape(STR_value);
}


/**
  * Funktion: getCookie()
  * holt cookie-Wert
  * Parameter: cookie-Name
  * Rückgabewert: cookie-Wert/ false
  **/
	
function getCookie( STR_cookieName )
{
    strValue = false;
    
    if( strCookie = document.cookie )
        {
            if( arrCookie = strCookie.match( new RegExp( STR_cookieName + '=([^;]*)', 'g')))
                {
                    strValue=RegExp.$1;
                }
        }
    return(strValue);
}


/**
  * Funktion: delCookie()
  * loescht cookie
  * Parameter: Cookie-Name
  * Rückgabewert: true/false
  **/

function delCookie(STR_cookieName)
{
	
	if(document.cookie)
	{
		document.cookie = STR_cookieName + '=' + getCookie(STR_cookieName) + '; expires=Fri, 01 Jan 1990 00:00:00 UTC; path=/';
		return true;
	}
return false;
}	

