

//----------------------------------
// NewWindow() Popup
// opens a new window with parameters
// description in know.namics under "generic open window script"
//----------------------------------
var win = null;
function NewWindow(thepageurl,thename,w,h,l,t,toolbar,location,directories,statusbar,resize,menubar,scroll,copyhistory) {
	
	LeftPosition = l;
	TopPosition = t;
	if (l == 'center')
		{
		LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
		}
	else
		{
		LeftPosition = (screen.width) ? (screen.width/2)-LeftPosition : 0;
		}
	if (t == 'center')
		{
		TopPosition = (screen.height) ? (screen.height-h)/4 : 0;
		}
	if (w != '') {
	settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable='+resize+',status='+statusbar+',toolbar='+toolbar+',location='+location+',directories='+directories+',menubar='+menubar+',copyhistory='+copyhistory;
	} else {
	settings = 'height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable='+resize+',status='+statusbar+',toolbar='+toolbar+',location='+location+',directories='+directories+',menubar='+menubar+',copyhistory='+copyhistory;
	}
	win = window.open(thepageurl,thename,settings);
	win.focus();
}


// -----------------------------------------------------------------------------
// Globals 4 flash
// Major version of Flash required
var requiredMajorVersion = 8;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Minor version of Flash required
var requiredRevision = 0;
// -----------------------------------------------------------------------------



(function($) {

	/* initialise nam object and add to jQuery */
	$.nam = $.nam || {};
	
	$.extend($.nam, {
	
		util: {
			hideAllExcept: function(elements,elementVisible){
				$(elements).addClass('none');
		    	$(elementVisible).removeClass('none');
			},
			getFlashversion: function() {
				return DetectFlashVer(9,0,0);
			}
		},
		
		css: {
			enableTabTeaser: function(index) {
			
				$('#TabTeaser > div:visible').hide(); /* hide all TabTeasers */
				
				if($('#TabTeaser > div').length) {
					
					if (!isNaN(index)) { /* show Teaser with this index */
						$('#TabTeaser > div:eq('+index+')').fadeIn(600);
					}
					else { /* find visible Tab and show appropriate Teaser */
						
						setTimeout(function() {
							
							var activeContentTab = 0;
							var $activeContentTab = $('#ContentTabs > div:visible');
							if ($activeContentTab.length && $activeContentTab.attr('id')) {
								activeContentTab = +$activeContentTab.attr('id').slice(-1) -1;
							}
							$('#TabTeaser > div:eq('+activeContentTab+')').show();
							
						}, 200);
					
					}
				}
			}
		},
		t: {
			customlink: function (vars) {
				
				// track the custom link
				if (typeof(vars) === 'object') {
					
					if (s && s.tl) {
						
						var _tevents = [],				// array of events
						_linkname = 'custom link';		// custom link name
						
						for (var item in vars ) {
							if (item === 'linkname') {
								_linkname = vars[item];
							}
							
							if (item === 'event') {
								_tevents.push(vars[item]);
							}
							// currently: only events
						}
						
						if (_tevents.length>0) {
							s.linkTrackVars="events";
							s.linkTrackEvents=_tevents.join(',');
							s.events=s.linkTrackEvents;
						}
						
						s.tl(true,'o',_linkname); 
						 
					}
				}
			}
		}
	});
	
})($);


$(document).ready(function() {
	
	/* hide all TabTeasers */
	$('#TabTeaser > div').hide();
	
	if($.browser.safari){
		
		$('#ContentTabs').css('margin-top', '-33px');
		$('#ContentTabs.two').css('margin-top', '-45px');
		$('#navigation .tabs').css('padding-top', '11px');
		$('#contactTabs').css('margin-top', '4px');
			
	}

	/* make tabs */
	$('#ContentTabs')
		.tabs({ fxFade: true, fxSpeed: 'fast' })
		.find('li').each(function(index){
			$(this).bind('click',function(e){
				$.nam.css.enableTabTeaser(index);
				e.stopPropagation();
			});
		});
	$('#contactTabs').tabs(+$('#contacttab').val(),{ fxFade: true, fxSpeed: 'fast' });	
	$('#ContentTabsBg').css('visibility', 'visible');
		
	/* show the desired TabTeaser */
	$.nam.css.enableTabTeaser();
	
	/* no comment */
	if($.browser.msie && $.browser.version === '6.0'){
	
		$('.tabs li, #ContentTabs ul li').mouseover(function(){
			$(this).addClass('hover');
			$('a', $(this)).addClass('hover');
		});

		$('.tabs li, #ContentTabs ul li').mouseout(function(){
			$(this).removeClass('hover');
			$('a', $(this)).removeClass('hover');
		});
		
	
		/* multiple-ie ie6
		$('#contactTabs').css('margin-top', '-20px');
		$('#contactTabs ul.tabs').css('padding-bottom', '35px');
		$('#tabs-background').css('bottom', '-1px');
		$('.tabs-nav').css('top', '0px');
		*/
		
	}
	
	
	
	/* popup */
	$('a.popup').click(function() {
		var href = this.href;
		if (href.indexOf('medium=5') === -1) {
			if (href.indexOf('?') === -1) {
				href = href + '?medium=5';
			}
			else {
				href = href + '&medium=5';
			}
		}
		NewWindow(href,'popup','500','600','center','50','no','no','no','no','yes','no','yes','no');
		return false;
	});
	$('a.popupprint').click(function() {
		NewWindow(this.href,'popup','800','600','center','50','no','no','no','no','yes','yes','yes','no');
		return false;
	});
	$('a.popupnpvr').click(function() {
		var href = this.href;
		NewWindow(href,'popup','500','600','center','50','no','no','no','no','yes','no','yes','no');
		return false;
	});
	
	/* display print-button */
	$('#navigation_print').css({'display':'inline','visability':'visible'});
	
	/* subnavigation - hover */
	$('#subnavigation ul.level2 > li:not(.mouseover)').mouseover(
		function() {
			$(this).addClass('mouseover');
		}).mouseout(
		function() {
			$(this).removeClass('mouseover');
		}
	);
	
	/* subnavigationKontaktPEX - hover */
	$('#subnavigationKontaktPEX ul.level2 > li:not(.mouseover)').mouseover(
		function() {
			$(this).addClass('mouseover');
		}).mouseout(
		function() {
			$(this).removeClass('mouseover');
		}
	);
	
	
	/* call hitox */
	if ($('#hitbox').length) {
		$.getScript("hbx.js");
	}
	
	/* form double-submit problem */
	$('#standardform').submit(function(){
		$(':submit[name!=mysubmit][class!=mysubmit]', this).attr('disabled', 'disabled');
	})
	.find(':input').change(function(){
		$('#standardform input:submit').removeAttr('disabled');
	});
	
});