/*---------------------------------------------------------------------------------------------------------*/
/* -------------------------- metacap js ----------------------------------------------------------------- */
/* ------------------------------------------------------------------------------------------------------- */

function addBet(){
	}

function popup(type, template, dx, dy, style){
	fenster = window.open("popup_"+type+".php?main="+template+"&style="+style,"popup","toolbar=no,scrollbars=yes,menubar=no,resizable=yes,status=no,width="+dx+",height="+dy+",dependent=yes");
	fenster.focus();
	}

function game(dx, dy){
	fenster = window.open("game.php","game","toolbar=no,scrollbars=no,menubar=no,resizable=yes,status=no,width="+dx+",height="+dy+",dependent=yes");
	fenster.focus();
	}

function open_page(page, close){
	document.location.href = 'index.php?main='+page;
	if(close)
		fenster.close();
	}

jQuery.noConflict();
jQuery(document).ready(function() {
	
	/* ### Meine Wetten / Kontoauszug / Ergebnisliste (country) ### */

//  tobias: funktionalität wegen ajax aufrufen überholt
//	jQuery(".drop_title, drop_down, .button_drop_on").click(function() {
//		var idString = jQuery(this).parent().attr("id");
//		console.info('sildeToggle #menue_'+idString);
//		jQuery("#menue_" + idString).slideToggle("fast");
//		});
	
	jQuery(".button_drop, .button_drop_on, .but_drop_160").mouseleave(function() {
		jQuery(this).find(".hide").hide();
	});
	
	jQuery("#menue_drop_1 div, #menue_drop_2 div, #menue_drop_3 div, #menue_drop_nav div, #menue_drop_affiliate div").hover(function () {
		jQuery(this).css({'background-color' : '#ebebeb'});
    	}, function () {
			jQuery(this).css({'background-color' : ''});
	});

// wird in statement.xhtml und ticketList.xhtml per onclick umgesetzt	
// INFO: In Update v39 zu: jQuery("#menue_drop_1 div, #menue_drop_2 div, #menue_drop_3 div, #menue_drop_nav div").click(function () {
//	jQuery("#menue_drop_1 div, #menue_drop_2 div, #menue_drop_3 div").click(function () {
//		var idString = jQuery(this).parent().attr("id");
//		idString = idString.substr(6);
//		jQuery("#"+idString+" .drop_title").text(jQuery(this).text());
//		jQuery(this).parent().hide();
		
// Wir haben einen eigenen Datepicker!
//		if(jQuery(this).parent().attr("id") == 'menue_drop_1' && jQuery(this).attr("id") != 'period'){
//			jQuery("#datepicker").hide();
//		}		
//	});
	
// Wir haben einen eigenen Datepicker!
//	jQuery("#period").click(function () {
//		jQuery("#datepicker").show();
//  });
	
	
	jQuery(".button_slider").click(function() {
		if(jQuery("#button_slider_all").is(':hidden')){
			jQuery(this).addClass("on");
			jQuery("#button_slider_all").show();
			jQuery(this).parent().parent().parent().find(".sheet_slider_body_off").addClass("sheet_slider_body");
			jQuery(this).parent().parent().parent().find(".sheet_slider_body_off").removeClass("sheet_slider_body_off");
			}
		else{
			jQuery(this).removeClass("on");
			jQuery("#button_slider_all").hide();
			jQuery(this).parent().parent().find(".sheet_slider_body").addClass("sheet_slider_body_off");
			jQuery(this).parent().parent().find(".sheet_slider_body").removeClass("sheet_slider_body");
			}
		});
	
	jQuery("#button_slider_foot").click(function() {
		jQuery("#button_slider_all").hide();
		jQuery(this).parent().parent().find(".button_slider").removeClass("on");
		jQuery(this).parent().find(".sheet_slider_body").addClass("sheet_slider_body_off");
		jQuery(this).parent().find(".sheet_slider_body").removeClass("sheet_slider_body");
		});
	
	jQuery(".sheet_slider_s").click(function() {
		if(jQuery(this).parent().parent().find(".hide").is(':hidden')){
			jQuery(this).addClass("s_on");
			jQuery(this).parent().parent().find(".hide").show();
			jQuery(this).parent().parent().find(".sheet_slider_body_off").addClass("sheet_slider_body");
			jQuery(this).parent().parent().find(".sheet_slider_body_off").removeClass("sheet_slider_body_off");
			}
		else{
			jQuery(this).removeClass("s_on");
			jQuery(this).parent().parent().find(".hide").hide();
			jQuery(this).parent().parent().find(".sheet_slider_body").addClass("sheet_slider_body_off");
			jQuery(this).parent().parent().find(".sheet_slider_body").removeClass("sheet_slider_body");
			}
		});
	
	// siehe ebet.js
//	jQuery(".sheet_slider_m").click(function() {
//		if(jQuery(this).parent().parent().find(".hide").is(':hidden')){
//			jQuery(this).addClass("m_on");
//			jQuery(this).parent().parent().find(".hide").show();
//			jQuery(this).parent().parent().find(".sheet_slider_body_off").addClass("sheet_slider_body");
//			jQuery(this).parent().parent().find(".sheet_slider_body_off").removeClass("sheet_slider_body_off");
//			}
//		else{
//			jQuery(this).removeClass("m_on");
//			jQuery(this).parent().parent().find(".hide").hide();
//			jQuery(this).parent().parent().find(".sheet_slider_body").addClass("sheet_slider_body_off");
//			jQuery(this).parent().parent().find(".sheet_slider_body").removeClass("sheet_slider_body");
//			}
//		});
	
	jQuery(".sheet_slider_foot").click(function() {
		jQuery(this).parent().find(".hide").hide();
		jQuery(this).parent().find(".sheet_slider_s").removeClass("s_on");
		jQuery(this).parent().parent().find(".sheet_slider_m").removeClass("m_on");
		jQuery(this).parent().find(".sheet_slider_body").addClass("sheet_slider_body_off");
		jQuery(this).parent().find(".sheet_slider_body").removeClass("sheet_slider_body");
		});
	
	jQuery(".sheet_close_all").click(function() {
		jQuery("#main").find(".this_sheet").each(function(i) {
			var sheet = jQuery(".this_sheet");
			jQuery(sheet).find(".hide").hide();
			jQuery(sheet).find(".sheet_slider_s").removeClass("s_on");
			jQuery(sheet).find(".sheet_slider_m").removeClass("m_on");
			jQuery(sheet).find(".sheet_slider_body").addClass("sheet_slider_body_off");
			jQuery(sheet).find(".sheet_slider_body").removeClass("sheet_slider_body");
			});
		});	
			
	/* ### Persönliche Daten ### */

// muss auskommentiert sein (Daten ändern bei editUser.faces)	
//	jQuery("#change input").click(function() {
//		jQuery(this).parent().parent().parent().find(".off").hide();
//		jQuery(this).parent().parent().parent().find(".hide").show();
//		});
//
//	jQuery("#cancel").click(function() {
//		jQuery(this).parent().parent().parent().find(".off").show();
//		jQuery(this).parent().parent().parent().find(".hide").hide();
//		});
		
	/* ### Head-Drop-Menue: Mein Tipico, Kasse ### */

	jQuery("#mytipico_foot, #mytipico_title, #head_mytipico .head_shadow").click(function() {
		jQuery("#mytipico").slideToggle("fast");
		jQuery("#mytipico_foot div").toggle();
		});
			
	jQuery("#headdrop2_foot, #headdrop2_title, #head_headdrop2 .head_shadow").click(function() {
		jQuery("#headdrop2").slideToggle("fast");
		jQuery("#headdrop2_foot div").toggle();
		});
			
	/* ### Navigation ### */

// muss auskommentiert sein (Hover für Logo)	
//	jQuery("#claim").hover(
//			function () {
//				jQuery(this).attr({src : "img/tipico_home.gif"});
//	    		}, 
//	function () {
//	    		jQuery(this).attr({src : "img/tipico.gif"});
//				});
	
	/*
	jQuery(".nav_more").toggle(function () {
		jQuery(this).find("span:first").hide();
		jQuery(this).find("span:last").show();
		jQuery(this).parent().find("ul.hide").slideDown("fast");
		}, 
		function () {
			jQuery(this).find("span:first").show();
			jQuery(this).find("span:last").hide();
			jQuery(this).parent().find("ul.hide").slideUp("fast");
		});
	
	jQuery(".nav_main_2").click(function() {
		jQuery(this).parent().find("ul").toggle();
		if(jQuery(this).parent().find("ul").is(':hidden')){
			jQuery(this).removeClass("pointline");
			jQuery(this).parent().removeClass("bold");
			jQuery(this).parent().removeClass("down");
			}
		else{
			jQuery(this).addClass("pointline");
			jQuery(this).parent().addClass("bold");
			jQuery(this).parent().addClass("down");
			}
		});
	*/
	jQuery("#nav_more").click(function() {
		jQuery("#nav_more").hide();
		jQuery("#nav_corner_off").show();
		jQuery("#root_box").slideDown("fast");
		});
		
	jQuery("#nav_corner_off").click(function() {
		jQuery(this).hide();
		jQuery("#root_box").slideUp("fast");
		jQuery("#nav_more").show();
		});

//	auskommentiert, da die Funktionalität in "groupSelectAll()" (s.u.) ausgelagert wurde
//	und mit zusätzlicher Funktionalität zur Gruppenauswahl angereichert wurde
//	jQuery(".nav_main_2").click(function() {
//		jQuery(this).parent().find("ul").toggle();
//		if(jQuery(this).parent().find("ul").is(':hidden')){
//			jQuery(this).parent().addClass("line");
//			jQuery(this).parent().removeClass("bold");
//			}
//		else{
//			jQuery(this).parent().addClass("bold");
//			jQuery(this).parent().removeClass("line");
//			}
//		});
	
	/* ### Ticket ### */
	
//	jQuery("#ticket_foot, #side .slider_name").click(function() {
//		jQuery("#ticket_body").slideToggle("slow");
//		jQuery("#ticket_foot div").toggle();
//		});
	
	/* ### Buttons ### */
	/*
	// get id
	jQuery(".col_4 a[id]").click(function() {
		var idString = jQuery(this).attr("id");
		alert('jau' + idString);
		});
	*/

// darf auskommentiert sein (Wettschein Überschriften "Einzel", "Kombi", "System"
	// ticket: toggle background-image
//	jQuery("#ticket .but_60 a").click(function () {
//		// Button zurücksetzen
//		jQuery(this).parent().parent().find(".but_60").css('backgroundImage','url(img/but_60.gif)');
//		jQuery(this).parent().parent().find(".but_60 a").css({'color' : '#000000'});
//		
//		// Button hiliten
//		jQuery(this).parent().css('backgroundImage','url(img/but_60_on.gif)');
//		jQuery(this).css({'color' : '#ffffff'});
//		jQuery(this).blur();
//		});

// darf auskommentiert sein (Wettschein Überschriften "Einzel", "Kombi", "System"
	// ticket: hover
//	jQuery("#ticket .but_60 a").hover(
//		function () {
//			var this_color;
//    		jQuery(this).css("color").substr(0,3) == 'rgb' ? this_color = 'rgb(0, 0, 0)' : this_color = '#000000';
//			if(jQuery(this).css("color") == this_color){
//				jQuery(this).css({'color' : '#dc0037'});
//				}
//    		}, 
//   	function () {
//    		var this_color;
//    		jQuery(this).css("color").substr(0,3) == 'rgb' ? this_color = 'rgb(220, 0, 55)' : this_color = '#dc0037';
//			if(jQuery(this).css("color") == this_color){
//				jQuery(this).css({'color' : '#000000'});
//				}
//			});

// darf auskomenntiert sein (Highlights Fussball)	
	// highlights: toggle background-image
//	jQuery(".col_5 button").toggle(function () {
//		jQuery(this).css('backgroundImage','url('+CONTEXT_PATH+'/img/but_on.gif)');
//		jQuery(this).css({'color' : '#ffffff', 'font-weight' : 'bold'});
//		jQuery(this).blur();
//		}, 
//		function () {
//			jQuery(this).css('backgroundImage','url('+CONTEXT_PATH+'/img/but.gif)');
//			jQuery(this).css({'color' : '#000000', 'font-weight' : 'normal'});
//			jQuery(this).blur();
//		});

// darf auskomenntiert sein (Highlights Fussball)	
	// quote button: hover
//	jQuery(".col_5 button").hover(
//		function () {
//			var this_color;
//    		jQuery(this).css("color").substr(0,3) == 'rgb' ? this_color = 'rgb(0, 0, 0)' : this_color = '#000000';
//			if(jQuery(this).css("color") == this_color){
//				jQuery(this).css({'font-weight' : 'bold', 'color' : '#dc0037'});
//				}
//    		}, 
//   	function () {
//    		var this_color;
//    		jQuery(this).css("color").substr(0,3) == 'rgb' ? this_color = 'rgb(220, 0, 55)' : this_color = '#dc0037';
//			if(jQuery(this).css("color") == this_color){
//				jQuery(this).css({'font-weight' : 'normal', 'color' : '#000000'});
//				}
//			});
	
	/* ### Login ### */

// muss auskommentiert sein (Login ein-/ausblenden)	
//	jQuery("#logout .but_80").click(function () {
//		jQuery("#login").show();
//		jQuery("#logout").hide();
// 		jQuery("#set_password").css({'display' : 'block'});	
//		});
//	
//	jQuery("#login .but_80").click(function () {
//		jQuery("#login").hide();
//		jQuery("#logout").show();
//		});

	jQuery("#help_login").click(function () {
		jQuery("#help_login_layer").show();
		jQuery("#help_login_layer").css({'top' : '85px', 'left' : '790px'});
		
		/* Flying Layer: Warning bei Login öffnen */
// war auskommentiert, evtl von Tobi?		
		
//		jQuery("#head .fly_warning_layer").show();
//		jQuery("#head .fly_warning_layer").css({'width' : '200px', 'top' : '35px', 'left' : '582px'});
		
		});
	
	jQuery("#help_login_2").click(function () {
		jQuery("#help_login_layer").show();
		jQuery("#help_login_layer").css({'top' : '355px', 'left' : '680px'});
		});
		
	jQuery("#help_login_layer .but_close").click(function () {
		jQuery("#help_login_layer").hide();
		});

// muss auskommentiert sein (Passwortfeld ausblenden)	
//	jQuery("#set_password").click(function () {
//		jQuery(this).css({'display' : 'none'});
//		//jQuery('#password').css({'display' : 'block'});
//		jQuery('#password').focus();
//		});
//	
//	jQuery("#password").focus(function () {
//		jQuery("#set_password").css({'display' : 'none'});
//		});
		
	/* Flying Layer: Warning bei Login schliessen */
	jQuery("#head .fly_warning_layer .but_close").click(function () {
		jQuery("#head .fly_warning_layer").hide();
		});
	
	/* Flying Layer: Warning bei Casino-Login schliessen */
	jQuery("#main_casino .fly_warning_layer .but_close").click(function () {
		jQuery("#main_casino .fly_warning_layer").hide();
		});
	
	/* Flying Infolayer: alle schliessen */
	jQuery(".fly_info_layer .but_close, #ticket .fly_warning_layer .but_close").click(function () {
		jQuery(".fly_info_layer").hide();
		jQuery("#ticket .fly_warning_layer").hide();
		});
	
	/* Flying Infolayer: nach vorne holen */
	jQuery(".fly_info_layer").click(function () {
		jQuery(".fly_info_layer").css({'z-index' : '30'});
		jQuery(this).css({'z-index' : '31'});
		});
	
	/* ### Highlights ### */
	
	jQuery("#hilights_1 .hilights_head_2").click(function () {
		jQuery("#hilights_1").hide();
		jQuery("#hilights_2").show();
		jQuery(this).blur();
		});
	
	jQuery("#hilights_2 .hilights_head_2").click(function () {
		jQuery("#hilights_2").hide();
		jQuery("#hilights_1").show();
		jQuery(this).blur();
		});
	
	/* ### Search Mainpage ### */

// war auskommentiert, evtl von Tobi?	
//	jQuery("#search_head a").click(function () {
//		jQuery("#search_body").slideDown("fast");
//		});

// wird in start.xhtml gemacht	
//	jQuery("#search_body .corner").click(function () {
//		jQuery("#search_body").slideUp("fast");
//	});
	
	/* ### Payout: Conditions ### */
	
	jQuery(".paymethod_box .but_close, #change_name_layers .but_close").click(function () {
		jQuery(this).parent().hide();
		});
	
	jQuery(".paymethod_box a, #ch_name_1").click(function () {
		jQuery(".condition, #change_name_layers .change_name_layer").hide();
		var idString = jQuery(this).attr("id");
		jQuery("#" + idString + "_layer").show();
		jQuery(this).blur();
		});
	
	/* ### Tooltip ### */

	jQuery(".nav_main_1 .left, .nav_main_2 .left, .check_l").hover(function () {
		tip(jQuery(this).text(), 20);
		document.onmousemove = update_tip;
    	}, function () {
		untip();
		});
	
	jQuery(".sheet_col_7, #hilights_1 .col_3").hover(function () {
		tip(jQuery(this).text(), 45);
		document.onmousemove = update_tip;
    	}, function () {
		untip();
		});	
		
	jQuery(".sheet_col_3").hover(function () {
		tip(jQuery(this).text(), 35);
		document.onmousemove = update_tip;
    	}, function () {
		untip();
		});
		
	jQuery(".check_r, .sheet_col_4 .left").hover(function () {
		tip(jQuery(this).parent().find(".left").text(), 20);
		document.onmousemove = update_tip;
    	}, function () {
		untip();
		});
	
	jQuery(".sheet_col_1.over, .sheet_col_5").hover(function () {
		tip(jQuery(this).text(), 10);
		document.onmousemove = update_tip;
    	}, function () {
		untip();
		});
	
	/* ### Zeitzonen Layer ### */
	
	jQuery(".zone_change").click(function() {
		if(jQuery("#zone_layer").is(':hidden')) {
			jQuery("#zone_layer").show();
			jQuery(this).blur();
			}
		else {
			jQuery("#zone_layer").hide();
			jQuery(this).blur();
			}
		});
	
	});

//Tooltip
var mytip = null;

function update_tip(e){
	if(mytip){
		var x = (document.all) ? window.event.x + mytip.offsetParent.scrollLeft : e.pageX;
		var y = (document.all) ? window.event.y + mytip.offsetParent.scrollTop : e.pageY;
		mytip.style.left = (x + 15) + 'px';
		mytip.style.top = (y + 15) + 'px';
	}
}

function tip(text, len){
	if(text.length > len){
		mytip = document.getElementById('tooltip');
		mytip.style.display = 'block';
		mytip.innerHTML = text;
	}
}
 
function untip(){
	if(mytip){
		mytip.style.display = 'none';
	}
}


/*---------------------------------------------------------------------------------------------------------*/
/* -------------------------- ebet js -------------------------------------------------------------------- */
/* ------------------------------------------------------------------------------------------------------- */

function doClear(theText) {
	if (theText.value == theText.defaultValue) {
		theText.value = ""
	}
}

// >>> secure login
function makeLoginSecure(formId) {
	var hostname = location.hostname;
	var port = location.port == "" ? "" : ":8443";  
	var elm = document.getElementById(formId);
	var action = elm.getAttribute("action");
	action = "https://" + location.hostname + port + action;
	elm.setAttribute("action", action);
}
// <<<

// >>> Marker for odds
var markedResults = new Array();

function getMarkedResults() {
	return markedResults.join(",");
	//return markedResults; 
}

function markResults() {
	for (i = 0; i < markedResults.length; i++) {
		markResultButton(markedResults[i]);
	}
}
function markResultButton(resultId) {
	var btns = document.getElementsByName("q"+resultId);
	for (var i = 0; i < btns.length; i++) {
		var b = jQuery(btns[i]);
		b.removeClass('roll_red');
		b.addClass('white');
		b.addClass('red_quote');
		b.blur();
	}
}
function markResult(resultId) {
	markedResults.push(resultId);
	markResultButton(resultId);
}
function clearMarks() {
	markedResults = new Array();
	var btns = jQuery('.red_quote');
	for (var i = 0; i < btns.length; i++) {
		var b = jQuery(btns[i]);
		b.addClass('roll_red');
		b.removeClass('white');
		b.removeClass('red_quote');
		b.blur();
	}
}
// <<< Marker for odds

// >>> Marker for groups

var markedGroups = new Array();

function markGroup(groupId) {
	markedGroups.push(groupId);
	markNavTreeNode(groupId);
}

function markNavTreeNode(groupId) {
	jQuery('#t'+groupId).addClass('on');
	// Dummy-Klasse hinzufügen für den jQuery-Selektor in clearNavTreeMarks()
	jQuery('#t'+groupId).addClass('groupSelected'); 
	var obj = jQuery('#t'+groupId).parent().parent().parent();
	if (jQuery(obj).is(':hidden')) {
		jQuery(obj).show();
		jQuery(obj).parent().addClass("bold down");
		if (jQuery(obj).parent().parent().is(':hidden')) {
			jQuery(obj).parent().parent().show();
			jQuery(obj).parent().parent().parent().find(".moreGroups").hide();
			jQuery(obj).parent().parent().parent().find(".lessGroups").show();
		}
	}
}

function showGroups(groupId) {
	jQuery("#nav_more"+groupId).hide();
	jQuery("#nav_corner_off"+groupId).show();
	jQuery("#nav #ul"+groupId+".hide").slideDown("fast");
}

function hideGroups(groupId) {
	jQuery("#nav_corner_off"+groupId).hide();
	jQuery("#nav #ul"+groupId+".hide").slideUp("fast");
	jQuery("#nav_more"+groupId).show();
}

function clearNavTreeMarks() {
	var icons = jQuery('.groupSelected');
	for(var i = 0; i < icons.length; i++) {
		var icon = icons[i];
		jQuery(icon).removeClass('on');
	}
}

function groupSelectAll(groupId) {
	var navEntry = jQuery('#navEntry' + groupId);
	jQuery(navEntry).parent().parent().find("ul").toggle();
	if(jQuery(navEntry).parent().parent().find("ul").is(':hidden')){
		jQuery(navEntry).find('.left').removeClass("bold down");
		jQuery(navEntry).find('.check_r').removeClass("bold");
		jQuery(navEntry).parent().removeClass("pointline");
	} else{
		jQuery(navEntry).find('.left').addClass("bold down");
		jQuery(navEntry).find('.check_r').addClass("bold");
		jQuery(navEntry).parent().addClass("pointline");
	}
}

// <<< Marker for groups


// >>> Popup functions
var popwin = null;

function popupScrollbars(url, name, width, height) {
    popwin = window.open(url,"popup","toolbar=no,scrollbars=yes,menubar=no,resizable=yes,status=no,width="+width+",height="+height+",dependent=yes");
    popwin.focus();
}

function popupNoScrollbars(url, name, width, height) {
    popwin = window.open(url,"popup","toolbar=no,scrollbars=no,menubar=no,resizable=yes,status=no,width="+width+",height="+height+",dependent=yes");
    popwin.focus();
}

// aus einem Popup das Elternfenster delegieren eine neue Seite aufzurufen und das Popup schliessen 
function openPage(url){
	document.location.href = url;
	popwin.close();
}
// <<< Popup functions


// >>> Ticket-Editor
function enterCode(message) {
	with (document.editorForm) {
		var enteredCode = prompt(message);
		if (enteredCode) {
			action = 'TODO' + enteredCode;
			// url value="/ticket/editor.do?method=loadBonus UND code="
			submit();
		}
	}
}

function stakeClick() {
	document.getElementById('editorForm\:amountDisplay').select();
	document.getElementById('editorForm\:selected').value = 'stake';
	return true;
}
function totalStakeClick() {
	document.getElementById('editorForm\:totalStakeDisplay').select();	
	document.getElementById('editorForm\:selected').value = 'totalStake';
	return true;
}
function winClick() {
	document.getElementById('editorForm\:winDisplay').select();
	document.getElementById('editorForm\:selected').value = 'win';
	return true;
}

function pressedReaction(question) {
	if (confirm(question)) {
		/*
		var btns = jQuery(".ticket_button");
		for (var i = 0; i < btns.length; i++) {
			var b = btns[i];
			jQuery(b).disabled = true;
		}
		*/
		return true;
	}
	return false;
}
// <<< Ticket-Editor


// >>> Selection Handling
// ts: toggle special bets
function ts(component) {
	//var component = jQuery(component).parent();
	if (jQuery(component).parent().parent().find(".hide").is(':hidden')) {
		jQuery(component).addClass("m_on");
		jQuery(component).parent().parent().find(".hide").show();
		jQuery(component).parent().parent().find(".sheet_slider_body_off").addClass("sheet_slider_body");
		jQuery(component).parent().parent().find(".sheet_slider_body_off").removeClass("sheet_slider_body_off");
	} else {
		jQuery(component).removeClass("m_on");
		jQuery(component).parent().parent().find(".hide").hide();
		jQuery(component).parent().parent().find(".sheet_slider_body").addClass("sheet_slider_body_off");
		jQuery(component).parent().parent().find(".sheet_slider_body").removeClass("sheet_slider_body");
	}
	jQuery("#help_resultType_layer").hide();
}

// <<< Selection Handling

// >>> Ajax4JSF error/expired handling
var A4J_ERROR_MESSAGE = '';
if (typeof A4J != 'undefined') { // some pages made error "A4J not defined"
	A4J.AJAX.onError = function(req,status,message) {
		if (A4J_ERROR_MESSAGE == '') {
			window.alert('Error ' + status + "\n" + message);			
		} else {
			window.alert(A4J_ERROR_MESSAGE);
			A4J_ERROR_MESSAGE = "";
		}
	}
	A4J.AJAX.onExpired = function(loc,expiredMsg) {
		window.alert('Your session has been expired. You will be redirected to the start page.' + "\n" + 
				'Ihre Sitzung ist abgelaufen. Sie werden nun auf die Startseite weitergeleitet.');
		location.href = CONTEXT_PATH + "/index.faces";
	}
}

// >>> common functions
function showHintLayer(id, top, left) {
	jQuery("#"+id).show();
	jQuery("#"+id).css({'top' : top+'px', 'left' : left+'px'});
}
// <<< common functions


// Backup aus popupUtil.js
// wird wahrscheinlich gar nicht mehr benutzt...

/* 
Version: 2004-10-25

default values:
    name=<random value>
    width=760
    height=540
    top=10
    left=50
    status=yes
*/
function popup(url, name, width, height, top, left, status) {
	if ((typeof name) == "undefined") {
	    name = "popup_" +
	        createRandomString("abcdefghiklmnopqrstuvwxyz", 8);
	}
	if ((typeof width) == "undefined")
	    width = 760;
	if ((typeof height) == "undefined")
	    height = 540;
	if ((typeof top) == "undefined")
	    top = 10;
	if ((typeof left) == "undefined")
	    left = 50;
	if ((typeof status) == "undefined")
	    status = "yes";
	var params = "dependent=yes,location=no,menubar=no,toolbar=no,resizable=yes,scrollbars=yes"
	    + ",width=" + width
	    + ",height=" + height
	    + ",top=" + top
	    + ",left=" + left
	    + ",status=" + status;
	var popwin = window.open(url, name, params);
	popwin.focus();
}

function popupStatistics(lang, param) {
	var url = 'http://stats.betradar.com/statistics/tipico2/?' + lang + '&' + param;
	popup(url, 'stats', 900, 600);
}

function createRandomString(chars, string_length) {
	var randomstring = '';
	for (var i=0; i<string_length; i++) {
	    var rnum = Math.floor(Math.random() * chars.length);
	    randomstring += chars.substring(rnum, rnum+1);
	}
	return randomstring;
}

// >>> payment
function radioClick(component, field) {
	document.getElementById(field).setAttribute("value", component.value);
}
function selectTemplate(selectedDataPk) {
	document.getElementById('form:selectedDataPk').value = selectedDataPk;
	var elm = document.getElementById("securityCode" + selectedDataPk);
	if (elm != null) {
		document.getElementById('form:selectedSecurityCode').value = elm.value;
	}
}
function submitForm(submitButton, text) {
	submitButton.value=text;
	submitButton.onclick=doNothing;
}
function doNothing() {
	return false;
}
// <<< payment


//function pressedReactionDelay(delayInput) {
//	if (delayInput > 0) {
//		jQuery('#delay_layer, #delay_layer_inner').show();
//		delay(delayInput);
//		}
//	}

//function delay(delayInput) {
//	if (delayInput > 0) {
//		document.getElementById('counter').innerHTML = delayInput;
//		var delayTimeout = window.setTimeout('delay('+(delayInput - 1)+')', 1000);
//		}
//	else
//		jQuery('#delay_layer, #delay_layer_inner').hide();
//}

// help_layer

var clickX;
var clickY;
function showHelp (text) {
 var scrollPosition;
 var screenWidth;
  if(window.pageYOffset) {
	  scrollPosition = window.pageYOffset;
	} else if (document.documentElement.scrollTop) {
		scrollPosition = document.documentElement.scrollTop;
	} else if ( document.body.scrollTop ) {
		scrollPosition = document.body.scrollTop;
	} else {
		scrollPosition = 0;
   }
   if (document.body.offsetWidth) {
  		screenWidth = document.body.offsetWidth;
   } else {
  		screenWidth = window.innerWidth;
   }
  jQuery('#help_resultType_layer').css("left", (clickX + 280) > screenWidth ? screenWidth - 280 : clickX);
  jQuery('#help_resultType_layer').css("top", clickY + scrollPosition);
  document.getElementById('help_resultType_layer_inner').innerHTML = text;
  jQuery('#help_resultType_layer').show();	  
}

function closeHelp() {
  jQuery('#help_resultType_layer').hide();	  
}

function trackClick (clickEvent) {
	var obj;
	var insideLayer = false;
	if (clickEvent != null) {
		obj = clickEvent.target;
	} else {
		clickEvent = window.event;
		obj = clickEvent.srcElement;
	}
	if (document.getElementById) {
		clickX  = clickEvent.clientX;
		clickY = clickEvent.clientY;
	} else if (document.all) {
		clickX = clickEvent.clientX;
		clickY = clickEvent.clientY;
	}
	
	if (jQuery(obj).hasClass("layerClass")) {
		insideLayer = true;
	} else {
		var parents = 2;
		var parent = obj;
		for (var count=0; count<=parents; count++) {
			if (jQuery(parent).parent().hasClass("layerClass")) {
				insideLayer = true;
				break;
			} else {
				parent = jQuery(parent).parent();
			}
		}
	}	
	if(!insideLayer) {
		jQuery(".layerClass").hide();
	}
}

document.onmousedown = trackClick;

// editor

var lock = false;
var delayTimeout;

function refresh() {
	if (!lock) {
		lock = true;
		refreshServer();
	}
}

function onReactionComplete() {
	A4J_ERROR_MESSAGE = ''; 
	lock = false; 
	reRenderHead(); 
	hideDelayLayer();
}

function delay(delayInput) {
	if (delayInput > 0) {
		document.getElementById('counter').innerHTML = delayInput;
		delayTimeout = window.setTimeout('delay('+(delayInput - 1)+')', 1000);
	}
}

function hideDelayLayer() {
	jQuery('#delay_layer, #delay_layer_inner').hide();
	clearTimeout(delayTimeout);
}

function showDelayLayer() {
	jQuery('#delay_layer, #delay_layer_inner').show();
	jQuery('#counter').css("color","white");
	jQuery('#counter').html('dummy');
}

function iFrameHeight(iframeId) {
	if(document.getElementById && !(document.all)) {
		h = 10 + document.getElementById(iframeId).contentDocument.body.scrollHeight;
		jQuery('#'+iframeId).css('height', h + 'px');
	} else if(document.all) {
		h = document.frames(iframeId).document.body.scrollHeight;
		jQuery('#' + iframeId).css('height', h + 'px');
	}
}


// affiliate
function toggleOverview(field) {
	if (field == 'overviewInformation') {
		jQuery('.overviewInformation').show();
		jQuery('.overviewSportsbook').hide();
		jQuery('.overviewCasino').hide();
		jQuery('.overviewBilling').hide();
	}
	if (field == 'overviewSportsbook') {
		jQuery('.overviewInformation').hide();
		jQuery('.overviewSportsbook').show();
		jQuery('.overviewCasino').hide();
		jQuery('.overviewBilling').hide();
	}
	if (field == 'overviewCasino') {
		jQuery('.overviewInformation').hide();
		jQuery('.overviewSportsbook').hide();
		jQuery('.overviewCasino').show();
		jQuery('.overviewBilling').hide();
	}
	if (field == 'overviewBilling') {
		jQuery('.overviewInformation').hide();
		jQuery('.overviewSportsbook').hide();
		jQuery('.overviewCasino').hide();
		jQuery('.overviewBilling').show();
	}
}

// timezone

function changeZone(zoneId) {
	document.getElementById('timeZoneForm:timeZoneId').value = zoneId;
	document.timeZoneForm.submit();
}

function startWaitAjax() {
	jQuery('body').css('cursor','wait');
}
function stopWaitAjax() {
	jQuery('body').css('cursor','default');
}

// search
function encodeRedirectLocation(redirect, url, input) {
	if (redirect) {
		var redirectUrl = CONTEXT_PATH + url + '?input=' + input;
		location.href = redirectUrl;
	}
}

// verhindert im Editor die Eingabe von Zeichen
// erlaubt die Eingabe von Ziffern und einem bestimmten Trennzeichen
function ensureValidInput(event, separator) {
	var keycode;

	if (window.event) {
		keycode = window.event.keyCode;
	} else if (event) {
		keycode = event.which;
	} else {
		return true;
	}
	
	// Zahlen erlauben
	if (47 < keycode) {
		if (keycode < 58) {
			return true;
		}
	}
	
	// Trennzeichen erlauben
	if (keycode == separator)
		return true;

	// Steuerzeichen erlauben
	var kcok = new Array(8, 10, 13, 0);
	while (kcok.length > 0) {
		if (keycode == kcok.pop()) {							
			return true;
		}
	}

	return false;
}