// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
// our application.js for effects


Event.observe(window, 'load', function() {
	/* highlight flashes automatically */
  $A(document.getElementsByClassName('flash')).each(function(o) {
   	new Effect.Highlight(o, {startcolor:'#bfe4b2', duration: 3});
		new Effect.Opacity(o, {duration:4, from:1.0, to:0}); 
  });  
  
  
  function respondToClick(event) {
    var element = event.element(); 
    var payment = "";     
    if(this.id=="cc_payment"){
      payment = "CC";   
      
    }else if(this.id == "proforma_payment"){
      payment = 'Pro Forma';  
    }   
    var tokens = window.location.href.split("/")
    
    new Ajax.Request('/account/track',{
      asynchronous:true, method:'post',parameters:{payment:payment, license_type:tokens[tokens.length-1]}}   
    );
    return false;
  }
   
  if($$("#cc_payment").size() > 0){
    $$("#cc_payment")[0].observe('click', respondToClick);   
  }  
  if($$("#proforma_payment").size() > 0){
    $$("#proforma_payment")[0].observe('click', respondToClick); 
  }
});

function before_submit(form){
	if($F('agree_terms')!='yes'){
		alert('You must agree to the terms and conditions');
		return false;
	}
  // fix_username();
}

function resets_all(){
	$$(".user_checkbox").each( function(box){
		box.checked = !box.checked;
	});
}

validate_password = function() {
    if($F('new_password') != $F('confirm_password')) {
      alert('Password does not match!!');
      return false;
    }
}

function hide_trial(object){
    $$('tr.trial').each( function(row) {
      if (object.checked){
          row.hide();
      }
      else {
          row.show();
      }
    });
    return false;
}


