Event.observe(window, 'load', function() {
  var newsletter_email = $('newsletter_email');
  if (newsletter_email) {
    newsletter_email.orginal_value = newsletter_email.value;
    Event.observe(newsletter_email, 'focus', function() {
      if (this.value == this.orginal_value ) {
        this.value = '';
      }
    });
    Event.observe(newsletter_email, 'blur', function() {
      if (this.value == '') {
        this.value = this.orginal_value;
      }
    });
  }
});

var Popup = {
  open: function(options) {
    this.options = {
      url: '#',
      width: 600,
      height: 500,
      name:"_blank",
      location:"no",
      menubar:"no",
      toolbar:"no",
      status:"yes",
      scrollbars:"yes",
      resizable:"yes",
      left:"",
      top:"",
      right:"",
      bottom:"",
      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";
    }
    
    if (this.options.right != "") this.options.left = screen.availWidth - this.options.width - this.options.right;
    if (this.options.bottom != "") this.options.top = screen.availHeight - this.options.height - this.options.bottom;

    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;
    if (this.options.left!="")openoptions+=",left="+this.options.left;
    
    window.popup = window.open(this.options.url, this.options.name,openoptions);
    window.popup.opener = window;
  
    return false;
  }
}

function validate(form){
	errors = new Array("There were errors while submitting your information:\n");
	Form.getElements($(form)).each(function(element){
			if((element.type == "text" || element.type == "textarea" && element.name != "mailing_address") && element.value == ""){
				errors.push("- " + element.name.replace(/_/g," ").capitalize() + " can't be left blank.\n");
			}
		}
	);
	if(errors.length > 1){
		var errors = errors.join("\n");
		alert(errors);
		return false;
	} else {
		return;		
	}
}