// BoldSolutions.de

var bold = {
    init : function () {
	$('.roterfadenwrapper').hover(
//            function () {$('.roterfadenwrapper').stop(true,true).animate({height : 68},'slow',
//									 function () {
//									     $('.rf_daybox').stop(true,true).show();
//									 });},
				      function () {$('.rf_daybox').stop(true,true).show();
                                                   $('.roterfadenwrapper').css({height : 68});
				      },
//	    function () {$('.roterfadenwrapper').stop(true,true).animate({height : 32},'slow',
//									 function () {
//									     $('.rf_daybox').stop(true,true).hide();
//									 });});
				      function () {$('.rf_daybox').delay(3000).stop(true,true).fadeOut(1500,
												       function () {$('.roterfadenwrapper').css({height : 32});})
				      });
        $('.rf_switch').click(function () {var classList=$(this).attr('class').split(/\s+/);
		var switchId="";
		$.each( classList, function(index, item) {
			if (item.substring(0,4) == 'rfs_') {
			    if (switchId) switchId+=', ';
			    switchId+='.'+item;
			}
		    });
		$('.rf_switchable').filter(switchId).stop(true,true).slideDown();
		$('.rf_switchable').not(switchId).stop(true,true).slideUp();
	    });
    },
    tabactive : function (tabid,elem) {
        $(elem).parent().children().removeClass('rf_tabhandle_focus').addClass('rf_tabhandle');
        $(elem).removeClass('rf_tabhandle').addClass('rf_tabhandle_focus');
        $('#'+tabid).show().parent().children().not('#'+tabid).hide();
    },
    imglocator : function () {
	var file=$('#zoom img').attr('src');
        var here=$('#zoom a.imglink[href='+file+']').parent();
        $('#zoom a.imglink[href!='+file+']').parent().stop(true,true).hide();
        $('p.imgtext[img_file!='+file+']').stop(true,true).hide();
        $('p.imgtext[img_file='+file+']').stop(true,true).show();
        here.stop(true,true).show();
        //if (here.prev().prev().size()) here.prev().stop(true,true).show();
        //if (here.next().next().size()) here.next().stop(true,true).show();
        var firstlink=$('#zoom a.firstlink');
        var lastlink=$('#zoom a.lastlink');
        var previous=here.prev().children('a.imglink');
        var next=here.next().children('a.imglink');
        if (previous.size()==1) {
	    //firstlink.attr('href',previous.attr('href'));
	    firstlink.die('click');
	    firstlink.live('click',previous.attr('onclick'));
            firstlink.parent().stop(true,true).show();
	} else {
            firstlink.parent().stop(true,true).hide();
	}
        if (next.size()==1) {
	    //lastlink.attr('href',next.attr('href'));
	    lastlink.die('click');
	    lastlink.live('click',next.attr('onclick'));
            lastlink.parent().stop(true,true).show();
	} else {
            lastlink.parent().stop(true,true).hide();
	}
    } 
}



$(document).ready(function () {
	bold.init();
        $('div.bar.oxid div.roterfaden_menu').hover(
						    function () {$(this).children('ul').stop(true,true).slideDown('slow');},
						    function () {$(this).children('ul').stop(true,true).delay(1000).slideUp('slow');}
						    );
        var theWindow        = $(window),
            $bg              = $("#roterfaden_bg_img"),
            aspectRatio      = $bg.width() / $bg.height();
        if ( (theWindow.width() / theWindow.height()) < aspectRatio ) {
            $bg
              .removeClass()
              .addClass('rf_bgheight');
        } else {
            $bg
              .removeClass()
              .addClass('rf_bgwidth');
        }
        $('.haendlerbox').draggable();
         
});

$(function() {   
        var theWindow        = $(window),
            $bg              = $("#roterfaden_bg_img"),
            aspectRatio      = $bg.width() / $bg.height();
        function resizeBg() {
	        $bg.removeClass();
                aspectRatio      = $bg.width() / $bg.height();
                if ( (theWindow.width() / theWindow.height()) < aspectRatio ) {
                    $bg
                        .removeClass()
                        .addClass('rf_bgheight');
                } else {
                    $bg
                        .removeClass()
                        .addClass('rf_bgwidth');
                }
        }
        theWindow.resize(function() {
                resizeBg();
        }).trigger("resize");
});
