window.addEvent('domready', function() {
var accordion = new Accordion('h2.atStart', 'div.atStart', {
	opacity: false,
	onActive: function(toggler, element){
		toggler.setStyle('color', '#F77503');
		toggler.setStyle('background', 'url(images/bg_accordion_closed.jpg)');
	},
	
	onBackground: function(toggler, element){
		toggler.setStyle('color', '#ffffff');
		toggler.setStyle('background', 'url(images/bg_accordion_open.jpg)');
	}
}, $('accordion'));

function validate(){
				if ($('name').value.trim() == "") {
					alert("Please enter your name");
					$('name').focus();
					return false;
				}else if($('email').value.trim() == "") {
					alert("Please enter your Email");
					$('email').focus();
					return false;
				}else if($('email').value.indexOf('@') == -1 ) {
					alert("Please enter a valid Email");
					$('email').focus();
					return false;
				}else if($('checker').value.trim() != "4") {
					alert("The answer is 4");
					$('checker').focus();
					return false;
				}else if($('message').value.trim() == "") {
					alert("Please enter your message");
					$('message').focus();
					return false;
				}return true				
}

if($('contact_form'))
{
  var mysubmit = function() {
    var that = $('contact_form');
    that.addClass('loading').send({
			update: that,
			onComplete: function() { that.removeClass('loading') }
		});
	};
  
  $('contact_form').addEvent('submit', function(e){  
    new Event(e).stop();
    if(validate())
    mysubmit();
  });
}


var moopop = {
  width: 0,
  height: 0,

  captureByRel: function(attrVal, parent) {
    this.capture($ES('a', parent || document).filterByAttribute('rel', '*=', attrVal));
  },
  
  capture: function(el, width, height) {
    if ($defined(width) && $defined(height)) {
      this.width = width;
      this.height = height;
    }
    
    switch ($type(el)) {
      case 'element':
        this.add_pop_to(el);
        break;
      case 'string':
      case 'array':
        $$(el).each( function(el) {
          this.add_pop_to(el);
        }, this);
        break;
    }
    
    this.width = null; 
    this.height = null;
  },
  
  add_pop_to: function(el) {
    el.addEvent('click', function(e){ new Event(e).stop(); this.popup(el); }.bind(this));
    
    var size = el.getAttribute('rel').match(/\[(\d+),\s*(\d+)\]/) || ['', this.width, this.height];
    
    if (size[1]) el.setAttribute('popupprops', 'width=' + size[1] + ', height=' + size[2] );
  },
  

  popup: function(el) {
    window.open(el.href, '', el.getAttribute('popupprops') || '');
  }
};

/*
  process all links with rel="popup" by default.
*/
window.addEvent('domready', function () {
  moopop.captureByRel('popup');
});





});
