function getIeVersion()
{
	var ieVersion = 10;
	/*@cc_on
		 @if   (@_jscript_version == 9.0)  ieVersion = 9;
		 @elif (@_jscript_version == 5.8)  ieVersion = 8;
		 @elif (@_jscript_version == 5.7)  ieVersion = 7;
		 @elif (@_jscript_version == 5.6)  ieVersion = 6;
		 @elif (@_jscript_version == 5.5)  ieVersion = 5.5;
		 @elif (@_jscript_version == 5.0)  ieVersion = 5;
		 @elif (@_jscript_version == 5.01) ieVersion = 5;
		 @elif (@_jscript_version == 3.0)  ieVersion = 4;
		 @elif (@_jscript_version == 1.0)  ieVersion = 3;
		 @else @*/                     //  ieVersion = null;
	   /*@end
	@*/
	if (ieVersion == 7 && !window.XMLHttpRequest)
	{
		ieVersion = 6;
	}
	return ieVersion;	
}

function newWindow(url, width, height) {
	var w;
	var h;
	
	(width==null) ? w=800:w=width;
	(height==null) ? h=600:h=height;
	
	window.open(url,"cns_window","status=1, height="+h+", width="+w+", resizable=1, scrollbars=1, screenX=100, screenY= 120");	
}

function langChange(choice){ 
	if (choice.options[choice.selectedIndex].value == 'active')	{ 
		return; 
	} else {
		var base = $('base').attr('href');
		var fallback_split = choice.options[choice.selectedIndex].value.split("items/"); // Clean-up for news and events 
		var url = fallback_split[0];
		window.location.href = base + url; 
	}	
} 

$(document).ready(function() {
	
	/* THUMBNAILS */
	
	$('body').not('.iforum').find('.mod_article').not('.videoGallery').find('.ce_text a').each(function() {
		if($(this).attr('rel')) {
				if( $(this).attr('rel').substr(0,8) == 'lightbox' ) {
				$(this).addClass('lightbox');
				
				var html = $(this).html() + '';
				if ( $(this).find('img')[0] != undefined ){
					var y_position = $(this).find('img').height() - 23;
					var x_position = $(this).find('img').position().left + 3;
				}
				
				/* if ($(this).find('img:first').width() > 400) {
					x_position = $(this).find('img:first').position().left + $(this).find('img:first').width() - 27;
				} */
				
				$(this).html('<div class="thumbnailHint" style="margin-top:' +y_position +'px; left:' + x_position +'px;"><img src="/tl_files/cadenas/images/icons/thumbnail_magnifier.png"/></div>' + html);
			}
		}
	});
	
	$('#tl_search input').focus(function() {
		$(this).attr("value","");	
	})
	
	/* BUTTONS 
	generates graphical buttons from following Code:
	
	<a class="buttonLink" href="" title="" onclick="" target=""> 
	
	Options:	
	- By adding attribute rel="left" to the a tag the button floats left.
	*/
	
	$('a.buttonLink').each(function() {
		var url = $(this).attr('href');
		var title = $(this).attr('title');
		var target = $(this).attr('target'); 	if (!target) target="_self";
		var onclick = $(this).attr('onclick');	if (!onclick) onclick="";
		var rel = $(this).attr('rel');
		var text = $(this).html();
		
		if (rel) {
			if (rel.match(/[0-9]{2,3}/)) {
				var width = rel;
			}
		}
		
		_html = '';
		
		_html += '<div class="linkButton">\n';
		_html += '<div class="buttonLeft">&nbsp;</div>\n';
		if (width) {
			_html += '<div class="buttonCenter" style="width:'+ width +'px; text-align: center;">';
			_html += '<a href="' +url + '" title="' +title + '" target="' +target + '" onclick="' +onclick + '">'; 
		} else {
			_html += '<div class="buttonCenter"><a href="' +url + '" title="' +title + '" target="' +target + '" onclick="' +onclick + '">';	
		}
		_html += text;
		_html += '</a></div>\n';
		_html += '<div class="buttonRight">&nbsp;</div>\n'
		_html += '</div>\n';
		if (rel != 'left') _html += '<div class="float-stopper"></div>';
		
		$(this).replaceWith(_html);
		$(this).click(onclick);
	});
	
	
	$('.linkButton').hover(function() {
		$(this).find('.buttonLeft').css('background-image','url(tl_files/cadenas/images/buttons/button_left_hover.jpg)');
		$(this).find('.buttonCenter').css('background-image','url(tl_files/cadenas/images/buttons/button_center_hover.jpg)').find('a').css('color','white');
		$(this).find('.buttonRight').css('background-image','url(tl_files/cadenas/images/buttons/button_right_hover.jpg)');		
	}, function() {
		$(this).find('.buttonLeft').css('background-image','url(tl_files/cadenas/images/buttons/button_left.jpg)');
		$(this).find('.buttonCenter').css('background-image','url(tl_files/cadenas/images/buttons/button_center.jpg)').find('a').css('color','#67a2c0');
		$(this).find('.buttonRight').css('background-image','url(tl_files/cadenas/images/buttons/button_right.jpg)');		
	});
	
	$('.linkButton').click(function() {
		$(this).find('.buttonLeft').css('background-image','url(tl_files/cadenas/images/buttons/button_left.jpg)');
		$(this).find('.buttonCenter').css('background-image','url(tl_files/cadenas/images/buttons/button_center.jpg)').find('a').css('color','#67a2c0');
		$(this).find('.buttonRight').css('background-image','url(tl_files/cadenas/images/buttons/button_right.jpg)');	
	});
	
	/* CREATE CALENDAR APPOINTMENTS */
	
	$('.mod_calendar .event').mouseenter( function() {
		$(this).find('.createAppointment:first').css('display','block');
	});
	
	$('.mod_calendar .event').mouseleave( function() {
		$(this).find('.createAppointment:first').css('display','none');
	});
	
	$('.mod_calendar .event .createAppointment a').click( function() {
		$('.createAppointment').css('display','none');
	});
			
	/* CSS ADJUSTMENT */		
	if ( $('#main h1').next().find('*:first-child')[0] ) {
		if ($('#main h1').next().find('*:first-child')[0].tagName == 'H2' ) {
			$('#main h1').next().find('*:first-child').css('margin-top', '0px');
		}
	}
	
	var pdf_y = $('h1:first').height();
	$('.pdf_link').css({
		'margin-top': pdf_y+15,
		'top': '0px'
	});	
	
	
	/* BUTTONS DE */
	
	$('body.de img.broschureButton').hover(function() {	$(this).attr('src','tl_files/cadenas/images/buttons/broschure_button_de_hover.jpg');},
		function() {$(this).attr('src','tl_files/cadenas/images/buttons/broschure_button_de.jpg');	});
	$('body.de img.broschureButton').click(function() { $(this).attr('src','tl_files/cadenas/images/buttons/broschure_button_de.jpg');	});			
		
	$('body.de img.successButton').hover(function() {$(this).attr('src','tl_files/cadenas/images/buttons/success_button_de_hover.jpg');
		},	function() {$(this).attr('src','tl_files/cadenas/images/buttons/success_button_de.jpg');	});	
	$('body.de img.successButton').click(function() {$(this).attr('src','tl_files/cadenas/images/buttons/success_button_de.jpg');	});	
	
	$('body.de img.videoButton').hover(function() {	$(this).attr('src','tl_files/cadenas/images/buttons/play_video_hover.jpg');	},
		function() {$(this).attr('src','tl_files/cadenas/images/buttons/play_video.jpg');	});	
	$('body.de img.videoButton').click(function() {	$(this).attr('src','tl_files/cadenas/images/buttons/play_video.jpg');});	
		
	$('body.de img.routeButton').hover(function() {	$(this).attr('src','tl_files/cadenas/images/buttons/routenplanung_button_de_hover.jpg');},
		function() {$(this).attr('src','tl_files/cadenas/images/buttons/routenplanung_button_de.jpg');	});	
	$('body.de img.routeButton').click(function() {	$(this).attr('src','tl_files/cadenas/images/buttons/routenplanung_button_de.jpg');	});	

	$('body.de img.appointmentButton').hover(function() {$(this).attr('src','tl_files/cadenas/images/buttons/appointment_button_de_hover.jpg');},
		function() {$(this).attr('src','tl_files/cadenas/images/buttons/appointment_button_de.jpg');	});	
	$('body.de img.appointmentButton').click(function() {$(this).attr('src','tl_files/cadenas/images/buttons/appointment_button_de.jpg');	});		
	
	$('body.de img.newsletterButton').hover(function() {$(this).attr('src','tl_files/cadenas/images/buttons/newsletter_button_de_hover.jpg');},
		function() {$(this).attr('src','tl_files/cadenas/images/buttons/newsletter_button_de.jpg');	});	
	$('body.de img.newsletterButton').click(function() {$(this).attr('src','tl_files/cadenas/images/buttons/newsletter_button_de.jpg');	});	
	
	$('body.de img.kalkulatorButton').hover(function() {$(this).attr('src','tl_files/cadenas/images/buttons/kalkulator_hover.jpg');},
		function() {$(this).attr('src','tl_files/cadenas/images/buttons/kalkulator.jpg');	});	
	$('body.de img.kalkulatorButton').click(function() {$(this).attr('src','tl_files/cadenas/images/buttons/kalkulator_hover.jpg');	});	
	
	
	
	
	/* BUTTONS EN */
	
	$('body.en img.broschureButton').hover(function() {	$(this).attr('src','tl_files/cadenas/images/buttons/en/broschure_button_hover.jpg');},
		function() {$(this).attr('src','tl_files/cadenas/images/buttons/en/broschure_button.jpg');	});
	$('body.en img.broschureButton').click(function() { $(this).attr('src','tl_files/cadenas/images/buttons/broschure_button.jpg');	});			
		
	$('body.en img.successButton').hover(function() {$(this).attr('src','tl_files/cadenas/images/buttons/en/success_button_hover.jpg');
		},	function() {$(this).attr('src','tl_files/cadenas/images/buttons/en/success_button.jpg');	});	
	$('body.en img.successButton').click(function() {$(this).attr('src','tl_files/cadenas/images/buttons/success_button.jpg');	});	
	
	$('body.en img.videoButton').hover(function() {	$(this).attr('src','tl_files/cadenas/images/buttons/en/play_video_hover.jpg');	},
		function() {$(this).attr('src','tl_files/cadenas/images/buttonsen//play_video.jpg');	});	
	$('body.en img.videoButton').click(function() {	$(this).attr('src','tl_files/cadenas/images/buttons/play_video.jpg');});	
		
	$('body.en img.routeButton').hover(function() {	$(this).attr('src','tl_files/cadenas/images/buttons/en/routenplanung_button_hover.jpg');},
		function() {$(this).attr('src','tl_files/cadenas/images/buttons/en/routenplanung_button.jpg');	});	
	$('body.en img.routeButton').click(function() {	$(this).attr('src','tl_files/cadenas/images/buttons/routenplanung_button.jpg');	});	

	$('body.en img.appointmentButton').hover(function() {$(this).attr('src','tl_files/cadenas/images/buttons/en/appointment_button_hover.jpg');},
		function() {$(this).attr('src','tl_files/cadenas/images/buttons/en/appointment_button.jpg');	});	
	$('body.en img.appointmentButton').click(function() {$(this).attr('src','tl_files/cadenas/images/buttons/appointment_button.jpg');	});		
	
	$('body.en img.newsletterButton').hover(function() {$(this).attr('src','tl_files/cadenas/images/buttons/en/newsletter_button_hover.jpg');},
		function() {$(this).attr('src','tl_files/cadenas/images/buttons/en/newsletter_button.jpg');	});	
	$('body.en img.newsletterButton').click(function() {$(this).attr('src','tl_files/cadenas/images/buttons/newsletter_button.jpg');	});	
	
	$('body.en img.kalkulatorButton').hover(function() {$(this).attr('src','tl_files/cadenas/images/buttons/en/kalkulator_hover.jpg');},
		function() {$(this).attr('src','tl_files/cadenas/images/buttons/en/kalkulator.jpg');	});	
	$('body.en img.kalkulatorButton').click(function() {$(this).attr('src','tl_files/cadenas/images/buttons/kalkulator_hover.jpg');	});	
	
	
	
	/* BUTTONS IT */
	
	$('body.it img.broschureButton').hover(function() {	$(this).attr('src','tl_files/cadenas/images/buttons/broschure_button_it_hover.jpg');},
		function() {$(this).attr('src','tl_files/cadenas/images/buttons/broschure_button_it.jpg');	});
	$('body.it img.broschureButton').click(function() { $(this).attr('src','tl_files/cadenas/images/buttons/broschure_button_it.jpg');	});			
		
	$('body.it img.successButton').hover(function() {$(this).attr('src','tl_files/cadenas/images/buttons/success_button_it_hover.jpg');
		},	function() {$(this).attr('src','tl_files/cadenas/images/buttons/success_button_it.jpg');	});	
	$('body.it img.successButton').click(function() {$(this).attr('src','tl_files/cadenas/images/buttons/success_button_it.jpg');	});	
	
	$('body.it img.videoButton').hover(function() {	$(this).attr('src','tl_files/cadenas/images/buttons/play_video_hover.jpg');	},
		function() {$(this).attr('src','tl_files/cadenas/images/buttons/play_video.jpg');	});	
	$('body.it img.videoButton').click(function() {	$(this).attr('src','tl_files/cadenas/images/buttons/play_video.jpg');});	
		
	$('body.it img.routeButton').hover(function() {	$(this).attr('src','tl_files/cadenas/images/buttons/routenplanung_button_it_hover.jpg');},
		function() {$(this).attr('src','tl_files/cadenas/images/buttons/routenplanung_button_it.jpg');	});	
	$('body.it img.routeButton').click(function() {	$(this).attr('src','tl_files/cadenas/images/buttons/routenplanung_button_it.jpg');	});	

	$('body.it img.appointmentButton').hover(function() {$(this).attr('src','tl_files/cadenas/images/buttons/appointment_button_it_hover.jpg');},
		function() {$(this).attr('src','tl_files/cadenas/images/buttons/appointment_button_it.jpg');	});	
	$('body.it img.appointmentButton').click(function() {$(this).attr('src','tl_files/cadenas/images/buttons/appointment_button_it.jpg');	});		
	
	$('body.it img.newsletterButton').hover(function() {$(this).attr('src','tl_files/cadenas/images/buttons/newsletter_button_it_hover.jpg');},
		function() {$(this).attr('src','tl_files/cadenas/images/buttons/newsletter_button_it.jpg');	});	
	$('body.it img.newsletterButton').click(function() {$(this).attr('src','tl_files/cadenas/images/buttons/newsletter_button_it.jpg');	});	
	
	$('body.it img.kalkulatorButton').hover(function() {$(this).attr('src','tl_files/cadenas/images/buttons/kalkulator_it_hover.jpg');},
		function() {$(this).attr('src','tl_files/cadenas/images/buttons/kalkulator_it.jpg');	});	
	$('body.it img.kalkulatorButton').click(function() {$(this).attr('src','tl_files/cadenas/images/buttons/kalkulator_it_hover.jpg');	});

});
