/* Navigation . Hover */
$.navigation = function(e) {
	$('#' + e + ' li a').children('img').each(function() {
		$(this).hover(
			function() {
				if ($(this).parent().attr('class') != 'current') {
					this.src = this.src.replace(/\.gif$/, '_on.gif');
				}
			},
			function() {
				if ($(this).parent().attr('class') != 'current') {
					this.src = this.src.replace(/_on\.gif$/, '.gif');
				}
			}
		);
	});
}

/* Load Flash Movie */
function loadMovie(f_url, e_id, f_id, f_width, f_height) {
	// Required Flash Player Version
	var majorVersion = '8.0.0';
	// Insert Flashmovie into DOM
	var so = new SWFObject(f_url, f_id, f_width, f_height, majorVersion, '#ffffff');
	so.addParam('allowScriptAccess', 'always');
	so.addParam('menu', 'false');
	so.addParam('quality', 'high');
	so.addParam('swLiveConnect', 'true');
	so.addParam('wmode', 'transparent');
	so.write(e_id);
	// Hide background image
	if (document.getElementById(f_id)) {
		$('#' + e_id).css('background-image', 'none');
	}
}

/* Resize Media Header */
function resizeMediaHead(eHeight) {
	// Initialize variables
	var dHeight = 190;
	// Calculate new position
	if (eHeight) {
//		var pos = parseInt($('#content').css('top'))+(eHeight-dHeight);
		var pos = eHeight;
	} else {
		var eHeight = dHeight;
		var pos = dHeight;
	}
	// Shift Content
	if (parseInt($('#content').css('top')) != parseInt(eHeight)) {
		$('#content').animate({ top: pos + 'px' }, 1500, function() {
			if (eHeight != 190) {
				// Include intro movie
				loadMovie('/flash/intro.swf', 'mediaHead', 'mediaHeadFlash', '977', '400');
			} else {
				$('li:first').removeClass('first');
				// Build 'Intro'-Link
				$('#metanavi').prepend('<li id="introLink" class="first" style="display: none;"><a href="javascript:intro();" title="Replay Intro">Intro</a></li>');
				$('#introLink').fadeIn('slow');
			}
		});
	}
}

/* Flash Intro */
function intro() {
	// Remove Flash movie
	if (document.getElementById('mediaHeadFlash')) {
		$('#mediaHeadFlash').remove();
	}
	// Remove 'Intro'-Link
	if (document.getElementById('introLink')) {
		$('#introLink').remove();
	}
	$('li:first').addClass('first');

	// Hide CSS Background images
	$('#header h1 a').css('background-image', 'none');
	$('#mediaHead').css('background-image', 'none');
	// Resize Header
	resizeMediaHead(400);
}

/* Get Service Center */
function getServiceCenter(sc) {
	// Toggle content
	$('#serviceCentersData').slideToggle('slow', function() {
		// Remove content
		$(this).empty();
		// Get Service Center Data
		$.ajax({
			type: 'GET',
			url: initialRootUrl+'/include/ajax_servicecenters.jsp',
			data: 'sc=' + sc,
			success: function(output) {
				// Show content
				$('#serviceCentersData').append(output).slideToggle('slow');
		   }
		});
	});
}

function searchNextpage() {
	var df	=	document.forms['search'];
	var actpage	=	df.searchpage.value;
	df.searchpage.value	=	(parseInt(actpage)+1);
	df.submit();
}

function searchPrevpage() {
	var df	=	document.forms['search'];
	var actpage	=	df.searchpage.value;
	df.searchpage.value	=	(parseInt(actpage)-1);
	df.submit();
}

function searchPage(page) {
	var df	=	document.forms['search'];
	df.searchpage.value	=	page;
	df.submit();
}

function getPDF(filename) {
	document.write("Hallo Welt...");
}

function getSPDF(filename) {

}

