
//alert("Neue Kollektion in wenigen Tagen online!");

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

(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

try {
	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,
	 group: 'images'
	}
});

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', '' ); }
	}
});
*/
} catch (e) {}


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


$(function () {

	var is_msie = $.browser.msie;
	var vers = parseFloat($.browser.version);
	
	if (is_msie && $.cookies.get('ignore_ie6') != '2') {
		if (vers <= 6) {
			$.getScript('fileadmin/templates/diamantrad.com/ie6_warning/warning.js', function () {
				alert_ie6_warning("fileadmin/templates/diamantrad.com/ie6_warning/");
			});
		}
		
	}	
	
});




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

$( function () {
	//alert("ok");
	// Alte Kollektion
	$('#shop_prodInfo_fadeIn').click( function () {
		$('#fade_productTable').slideDown();
		$(this).hide();
		$('#shop_prodInfo_fadeOut').show();
		return false;
	});
	$('#shop_prodInfo_fadeOut').click( function () {
		$('#fade_productTable').slideUp();
		$(this).hide();
		$('#shop_prodInfo_fadeIn').show();
		return false;
	});
	
	// Neue Kollektion (ab 2012)
	$('li.show_specs a').click( function () {
		if ($('.bikemetrics').is(':visible')) $('.bikemetrics').slideUp();
		if ($('.bikespecs').is(':visible')) {
			$('.bikespecs').stop(true,true).slideUp();
		} else {
			$('.bikespecs').stop(true,true).slideDown();
		}
		return false;
	});
	
	$('li.show_metrics a').click( function () {
		if ($('.bikespecs').is(':visible')) $('.bikespecs').slideUp();
		if ($('.bikemetrics').is(':visible')) {
			$('.bikemetrics').stop().slideUp();
		} else {
			$('.bikemetrics').stop().slideDown();
		}
		return false;
	});
	
	// Tabs für Geometrie-Daten
	$('.bikemetrics').prepend('<ul class="tabs" />');
	$('.bikemetrics h1').each( function ( k, v ) {
		var tab = $('<li><span>' + $(this).text() + '</span></li>');
		if (k == 0) tab.addClass('first');
		if (k == $('.bikemetrics h1').length-1) tab.addClass('last');
		$('.bikemetrics .tabs').append( tab );
		$('.bikemetrics .tabs li:last').data({ref:$(this).parent().parent() });
	});
		
	$('.bikemetrics li').click( function () {
		$('.bikemetrics .tabs li').removeClass('selected');
		$(this).addClass('selected');
		show_bikemetrics_tab($(this).data().ref.find('.contenttable'));
	});
	
	$('.bikemetrics li:first').click();
	
	function show_bikemetrics_tab ( ref ) {
		var v = $('.bikemetrics').is(':visible');
		$('.bikemetrics').show().css( {'height':$('.bikemetrics').height()} );
		$('.bikemetrics .contenttable:visible').fadeOut( function () {
			ref.fadeIn();
			$('.bikemetrics').css({'height':'auto'});
		});
		if (!v) $('.bikemetrics').hide();
	}
	
	
	// Zoom der Bikes per Lightbox und mit Lupenfunktion
	
	$('.bikeimage .image a').click( function () {
		var _this = $(this);
		
		var myLightbox = $.lightBox( { full:$(this).attr('href') }, 0, 
			{
				onLoad: function ( obj ) {
					obj.img.zoomLens({
						url:		_this.parent().find('.bikemaxzoom').attr('href'), 
						onClick: 	function () { myLightbox.close(); },
						offset:		{left:0,top:0}
					});
				},
				addClass: 'dblightbox_bike',
				offset: {left:-30, top:30}
		});
		
		return false;
	});
	
	// Zoom der Bilder im Content-Bereich
	$('.shaded').click( function () {
		$.lightBox( {full:$(this).attr('href')});
		return false;
	});
	
	// Übersichts-FCE: Bei RollOver Text hochfahren
	$('.fce_uebersicht').unbind().mouseenter( function () {
		$(this).find('.text').stop().animate({top:0}, {easing:'easeOutQuint', duartion:1000});
	}).mouseleave( function () {
		$(this).find('.text').stop().animate({top:200}, {easing:'easeInQuint', duartion:1000});
	}).click( function () {
		window.location.href = $('base').attr('href') + $(this).find('a').attr('href');
	});
	
	//
	$('.bikeimage .logos, .rahmen_130').click( function () {
		$.urlBox({
			url:'index.php?id=435&L='+$('meta[name=typo3_lang]').attr('content'), 
			target:'.rahmen_120',
			width: 980, height: 630
		});
	});
	
	// Geotool-Legende (von Niki) öffnen
	$('.rahmen_140').click( function () {
		$.iframeBox({
			url: $('base').attr('href')+'fileadmin/geometrie/?L='+$('meta[name=typo3_lang]').attr('content'),
			width: 880, height: 590
		});
	});
	
	// Bis Daten drin sind: Platzhalter
	//$('.bikemetrics .col_left .inner').html('<h2>Die Geometriedaten sind in wenigen Tagen online!</h2>');
} );





/* ------------------------------------------------------------------------ */
// 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?
$(element).rolloverColor({color:'#000'});	->	Ändert bei RollOver die Textfarbe, z.B. für Menüs

*/


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

(function($){
	$.fn.extend({
	
		'copyProtectImage': function ( opt ) {
			var def = {transparent:'fileadmin/templates/imgs/trans.gif' };
			var opt = $.extend( def, opt);
			return this.each( function () {
				if ($(this).parent().nodeName() == 'a') $(this).parent().bind("contextmenu", function(e) { e.preventDefault(); });
				$(this).wrap('<span />');
				$(this).parent().prepend('<span style="position:absolute;"><img src="'+opt.transparent+'" width="'+$(this).width()+'" height="'+$(this).height()+'"></span>');
			});
		},
		
		'exists': function () {
			//return $(this).length>0;
			return $($(this).selector).length>0;
		},
		'nodeName': function () {
			return $(this)[0].nodeName.toLowerCase();
		},
		'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(); 
						}});
					}
				}
			});
		},
		
		'fadeInRemoveFilter': function ( opt ) {
			var def = {duration:500, easing:'linear' };
			var opt = $.extend( def, opt);
			return this.each( function () {
				var el = $(this);
				el.animate({'opacity':1}, {duration:opt.duration, easing:opt.easing, complete:function(){
					var el = $(this)[0];
					if (el.style.filter && el.style.removeAttribute) el.style.removeAttribute('filter');
				}});
			});
		},
		
		'rolloverColor': function ( opt ) {
			
			var def = { color:'#777A66', duration: 400, durationOut: 100, 'background-color': false };
			var opt = $.extend( def, opt);
			$(this).resetRolloverColor();
			
			return this.each( function () {	
				$(this).data('col', $(this).css('color') );
				$(this).data('bgcol', $(this).css('background-color') );
				$(this).unbind('mouseenter focus').bind( 'mouseenter focus', function () {
					var obj = {};
					if (opt.color) obj['color'] = opt.color;
					if (opt['background-color']) obj['background-color'] = opt['background-color'];
					$(this).stop(true,true).animate(obj, opt.duration);
				}).unbind('mouseleave focusout').bind('mouseleave focusout', function () {
					var obj = {};
					if (opt.color) obj['color'] = $(this).data('col');
					if (opt['background-color']) obj['background-color'] = $(this).data('bgcol');
					$(this).stop(true,true).animate(obj, opt.durationOut);
				});
			});
		},
		
		'resetRolloverColor': function () {	
			return this.each( function () {
				$(this).removeAttr('style');
			});
		},
		
		'callFlashFunction': function ( func, params ) {
			return this.each( function () {
				$(this)[0][func].apply( this, params );
			});
		}
		
	});
})(jQuery);



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

(function($){
	$.extend({
	
		
		'isIE': function ( vers ) {
			if (!vers) return $.browser.msie;
			return ($.browser.msie && $.browser.version.split('.')[0] == vers);
		},
		
		'metaTagValue': function ( id, data ) {
				if (!data) var data = $('head').html();
				var val = data.split("<meta name=\""+id+"\" content=\"")[1].split("\"")[0];
				return val;
			},
			
		'currentURL': function () {
			return window.location.href;
		},
		
		'reqVars': function ( id, url) {
			if (!url) url = $.currentURL();
			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 ) {
			if (!data) return '';
			return data.split("\t").join("").split("\r").join("").split("\n").join("");
		},
		
		'htmlentitiesdecode': function ( str ) {
			if (!$("<div />").html(str)) return '';
			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;
			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 ) {
			if (!obj.id) obj.id = '';
			try {
				$('body').data('m_ajax_loader_'+obj.id).abort();
			} catch (e) {}
			var n = $.ajax({ 	url: $.noCacheURL(obj.url), 
						success: function (data) {
							if (!data) return false;
							document.title = $.htmlentitiesdecode( $.getAllTags(data, 'title')[0] );

							// Aus dem Body-Tag ein DIV machen, sonst kann man die Klasse nicht lesen!
							var body2div = $.stripNL($.getAllTags(data, 'body', true)[0]).split("<body").join("<div").split("</body").join("</div");
							var html_data = $(body2div);
							//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 );
						}
				});
			$('body').data('m_ajax_loader_'+obj.id, n );

		}
		
	});
})(jQuery);

/**
 * Copyright (c) 2005 - 2010, James Auldridge
 * All rights reserved.
 *
 * Licensed under the BSD, MIT, and GPL (your choice!) Licenses:
 *  http://code.google.com/p/cookies/wiki/License
 *
 */
var jaaulde=window.jaaulde||{};jaaulde.utils=jaaulde.utils||{};jaaulde.utils.cookies=(function(){var resolveOptions,assembleOptionsString,parseCookies,constructor,defaultOptions={expiresAt:null,path:'/',domain:null,secure:false};resolveOptions=function(options){var returnValue,expireDate;if(typeof options!=='object'||options===null){returnValue=defaultOptions;}else
{returnValue={expiresAt:defaultOptions.expiresAt,path:defaultOptions.path,domain:defaultOptions.domain,secure:defaultOptions.secure};if(typeof options.expiresAt==='object'&&options.expiresAt instanceof Date){returnValue.expiresAt=options.expiresAt;}else if(typeof options.hoursToLive==='number'&&options.hoursToLive!==0){expireDate=new Date();expireDate.setTime(expireDate.getTime()+(options.hoursToLive*60*60*1000));returnValue.expiresAt=expireDate;}if(typeof options.path==='string'&&options.path!==''){returnValue.path=options.path;}if(typeof options.domain==='string'&&options.domain!==''){returnValue.domain=options.domain;}if(options.secure===true){returnValue.secure=options.secure;}}return returnValue;};assembleOptionsString=function(options){options=resolveOptions(options);return((typeof options.expiresAt==='object'&&options.expiresAt instanceof Date?'; expires='+options.expiresAt.toGMTString():'')+'; path='+options.path+(typeof options.domain==='string'?'; domain='+options.domain:'')+(options.secure===true?'; secure':''));};parseCookies=function(){var cookies={},i,pair,name,value,separated=document.cookie.split(';'),unparsedValue;for(i=0;i<separated.length;i=i+1){pair=separated[i].split('=');name=pair[0].replace(/^\s*/,'').replace(/\s*$/,'');try
{value=decodeURIComponent(pair[1]);}catch(e1){value=pair[1];}if(typeof JSON==='object'&&JSON!==null&&typeof JSON.parse==='function'){try
{unparsedValue=value;value=JSON.parse(value);}catch(e2){value=unparsedValue;}}cookies[name]=value;}return cookies;};constructor=function(){};constructor.prototype.get=function(cookieName){var returnValue,item,cookies=parseCookies();if(typeof cookieName==='string'){returnValue=(typeof cookies[cookieName]!=='undefined')?cookies[cookieName]:null;}else if(typeof cookieName==='object'&&cookieName!==null){returnValue={};for(item in cookieName){if(typeof cookies[cookieName[item]]!=='undefined'){returnValue[cookieName[item]]=cookies[cookieName[item]];}else
{returnValue[cookieName[item]]=null;}}}else
{returnValue=cookies;}return returnValue;};constructor.prototype.filter=function(cookieNameRegExp){var cookieName,returnValue={},cookies=parseCookies();if(typeof cookieNameRegExp==='string'){cookieNameRegExp=new RegExp(cookieNameRegExp);}for(cookieName in cookies){if(cookieName.match(cookieNameRegExp)){returnValue[cookieName]=cookies[cookieName];}}return returnValue;};constructor.prototype.set=function(cookieName,value,options){if(typeof options!=='object'||options===null){options={};}if(typeof value==='undefined'||value===null){value='';options.hoursToLive=-8760;}else if(typeof value!=='string'){if(typeof JSON==='object'&&JSON!==null&&typeof JSON.stringify==='function'){value=JSON.stringify(value);}else
{throw new Error('cookies.set() received non-string value and could not serialize.');}}var optionsString=assembleOptionsString(options);document.cookie=cookieName+'='+encodeURIComponent(value)+optionsString;};constructor.prototype.del=function(cookieName,options){var allCookies={},name;if(typeof options!=='object'||options===null){options={};}if(typeof cookieName==='boolean'&&cookieName===true){allCookies=this.get();}else if(typeof cookieName==='string'){allCookies[cookieName]=true;}for(name in allCookies){if(typeof name==='string'&&name!==''){this.set(name,null,options);}}};constructor.prototype.test=function(){var returnValue=false,testName='cT',testValue='data';this.set(testName,testValue);if(this.get(testName)===testValue){this.del(testName);returnValue=true;}return returnValue;};constructor.prototype.setOptions=function(options){if(typeof options!=='object'){options=null;}defaultOptions=resolveOptions(options);};return new constructor();})();(function(){if(window.jQuery){(function($){$.cookies=jaaulde.utils.cookies;var extensions={cookify:function(options){return this.each(function(){var i,nameAttrs=['name','id'],name,$this=$(this),value;for(i in nameAttrs){if(!isNaN(i)){name=$this.attr(nameAttrs[i]);if(typeof name==='string'&&name!==''){if($this.is(':checkbox, :radio')){if($this.attr('checked')){value=$this.val();}}else if($this.is(':input')){value=$this.val();}else
{value=$this.html();}if(typeof value!=='string'||value===''){value=null;}$.cookies.set(name,value,options);break;}}}});},cookieFill:function(){return this.each(function(){var n,getN,nameAttrs=['name','id'],name,$this=$(this),value;getN=function(){n=nameAttrs.pop();return!!n;};while(getN()){name=$this.attr(n);if(typeof name==='string'&&name!==''){value=$.cookies.get(name);if(value!==null){if($this.is(':checkbox, :radio')){if($this.val()===value){$this.attr('checked','checked');}else
{$this.removeAttr('checked');}}else if($this.is(':input')){$this.val(value);}else
{$this.html(value);}}break;}}});},cookieBind:function(options){return this.each(function(){var $this=$(this);$this.cookieFill().change(function(){$this.cookify(options);});});}};$.each(extensions,function(i){$.fn[i]=this;});})(window.jQuery);}})();
