

function openWindow(url, winname, width, height, fld)
{
	window.open(url,winname,"resizable=yes,status=no,scrollbars=no,width=" + width + ",height=" + height + ",left=" + ((window.screen.availWidth- width)/2 ) + ",top="+((window.screen.availHeight - height)/2));
}  


function openDialog(url,param,width,height)
{
	return window.showModalDialog(url,param,"dialogHeight: " + height +"px; dialogWidth:" + width + "px;  center: Yes; help:no; resizable: no; status: no;");
}




function alphaFirst(str)
{
    var re = new RegExp("([A-Za-z].*)");
    return (re.exec(str)!=null && RegExp.$1==str);
}

function trim(str)
{
	if( str == null) return null;
    return str.replace(/^\s+/,"").replace(/\s+$/,"");
}

function rTrim( str )
{
	if ( str == null) return str;
	var temp = str;
	for( ;temp.lastIndexOf(' ') == temp.length - 1 && temp.length > 0 ; )
	{
		temp = temp.substring(0,temp.length -1);
	}
	return temp;
}

function lTrim( str )
{
	if( str == null) return str;
	
	var temp = str;
	for( ;temp.indexOf(' ') == 0 && temp.length > 0; )
	{
		temp = temp.substring(1);
	}
	return temp;
}

function isEmpty( str )
{
	if( trim(str) == '' ) return true;
	else return false;
}

function onlyDigitsAndChars(str)
{
    var re = new RegExp("([A-Za-z0-9]+)");
    return (re.exec(str)!=null && RegExp.$1==str);
}

function onlyDigits(str)
{
    var re = new RegExp("([0-9]+)");
    return (re.exec(str)!=null && RegExp.$1==str);
}

function onlyFloatDigits(str)
{
	var re = new RegExp("([0-9.-]+)");
    return (re.exec(str)!=null && RegExp.$1==str);
}

function isInteger( str )
{
	return onlyDigits(trim(str));
}

function isFloat(str)
{
	return onlyFloatDigits(trim(str));
}

function isEmailAddress( mailStr)
{
	var temp = trim( mailStr);
	if( temp.indexOf('@') == -1 || temp.indexOf('.') == -1) return false;
	else return true;
}


function isDate(strDate,delimiter)
	{
		var d = new Date();
		var yy,mm,dd;
	
		strDates = strDate.split(delimiter);
		if( strDates.length != 3)
		{
			return false;
		}else
		{
			yy=strDates[0];
			mm=strDates[1];
			dd=strDates[2];	
		}
		
		if (isNaN(yy) || isNaN(mm) || isNaN(dd))
		{
			return false;
		} 
		var intyy=parseInt(eval(yy));
		var intmm=parseInt(eval(mm));
		var intdd=parseInt(eval(dd));
		var addyear
		
		if( intyy<1900 || intyy > d.getYear()+100 )
		{
			return false;
		}
		
		if( intmm<1 || intmm >12 )
		{
				return false;
		}
		
		if(  intmm !=2 )
		{
			if( intmm  ==1 || intmm ==3 || intmm ==5 || intmm ==7 || intmm==8 || intmm==10 || intmm== 12)
			{
				if( intdd< 1 || intdd>31 )
				 {
					return false;
				 }
			}else
			{
				if( intdd<1 || intdd>30)
				{
					return false;
				}
			}
			
		}else
		{
			if( !(intyy%4 != 0 ||  (intyy%100==0 && intyy%400 == 0)))
			{
				if (intdd<1 || intdd>28 )
				{
					return false;
				}
			}else
			{
				if(intdd<1 || intdd>29)
				{
					return false;
				}
			} 	
		}
		return true;
	}



function filter(str,before,after)
{

	var tmp = new String("");
	
	if( str.indexOf(before) != -1)
	{
		idx = str.indexOf(before);
		tmp += str.substring(0,idx) + after +  filter(str.substring(idx+before.length,str.length),before,after);
		
		return tmp;
	}else
	{
		return str;
	}
	
}
