

/* ------------------------------------------------------------------------

(c) 99°

Alle Scripte in diesem Dokument unterliegen dem strengen Copyright der
Firma 99° und dürfen ohne deren Zustimmung nicht kopiert, vervielfältigt
oder verfremdet werden.

Für Fragen: www.99grad.de / 0611-4080919

------------------------------------------------------------------------ */



// ---------------------------------------------------------------------
// http://gettopup.com/documentation

TopUp.players_path = "fileadmin/templates/js/topup/players/";
TopUp.images_path = "fileadmin/templates/js/topup/top_up/";

TopUp.addPresets({
	".shaded": {
	 shaded: 1,
	 overlayClose: 1,
	 layout: 'dashboard',
	 resizable: 0
	}
});

TopUp.addPresets({
	".flv-video": {
	 shaded: 1,
	 overlayClose: 1,
	 layout: 'dashboard',
	 resizable: 0,
	 width: 950,
	 height: 550,
	 effect: 'appear',
	 ondisplay: function () { tell_flash( 'flash_banner', 'sound_leise', '' ); },
	 onclose: function () { tell_flash( 'flash_banner', 'sound_laut', '' ); }
	}
});


// ---------------------------------------------------------------------
// IE6 Warning, Spezielle CSS/JS-Dateien

$(function () {

	var is_msie = $.browser.msie;
	var vers = parseFloat($.browser.version);
	
	if (is_msie) {
		if (vers <= 6) {
			$.getScript('fileadmin/ie6_warning/warning.js', function () {
				alert_ie6_warning("fileadmin/ie6_warning/");
			});
		}
	}	

});

/* ------------------------------------------------------------------------ */
// I N I T 

$( function () {
	init_page();
} );


function init_page () {

	$('#main_menu ul li a').rolloverColor( {color:'#e47faf'} );
	
	$('.fce_accordeon .title').click( function () {
		var ref = $(this).parent().find('.inhalt');
		var vis = ref.is(':visible');
		//ref[vis ? 'slideUp' : 'slideDown']();
		ref.slideToggle(!vis);
		$(this)[vis ? 'removeClass' : 'addClass']('open');
	});
	
}



/* ------------------------------------------------------------------------ */
// EIGENE PLUG-INS für jQuery

// http://www.queness.com/post/112/a-really-simple-jquery-plugin-tutorial
// http://matthiasschuetz.com/jquery-tutorial-eigenes-tooltip-plugin-erstellen

/*

$.metaTagValue('pid');				->	gibt Wert eines Meta-Tags zurück
$.reqVars();						->	alle GET-Vars als Object holen, z.B. aus www.99grad.de/?test=hallo&...
$.reqVars('test');					->	GET-Var 'test' zurückgeben
$.stripTags(html, ['h2'], false );	->	HTML-Tags entfernen: code, allowed-tags-Array, allow-invers 
$.stripNL(html);					->	Tabs und Umbrüche entfernen (IE6-Problem)
$.htmlentitiesdecode( html );		->	Decode HTML
$.getAllTags(html, 'b', true );		->	HTML-Tags holen: code, tag-name, include-tag
$.gaTrackPage( title );				->	Seiten-Titel an Google Analytics senden, falls Tracking-ID im Quelltext gefunden wurde
$.execScripts(html, debug);			->	JavaScript in HTML-Code ausführen
$.isNumeric( str );					->	Gibt true zurück, wenn str eine Zahl ist
$.noCacheURL( url );				->	Hängt einen noCache=... an die URL, damit Seite beim Laden nicht gecached wird

$(sel).exists();			-> 	Existiert das Element?

*/


// Erweiterung der Funktionen für den Typ $('id').plugin();

(function($){
	$.fn.extend({
		'exists': function () {
			//return $(this).length>0;
			return $($(this).selector).length>0;
		},
		'slideToggle': function ( bShow ) {
			return this.each( function () {
				var el = $(this), height = el.data('originalHeight'), visible = el.is(':visible');
				if (bShow == undefined) bShow = !visible;
				if (bShow != visible) {
					if (!height) {
						height = el.show().height();
						el.data('originalHeight', height);
						if (!visible) el.hide().css({height:0});
					}
					if (bShow) {
						el.hide().css({height:0});
						el.stop(true, true).show().animate({height:height}, {duration:500, easing:'easeInOutQuint'} );
					} else {
						el.stop(true, true).animate({height:0}, {duration:500, easing:'easeInOutQuint', complete:function () { 
							el.hide(); 
						}});
					}
				}
			});
		},
		'rolloverColor': function ( opt ) {
			
			var def = { color:'#777A66', duration: 400, durationOut: 100 };
			var opt = $.extend( def, opt);
			
			return this.each( function () {
				$(this).data('col', $(this).css('color') );
				$(this).mouseenter( function () {
					$(this).stop(true,true).animate({color: opt.color}, opt.duration);
				}).mouseleave( function () {
					$(this).stop(true,true).animate({color: $(this).data('col')}, opt.durationOut);
				});
			});
		}
		
	});
})(jQuery);



// Erweiterung der Funktionen für Typ $.plugin();

(function($){
	$.extend({
	
		'metaTagValue': function ( id, data ) {
				if (!data) var data = $('head').html();
				var val = data.split("<meta name=\""+id+"\" content=\"")[1].split("\"")[0];
				return val;
			},
			
		'reqVars': function ( id, url) {
			if (!url) url = document.location.href;
			var paramsRaw = (url.split("?", 2)[1] || "").split("#")[0].split("&") || [];
			var _params = {};
			for (var i = 0; i < paramsRaw.length; i++){
				var single = paramsRaw[i].split("=");
				if (single[0]) _params[unescape(single[0])] = unescape(single[1]);
			}
			return id ? _params[id] : _params;
		},
		
		'stripTags': function ( html ) {
			if(arguments.length < 2) {
				html=html.replace(/<\/?(?!\!)[^>]*>/gi, '');
			} else {
				var allowed = arguments[2] == undefined ? true : arguments[2];				
				var specified = arguments[1];
				if(allowed){
					html=html.replace(new RegExp('</?[^('+specified.join('|')+'|/)][^>]*>', 'gi'), '');
				} else{
					html=html.replace(new RegExp('</?[('+specified.join('|')+')][^>]*>', 'gi'), '');
				}
			}
				
			return $.trim( html );
		},
		
		'stripNL': function ( data ) {
			return data.split("\t").join("").split("\r").join("").split("\n").join("");
		},
		
		'htmlentitiesdecode': function ( str ) {
			return $("<div/>").html(str).text();
		},
		
		'getAllTags': function  ( source, tagname, include_tag ) {
			var arr = [];
			while(source.indexOf("<"+tagname) > -1 || source.indexOf("</"+tagname) > -1) {
				var s = source.indexOf("<"+tagname);
				var s_e = source.indexOf(">", s);
				var e = source.indexOf("</"+tagname, s);
				var e_e = source.indexOf(">", e);
				
				var str = include_tag ? source.substring(s,e_e+1) : source.substring(s_e+1, e);
				
				if (tagname == "script" && (str.indexOf("gaJsHost") > -1 || str.indexOf("_getTracker") >-1 || str.indexOf("only_execute_once") >-1 )) {
					// ignorieren, weil Page-Tracker-Script von Google
				} else {
					if ($.trim(str)) arr.push( str );
				}
				
				source = source.substring(0, s) + source.substring(e_e+1);
			}
			return arr;	
		},
		
		'execScripts': function ( source, debug ) {
			var sc = $.getAllTags(source, "script");
			for (var i = 0; i < sc.length; i++) {
				try {
					eval( sc[i] );
				} catch (e) {
					if (debug) {
						alert( e );
						alert( sc[i] );
					}
					return false;
				}
			}
			return true;
		},
		
		'isNumeric': function ( input ) {
			return (input - 0) == input && input.length > 0;
		},
		
		'noCacheURL': function ( url ) {
			return url + (url.indexOf('?') > 0 ? '' : '?') + '&nocache='+Math.floor(Math.random()*10000);
		},
		
		'gaTrackPage': function ( title ) {
			if (!title) title = document.title.split(': ')[1];
			try { 
				var gaid = $( 'body' ).html().split('_getTracker("')[1].split('"')[0];
				var pageTracker = _gat._getTracker( gaid );
				_gat._anonymizeIp();
				pageTracker._trackPageview( title );
			} catch (e) {}

		},
		
		'm_ajax': function ( obj ) {
			
			$.ajax({ 	url: $.noCacheURL(obj.url), 
						success: function (data) {
						
							document.title = $.htmlentitiesdecode( $.getAllTags(data, 'title')[0] );
							var html_data = $($.stripNL($.getAllTags(data, 'body')[0]));
							
							for (var target in obj.targets) {
								var o = html_data.find( target );
								var div = obj.targets[target] === true ? target : obj.targets[target];
								$( div ).html( o.html() );
							}
							
							if (obj.execScripts !== false) $.execScripts( data );
							$.gaTrackPage();
							if (obj.success) obj.success( data, html_data );
						}
			});
		}
		
	});
})(jQuery);





// PNG-FIX für IE6+
// http://jquery.andreaseberhard.de/pngFix/

$( function() {$(document).pngFix();});
(function($) {

jQuery.fn.pngFix = function(settings) {

	// Settings
	settings = jQuery.extend({
		blankgif: 'blank.gif'
	}, settings);

	var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
	var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);

	if (jQuery.browser.msie && (ie55 || ie6)) {

		//fix images with png-source
		jQuery(this).find("img[src$=.png]").each(function() {

			jQuery(this).attr('width',jQuery(this).width());
			jQuery(this).attr('height',jQuery(this).height());

			var prevStyle = '';
			var strNewHTML = '';
			var imgId = (jQuery(this).attr('id')) ? 'id="' + jQuery(this).attr('id') + '" ' : '';
			var imgClass = (jQuery(this).attr('class')) ? 'class="' + jQuery(this).attr('class') + '" ' : '';
			var imgTitle = (jQuery(this).attr('title')) ? 'title="' + jQuery(this).attr('title') + '" ' : '';
			var imgAlt = (jQuery(this).attr('alt')) ? 'alt="' + jQuery(this).attr('alt') + '" ' : '';
			var imgAlign = (jQuery(this).attr('align')) ? 'float:' + jQuery(this).attr('align') + ';' : '';
			var imgHand = (jQuery(this).parent().attr('href')) ? 'cursor:hand;' : '';
			if (this.style.border) {
				prevStyle += 'border:'+this.style.border+';';
				this.style.border = '';
			}
			if (this.style.padding) {
				prevStyle += 'padding:'+this.style.padding+';';
				this.style.padding = '';
			}
			if (this.style.margin) {
				prevStyle += 'margin:'+this.style.margin+';';
				this.style.margin = '';
			}
			var imgStyle = (this.style.cssText);

			strNewHTML += '<span '+imgId+imgClass+imgTitle+imgAlt;
			strNewHTML += 'style="position:relative;white-space:pre-line;display:inline-block;background:transparent;'+imgAlign+imgHand;
			strNewHTML += 'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;';
			strNewHTML += 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + jQuery(this).attr('src') + '\', sizingMethod=\'scale\');';
			strNewHTML += imgStyle+'"></span>';
			if (prevStyle != ''){
				strNewHTML = '<span style="position:relative;display:inline-block;'+prevStyle+imgHand+'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;'+'">' + strNewHTML + '</span>';
			}

			jQuery(this).hide();
			jQuery(this).after(strNewHTML);

		});

		// fix css background pngs
		jQuery(this).find("*").each(function(){
			var bgIMG = jQuery(this).css('background-image');
			if(bgIMG.indexOf(".png")!=-1){
				var iebg = bgIMG.split('url("')[1].split('")')[0];
				jQuery(this).css('background-image', 'none');
				jQuery(this).get(0).runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + iebg + "',sizingMethod='scale')";
				jQuery(this).find('a').css({'background-color':'#000000'});
			}
		});
		
		
		
		//fix input with png-source
		jQuery(this).find("input[src$=.png]").each(function() {
			var bgIMG = jQuery(this).attr('src');
			jQuery(this).get(0).runtimeStyle.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + bgIMG + '\', sizingMethod=\'scale\');';
   		jQuery(this).attr('src', settings.blankgif)
		});
	
	}
	
	return jQuery;

};

})(jQuery);
