var lastaction;
var refreshing = 8*1000; // 60 * 1000 = 1 Minute (1000 = millisekunden, 60 = sekunden)
var refreshId=0;

$(document).ready(function() {    
    if ($(document).width()>=1400){// && (screen.height>=768)) {
		$("body").addClass("big");
	}
	
    $('a#cms_login_click').click(function() {
        $('#loginform').dialog('open');
        return false;
    });
    $('#loginform').dialog({
        bgiframe: true,
        autoOpen: false,
        modal: true,
        title: "LOGIN",
        buttons: {
            'Login': function() {
                $.post("/login.php",$('#form_loginform').serialize(), function(response) {
                    response = eval(response);
                    if (response) {
                        location=$('#langlink_site').attr("href");
                    } else {
                        alert("login nicht erfolgreich");
                    }
                },"JSON"
                );	
                return false;	            
            }
        },
        close: function() {
		
        }
    });
    
    
    $('input.date').datepicker({
        dateFormat:'yy-mm-dd'
    });
	
    $('a.lightbox').hover(function() {
        $('img',$(this)).fadeTo("fast",1);
        $('a.lightbox').removeClass("active").addClass("notactive");
        $(this).addClass("active").removeClass("notactive");
        $('a.notactive').stop().animate({
            opacity:'0.5'
        });
    },function() {
        $('a.lightbox').removeClass("notactive").removeClass("active");
        $('a.lightbox').stop().animate({
            opacity:'1'
        });
    });
	
    $('#fileupload_iframe').remove();
        
    $('#category_template_wrap #categoryNavigation li a.categorytitle')
    .hover(function() {
        //$(this).stop().animate({'opacity':1});
        if ($(this).parent().hasClass("notactive")) {
        	$('span.title',$(this)).stop().animate({'paddingBottom':'40px','paddingTop':'10px'},'fast');
        } 
        $('div#pagenavigation ul').removeClass("active").addClass("notctive").hide();
        var id = ".pagenavigation_"+$(this).attr("cat");
        $(id).show().addClass("active");
        $('li',$(this).parent().parent()).addClass("notactive");
        
    },function() {
        //$(this).stop().animate({'opacity':'0.8'});
       if ($(this).parent().hasClass("notactive")) {
       	$('span.title',$(this)).stop().animate({'paddingBottom':'6px','paddingTop':'8px'},'fast');
       }
    });
    $('#category_home_wrap #categoryNavigation a.categorytitle')
    .hover(function() {
        //$(this).stop().animate({'opacity':1});
        $(this).parent().stop().animate({'marginTop':'-10px'},'fast'); 
    },function() {
        //$(this).stop().animate({'opacity':'0.8'});
       $(this).parent().stop().animate({'marginTop':'0px'},'fast');
    });
    
    
    $('#categoryNavHome a .desc i').css("opacity",0.7);
    
    $('#categoryNavHome a').hover(function() {
    	$('.desc i',this).css("opacity",1);
    	//$('.pfeil',this).stop().animate({'marginLeft':'20px'});
    	$('.arrow2',this).stop().animate({'paddingRight':'30px'});
    },function() {
    	
    	$('.desc i',this).css("opacity",0.7);
    	//$('.pfeil',this).stop().animate({'marginLeft':'0px'});
    	$('.arrow2',this).stop().animate({'paddingRight':'10px'});
    });
    
    $('a',$('#home_side .links')).css('opacity','0.6').hover(function() {
    	$(this).stop().animate({'opacity':1});
    },function() {
    	$(this).stop().animate({'opacity':0.6});
    });
    
    $('a',$('#home_side .summerwinter')).hover(function() {
    	$(this).stop().animate({'textIndent':'10px'});
    },function() {
    	$(this).stop().animate({'textIndent':'0'});
    });
    
    $('a',$('#topline')).hover(function() {
        $(this).stop().animate({'height':'30px'});
    },function() {
        $(this).stop().animate({'height':'20px'});
    });

    $('.listsubnavigation a.pagetitle').hover(function() {
        $('span.more',$(this)).stop().animate({'paddingTop':'30px'});
    },function() {
        $('span.more',$(this)).stop().animate({'paddingTop':'10px'});
    });
    
    
    
    $('div#pagenavigation li.page').each(function() {
	    if (!$(this).hasClass("active")) {
	    	$('b',this).css('opacity',0.6);
	    }
    });
    
    $('div#pagenavigation a.pagetitle').hover(function() {
    	if (!$(this).parent().hasClass("active")) {
	    	$('b',this).stop().animate({'paddingTop':'4px','paddingBottom':'4px','opacity':'1'},'fast');
	     }
    },function() {
    	
    	 if (!$(this).parent().hasClass("active")) {
	    	$('b',this).stop().animate({'paddingTop':'2px','paddingBottom':'2px','opacity':'0.6'},'fast');
	     }
    });
    
    
});

