$(document).ready(function(){


    /*$(".level1 li").hover(
      function () {
        $(this).addClass("active");
      },
      function () {
        $(this).removeClass("active");
      }
    );

    $(".level2 li").hover(
      function () {
        $(this).addClass("active");
      },
      function () {
        $(this).removeClass("active");
      }
    );*/

    //**************************************************************************
    // Leere Navigation ausblenden - 08.09.2009 - Simon Milz ( mi )
    //**************************************************************************
    var nav_content = $('ul.level2').text();
    var trimed_nav_content = $.trim(nav_content);

    if(trimed_nav_content == '') {
        $(this).css("display","none");
        $('#header').height('180px');
    }
    //******************* Leere Navigation ausblenden #ENDE# *******************

    $("#nav_top ul.left a:last").css("border-right","0px solid");
    $("#nav_top ul.right a:last").css("border-right","0px solid");
    $("#nav_top ul.right a:last").css("padding-right","0");

    $("#nav_main ul.level1 li:first").css("margin-left","11px");

    $("#footer_nav li.gruen").css("margin-right","400px");
    $("#footer_nav li.gruen").css("border-right","0px solid");

    $(".iRadio").click(function(){
            $(this).siblings().attr({checked:""});
    });

    // KOMMENTARE
    $('#comment').hide();
    $('img.show_comment').click(
        function(){
            if ($("#comment").is(":hidden")) {
                $("#comment").fadeIn("slow");
            } else {
                 $("#comment").fadeOut("slow");
            }
        }
    );


    $('#lieblingsliste_neuanlage').ajaxForm(
    {
        clearForm: true,
        success: function() {
            alert('Vielen Dank!');
            location.href = location.href;
        }
    });

    $('#profil_speichern').ajaxForm(
    {
        success: function() {
            $('#profil_speichern :text').addClass('view').attr('disabled', true)
            $('#profil_speichern .iSend').hide();
			$('#profil_speichern .edit').show();
			var herz_val = $('#form_HERZANGL').val();
			$('#form_HERZANGL').replaceWith('<input type="text" value="'+herz_val+'" id="form_HERZANGL" name="HERZANGL" class="view" disabled=""/>');
        }
    });
    
    $('#profil_speichern :text').addClass('view').attr('disabled', true);
    $('#profil_speichern .iSend').hide();

    $('#profil_speichern .edit').click(function() {
        $('#profil_speichern :text:not(.locked)').removeClass('view').attr('disabled', false);
        $('#profil_speichern .iSend').show();
		$('#profil_speichern .edit').hide();
		var herz_arten = new Array(
			'verknallt',
			'verliebt',
			'frisch verliebt',
			'schwer verliebt',
			'in einer Beziehung',
			'unschlüssig',
			'Single und glücklich',
			'Single und auf der Suche',
			'Single',
			'Nase voll',
			'gerade Schluss gemacht',
			'Liebeskummer'
		);
		
		var herz_val = $('#form_HERZANGL').val();		
		var herz_select = '<select id="form_HERZANGL" name="HERZANGL">';
		
		herz_select = herz_select+'<option value=""></option>';
		
		for(var i = 0;i < herz_arten.length;i++)
		{
			var selected = '';
			if(herz_val == herz_arten[i])
			{
				selected = 'selected="selected"';
			}
			herz_select = herz_select+'<option '+selected+' value="'+herz_arten[i]+'">'+herz_arten[i]+'</option>';
		}
		
		herz_select = herz_select+'</select>';

		
		$('#form_HERZANGL').replaceWith(herz_select);

        return false;
    });




    

    $(".emoticons img").click(
            function () {
                    //var temp = $('#editor').html() + '<img src="' + $(this).attr('src') + '" alt="Emoticon" border="0" />';
            var temp = $('#INHALT').val() + $(this).attr('alt');
            $("#INHALT").val(temp);

            }
    );
    
    

    // Padding fuer Content-Ueberschriften mit Icon
    $(".content_wrapper span.icon").parent().css("padding-left","45px");

    var height_subcol_left = 0;
    var height_subcol_right = 0;
    $("#col_m div.container.subcol_50").each(function(){
        if(navigator.appVersion.search(/msie\s+6/i) != -1) {
            $(this).width(260);
            $(".top3 .even").removeClass("even");
            $(".orange thead tr th :not(:first-child)").css("background-image","none !important");
        }
        else {
            $(this).width(280);
        };

        $(this).css('clear', 'both');
        $(this).css('float', 'none');
        var container_float = '';
        if (height_subcol_left == 0 || height_subcol_left < height_subcol_right) {
            container_float = 'left';
            height_subcol_left += $(this).height() + 16;
        }
        else {
            container_float = 'right';
            height_subcol_right += $(this).height() + 16;
        }
        $(this).css('float', container_float);
        $(this).css('clear', 'none');
    });
    
    
    $('#profil_speichern div').addClass('clearfix');
    $('.purple.xmag .content .odd:first').addClass('clearfix');
//    $('.container div').addClass('clearfix');

	$("div.entry img[align='right']").addClass('cfe_right');
	$("div.entry img[align='left']").addClass('cfe_left');

    $('.media_item a img, .media_item_video a img').each(function() {
       var imgHeight = $(this).height();
       var divHeight = $('.media_item').height();
       if(imgHeight < divHeight)
       {
            var padding = (divHeight-imgHeight)/2;
            $(this).css('padding-top',padding);
       }
    });
});

function showSide(i) {
	$('#search_side').val(i);
	$('#suchergebnis_seiten').submit();
}