function winopen(site)
{
	win = open(site,"win","width=700,height=480,screenX=0,screenY=0,menubar=no,scrollbars=yes,resizable=no");
	win.focus();
}

function oeffnefenster (url) {   fenster = window.open(url, "fenster1", "width=600,height=600,status=no,scrollbars=no,resizable=no");   fenster.focus();  }

(function($) {
    $.fn.pulsate = function(dat){
        if (this.length == 0){
            return $(this);
        }
        var par = {
            fadeinTime : 100,
            fadeoutTime : 1000
        };
        var pulseCounter = 20; // Anzahl der Pulsierungen
        var par = $.extend(par, dat);
        var $obj = $(this);
        var varCounter = 0;
        var pfn = function(){
                if(varCounter <= pulseCounter) { 
                varCounter++;
                $obj.fadeIn(par.fadeinTime, function(){
                    $obj.fadeOut(par.fadeoutTime);
                    
                });
            } else {
              clearInterval(pfn);
            };
        };
        
        pfn();
        setInterval(pfn, par.fadeinTime + par.fadeoutTime);

        return $obj;
    }
})(jQuery);

$(document).ready(function() {

    $("#flash_box_link").click(function() {
        $('#pulse').pulsate();
        return false;
    });
    
    $("ul#topten li:nth-child(odd)").addClass("colored");     
    
    $("ul#topten span#one").mouseover(function () {
      $("ul#topten li span.one").pause(slideToggle("slow"));
    });
    
    $(".sub_header_center .button").click(function() {
      $(this).toggleClass("hover");
      $(this).parents(".sub_header").next(".box").slideToggle("slow");
      $(this).parents(".sub_header").next(".bc_slide").slideToggle("slow", function() {
        $(".bar", this).animate({
          "width":"toggle"
        }, {
          duration: "slow" });
        });
      });
    
    $("#togglewrite").click(function() {
      $("#bc_review").slideToggle("slow");
      return false;
    });

    $("#togglenmdf").click(function() {
      $("#bc_nmdf_nonmemberform").slideToggle("slow");
      return false;
    });
    $("#togglenmdf").click(function() {
      $("#bc_nmdf_select").slideToggle("slow");
      return false;
    });
    
    $(".show_preview").hover(function () {
       $(this).children(".spot.info").stop().fadeIn("fast").fadeTo("fast", 1);
       }, function () {
       $(this).children(".spot.info").stop().fadeOut("fast");
    });
 
    $(".spot.info").click(function () {
        var aktuell = $(this).parent().children(".preview.dn");
        
        var img_width = $(this).parent().find("img:first").attr("width");
        var img_height = $(this).parent().find("img:first").attr("height");
        
        $(aktuell).width(img_width-15);
        
        var info_height = $(aktuell).height();
        
        $(aktuell).css("top", img_height - info_height - 10);
        $(aktuell).css("left", 3);
        
        $(".preview").not(aktuell).fadeOut();
        $(aktuell).fadeIn("fast");
        return false;
    });

      $("a.close_description").click(function () {
       $(this).parent().parent().parent().fadeOut("fast");
       return false;
       });
       
     $(".partner img").fadeTo("fast", 0.33);
     $(".partner img").hover(function() {
        $(this).fadeTo("fast", 1.00);
     }, function () {
        $(this).fadeTo("fast", 0.33); 
    });
     
    // Umfrage
    // Umfrage abgegeben?
    /*    
    if($.cookie('hide_poll'))
    {
        if($.cookie('hide_poll') == "true")
        {
            $("#show_poll").hide();
        }
        else
        {
            $("#show_poll").show();
        }
    }
   
    $("#poll_button").click(function(){
        var display = $("#show_poll").css("display");
        if (display == "none" )
        {
            $("#show_poll").show();
            $.cookie('hide_poll', 'false', { expires: 1, path: '/' });
            $(".bar").fadeIn("slow");
        }
        else
        {
            $("#show_poll").hide();
            $(".bar").fadeOut("slow");
        }
        return false; 
    });
    
    $("#close_poll").click(function(){
        $("#show_poll").hide();
        $.cookie('hide_poll', 'true', { expires: 1, path: '/' });
        return false;
    });  
    // Umfrage
                    
    // Produktvoting
    
    $("#productvoting").easySlider({
            orientation:'vertical',
            prevText:         '',    
            nextText:         ''
        });
    
    // Produktvoting */ 
	
    // Fancy Zoom
    $('div.photo a').fancyZoom({scaleImg: true, closeOnClick: true});
	$('.thumbborder a.zoom').fancyZoom({scaleImg: true, closeOnClick: true});
    $('#medium_box_link').fancyZoom({width:400, height:300});
    $('#large_box_link').fancyZoom();
    $('#flash_box_link, .flash_box_link').fancyZoom();
	
	  $("#videos li").hide();
      $("#videos li:first-child").show();
	  $("#videolinks li").fadeTo('fast',0.5, function(){$("#videolinks li:first-child").fadeTo('fast',1)});
    // Fancy Zoom
    
    $('.flash_box_link[class*=element]').click(function() {
        var classes = $(this).attr('class');
        classes = classes.split(' ');
        for (i=0; i<classes.length; i++)
        {
            var index = classes[i].substr(classes[i].indexOf('_')+1);
            if( ! isNaN(index))
            {
                index = parseInt(index);
                $("#videos li").hide().eq(index).show();
            }
        }
    });
    
	// Fancy-Zoom Autolaunch
    if(window.location.href.indexOf('#flash_') >= 0)
    {
        id = window.location.href.substr(window.location.href.indexOf('#'));
        index = id.substr(id.lastIndexOf('_')+1);
        if ( ! isNaN(index))
        {
			index = parseInt(index);
            if (index < 0 || $("#videos li").size()-1 < index)
                index = 0;
            
            id = id.substr(0, id.lastIndexOf('_'));
            $("a[href="+id+"], area[href="+id+"]").click();
            $("#videos li").hide().eq(index).show();
        }
		else
		{
			index = 0;
            $("a[href="+id+"], area[href="+id+"]").click();
		}
    } // Fancy-Zoom Autolaunch
});
