// 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	





/*------------ 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") {
			$(myid).parent().remove();
		}
	}
}


/* 
START: Slottracking für die BEPs
@desc: 21.09.2009 / alle Divs der Seite werden gesucht, die diese (Slot-)Klasse haben (wird als Parameter übergeben)
@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;
			var INT_result_slot = STR_url.search(/slot=|javascript:/);

			// die Slotbezeichnung schon vorhanden?
			if (INT_result_slot == -1)
			{
				var INT_result = STR_url.search(/\?/);
				/* Slot-Parameter werden jetzt hier ersetzt! */
				if (INT_result > -1)
				{
					STR_url += "&slot=" + item + "_pos" + i;
				}
				else
				{
					STR_url += "?slot=" + item + "_pos" + i;
				}
				$(this).attr('href', STR_url);
			}	
		});
		
		return false;
	}
/* 
ENDE: Slottracking für die BEPs
*/

/*
 * 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 {
		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';
			$("#"+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, haslead:'1', companyid: INT_companyid},0,BOO_isliveEvent);
						}				
					
						
                    }
                    else {
                        alert("Fehler beim Starten");
                    }
                    
                }
            });
        }
    catch (e) {
    }
}
