$(document).ready(function() {
	/** eventhandler **/
	$('.teaser_close').click(function() {
		var strTeaser = $(this).attr('rel');
		$('#teaser_'+strTeaser).hide();
		$.ajax({
			type:"GET",
			url:host+"functions/closeTeaser.php?id="+strTeaser
		});		
	});
	
	$("#stat_details").draggable({
		cursor: "move",
		handle: ".head",
		opacity: 0.75,
		drag: function(event, ui) {
			$("#stat_details").redrawShadow();
		},
		stop: function(event, ui) {
			$("#stat_details").redrawShadow();
		}
	});
	
	/** register input **/
	$('input.register').focus(function() {
		$(this).addClass('register_active');
		var strName = $(this).attr('name');
		$('#info_'+strName).show();
	});
	
	$('input.register').blur(function() {
		$(this).removeClass('register_active');
		var strName = $(this).attr('name');
		$('#info_'+strName).hide();
	});
	
	$('select.register').focus(function() {
		$(this).addClass('register_active');
		var strName = $(this).attr('name');
		$('#info_'+strName).show();
	});
	
	$('select.register').blur(function() {
		$(this).removeClass('register_active');
		var strName = $(this).attr('name');
		$('#info_'+strName).hide();
	});
	
	$('input[type=radio].account_country').focus(function() {
		var strValue = $(this).val();
		$('.account_box').hide();
		$('#account_'+strValue).show();
	}); 
	
	$('.payment_checkbox').click(function() {
		var arrTemp = $(this).attr('id').split('_');
		var strPaymentMethod = arrTemp[1];
		if(arrTemp[2]) {
			strPaymentMethod += '_'+arrTemp[2];
		}
		if($(this).attr('checked')) {
			$('#payment_'+strPaymentMethod).addClass('payment_box_active');	
			if($(this).attr('rel') != "" && $(this).attr('rel') != undefined) {
				var arrTempRequiresOverall = $(this).attr('rel').split(' ');	
				var arrTempRequires = arrTempRequiresOverall[0].split(',');	
				for each (var strRequire in arrTempRequires) {
					$('#payment_'+strRequire).addClass('payment_box_active');
					$('#checkbox_'+strRequire).attr('checked','checked');	
				}
			}
		} else {
			$('#payment_'+strPaymentMethod).removeClass('payment_box_active');	
			if($(this).attr('rel') != "" && $(this).attr('rel') != undefined) {
				var arrTempRequiresOverall = $(this).attr('rel').split(' ');	
				var arrTempRequiredBy = arrTempRequiresOverall[1].split(',');	
				for each (var strRequiredBy in arrTempRequiredBy) {
					$('#payment_'+strRequiredBy).removeClass('payment_box_active');
					$('#checkbox_'+strRequiredBy).attr('checked','');	
				}
			}
		}
		
	});
	
//	$('div.payment_box').click(function() {
//		var arrTemp = $(this).attr('id').split('_');
//		var strPaymentMethod = arrTemp[1];
//		console.log($('#checkbox_'+strPaymentMethod));
//		console.log($('#checkbox_'+strPaymentMethod).attr('checked'));
//		if($('#checkbox_'+strPaymentMethod).attr('checked')) {
//			console.log('aktiv');
//		} else {
//			console.log('inaktiv');
//		}
//		$('#payment_'+strPaymentMethod).addClass('payment_box_active');
//	});
	
	$('div.payment_box').mouseover(function() {
		var arrTemp = $(this).attr('id').split('_');
		var strPaymentMethod = arrTemp[1];
		
		$('#payment_'+strPaymentMethod).addClass('payment_box_hover');
	});
	
	$('div.payment_box').mouseout(function() {
		var arrTemp = $(this).attr('id').split('_');
		var strPaymentMethod = arrTemp[1];
		
		$('#payment_'+strPaymentMethod).removeClass('payment_box_hover');
	});
});
