///////////////////////////////
// Mootools Javascript Functions
// Changes and Updates for Maccon
// Author Torsten Schäfer Handspiel GmbH
///////////////////////////////

var myMorphStatus = false;
/**
 * 
 */
function replaceNewsLinkLang() {
  var currentURL = window.location.href;
  //alert(currentURL);
    if(currentURL.indexOf('de.html') != -1) {
      $$('.news-latest-morelink a').each(function(el) {
        el.setProperty('href','de'+el.getProperty('href'));
      });
    }
    if(currentURL.indexOf('/de/') != -1) {
      $$('.news-latest-morelink a').each(function(el) {
        el.setProperty('href','de'+el.getProperty('href'));
      });
    }

    if(currentURL.indexOf('en.html') != -1) {
      $$('.news-latest-morelink a').each(function(el) {
        el.setProperty('href','en'+el.getProperty('href'));
      });
    }
    if(currentURL.indexOf('/en/') != -1) {
      $$('.news-latest-morelink a').each(function(el) {
        el.setProperty('href','en'+el.getProperty('href'));
      });
    }
}

function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            if (oldonload) {
                oldonload();
            }
            func();
        }
    }
}

function getCookie(name) {
   i=0;
   suche = name + "=";
   while (i<document.cookie.length) {
      if (document.cookie.substring(i, i + suche.length) == suche) {
         var ende = document.cookie.indexOf(";", i + suche.length);
         if(ende == -1) {
         ende = document.cookie.length;
         }
         var cook = document.cookie.substring(i + suche.length, ende);
         return unescape(cook);
      }
      i++;
   }

   return "";
}

// call some stuff at domeready

window.addEvent('domready',function(){ 
  replaceNewsLinkLang();
  
  
  // call slide domready , dont know what
  /*

  var mySlide1 = new Fx.Morph('address', {
    duration: 'long',
    transition: Fx.Transitions.Sine.easeOut
  });
  $$('.contact').addEvent('click', function(event){
    event.stop();
    //for IE6 style.bottom have to be 0px 
    document.getElementById('footer').style.bottom = '0px';
    if(myMorphStatus === false){
      myMorphStatus = true;
      
      mySlide1.start({
        'height' : 80
      });
    } else{
      myMorphStatus = false;
      
      mySlide1.start({
        'height' : 0
      });
    }

  });*/
  
  /*
  var mySlide2 = new Fx.Slide('cform');
  mySlide2.hide();
  $('cform_toggler').addEvent('click', function(e){
    e = new Event(e);
    //$('address_toggler').setStyle('height', '');
    mySlide2.show();
    mySlide1.slideIn();
    e.stop();
  });
  */
});

