/* #################################################
# Projekt	: Cosmic - Main Javascripts
# Stand		: 03.07.09
# Autor		: Daniel Zander, Source-Media.com
#################################################### */



$(function(){//ready

// ---------- input filter ----------

$('input[@type=checkbox]').addClass('ckbx');


var charset = function() {
	var exp = new RegExp('([^'+ $(this).attr('charset') +']*)','g');
	$(this).attr('value', $(this).attr('value').replace(exp,''));
};
$('input[@charset]').keyup(charset).blur(charset);


// ---------- set value ----------

// 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
$('input#submit').click(function(){

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


// ---------- shop ----------

$('#shop-geo a').click(function(){
	$(this).parent().hide();
	$('#'+$(this).attr('href')).fadeIn();
	return false;
});
$('#shop-euro a, #shop-rest a').click(function(){
	window.location = window.location+'&shop='+$(this).attr('href');
	return false;
});



// ---------- diverse ----------

$('a.submit').click(function(){
	$('#'+$(this).attr('rel')).submit();
	return false;	
});


// ---------- info toggle ----------

$('a.info').click(function(){
	var p = $('p',$(this).parent());
	$(this).html( (p.is(':hidden') ? '(&minus;)':'(+)') );
	p.slideToggle('fast');
	return false;
});


});//ready