//
// jQuery FIle for Maccon to Aniamte Stuff
//

jQuery.noConflict();
var contactStatus = false;
jQuery(document).ready(function($){
  
  $('.contact').click(function(event){
    event.preventDefault();
    $('#address').stop().animate({
      'height' : (contactStatus == false ? 80 : 0)
    },600,function(){
      if (parseInt($(this).height()) == 80) {
        contactStatus = true;
      }else{
        contactStatus = false;
      }
    });
  });
  // hide news id given text, if there is one
  $('.fce-two-cols-left-top div.csc-default').each(function(){
    var myText = $(this).text();
    if (myText.match(/Keine news_id/i) || myText.match(/No news_id given/i)) {
      $(this).hide();
    }
  });
  
  
  // rewrite all links from FCE
  var cur_uri = location.pathname;
  if(location.pathname.match(/\/en\//))
  {
	// go trough content and rewrite links
	jQuery('#content a, a.internal-link').each(function(){
		var cur_a = jQuery(this);
		if(typeof jQuery(cur_a).attr('href') != "undefined" && jQuery(cur_a).attr('href').match(/id=[\d]{1,3}/))
		{
			// rewrite matching elements
			jQuery(cur_a).attr('href', jQuery(cur_a).attr('href').replace(/(id=[\d]{1,3})/,"$1" + '&L=1'));
		}
	});
  }
});

