/* #################################################
# Projekt	: Scripts - Kanalbau Public
# Stand		: 15.01.09
# Autor		: Daniel Zander, Source-Media.com
#################################################### */

$(function(){


// detect mac/ff
var userAgent = navigator.userAgent.toLowerCase();
if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) {
	$("#nav2").addClass('macff');
}


// ---------- toolbar ----------

$('#toolbar a.size').click(function(){
	var id = $(this).parent();
	var sz = parseInt(id.attr('data'));
	var go = parseInt($(this).attr('rel'));
	
	if ((go<0 && sz>0) || (go>0 && sz<2)) {
		id.attr('data',sz+go);
		id.parent().addClass('size'+(sz+go)).removeClass('size'+sz);
	}
	return false;
});


// ---------- box toggle  ----------

$("a[href=toggle]").click(function(){
	var n = $(this);
	while ((n = n.next()).length) {
		if (n.is('div.hide')) { n.slideToggle(); break; }
	}
	return false;
});


// ---------- form funcs ---------- ### CHECK

// set default value
$('input').each(function(){
	if (!$(this).attr('value'))
		$(this).attr('value', $(this).attr('title'));
});

// onfocus clear default
$('input').focus(function(){
	if ($(this).attr('value') == $(this).attr('title'))
		$(this).attr('value','');
});

// onsubmit clear default
$('a.submit').click(function(){

	$('input').each(function(){
		if ($(this).attr('value') == $(this).attr('title'))
			$(this).attr('value','');
	});
	
	$('#'+$(this).attr('rel')).submit();
	return false;	
});

$('select[name=seminar]').change(function(){
	window.location = $(this).attr('data')+$(this).val();
});


});//ready