window.addEvent('domready', function() {
	initSocialBookmarks();
	  
  if(!Cookie.read('prf_disclaimer') && !$('nodisclaimer')) {
    new Element('div', {id: 'dim'}).inject(document.body);
    var d = new Element('div', {id: 'disclaimer'}).inject(document.body);
    
    var h2 = new Element('h3', {html: 'Olet siirtymässä Pernod Ricard Finland Oy:n verkkosivuille. Käyttäessäsi sivustoa yksityisasiakkaana emme voi näyttää sivuillamme yli 22 % alkoholia sisältäviä tuotteita. Kielto koskee kaikkia alkoholialalla Suomessa toimivia yrityksiä. Siirtymällä sivustolle vakuutat olevasi yli 18-vuotias.'}).inject(d);
    new Element('p', {text: 'Ole hyvä ja anna syntymäaikasi'}).inject(d);
    
    var sd = new Element('select', {styles: {width: 65}}).inject(d);
    var sm = new Element('select', {styles: {width: 65}}).inject(d);
    var sy = new Element('select', {styles: {width: 105}}).inject(d);
    
	new Element('option', {value: '', text: ''}).inject(sd);
	new Element('option', {value: '', text: ''}).inject(sm);
	new Element('option', {value: '', text: ''}).inject(sy);
	
    for(i = 1; i <= 31; i++) {
      new Element('option', {value: i, text: i}).inject(sd);
    }
    for(i = 1; i <= 12; i++) {
      new Element('option', {value: i, text: i}).inject(sm);
    }
    for(i = new Date().getFullYear(); i >= 1900; i--) {
      new Element('option', {value: i, text: i}).inject(sy);
    }
        
    new Element('a', {'class': 'stylish', text: 'Jatka'}).inject(d).addEvent('click', function() {
      var date = new Date();
      var allow = false;
      
      if(sy.get('value').toInt() < date.getFullYear() - 18) {
        allow = true;
      }
      else if(sy.get('value').toInt() == date.getFullYear() - 18) {
        if(sm.get('value').toInt() < date.getMonth()+1) {
          allow = true;
        }
        else if(sm.get('value').toInt() == date.getMonth()+1 && sd.get('value').toInt() <= date.getDate()) {
          allow = true;
        }
      }
      
      if(allow == true) {
        $$('#dim, #disclaimer').destroy();
        Cookie.write('prf_disclaimer', 'true', {path: '/', duration: 9999});
      }
      else {
        window.location = "http://www.wineinmoderation.eu/"
      }
    });

  }
});


