﻿// base.js
if(typeof jQuery != 'undefined') {
	$(document).ready(function() {
		
		// make the menu work in IE
		if($.browser.msie) {
			$('#mainmenu li').hover(function() {
				$(this).find('ul').show(0);
				$(this).addClass('active');
			}, function() {
				$(this).find('ul').hide(0);
				$(this).removeClass('active');
			});
		}
		$('#mainmenu li').hover(function() {
			$(this).addClass('active');
		}, function() {
			$(this).removeClass('active');
		});
		
		
		
		// searchbox
		if($('#searchbox').val() == '') {
			id = $('#searchbox').attr('id');
			value = $('label[for=' + id + ']').text();
			$('#searchbox').val(value);
			$('#searchbox').addClass('inactive');
		}
		else {
			$('#searchbox').removeClass('inactive');	
		}

		$('#searchbox').focus(function () {
			$(this).addClass('hover');
			
			id = $(this).attr('id');
			value = $('form label[for=' + id + ']').text();
			
			if($(this).val() == value) {
				$(this).val('');
				$(this).removeClass('inactive');
			}
		});
		$('#searchbox').blur(function () {
			$(this).removeClass('hover');
			
			id = $(this).attr('id');
			value = $('form label[for=' + id + ']').text();
			
			if($(this).val() == '') {
				$(this).val(value);
				$(this).addClass('inactive');
			}
		});

	});
	
	
	
	// Bilder in Sidebar bei MouseOver vergrößern
	function resize() {
		if($('#sidebar')) {
			oriHeight = $('#sidebar .csc-textpic-imagewrap img').height();
			newHeight = oriHeight * 125 / 100;
			
			oriWidth = $('#sidebar .csc-textpic-imagewrap img').width();
			newWidth = oriWidth * 125 / 100;
			distance = oriWidth - newWidth;
			
			$('#sidebar .csc-textpic-imagewrap').css('text-align','center');
			$('#sidebar .csc-textpic-imagewrap').css('width','300px');
			$('#sidebar .csc-textpic-image').css('text-align','center');
			$('#sidebar .csc-textpic-image').css('width','300px');
			$('#sidebar .csc-textpic-image dt').css('text-align','center');
			$('#sidebar .csc-textpic-image dt').css('width','300px');
			
			
			// nachdem das Bild dauernd zwischen groß und klein gewechselt hat, 
			// hab ich den hover einfach mal direkt aufs bild und nicht den wrap gegeben. 
			// mal schauen, obs so klappt. 
			// kp | 2009-10-15
			
			//$('#sidebar .csc-textpic-imagewrap').mouseover(function() {
			$('#sidebar .csc-textpic-imagewrap img').mouseover(function() {
				$('#sidebar .csc-textpic-imagewrap img').animate({ 
					height: newHeight,
					width: newWidth
				}, 500);
				/*$('#sidebar .csc-textpic-imagewrap').animate({ 
					width: newWidth
				}, 500);
				$('#sidebar .csc-textpic-image').animate({ 
					width: newWidth
				}, 500);*/
			});
			
			//$('#sidebar .csc-textpic-imagewrap').mouseout(function() {
			$('#sidebar .csc-textpic-imagewrap img').mouseout(function() {
				$('#sidebar .csc-textpic-imagewrap img').animate({ 
					height: oriHeight,
					width: oriWidth
				}, 500);
				/*$('#sidebar .csc-textpic-imagewrap').animate({ 
					width: oriWidth
				}, 500);
				$('#sidebar .csc-textpic-image').animate({ 
					width: oriWidth
				}, 500);*/
			});
	
		}
	}
	
}