// Prevent users from right clicking
function stop_click(){
  if(event.button == 2){
    return false;
  }
}

if(document.all && !document.getElementById){
  document.onmousedown = stop_click;
}

//document.oncontextmenu = new Function("return false");

/* Instructional text in subscribe field */
var subscribe_text = 'Enter your email address';
var subscribe_field = $('mb-oykkl-oykkl');
var subscribe_button = $('subscribe-button');
if(subscribe_field != null && subscribe_button != null){
  subscribe_field.value = subscribe_text;
  subscribe_field.observe('focus', function(event){
    if(subscribe_field.value == subscribe_text){
      subscribe_field.value = '';
    }
  });
  subscribe_field.observe('blur', function(event){
    if(subscribe_field.value == ''){
      subscribe_field.value = subscribe_text;
    }
  });

  subscribe_button.observe('click', function(event){
    if(subscribe_field.value != '' && subscribe_field.value != subscribe_text){ // TODO: check for validity
      alert('Thank you for subscribing');
      Event.stop(event);
    }else{
      alert('Please enter you email address');
      Event.stop(event);
    }
  });
}


// terms popup thingy
var Popup = {
  open: function(options)
  {
    this.options = {
      url: '#',
      width: 977,
      height: 741,
      name:"_blank",
      location:"no",
      menubar:"no",
      toolbar:"no",
      status:"yes",
      scrollbars:"no",
      resizable:"no",
      left:"",
      top:"",
      normal:false
    }
    Object.extend(this.options, options || {});

    if (this.options.normal){
        this.options.menubar = "yes";
        this.options.status = "yes";
        this.options.toolbar = "yes";
        this.options.location = "yes";
    }

    this.options.width = this.options.width < screen.availWidth?this.options.width:screen.availWidth;
    this.options.height=this.options.height < screen.availHeight?this.options.height:screen.availHeight;
    var openoptions = 'width='+this.options.width+',height='+this.options.height+',location='+this.options.location+',menubar='+this.options.menubar+',toolbar='+this.options.toolbar+',scrollbars='+this.options.scrollbars+',resizable='+this.options.resizable+',status='+this.options.status
    if (this.options.top!="")openoptions+=",top="+this.options.top;
    else openoptions+=",top="+parseInt((parseInt(screen.height)/2) - (parseInt(this.options.height)/2));
    if (this.options.left!="")openoptions+=",left="+this.options.left;
    else openoptions+=",left="+parseInt((parseInt(screen.width)/2) - (parseInt(this.options.width)/2));
    window.open(this.options.url, this.options.name,openoptions );
    return false;
  }
}