var boxOpen = false;
$(document).ready(function () {
dropDownHeader();
$('.breadcrumb-button').on('click', function () {
//_gaq.push(['_trackEvent', 'breadcrumb-button', 'click', 'menu']);
tmEvent('breadcrumb-button', 'click', 'menu');
});
if (!document.addEventListener) {
document.attachEvent('touchstart', function () { });
} else {
document.addEventListener('touchstart', function () { }, false);
}
});
function dropDownHeader() {
$('.dropdown-header, .dropdown-image').on('click', function () {
$(this).toggleClass('active_dropdown-header');
$(this)
.parent()
.find('.dropdown-content')
.toggle('fast');
});
}
$(function () {
$('.js-switcher select').change(function () {
switchPage($(this));
});
$('.js-switcher').submit(function () {
switchPage($(this).find('select'));
return false;
});
$('.js-form-params2path').submit(function () {
sendFormParams2Path($(this));
return false;
});
$('.toggler').click(function () {
var target = $(this).attr('data-toggle');
$('#' + target).toggle('fast');
$(this).toggleClass('offen');
});
$('.info-content').click(function () {
$(this).toggleClass('info-offen', 'fast');
//_gaq.push(['_trackEvent', 'info-text', 'click', 'info']);
// tmEvent('info-text', 'click', 'info');
});
$('.breadcrumb .home').click(function () {
if ($('#main').innerWidth() < 768) {
$('.breadcrumb').toggleClass('breadcrumb-offen', 'fast');
}
});
$('.breadcrumb-select select').change(function () {
if ($(this).val() !== '') {
$(this)
.parents('form.breadcrumb-form')
.find('.breadcrumb-button')
.removeAttr('disabled')
.removeClass('disabled');
}
});
$(window).resize(function () {
if ($(window).width() > 766) {
$('#mainmenue li:not(.megamenu_button)').show();
}
});
});
function switchPage(element) {
property = element.attr('name');
value = element.val();
pathname = window.location.pathname;
n = pathname.lastIndexOf(property);
if (n > 0) {
pathname = pathname.substring(0, n - 1);
}
if (value != '') {
pathname = pathname + '/' + property + '/' + value;
}
window.location.href = pathname;
}
function sendFormParams2Path(form) {
formParams = form.serializeArray();
path = '';
jQuery.each(formParams, function (i, formParam) {
if (formParam.value) {
path = path + '/' + formParam.name + '/' + formParam.value;
}
});
url = form.attr('action') + path;
location.href = url;
}
function wechselLiga(liga_id) {
var url = splitLocation();
if (url[2] == 'spielerbieten') {
url[2] = 'transfermarkt';
}
if (url[2] == 'verein' || url[2] == 'spieler' || url[2] == 'spielerprofil') {
location.href =
window.location.protocol +
'//' +
window.location.host +
'/' +
url[1] +
'/' +
url[2] +
'/' +
url[3] +
'/' +
liga_id +
'/' +
url[5] +
'/' +
url[6];
} else {
location.href =
window.location.protocol +
'//' +
window.location.host +
'/' +
url[1] +
'/' +
url[2] +
'/' +
url[3] +
'/' +
liga_id +
'';
}
}
function wechselKaderuebersicht(user_id) {
var url = splitLocation();
url[2] = 'aufstellungUndKader';
location.href =
window.location.protocol +
'//' +
window.location.host +
'/' +
url[1] +
'/' +
url[2] +
'/' +
url[3] +
'/' +
url[4] +
'/user/' +
user_id +
'';
}
function wechselTipprunde(wettbewerb_id) {
var url = splitLocation();
if (url[3] == 'fanliga') {
url[3] = 'fanligen';
}
if (url[3] == 'privateliga') {
url[3] = 'privateligen';
}
location.href =
window.location.protocol +
'//' +
window.location.host +
'' +
url[0] +
'/' +
url[1] +
'/' +
url[2] +
'/' +
url[3] +
'/' +
url[4] +
'/' +
wettbewerb_id +
'';
}
function nl2br(str, is_xhtml) {
var breakTag =
is_xhtml || typeof is_xhtml === 'undefined' ? '
' : '
';
return (str + '').replace(
/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,
'$1' + breakTag + '$2'
);
}
function splitLocation() {
var parts = window.location.pathname.split('/');
return parts;
}
function formatiereMarktwert(marktwert) {
if (marktwert >= 1000000000) {
marktwert = round(marktwert / 1000000000, 2);
marktwert = number_format(marktwert, 2, ',', '.') + ' Mrd. €';
} else if (marktwert >= 1000000) {
marktwert = round(marktwert / 1000000, 2);
marktwert = number_format(marktwert, 2, ',', '.') + ' Mio. €';
} else if (marktwert == 0) {
marktwert = '-';
} else if (marktwert <= -1000000) {
marktwert = round(marktwert / 1000000, 2);
marktwert = number_format(marktwert, 2, ',', '.') + ' Mio. €';
} else {
marktwert = marktwert / 1000;
marktwert = number_format(marktwert, 0, '', '.') + ' Tsd. €';
}
return marktwert;
}
function round(value, precision, mode) {
//phpjs.org/functions/round/
http: var m, f, isHalf, sgn; // helper variables
precision |= 0; // making sure precision is integer
m = Math.pow(10, precision);
value *= m;
sgn = (value > 0) | -(value < 0); // sign of the number
isHalf = value % 1 === 0.5 * sgn;
f = Math.floor(value);
if (isHalf) {
switch (mode) {
case 'PHP_ROUND_HALF_DOWN':
value = f + (sgn < 0); // rounds .5 toward zero
break;
case 'PHP_ROUND_HALF_EVEN':
value = f + (f % 2) * sgn; // rouds .5 towards the next even integer
break;
case 'PHP_ROUND_HALF_ODD':
value = f + !(f % 2); // rounds .5 towards the next odd integer
break;
default:
value = f + (sgn > 0); // rounds .5 away from zero
}
}
return (isHalf ? value : Math.round(value)) / m;
}
function number_format(number, decimals, dec_point, thousands_sep) {
// http://phpjs.org/functions/number_format/
number = (number + '').replace(/[^0-9+\-Ee.]/g, '');
var n = !isFinite(+number) ? 0 : +number,
prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
sep = typeof thousands_sep === 'undefined' ? ',' : thousands_sep,
dec = typeof dec_point === 'undefined' ? '.' : dec_point,
s = '',
toFixedFix = function (n, prec) {
var k = Math.pow(10, prec);
return '' + Math.round(n * k) / k;
};
// Fix for IE parseFloat(0.55).toFixed(0) = 0;
s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');
if (s[0].length > 3) {
s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);
}
if ((s[1] || '').length < prec) {
s[1] = s[1] || '';
s[1] += new Array(prec - s[1].length + 1).join('0');
}
return s.join(dec);
}
function changeIcon(schaetzung, originalwert) {
if (schaetzung > originalwert) {
$('#amount_icon')
.removeAttr('class')
.attr('class', 'icons_sprite green-arrow-ten');
} else if (schaetzung < originalwert) {
$('#amount_icon')
.removeAttr('class')
.attr('class', 'icons_sprite red-arrow-ten');
} else {
$('#amount_icon')
.removeAttr('class')
.attr('class', 'icons_sprite grey-block-ten');
}
}
$(function () {
var targets = $('[rel~=tooltip]'),
target = false,
tooltip = false,
type = false,
content = false;
targets.bind('mouseenter', function () {
target = $(this);
type = target.attr('data-type');
content = target.attr('data-content');
tooltip = $('