/*
   Author: Frodo Larik <frodo@medid.nl>
*/
var Prepaid = Class.create()

Prepaid.prototype = {
	
	initialize: function() {
		// this.email_match = new RegExp("^[A-Za-z0-9\.\-_]+@[A-Za-z0-9\.\-_]+\.[A-Za-z]+$") 
		this.email_match = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/
	},
	
	check_lost_password: function() {
   	if ( ( $F('user_email') == '' ) || !$F('user_email').match(this.email_match) ) {
      	new Effect.Highlight('user_email',{duration: 4, startcolor: '#b80000', endcolor: '#FCF6EF'})
      	$('email_error').innerHTML = "Email adres is onjuist"
      	return false
      } 
      return true
	},
	
	confirm_newpass: function() {
	   if ( confirm("Weet u zeker dat u een nieuw wachtwoord toegestuurd wilt krijgen?") ) {
	      return true
	   }
	   return false
	},
	
	highlight: function(domid) {
	   new Effect.Highlight(domid,{duration: 2})
	   return true
	},
	
	popup: function(url,window_name,options) {
	   window.open(url,window_name,options);
	},
	
	confirm: function(txt) {
	   if ( confirm(txt) ) {
	      return true
	   }
	   return false
	},
	
	setns: function(nr) {
      var nsinfo = $F('nselect'+nr).split(',')
      $('ns'+nr).value = nsinfo[0]
      $('ns'+nr+'ip').value = nsinfo[1]
      $('opt2').checked = true;
	},
	
	popup: function( url, name, width, height, scrollbars, resizable ) { 

   	if ( scrollbars == null ) scrollbars = "0" 
   	if ( resizable == null )  resizable = "0"
 
   	str  = ""; 
   	str += "resizable=" + resizable + ","; 
   	str += "scrollbars=" + scrollbars + ","; 
   	str += "width=" + width + ","; 
   	str += "height=" + height + ","; 
 
   	if ( window.screen ) { 
   		var ah = screen.availHeight - 30; 
   		var aw = screen.availWidth - 10; 
 
   		var xc = ( aw - width ) / 2; 
   		var yc = ( ah - height ) / 2; 
 
   		str += ",left=" + xc + ",screenX=" + xc; 
   		str += ",top=" + yc + ",screenY=" + yc; 
   	} 
   	var popup = window.open( url, name, str ); 
   	popup.focus();
   	return popup
   }

}

function initPrepaid() { prepaid = new Prepaid(); }
Event.observe(window, 'load', initPrepaid, false);

