    
//-------------------------------------------------------------------
// Trim functions
//   Returns string with whitespace trimmed
//-------------------------------------------------------------------
function LTrim(str){
	if (str==null){return null;}
	for(var i=0;str.charAt(i)==" ";i++);
	return str.substring(i,str.length);
	}
function RTrim(str){
	if (str==null){return null;}
	for(var i=str.length-1;str.charAt(i)==" ";i--);
	return str.substring(0,i+1);
	}
function Trim(str){return LTrim(RTrim(str));}
function LTrimAll(str) {
	if (str==null){return str;}
	for (var i=0; str.charAt(i)==" " || str.charAt(i)=="\n" || str.charAt(i)=="\t"; i++);
	return str.substring(i,str.length);
	}
function RTrimAll(str) {
	if (str==null){return str;}
	for (var i=str.length-1; str.charAt(i)==" " || str.charAt(i)=="\n" || str.charAt(i)=="\t"; i--);
	return str.substring(0,i+1);
	}
function TrimAll(str) {
	return LTrimAll(RTrimAll(str));
	}
//-------------------------------------------------------------------
// isNull(value)
//   Returns true if value is null
//-------------------------------------------------------------------
function isNull(val){return(val==null);}

//-------------------------------------------------------------------
// isBlank(value)
//   Returns true if value only contains spaces
//-------------------------------------------------------------------
function isBlank(val){
	if(val==null){return true;}
	for(var i=0;i<val.length;i++) {
		if ((val.charAt(i)!=' ')&&(val.charAt(i)!="\t")&&(val.charAt(i)!="\n")&&(val.charAt(i)!="\r")){return false;}
		}
	return true;
	}
	
function isDate(mystring)
{ 
var mystring, myresult ;
var mystring = new Date(mystring);
isNaN(mystring)? myresult=false : myresult=true ;
return myresult ;
}


function confirmBox(confirm_question, confirm_url) {
	if (confirm(confirm_question)) {
		document.location = confirm_url;
	}
}

function switchView(id){
	var u;
	if (document.getElementById) {
	u = document.getElementById(id);
	if(u){u.style.display=(u.style.display=='none'||u.style.display=='')?'block':'none';}	
	}
}

function openWin(url, targ, feat)
{
	var oWin = window.open(url, targ, feat);
	oWin.focus();
}

function popUpWindow(URL, width, height) {
    window.open(URL, 'PopupWin', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width='+width+',height='+height+',left = 440,top = 150');
}
function popUpWindowScroll(URL, width, height, scroll) {
    window.open(URL, 'PopupWin', 'toolbar=0,scrollbars='+scroll+',location=0,statusbar=0,menubar=0,resizable=0,width='+width+',height='+height+',left = 440,top = 150');
}

function closeWinReload()
{
	opener.window.location.reload();
	//window.opener.reload();
	window.close();
}

function closeWin()
{
	window.close();
}

function cancel()
{
	window.returnValue = "";
	window.close();
}

function Left(str, n)
{
	if (n <= 0)
		return "";
	else if (n > String(str).length)
		return str;
	else
		return String(str).substring(0,n);
}

function custom_random() {
        var order_value = 2;
        while ( (order_value < 1) || (order_value > num_strings) || (isNaN(order_value)) ) {
                order_value = parseInt(Math.random() * (num_strings + 1));
        }
        return order_value;
}


