// ----------------------------------------------------------------------------------------------
// COPYRIGHT 2003-2009 CALENDARWIZ, LLC. ALL RIGHTS RESERVED.
// PURPOSE: JavaScript functions for CalendarWiz Website
// ----------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------
// Function to  
// ----------------------------------------------------------------------------------------------
function submitForm(theform) {
  
  var status = AjaxRequest.submit(
  theform
  ,{
    'onSuccess':function(req){ eval(req.responseText); }
  }
  );
}

// ----------------------------------------------------------------------------------------------
// Function to  
// ----------------------------------------------------------------------------------------------
function ajax_check_calname(calname) {

	// Trim calendar name
	calname = calname.trim();
    
    // Construct Ajax URL
    strURL = encodeURI('trial.php?chkcalname=' + calname);
        
  	AjaxRequest.get(
  	{
  		'url':strURL
      	,'onSuccess':function(req){ eval(req.responseText); }
    	}
  	);
}

// ----------------------------------------------------------------------------------------------
// Function to  
// ----------------------------------------------------------------------------------------------
function setScreenName()
{
	if (document.getElementById('login').value != '') { return; }
	var firstname = document.getElementById('admin_firstname').value;
	document.getElementById('login').value = firstname.toLowerCase();
}

// ----------------------------------------------------------------------------------------------
// Give all strigs a trim methods  
// ----------------------------------------------------------------------------------------------

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}
