var config = {
	baseUrl: ''
//	baseUrl: '/werbung/html'
};
var common = {
    prevSelector: null,
    
    checkGutscheine: function()
    {
    	var code = '';
    	var fields = jQuery('input.gutscheincode-small-input');
    	jQuery.each(fields, function(i, v){
    		var field = jQuery(v);
    		code += field.val();
    	});
		jQuery('input#gutscheincode-hidden').val(code);
    },
    
    changeFrame: function(w, h)
    {
        var box = parent.document.getElementById('fbBox');
        var iframe = parent.document.getElementById('fbContent');
        var main = parent.document.getElementById('fbMainDiv');
        if (h > 0) {
        	$(box).css('height', h);
        	$(main).css('height', h);
        	$(iframe).attr('height', h);
        }
        if (w > 0) {
        	$(box).css('width', w);
        	$(main).css('width', w);
        	$(iframe).attr('width', w);
        }
    },
    
    changeFrameSize: function()
    {
        var h = $('body').height();
		common.changeFrame(0, h);
    },
    
    changeFramePayment: function()
    {
		setTimeout("common.changeFrame(0, 670);", 800);
    },
    
    closeBox: function()
    {
        var box = parent.document.getElementById('fbOverlay');
        $(box).click();
    },
    
    showAjax: function(selector) {
    	common.prevSelector = selector;
    	$(selector).hide();
        $(selector).before('<div id="ajax-load" style="text-align: center;"><img src="' + config.baseUrl + '/images/ajax-loader.gif" alt="loading" /></div>');
    },
    
    hideAjax: function() {
        $('#ajax-load').remove();
        $(common.prevSelector).show();
    },
    
    markError: function(field) {
        jQuery.each(jQuery('label'), function(i, el){
            var label = jQuery(el);
            var forEl = label.attr('for');
            if(forEl == field) {
                label.css('color', 'red');
            }
        });
    },
    
    markRequiredFields: function() {
    	var required = $('label.required');
    	$.each(required, function(i, field){
    		var f = $(field);
    		var len = f.html().length;
    		var index = f.html().lastIndexOf( ' *' );
    		if ( len - 2 == index ) {
    			f.html( f.html().substr(0, index) );
    		}
    		f.append(' *');
    	});
    	
    	var optional = $('label.optional');
    	$.each(optional, function(i, field){
    		var f = $(field);
    		var len = f.html().length;
    		var index = f.html().lastIndexOf( ' *' );
    		if ( len - 2 == index ) {
    			f.html( f.html().substr(0, index) );
    		}
    	});
    },
    
    showPaymentForm: function() {
    	window.open(config.baseUrl + '/credits/payment')
    },
    
    closePaymentForm: function() {
    	parent.window.location.href = parent.window.location.href;
    },
    
    clearFieldFocus: function(selector, defValue) {
    	if ($(selector).val() == defValue) {
    		$(selector).val('');
    	}
    },
    
    clearFieldBlur: function(selector, defValue) {
    	if ('' == $(selector).val()) {
    		$(selector).val(defValue);
    	}
    },
    
    billingFirstClick: false,
    
    showBilling: function(event)
    {
    	var chb = $(this);
    	var spans = $('span.bil_det');
    	if('click' == event.type) {
    		chb.attr('checked', chb.attr('checked'));
    	}
    	if (chb.attr('checked')) {
    		spans.show();
    	} else {
    		spans.hide();
    	}
    	if('click' == event.type && !common.billingFirstClick) {
    		chb.attr('checked', !chb.attr('checked'));
    		common.billingFirstClick = true;
    	}
    }
};
var registration = {
	resendEmail: function(userId)
	{
        $.post(
            config.baseUrl + '/registration/resend.html',
            {user_id: userId},
            function(res) {
				if (res.status) {
					//$('div#message').css('color', 'green');
					$('input#btn_ok').css('display', 'none');
					$('a#link_ok').css('display', '');
				} else {
					$('div#message').css('color', 'red');
					$('a#link_ok').css('display', 'none');
					$('input#btn_ok').css('display', '');
				}
				$('div#message').html(res.message);
				common.changeFrameSize();
            },
            'json'
        );
	},
	
	changeUserType: function(elem) {
		var compInp = $('input#company');
		var compLbl = compInp.parent('div').prev('div').children('label');
		if ('company' == $(elem).val()) {
			$('input#ust_id').attr('disabled', false);
			compLbl.removeClass('optional');
			compLbl.addClass('required');
		} else {
			$('input#ust_id').val('');
			$('input#ust_id').attr('disabled', true);
			compLbl.removeClass('required');
			compLbl.addClass('optional');
		}
		common.markRequiredFields();
	},
	
	changeCountry: function(elem)
	{
		var select = $(elem);
		$('select#country_short').val(select.val());
		$('select#country_iso').val(select.val());
	},
	
	noCountry: function()
	{
		if ($('input#no-country').attr('checked')) {
			$('select#country_short').parent('div').css('display', 'none');
			$('select#country_iso').parent('div').css('display', '');
			$('select#country_short').change();
		} else {
			$('select#country_short').parent('div').css('display', '');
			$('select#country_iso').parent('div').css('display', 'none');
			$('select#country_iso').change();
		}
	},
	
	initCountries: function()
	{
		var country = $('select#country_iso').val();
		
		if('AF' == country || ("undefined" != typeof($('select#country_short').val(country)) && country == $('select#country_short').val(country).val())) {
			$('select#country_short').parent('div').css('display', '');
			$('select#country_iso').parent('div').css('display', 'none');
			$('input#no-country').attr('checked', false);
		} else {
			$('select#country_short').parent('div').css('display', 'none');
			$('select#country_iso').parent('div').css('display', '');
			$('input#no-country').attr('checked', true);
		}
	}
	
};

var billing = {
	changeCountry: function(elem)
	{
		var select = $(elem);
		$('select#billing-country_short').val(select.val());
		$('select#billing-country_iso').val(select.val());
	},
	
	noCountry: function()
	{
		if ($('input#billing-no-country').attr('checked')) {
			$('select#billing-country_short').parent('div').css('display', 'none');
			$('select#billing-country_iso').parent('div').css('display', '');
			$('select#billing-country_short').change();
		} else {
			$('select#billing-country_short').parent('div').css('display', '');
			$('select#billing-country_iso').parent('div').css('display', 'none');
			$('select#billing-country_iso').change();
		}
	},

	initCountries: function()
	{
		var country = $('select#billing-country_iso').val();
		if("undefined" != typeof($('select#billing-country_short').val(country)) && country == $('select#billing-country_short').val(country).val()) {
			$('select#billing-country_short').parent('div').css('display', '');
			$('select#billing-country_iso').parent('div').css('display', 'none');
			$('input#billing-no-country').attr('checked', false);
		} else {
			$('select#billing-country_short').parent('div').css('display', 'none');
			$('select#billing-country_iso').parent('div').css('display', '');
			$('input#billing-no-country').attr('checked', true);
		}
	}
};

var account = {
	changeCountry: function(elem)
	{
		var select = $(elem);
		$('select#user-country_short').val(select.val());
		$('select#user-country_iso').val(select.val());
	},
	
	noCountry: function()
	{
		if ($('input#no-country').attr('checked')) {
			$('select#user-country_short').parent('div').css('display', 'none');
			$('select#user-country_iso').parent('div').css('display', '');
			$('select#user-country_short').change();
		} else {
			$('select#user-country_short').parent('div').css('display', '');
			$('select#user-country_iso').parent('div').css('display', 'none');
			$('select#user-country_iso').change();
		}
	},

	initCountries: function()
	{
		var country = $('select#user-country_iso').val();
		if("undefined" != typeof($('select#user-country_short').val(country)) && country == $('select#user-country_short').val(country).val()) {
			$('select#user-country_short').parent('div').css('display', '');
			$('select#user-country_iso').parent('div').css('display', 'none');
			$('input#no-country').attr('checked', false);
		} else {
			$('select#user-country_short').parent('div').css('display', 'none');
			$('select#user-country_iso').parent('div').css('display', '');
			$('input#no-country').attr('checked', true);
		}
	}
};

var banner = {
	saveUrl: function()
	{
		var bannerId = $('input#banner_id').val();
		var url = $('input#ziel-url').val();
        $.post(
            config.baseUrl + '/banners/urlform.html',
            {banner_id:bannerId, new_url:url, act:'changeurl'},
            function(res) {
                $('div#res').empty();
                $('div#res').css('padding', '4px;');
				$('div#res').append(res.message);
				if (res.status) {
					$('div#message').css('color', 'green');
					$('div#btn-ok').css('display', '');
				} else {
					$('div#message').css('color', 'red');
					$('div#btn-ok').css('display', 'none');
				}
				$('div#message').html(res.message);
				common.changeFrameSize();
            },
            'json'
        );
	}
};
var payment = {
	changeOrder: function(element)
	{
		var s = $(element);
		location.href = s.val();
	}
};
var campaing = {
    groupDelete: function()
    {
    	var checkboxes = $('input.campdel');
    	var ids = [];
    	jQuery.each(checkboxes, function(i, item){
    		var chb = $(item);
    		if (chb.attr('checked')) {
    			ids.push(chb.val());
    		}
    	});
    	
    	jQuery.post(
    	   config.baseUrl + '/admin/campaings/delete',
    	   {ids: jQuery.toJSON(ids)},
    	   function(res){
    	   	if("undefined" != typeof(res.url)) {
    	   		window.location.href = res.url;
    	   	} else {
    	   		window.location.href = config.baseUrl + '/admin/campaings/';
    	   	}
    	   },
    	   'json'
    	);
    	
    	return false;
    },
    
    groupDeleteUser: function()
    {
        var checkboxes = $('input.campdel');
        var ids = [];
        jQuery.each(checkboxes, function(i, item){
            var chb = $(item);
            if (chb.attr('checked')) {
                ids.push(chb.val());
            }
        });
        
        jQuery.post(
           config.baseUrl + '/campaings/delete',
           {ids: jQuery.toJSON(ids)},
           function(res){
            if("undefined" != typeof(res.url)) {
                window.location.href = res.url;
            } else {
                window.location.href = config.baseUrl + '/campaings/';
            }
           },
           'json'
        );
        
        return false;
    },
    
    changeSizeImage: function()
    {
    	var el = $(this);
    	var url = $('input#size_images_' + el.val()).val();
    	$('img#size_preview').attr('src', url);
    },
    
    initStep1: function()
    {
	    	var checkboxes = $('div#areas-form input:checkbox');
	    	var checked = 'like-no';
	    	$.each(checkboxes, function(i, elem){
	    		var chb = $(elem);
	    		chb.unbind('change');
	    		chb.change(campaing.initStep1);
	    		if (chb.attr('checked')) {
	    			checked = 'like-yes';
	    		}
	    	});
    	if (!editCapmaing) {
    		$('input:radio#' + checked).attr('checked', true);
    	}
    },
    
    initFirstStepRadios: function()
    {
    	var checkboxes = $('div#areas-form input:checkbox');
    	var active = $('input:radio#like-yes').attr('checked');
    	$('div#areas-form').css('display', (!active) ? 'none' : '');
    	$.each(checkboxes, function(i, elem){
    		var chb = $(elem);
    		chb.attr('disabled', !active);
    	});
    	$('input:radio#like-yes').unbind('change');
    	$('input:radio#like-yes').change(campaing.initFirstStepRadios);
    	$('input:radio#like-no').unbind('change');
    	$('input:radio#like-no').change(campaing.initFirstStepRadios);
    },
    
    showBanners: function()
    {
        $('#banners').empty();
        common.showAjax('div#banners');
		var sizes = campaing.getCheckedBannerSizes();
        $('div.sortieren').show();
        $('#banners').load(config.baseUrl + '/banners', {order:$('select#banner-sort').val(), sizes:$.toJSON(sizes), campaing_id:$('input#campaing_id.hidden').val()}, function(){
            campaing.initPick();
            common.hideAjax();
        });
    },

	initBanners: function()
	{
		var sizes = campaing.getCheckedBannerSizes();
		if (0 == sizes.length) {
			var inputs = $('div#banner-sizes input');
			$(inputs[0]).attr('checked', true);
			campaing.showBanners();
			$.each(inputs, function(i, e){
				$(e).mouseover(campaing.changeSizeImage);
			});
		}
	},

	getCheckedBannerSizes: function()
	{
        var inputs = $('div#banner-sizes input');
        var sizes = new Array();
        $.each(inputs, function(i, v){
            var inp = $(v);
            if (inp.attr('checked') && (0 == inp.attr('id').indexOf('sizes-'))) {
                var size = inp.attr('id').split('sizes-');
                if (size[1]) {
                    sizes.push(size[1]);
                }
            }
        });
        return sizes;
	},

	showEvents: function(selectObj)
	{
		$('#left-content').load(config.baseUrl + '/campaings/addevents', {order:$(selectObj).val()}, function(){
			common.hideAjax();
		});
	},
	
	orderEvents: function()
	{
		var a = $(this);
		var order = a.children('input#order').val();
		var orderDir = a.children('input#orderDir').val();
		$('#left-content').load(config.baseUrl + '/campaings/addevents', {order:order, order_dir: orderDir}, function(){
			common.hideAjax();
		});
		return false;
	},

    initPick: function()
    {
        $('#banners input.pick').click(campaing.addBanner);
    },
    
    addBanner: function(event)
    {
        var t = $(this);
        var e = $(event);
        var tmp = t.attr('id').split('banner-');
        var banner_id = tmp[1];
        var campaing_id = $('input#campaing_id.hidden').val();
        var action = t.attr('checked');
        $.post(
            config.baseUrl + '/campaings/addbanner',
            {banner_id:banner_id, campaing_id:campaing_id, act:action},
            function(res) {
                //$('#banners').append(res);
            }
        );
    },
    
    initEvents: function()
    {
        $('input.pick').click(campaing.addEvent);
        $('a.event_order').click(campaing.orderEvents);
        campaing.loadSelectedEvents();
    },
    
    addEvent: function(event)
    {
        var t = $(this);
        var e = $(event);
        var tmp = t.attr('id').split('event-');
        var event_id = tmp[1];
        var campaing_id = $('input#campaing_id.hidden').val();
        var action = t.attr('checked');
        $.post(
            config.baseUrl + '/campaings/addevent',
            {event_id:event_id, campaing_id:campaing_id, act:action},
            function(res) {
                campaing.loadSelectedEvents();
            }
        );
    },
    
    selectAllEvents: function(img1,img2)
    {
    	var events = jQuery('input.pick');
    	
    	var ids = [];
    	
    	var check = false;
    	
    	var action = false;
    	
    	jQuery.each(events, function(i, e){
    		var event = jQuery(e);
    		if ( (!event.attr('checked')) ) {
    			action = true;
    		}
    	});
    	
    	jQuery.each(events, function(i, e){
    		var event = jQuery(e);
    		if (!event.attr('checked') || !action) {
		        var tmp = event.attr('id').split('event-');
		        var event_id = tmp[1];
		        ids.push(event_id);
    		}
    		event.attr('checked', action);
    	});

		var campaing_id = $('input#campaing_id.hidden').val();


		var img = jQuery('#select_all_events_img');
		if (action) {
			img.attr('src', '/images/' + img1);
		} else {
			img.attr('src', '/images/' + img2);
		}

        $.post(
            config.baseUrl + '/campaings/addevent',
            {event_id:jQuery.toJSON(ids), campaing_id:campaing_id, act:action, type: 'json'},
            function(res) {
                campaing.loadSelectedEvents();
            }
        );
    },
    
    loadSelectedEvents: function()
    {
    	$('div#selected-events').load(
    		config.baseUrl + '/campaings/selectedevents',
    		{},
    		function(res){
    			if (res) {
    				$('div#selected-events-container').show();
    			} else {
    				$('div#selected-events-container').hide();
    			}
    		}
    	);
    },
    
    initBudgets: function()
    {
    	$('input#total_budget_btn').unbind('click');
    	$('input.netto-box').unbind('change');
    	$('input#total_budget_btn').click(campaing.addBudget);
    	$('input.netto-box').change(campaing.addBudgetDetail);
    	
    	var budgetInp = $('input.netto-box');
    	$.each(budgetInp, function(i, v) {
    		var sub = $('input.for_event_' + $(v).attr('id'));
    		$.each(sub, function(k, val){
    			$(val).unbind('change');
    			$(val).change(campaing.addSubBudget);
    		});
    	});

    },

    distributeBudget: function()
    {
        if (!$('input#total_budget').val()) {
            $('input#total_budget').val(100);
        }
        $('input#total_budget_btn').click();
    },
    
    initBudgetsDetail: function()
    {
    	$('input#total_budget_btn').unbind('click');
    	$('input#total_budget_btn').click(campaing.addBudgetDetail);
    },
    
    addBudgetDetail: function()
    {
    	var budgetInp = $('input.netto-box');
//    	budgetInp.unbind('change');
    	budgetInp.change(campaing.addEventBudget);
    	$.each(budgetInp, function(i, v) {
    		// Set 0 for not selected disziplins
    		var notSelected = $('input.not_selected_disziplin.for_event_' + $(v).attr('id')).val(0);
    		
    		var sub = $('input.selected_disziplin.for_event_' + $(v).attr('id'));

    		var eventsCount = sub.length;
    		var subVal = $(v).val() / eventsCount;
    		var add = 0;
    		$.each(sub, function(k, val){
    			add += subVal - parseInt(subVal);
    			if (k+1 == sub.length) {
    				subVal += add;
    			}

    			$(val).val(parseInt(subVal));
    			$(val).unbind('change');
    			$(val).change(campaing.addSubBudget);
    		});
    	});
    },
    
    addEventBudget: function()
    {
    	var currentInp = jQuery(this);
    	var eventId = currentInp.attr('id');

    	var eventBudgetTd = jQuery('td.budget.ev_' + eventId);
    	eventBudgetTd.text(currentInp.val());
    	
    	var total = parseInt(jQuery('input#total_budget').val());
    	if (total) {
	    	var budgetSum = 0;
	    	var budgetInp = $('input.netto-box');

	    	$.each(budgetInp, function(i, v) {
	    		budgetSum += parseInt(jQuery(v).val());
	    	});
	    	
	    	if (budgetSum > total) {
	    		budgetInp.css('border-color', 'red');
	    		budgetInp.attr('hasError', true);
	    	} else {
	    		budgetInp.css('border-color', '#999');
	    		budgetInp.attr('hasError', false);
	    	}
    	}
    },
    
    addSubBudget: function()
    {
    	var inp = $(this);
		inp.removeClass('sub-netto-box');
		var className = inp.attr('class');
		inp.addClass('sub-netto-box');
		var eventId = className.replace('for_event_', '');
    	campaing.checkSumForEvent(eventId);
    },
    
    checkSumForEvent: function(eventId)
    {
    	eventId = eventId.replace(/\D/g, '');
    	var totalSum = $('input#' + eventId + '.netto-box').val();
    	var disSum = 0;
    	var disBudget = $('input.sub-netto-box.for_event_' + eventId);
    	$.each(disBudget, function(i, v){
    		disSum = new Number(disSum) + new Number($(v).val());
    	});
    	
    	if (disSum > totalSum) {
    		disBudget.css('border-color', 'red');
    		disBudget.attr('hasError', true);
    	} else {
    		disBudget.css('border-color', '#999');
    		disBudget.attr('hasError', false);
    	}
		$('span#span_total_' + eventId).remove();
		var min = totalSum - disSum;
		var sign = '+';
		var color = 'green';
		if (min < 0) {
			sign = '-';
			min = min * -1;
			color = 'red';
		}
		//$('input#' + eventId + '.netto-box').after('<span id="span_total_' + eventId + '" style="color: ' + color + ';">  ' + sign + ' ' + min + '</span>');
    },
    
    addBudget: function()
    {
    	var total = $('input#total_budget').val();
    	var maxBudget = $('input#max_budget').val();
    	if (isNaN(total)) {
    		$('input#total_budget').css('border', '1px solid red');
    		total = 0;
    	} else {
    		$('input#total_budget').css('border', '1px solid #999');
    	}
    	if ((maxBudget - total) < 0) {
    		$('input#total_budget').val($('input#max_budget').val());
    		$('input#total_budget_btn').click();
    		jQuery('div#low_money_auto').show();
    		return false;
    	} else {
    		jQuery('div#low_money_auto').hide();
    	}
    	var sum = total / $('input#events_count').val();
    	var additionSum = parseInt( (sum * $('input#events_count').val()) - (parseInt(sum) * $('input#events_count').val()) );
    	var budgetTd = $('td.budget');
    	$.each(budgetTd, function(i, v) {
            if (i == budgetTd.length - 1) {
                sum += additionSum;
            }
    		$(v).html(parseInt(sum));
    	});
    	sum -= additionSum;
    	
    	jQuery('input.sub-netto-box').css('border-color', '#999');
    	jQuery('input.sub-netto-box').attr('hasError', false);
    	
    	var budgetInp = $('input.netto-box');
    	budgetInp.css('border-color', '#999');
    	budgetInp.attr('hasError', false);
    	
    	$.each(budgetInp, function(i, v) {
    		if (i == budgetInp.length - 1) {
    			sum += additionSum;
    		}
    		$(v).val(parseInt(sum));
    	});
    	$('input.netto-box').unbind('change');
    	$('input.netto-box').change(campaing.addBudgetDetail);
    	campaing.addBudgetDetail();
    	campaing.countClients();
    },
    
    countClients: function()
    {
    	var clients_for_campaing = $('input#clients_for_campaing').val();
    	var clients =  $('input#total_budget').val() / clients_for_campaing;
    	
    	clients = parseInt(clients);
    	
    	if (isNaN(clients)) {
    		clients = 0;
    	}
   	
    	$('span#campaing_clients').text(clients);
    },
    
    checkBudgetErrors: function()
    {
    	var hasError = false;
    	
    	var forEvents = jQuery('input.netto-box');
    	jQuery.each(forEvents, function(i, v){
    		if (!hasError) {
	    		if ('true' == jQuery(v).attr('hasError')) {
	    			hasError = true;
	    		}
    		}
    	});

		if (!hasError) {
			var forSubEvents = jQuery('input.sub-netto-box');
	    	jQuery.each(forSubEvents, function(i, v){
	    		if (!hasError) {
		    		if ('true' == jQuery(v).attr('hasError')) {
		    			hasError = true;
		    		}
	    		}
	    	});
		}

    	return !hasError;
    },
    
    saveBudget: function(link)
    {
    	if (!campaing.checkBudgetErrors()) {
    		jQuery('div#budget_errors_div').show();
    		return false;
    	}
    	jQuery('div#budget_errors_div').hide();
    	
    	var link = $(link);
    	var result = new Array();
    	var disBudget = $('input.sub-netto-box');
    	$.each(disBudget, function(i, v){
    		var inp = $(v);
    		inp.removeClass('sub-netto-box');
    		var className = inp.attr('class');
    		inp.addClass('sub-netto-box');
    		result.push({
    			event_id: className.replace('for_event_', ''),
    			disziplin_id: inp.attr('id'),
    			budget: inp.val()
    		});
    	});

		var totalBudget = jQuery('input#total_budget').val();

        $.post(
            config.baseUrl + '/campaings/budget',
            {data:$.toJSON(result), total:totalBudget},
            function(res) {
            	
            	if (res.status) {
            		location.href = link.attr('href');
            	} else {
					$('div#temp').remove();
					var d = '<div id="temp"><ul class="errors"><li>' + res.message + '</li></ul></div>';
//					$('#showReviews').append(d);
					$('div.float-left').parent('div').prev().prev().after(d);
            	} 
            },
            'json'
        );
        return false;
    },
    
    extendReviews: function()
    {
    	var div = $('div#showReviews');
    	if ('none' == div.css('display')) {
    		div.show('slow');
    	} else {
    		div.hide('slow');
    	}
    },
    
    eventReviews: function(eventId)
    {
    	var div = $('div#extend_event_' + eventId);
    	var img = $('img.extend_event_img_' + eventId);
    	if ('none' == div.css('display')) {
    		div.show('slow');
    		img.attr('src', img.attr('src').replace('rechts.jpg', 'unten.jpg'));
    	} else {
    		div.hide('slow');
    		img.attr('src', img.attr('src').replace('unten.jpg', 'rechts.jpg'));
    	}
    },
    
    showDetails: function()
    {
    	var camp = $(this);
    	window.location.href = camp.val();
    },
    
    dailyEvents: function(selector)
    {
    	var tr = $(selector);
    	if ('none' == tr.css('display')) {
			tr.css('display', 'table-row');
    	} else {
    		var subTr = $(selector + '_all');
    		subTr.css('display', 'none');
    		tr.css('display', 'none');
    	}
    }
};
var faq = {
	init: function()
	{
		var f = $('span.faq_title');
		$.each(f, function(i, el){
			$(el).click(faq.show);
		});
	},
	
	show: function()
	{
		var fc = $('div#faq_' + $(this).attr('id'));
		/*if ('auto' == fc.css('height')) {
			fc.css('height', fc.height()+50);
		}*/
		if ('none' == fc.css('display')) {
			fc.slideDown('slow');
		} else {
			fc.slideUp('slow');
		}
	}
};

function clearFieldUser(fld) {
    if (fld.value == "Benutzername") fld.value = "";
}
function clearFieldKennwort(fld) {
    if (fld.value == "Kennwort") {
        fld.value = "";
    }
}

if ("undefined" != typeof(Shadowbox)) {

	Shadowbox.loadSkin('classic', config.baseUrl + '/js/src/skin');
	Shadowbox.loadLanguage('en', config.baseUrl + '/js/src/lang');
	Shadowbox.loadPlayer(['flv', 'html', 'iframe', 'img', 'qt', 'swf', 'wmp'], '/js/src/player');
	
}

$(document).ready(function(){
    common.markRequiredFields();
    $.each($('select'), function(i,v){
        var s = $(v);
        if ('' == s.attr('class')) {
            s.addClass('select');
        }
    });
    if ("undefined" != typeof(Shadowbox)) {
    	Shadowbox.init();
    }
});
