function AllTrim(){
	if(CheckEmpty(document.form.crm_user_dn)){
		return;
	}
	document.form.crm_user_dn.value = Trim(document.form.crm_user_dn.value);
}
function CheckEmpty(CONTROL){
	if(Trim(CONTROL.value)==""){
		CONTROL.value="";
		CONTROL.focus();
		return true;
	}
	else{
		return false;
	}
}
function Trim(TRIM_VALUE){
	if(TRIM_VALUE.length < 1){
		return "";
	}
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE==""){
		return "";
	}
	else{
		return TRIM_VALUE;
	}
} 

function RTrim(VALUE){
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if(v_length < 0){
		return"";
	}
	var iTemp = v_length -1;

	while(iTemp > -1){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else{
			strTemp = VALUE.substring(0,iTemp +1);
			break;
		}
	iTemp = iTemp-1;
	} 
	return strTemp;
} 
function LTrim(VALUE){
	var w_space = String.fromCharCode(32);
	if(v_length < 1){
		return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";

	var iTemp = 0;

	while(iTemp < v_length){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else{
			strTemp = VALUE.substring(iTemp,v_length);
			break;
		}
		iTemp = iTemp + 1;
	} //End While
	return strTemp;
} //End Function

/* Gets the user's local time */
function getLocalTime() 
   {
	var currentDate = new Date();
	var year = currentDate.getFullYear();
	var month = currentDate.getMonth() + 1; /* Jan = 0, Feb = 1 */
	var day = currentDate.getDate();
	var hour = currentDate.getHours();
	var minutes = currentDate.getMinutes();
	var seconds = currentDate.getSeconds();
	
	/* Pad month with a 0 if it is less than 10 */
	if(month < 10) {
		month = '0' + month;
	}
	
	/* Pad month with a 0 if it is less than 10 */
	if(day < 10) {
		day = '0' + day;
	}	

	/* Some years come back as an offset from 1900, so check and add 1900 */
	if(year < 1900) {
		year += 1900;
	}
	
	var dateTime = year + '-' + (month) + '-' + day + ' ' + hour + ':' + minutes + ':' + seconds;

	return dateTime;
   };

function MM_openBrWindow(theURL,winName,features) {
	window.open(theURL,winName,features);
}


function getCookie(NameOfCookie)
{ if (document.cookie.length > 0) 
{ begin = document.cookie.indexOf(NameOfCookie+"="); 
if (begin != -1) 
{ begin += NameOfCookie.length+1; 
end = document.cookie.indexOf(";", begin);
if (end == -1) end = document.cookie.length;
return unescape(document.cookie.substring(begin, end)); } 
}
return null; 
}

function ControlCookie(NameOfCookie, value, expiredays)
{ if (document.form.SaveUserName.checked) { var ExpireDate = new Date ();
ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
document.cookie = NameOfCookie + "=" + escape(value) + 
((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}
else { if (getCookie(NameOfCookie)) {
document.cookie = NameOfCookie + "=" +
"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
}
}

function setCookie(NameOfCookie, value, expiredays) 
{ var ExpireDate = new Date ();
ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
document.cookie = 'NOSAVEME' + "=" + escape(value) + 
((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}

function delCookie (NameOfCookie) 
{ if (getCookie(NameOfCookie)) {
document.cookie = NameOfCookie + "=" +
"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
}

function UseCookie()
{
username=getCookie('username');
if (username!=null) {document.form.crm_user_dn.value = username; document.form.user_password.focus();}
else {document.form.crm_user_dn.focus();}
}

var trialPath = "http://www.salesboom.com/crm_trial.html";
function trialLogin() 
{
	window.location.href=trialPath;
}



