jQuery.noConflict();
     
 // Use jQuery via jQuery(...)
jQuery(document).ready(function(){

//Bewertung
  jQuery('ul.rating li a').click(function(event){
    event.preventDefault();  //Verhindert das Springen zum Anchor
		jQuery.ajax({
       type: "GET",
       url: "/tria/wGlobal/scripts/custom/ajax.php",
       data: "rating="+jQuery(this).text()+"&path="+location.pathname,
       success: function(response){
         jQuery('#ratingText').text('Vielen Dank!');
         jQuery('#ratingText').next().html(response);
       }
     });
	});
	//Kommentare abgeben
	jQuery('a#publizieren').click(function(event){
    event.preventDefault();  //Verhindert das Springen zum Anchor
		jQuery.ajax({
       type: "POST",
       url: "/tria/wGlobal/scripts/custom/ajax.php",
       data: "action=comment&name="+jQuery('input#name').val()+"&email="+jQuery('input#email').val()+"&meinung="+jQuery('textarea').val()+"&path="+location.pathname,
       success: function(response){
         jQuery('#kommentarForm').slideUp("slow", function () {
           jQuery('#kommentarForm').parent().html("<h2>Vielen Dank für Ihre Meinung!</h2>");
         });
         jQuery('#kommentarForm').slideDown("slow");
         jQuery(response)    
          .fadeOut(1000, function() {
            
            jQuery('#kommentarPreview').animate({opacity: 1.0}, 200).remove();
          })
          .insertBefore('#markerInsert')
          .animate({opacity: 1.0}, 50)
          .fadeIn(1000);
       }
     });
	});
	//Kommentare preview
	jQuery('a#preview').click(function(event){
	  var validate = true;
	  if(jQuery('input#name').val() == ''){ jQuery('input#name').addClass('wglInputError'); validate = false;}
	  if(jQuery('input#email').val() == ''){ jQuery('input#email').addClass('wglInputError'); validate = false;}
	  if(jQuery('#meinung').val().length < 2){ jQuery('#meinung').addClass('wglInputError'); validate = false;}
	  if(validate == false) return false;
    event.preventDefault();  //Verhindert das Springen zum Anchor
    jQuery.ajax({
       type: "POST",
       url: "/tria/wGlobal/scripts/custom/ajax.php",
       data: "action=preview&name="+jQuery('input#name').val()+"&email="+jQuery('input#email').val()+"&meinung="+jQuery('textarea').val()+"&path="+location.pathname,
       success: function(response){
         
        jQuery(response)    
        .fadeOut(1000, function() {
          jQuery('#kommentarPreview').animate({opacity: 1.0}, 200).remove();
        })
        .insertBefore('#markerInsert')
        .animate({opacity: 1.0}, 50)
        .fadeIn(1000);
        /* 
         jQuery('#kommentarPreview').slideUp('slow', function () {
           jQuery('#kommentarPreview').remove();
         });
         jQuery('#blockExtraContent .kommentar:last').after(response);
         if(jQuery('#kommentarPreview').is(':hidden')){            
    		   jQuery('#kommentarPreview').addClass('kommentar');
    		   jQuery('#kommentarPreview').slideDown('slow');
         }*/
       }
     });
     
	});
	
	jQuery("textarea#meinung").focus(function() {
    if (jQuery(this).val().length == 1) {
      jQuery(this).val('');
    }
  });
  
  //Scrollt zum Seitenbeginng
  jQuery('a.top').click(function(){
		jQuery.scrollTo( 0, 3000);//reset the screen to (0,0)

		return false;
	});
	
	
  //Fancybox auf Bilder in group2 legen
  jQuery("a.group").fancybox({
    'hideOnContentClick': true,
    'zoomOpacity': true, 
    'zoomSpeedChange': 200,
    'zoomSpeedIn': 400, 
    'zoomSpeedOut': 400, 
    'overlayShow': false, 
    'overlayOpacity': 1
  });
  
  //Bilderstrecke starten
  jQuery("a#slideshow").css('cursor', 'pointer');
  jQuery("a#slideshow").click(function() {
    jQuery("a.group:first").click();
  });
  
  //Tickertext einblenden
  window.setTimeout("jQuery('#tickerInline marquee').css('visibility', 'visible')", 2000);
  window.setTimeout("jQuery('#tickerPage marquee').css('visibility', 'visible')", 2000);
  window.setTimeout("jQuery('#tickerContent marquee').css('visibility', 'visible')", 2000);
});

