<!--

//	Added by Ashish for PlanWell 3.5 Help start

var win;
var screenwidthsize, screenheightsize;
screenwidthsize = screen.width;
screenheightsize = screen.height;

//alert(screenwidthsize);
//alert(screenheightsize);

function OpenHelpWindow(url)
{
	if(win)	// Already open then Make help come on top..
	{
		if (!win.closed)
			win.focus();
		else
			win=null;
	}
	if (!win)
	{
		win = window.open(url,"help","toolbar=no,scrollbars=yes,resizable=yes,width=360,height=500",AlwaysOnTop=true);
		win.opener = self;
	}
}
	
function closehelpwindow()
{
	if(win)
	{
	win.close();
	}
}	

//	Added by Ashish for PlanWell 3.5 Help end

function StripString(strValue, wantedlen)
{
	if (wantedlen > 0)
		return (strValue.substr(1, wantedlen));
	else
		return strValue;
}

function checknumber(el)
{
	if (isNaN(el.value))
	{
		alert("Please enter a numeric value");
		el.value="";
		el.focus();
		return false;
		
	}
	else if (el.value<0) {
		alert("Please enter a positive number");
		el.value="";
		el.focus();
		return false;
	}
}


//	Added by Ashish for PlanWell 3.0 Design

agent = navigator.userAgent;
var version = navigator.appVersion;
browserVersion = 2;
function lite(imageName,hilite) {
   if (browserVersion == 1) {
      imageShow = eval(hilite + ".src");
      document [imageName].src = imageShow;
   }
}

function norm(imageName,normal) {
   if (browserVersion == 1) {
      imageShow = eval(normal + ".src");
      document [imageName].src = imageShow;
   }
}

if ((agent.indexOf("a/3",6) == -1) && (agent.indexOf("a/4",6) == -1)) {browserVersion = 2}
   else {browserVersion = 1}
if (browserVersion == 1) {     
}
//-->



<!--	ADDED BY ASHISH FOR PLANWELL 4.0 CASCADING MENU ITEMS	-->

//Added by Himadri
/**
 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month_m=parseInt(strMonth)
	day_d=parseInt(strDay)
	year_y=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month_m<1 || month_m>12){
		alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day_d<1 || day_d>31 || (month_m==2 && day>daysInFebruary(year_y)) || day_d > daysInMonth[month_m]){
		alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year_y==0 || year_y<minYear || year_y>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
return true
}

function ValidateForm(){
	var dt=document.frmSample.txtDate
	if (isDate(dt.value)==false){
		dt.focus()
		return false
	}
    return true
 }
 
function URLEncoding(strSource)
{
	strSource = strSource.replace("%", "%25");
	strSource = strSource.replace("{", "%7B");
	strSource = strSource.replace("}", "%7D");
	strSource = strSource.replace("^", "%5E");
	strSource = strSource.replace("~", "%7E");
	strSource = strSource.replace("[", "%5B");
	strSource = strSource.replace("]", "%5D");
	strSource = strSource.replace("`", "%60");
	strSource = strSource.replace(";", "%3B");
	strSource = strSource.replace("@", "%40");
	strSource = strSource.replace("=", "%3D");
	strSource = strSource.replace("&", "%26");
	strSource = strSource.replace("$", "%24");
	strSource = strSource.replace(" ", "%20");
	strSource = strSource.replace("#", "%23");
	
return strSource;
}

// validating Textarea maxlength
function imposeMaxLength(Object, MaxLen)
{
	var elementName;
	if (Object.name == "AddlInfo")
		elementName = "Additional Instructions";
	else	
		elementName = "";
	
	if (Object.value.length <= MaxLen)
		return false;
	else	
	{
		alert ("Please note that you have exceeded the maximum allowed character limit of " + MaxLen + " for " + elementName + ".\nYou have currently entered " + Object.value.length + " characters.\n\nPlease rephrase or delete some text so that it is under " + MaxLen + " characters for the description.");
		Object.focus();	
		Object.select();
		return true;
	}
}