/*
variable naming conventions in js file
prefix js_ with each variable and functions, this indicates javascript variable and functions
prefix int with variable of integer type
prefix flt with variable of float type
prefix str with variable of string type
prefix obj with variable of object type
prefix chr with variable of character type
prefix bol with variable of bool type
prefix dat with variable of datetime
prefix arr with variable of array type
functions naming conventins in js file
prefix fn with each function
*/

//********************* Global Variables ******************************
var SetLeft,SetTop,SetWidth,SetHeight


function GetGridID(id)
{
    var GridAndTextboxID = new String()
    var GridID,StartingNo
    var TextBoxID = new String()
    var CtlIndex = new Number()
    var Char = new Number()	    
          			
    GridAndTextboxID = id
	
    CtlIndex = GridAndTextboxID.indexOf("ctl")
    //alert(CtlIndex)							
    if(GridAndTextboxID.indexOf("ctl") > 0) //i.e Control is inside the Grid
    {
	    GridID = GridAndTextboxID.substring(0,CtlIndex+3) //OUTPUT : DataGrid_ctl
	    //alert(GridID)
	    TextBoxID = GridAndTextboxID.substring(CtlIndex,GridAndTextboxID.length) //OUTPUT : ctl2_TxtDrug (if grid item starts from 2)
	    //alert(TextBoxID)			
	    Char = TextBoxID.indexOf("_")								
	    //alert(Char)
	    StartingNo = TextBoxID.substring(3,Char) //OUTPUT : 2
	   //alert(StartingNo)	
	    return GridID+StartingNo
    } 
}

function Trim(TrimString)
{	//alert(TrimString.id)
	var tempObj;
	if(TrimString){tempObj = TrimString;TrimString = tempObj.value;}
	if(TrimString == "undefined" || TrimString == null) return null;
	if(TrimString.length == 0)TrimString="";
	else
	{	var Lcont=0,TempStrArray=TrimString.split(" "),Rcont=TempStrArray.length-1;
		while(TempStrArray[Lcont] == "")Lcont++;while(TempStrArray[Rcont] == "")Rcont--;
		if(Rcont<Lcont)TrimString="";else
		for(TrimString = TempStrArray[Lcont], Lcont++ ; Lcont <= Rcont ; Lcont++) TrimString += " " + TempStrArray[Lcont];
		var re = /\'|/g;
		TrimString = TrimString.replace(re,"");
	}
	if(tempObj && TrimString != "undefined" && TrimString != null) 
	{	tempObj.value = TrimString;	return tempObj	  }
	else return TrimString;
}

function FormTrim(oForm)
{	//alert(oForm.id)
	for (i=0; i<=oForm.length-1; i++)
	{	if (oForm[i].type == "text" || oForm[i].type == "textarea")		
			Trim(oForm[i])
	}
}

function FormTrim1(oForm)
{ 
	for (i=0; i<=oForm.length-1; i++)
	{	if (oForm[i].type == "text" || oForm[i].type == "textarea" || oForm[i].type == "Password")		
			Trim(oForm[i])
	}
}

function Trim1(TrimString)
{	var tempObj;
	if(TrimString){tempObj = TrimString;TrimString = tempObj.value;}
	if(TrimString == "undefined" || TrimString == null) return null;
	if(TrimString.length == 0)TrimString="";
	else
	{	var Lcont=0,TempStrArray=TrimString.split(" "),Rcont=TempStrArray.length-1;
		while(TempStrArray[Lcont] == "")Lcont++;while(TempStrArray[Rcont] == "")Rcont--;
		if(Rcont<Lcont)TrimString="";else
		for(TrimString = TempStrArray[Lcont], Lcont++ ; Lcont <= Rcont ; Lcont++) TrimString += " " + TempStrArray[Lcont];
		var re = /\'|/g;
		TrimString = TrimString.replace(re,"");
	}
	if(tempObj && TrimString != "undefined" && TrimString != null) 
	{	tempObj.value = TrimString;	return tempObj	  }
	else return TrimString;
}

var gblwin = new String()
var gblMsg = new String()
var gblStatusTable = new String()
function FnRemoveSingelQuation(obj)
{	var re=/\'|/g;
	obj.value=obj.value.replace(re,'')
}
function FnPrintErrMsg(strErrText)
{document.getElementById("lblErrMessage").innerHTML = strErrText;
document.getElementById("lblErrMessage").style.color = 'Red'}
function FnClearErrMessgae()
{document.getElementById("lblErrMessage").innerHTML = "";}
function FnSetFocusToTextBox(strTxtID)
{document.getElementById(strTxtID).focus();}

function isLocal()
{	var surl = new String() 
	surl = document.location.host 
	return (surl == "172.100.2.1")
}
function FnRemoveSpecial(F)
{
	for (var i = 0; i < F.elements.length; i++)
		if (F.elements[i].type == "text" || F.elements[i].type == "textarea")
		{
			re = /\'|\\|\/|\<|\*|\>|/g;
			//re = /\'|\\|\/|\<|\,|\*|\>|/g;
    		document.forms(0).elements(F.elements[i].id).value = document.forms(0).elements(F.elements[i].id).value.replace(re, "");
    	}
}

function FnRemoveSpecialMinus(F)
{
	for (var i = 0; i < F.elements.length; i++)
		if (F.elements[i].type == "text" || F.elements[i].type == "textarea")
		{
			re = /\'|\\|\/|\<|\,|\*|\-|\>|/g;
    		document.forms(0).elements(F.elements[i].id).value = document.forms(0).elements(F.elements[i].id).value.replace(re, "");
    	}
}

function filterOther(str) 
	{
		var val = str
		re = /\'|\\|\/|\<|\>|/g;
		var tmp = val.replace(re, "")
		return tmp
	}

function TrimTextAreaText(elementName)
{
    var stripMe = eval(document.getElementById(elementName));
    
    var stripped =stripMe.value.split('\r\n').join(' ');    
    stripMe.value = stripped;    
}
function TrimTextAreaTextInsideGrid(elementName)
{
    var stripMe = eval(document.getElementById(elementName));
  
    var stripped =stripMe.value.split('\r\n').join(' '); 
     
    
    return stripped;    
}
function isInteger(s)
{
	var i;
	for(i=0;i<s.length;i++)
	{
		var c=s.charAt(i);
		if(((c<"0")||(c>"9")))
		return false
	}
	return true
}
function fnCheckNumericInTxtBox(varTxtBoxID)
{
	var txtElement;
	txtElement=document.getElementById(varTxtBoxID);
	if(isInteger(txtElement.value)==false)
	{
		txtElement.value="";
		txtElement=null;
		return false;
	}
}	
function AllowNumberOnly(Decimal)
{	e = window.event;
	if (e)if(Decimal == "AloDOT"){	if((e.keyCode < 48 || e.keyCode > 57) && e.keyCode != 46)	{e.keyCode = 0;}	}
		  else {	if(e.keyCode < 48 || e.keyCode > 57 )	{e.keyCode = 0;}	}
}
function FnFilterAll(str) 
{
    re = /\$|,|#|~|`|\%|\@|\.|\*|\^|\&|\(|\)|\+|\=|\[|\-|\_|\]|\[|\}|\{|\;|\:|\'|\"|\ |\<|\>|\?|\||\\|\!|\$|/g;
    var tmp = str.replace(re, "");
	return tmp
}
function FnFilterGridval(str) 
{
    re = /\$|,|#|~|`|\%|\@|\.|\*|\^|\&|\(|\)|\+|\=|\[|\-|\_|\]|\[|\}|\{|\;|\:|\'|\"|\<|\>|\?|\||\\|\!|\$|/g;
    var tmp = str.replace(re, "");
	return tmp
}
function FnGeneralFilter(str) 
{
    re = /\$|,|#|~|`|\%|\@|\*|\^|\&|\(|\)|\+|\=|\[|\-|\_|\]|\[|\}|\{|\;|\:|\'|\"|\<|\>|\?|\||\\|\!|\$|/g;
    var tmp = str.replace(re, "");
	return tmp
}
function FnGeneralEmailFilter(str) 
{
    re = /\$|,|#|~|`|\%|\*|\^|\&|\(|\)|\+|\=|\[|\-|\]|\[|\}|\{|\;|\:|\'|\"|\<|\>|\?|\||\\|\!|\$|/g;
    var tmp = str.replace(re, "");
	return tmp
}
function Fn_ZipValidation(Cmbstate, txtZip)
{	var range = document.forms[0].elements[Cmbstate].value
	var zipcode = document.forms[0].elements[txtZip].value
	var zipval = document.forms[0].elements[txtZip].value.substring(0,3)	
	var lblerror=document.getElementById("txtZip_lblzip")
	
	
	
	var arr =new Number()
	arr = range.split("-")
	if (arr.length == 0)
	{
			lblerror.innerHTML ="Enter zip"
			return false 
	}
	if (arr.length == 1)
	{
		if (range != zipval) 
		{
			lblerror.innerHTML ="Invalid zip"
			return false 
		}	
	}
	else if (arr.length == 2)
	{
		var min = arr[0]
		var max = arr[1]
		if (zipval >= min && zipval <= max){}
		else
		{
			lblerror.innerHTML ="Invalid zip"
			return false
		}
	}
	else if (arr.length == 3)
	{
		var min = arr[0]
		var max = arr[1]
		var Equal = arr[2]
		if ((zipval >= min && zipval <= max) || (Equal == zipval)){}
		else
			{
				lblerror.innerHTML ="Invalid zip"
				return false
			}
		
	}
	
	lblerror.innerHTML =""
	return true;
}

/*
function FnCheckLessCurdate(todaydate, mont, dat, yea, lbl)
{
	
	//alert(todaydate  +'-'+  mont +'-'+ dat +'-'+ yea +'-'+ lbl)
	var mon = document.forms[0].elements[mont].value
	var day = document.forms[0].elements[dat].value
	var year = document.forms[0].elements[yea].value
	var Jslblerror = document.getElementById(lbl)
	
	//alert(mon +'-'+ day  +'-'+ year  +'-'+ Jslblerror)
	
	var splittodaydate = todaydate.split("/")
	var currentyr = splittodaydate[2]
	var currentmon = splittodaydate[0]
	var currentdd = splittodaydate[1]

	//alert(parseInt(year) +" // "+ parseInt(currentyr))
	if(parseInt(year) < parseInt(currentyr))
		{
		
			Jslblerror.innerHTML = "Date cannot be less than Current date"
			document.getElementById(yea).focus()
			return false;
		}
		else if(parseInt(year) == parseInt(currentyr))
		{
			//alert(parseInt(mon) +" // "+ parseInt(currentmon))
			if(parseInt(mon) < parseInt(currentmon))
			{
				Jslblerror.innerHTML = "Date cannot be less than Current date"
				document.getElementById(mont).focus()
				return false;
			}
			else if(parseInt(mon) == parseInt(currentmon))
			{
				//alert(parseInt(day) +" // "+ parseInt(currentdd))
				if(parseInt(day)< parseInt(currentdd))
				{
					Jslblerror.innerHTML = "Date cannot be less than Current date"
					document.getElementById(dat).focus()
					return false;
				}
			}
		}
}*/
function FnCheckLessCurdate(todaydate, mont, dat, yea, lbl)
{
	
	//alert(todaydate  +'-'+  mont +'-'+ dat +'-'+ yea +'-'+ lbl)
	var mon = document.forms[0].elements[mont].value
	var day = document.forms[0].elements[dat].value
	var year = document.forms[0].elements[yea].value
	var Jslblerror = document.getElementById(lbl)
	
	//alert(mon +'-'+ day  +'-'+ year  +'-'+ Jslblerror)
	
	var splittodaydate = todaydate.split("/")
	var currentyr = splittodaydate[2]
	var currentmon = splittodaydate[0]
	var currentdd = splittodaydate[1]

	if (document.forms[0].elements[mont].selectedIndex != 0 ||  document.forms[0].elements[dat].selectedIndex != 0 || document.forms[0].elements[yea].selectedIndex != 0)
		{
			if (document.forms[0].elements[mont].selectedIndex == 0)
			{
				Jslblerror.innerHTML ="Month cannnot be blank"
				document.getElementById(mont).focus()
				return false
			}
			if (document.forms[0].elements[dat].selectedIndex == 0)
			{
				Jslblerror.innerHTML ="Date cannnot be blank"
				document.getElementById(dat).focus()
				return false
			}
			if (document.forms[0].elements[yea].selectedIndex == 0)
			{
				Jslblerror.innerHTML ="Year cannnot be blank"
				document.getElementById(yea).focus()
				return false
			}
		}
	
	//alert(parseInt(year) +" // "+ parseInt(currentyr))
	if(parseInt(year) < parseInt(currentyr))
		{
			Jslblerror.innerHTML = "Date cannot be less than Current date"
			document.getElementById(yea).focus()
			return false;
		}
		else if(parseInt(year) == parseInt(currentyr))
		{
			//alert(parseInt(mon) +" // "+ parseInt(currentmon))
			if(parseInt(mon) < parseInt(currentmon))
			{
				Jslblerror.innerHTML = "Date cannot be less than Current date"
				document.getElementById(mont).focus()
				
				return false;
			}
			else if(parseInt(mon) == parseInt(currentmon))
			{
				//alert(parseInt(day) +" // "+ parseInt(currentdd))
				if(parseInt(day)< parseInt(currentdd))
				{
					Jslblerror.innerHTML = "Date cannot be less than Current date"
					document.getElementById(mont).focus()
					return false;
				}
			}
		}
}
function FnCheckGreaterCurdate(todaydate, mont, dat, yea, lbl)
{
	
	var iFocus = new Boolean()
	iFocus = true
	//alert(todaydate  +'-'+  mont +'-'+ dat +'-'+ yea +'-'+ lbl)
	var mon = document.forms[0].elements[mont].value
	var day = document.forms[0].elements[dat].value
	var year = document.forms[0].elements[yea].value
	var Jslblerror = document.getElementById(lbl)

//	alert(mon +'-'+ day  +'-'+ year  +'-'+ Jslblerror)

	var splittodaydate = todaydate.split("/")
	var currentyr = splittodaydate[2]
	var currentmon = splittodaydate[0]
	var currentdd = splittodaydate[1]
	//alert(splittodaydate[2] +'-'+ splittodaydate[0]  +'-'+ splittodaydate[1])
	
	if (document.forms[0].elements[mont].selectedIndex != 0 ||  document.forms[0].elements[dat].selectedIndex != 0 || document.forms[0].elements[yea].selectedIndex != 0)
	{
		if (document.forms[0].elements[mont].selectedIndex == 0)
		{
			Jslblerror.innerHTML ="Month cannnot be blank"
			document.getElementById(mont).focus()
			return false
		}
		if (document.forms[0].elements[dat].selectedIndex == 0)
		{
			Jslblerror.innerHTML ="Date cannnot be blank"
			document.getElementById(dat).focus()
			return false
		}
		if (document.forms[0].elements[yea].selectedIndex == 0)
		{
			Jslblerror.innerHTML ="Year cannnot be blank"
			document.getElementById(yea).focus()
			return false
		}
	}
	
	if(parseInt(year) > parseInt(currentyr))
		{
		
			Jslblerror.innerHTML = "Date cannot be greater than current date"
			document.getElementById(yea).focus()
			iFocus = false
		}
		else if(parseInt(year) == parseInt(currentyr))
		{
			
		//alert(parseInt(mon) +" // "+ parseInt(currentmon))
		if(parseInt(mon) > currentmon)
			{
				Jslblerror.innerHTML = "Date cannot be greater than current date"
				document.getElementById(mont).focus()
				iFocus = false
			}
			
	 else if(parseInt(mon) == parseInt(currentmon))
			{
				//alert(parseInt(day) +" // "+ parseInt(currentdd))
			if(parseInt(day)> eval(currentdd))
				{
					Jslblerror.innerHTML = "Date cannot be greater than current date"
					document.getElementById(dat).focus()
					iFocus = false
				}
			}
		}
		
		if(iFocus==false)
		return false
		 else
		 return true
}

//function to format the number for two decimal number
function js_fnFormat(strText)
{
	//parameter description
	//strText->text needs to be format
	
	var js_arrNum
	js_arrNum=strText.split(".")
	if(js_arrNum.length==1)
		js_arrNum[0]=js_arrNum[0] + "." + "00"
	else
	{
		if(js_arrNum[1].length==1)
			js_arrNum[0]=js_arrNum[0] + "." + js_arrNum[1] + "0"
		else if(js_arrNum[1].length==2)
			js_arrNum[0]=js_arrNum[0] + "." + js_arrNum[1]
	}	
	return js_arrNum[0]
}

//function used to trim the trialing and leading spaces and 
function js_fnTrim(strText)
{
	//parameter description
	//strText -> text which needs to be trim the spaces
	
	var js_intIndex,js_strLen;
	js_intIndex=0
	strText += "";
	if(strText== "undefined" || strText == null)
		return null;
	else if(strText.length == 0)
		strText = "";
	else
	{
		js_strLen= strText.length;
		//this loop will trim the left side spaces
		while ((js_intIndex <= js_strLen) && (strText.charAt(js_intIndex) == " "))
			js_intIndex++;
		strText = strText.substring(js_intIndex, js_strLen);
		if(strText.length>0)
		{
			//this loop will trim the right side spaces
			js_intIndex= strText.length - 1;
			while ((js_intIndex >= 0) && (strText.charAt(js_intIndex) == " "))
				js_intIndex--;
			strText = strText.substring(0, js_intIndex + 1);
		}
	}
	return strText
}

function js_fnUnCheck(objMainobject,objSubobject,objIdx)
	{
		//objMainobject->Main check box object name passsed it as object
		//objSubobject->name of the sub check boxes passed it as string
		//objIdx --> index of the sub check box
		//eg.,  ->  js_fnSelDesel(document.forms[0].chkAll,'chkAdd',10)
			
		
		var objSubLen=eval("document.forms[0]." +objSubobject)
		
		if(parseInt(objSubLen.length)>1)
			{
			   var objSub=eval("document.forms[0]." +objSubobject+"["+objIdx+"]")
			  if(objSub.checked==false)
				objMainobject.checked=false
			}
		else	
			{
			  var objSub=eval("document.forms[0]." +objSubobject)
			  if(objSub.checked==false)
				objMainobject.checked=false
			}
	}	

//function to select or deselect the check boxes
function js_fnSelDesel(objMainobject,objSubobject)
{
	//objMainobject->Main check box object name passsed it as object
	//objSubobject->name of the sub check boxes passed it as string 
	//eg.,  ->  js_fnSelDesel(document.forms[0].chkAll,'chkAdd')
	
	for (intIndex=0;intIndex<document.forms[0].elements.length;intIndex++)
	{
		if(document.forms[0].elements[intIndex].type=="checkbox" && document.forms[0].elements[intIndex].name==objSubobject)
			document.forms[0].elements[intIndex].checked=objMainobject.checked
	}
}

//function to trim the form objects(textboxes,textarea)
function js_fnTrimFormObjects()
{
	//This function will list all the objects in the form
	//if the objects are of type textbox and textarea then it will be trimmed
for (intIndex=0;intIndex<document.forms[0].elements.length;intIndex++)
	{
		if(document.forms[0].elements[intIndex].type=="text" || document.forms[0].elements[intIndex].type=="textarea")
			document.forms[0].elements[intIndex].value=js_fnTrim(document.forms[0].elements[intIndex].value)
	}
}

function js_fnClearFormObjects()
{
	//This function will list all the objects in the form
	//if the objects are of type textbox/textarea/select/checkbox then it will be cleared
	for (intIndex=0;intIndex<document.forms[0].elements.length;intIndex++)
		{
			if(document.forms[0].elements[intIndex].type=="text" || document.forms[0].elements[intIndex].type=="textarea")
				document.forms[0].elements[intIndex].value=""
			else if(document.forms[0].elements[intIndex].type=="select-one")
				document.forms[0].elements[intIndex].selectedIndex=0
			else if(document.forms[0].elements[intIndex].type=="checkbox")
				document.forms[0].elements[intIndex].checked=false
		}
		document.forms[0].method="post"
		document.forms[0].action=location.href
		document.forms[0].submit()
		return false;
}
//function user to validate the number
function js_fnValidateNum(objName,strMessage,intStrLen,intZeroYesNo,intNegYesNo,intDecYesNo,intManYesNo)
{
	
	if(objName.value=="" && intManYesNo==1)
		return true;
	else if(objName.value.length<intStrLen)
	{
		//alert("Please enter the "+ intStrLen+ " digit "+strMessage);
		objName.focus();
		return false;
	}
	else if(isNaN(objName.value)==true)
	{
		//alert(strMessage+"  is not a valid number");
		objName.focus();
		return false;
	}
	else if(parseFloat(objName.value)==0 && objName.value.indexOf("-")>-1)
	{
		//alert("Negative numbers not allowed");
		objName.focus();
		return false;
	}
	else if(intZeroYesNo==1 && parseFloat(objName.value)==0)
	{
		//alert(strMessage+" cannot be zero");
		objName.focus();
		return false;
	}
	else if(intDecYesNo==1 && objName.value.indexOf(".")>-1)
	{
		//alert("Decimal numbers not allowed");
		objName.focus();
		return false;
	}
	else if(intNegYesNo==1 && parseFloat(objName.value)<0)
	{
		//alert("Negative numbers not allowed");
		objName.focus();
		return false;		
	}
	else if(objName.value.indexOf("+")>-1)
	{
		//alert("+ sign is not allowed");
		objName.focus();
		return false;			
	}
	else if(objName.value.indexOf("e")>-1)
	{
		//alert("e (exponential) is not allowed");
		objName.focus();
		return false;			
	}
	return true;
}

//function to validate the decimal numbers
//before calling this function call the fnValidateNum to validate the number
function js_fnDecimalNum(objName,strMessage,intIntPart,intDelpart)
{
	var ps_arrNumb
	if(isNaN(objName.value))
	  {
		alert("Enter a valid number")
		objName.focus()
		return false;
	  }
	ps_arrNumb=objName.value.split(".")
        if(objName.value.substring(0,1)=="-" || objName.value.substring(0,1)=="+" )
		{
			alert("Negative numbers not allowed")
			objName.focus()
			return false;
		}
	
	if(ps_arrNumb[0].length>intIntPart)
		{
			if (intIntPart == "3")
				alert("Enter " + strMessage.toLowerCase() + " less than or equal to 999.99")
			else if (intIntPart == "4")	
				alert("Enter " + strMessage.toLowerCase() + " less than or equal to 9999.99")
			else 
				alert("Enter " + strMessage.toLowerCase() + " less than or equal to 99.99")	
			objName.focus()
			return false;
		}
	else if(ps_arrNumb.length>1 && ps_arrNumb[1].length>intDelpart)
	{
		alert("Enter " + strMessage.toLowerCase() + " less than or equal to 2 decimals")
		objName.focus()
		return false;
	}
	return true;
}

//function to validate the alpha numeric
function js_fnValidateString(objName,strMessage,intManYesNo,intSplYesNo,sLength,sSlash,boolCustomMessage,strCustomMessage)
{
	//parameter description
	//objName->Name of the object
	//intManYesNo-> mandatory or optional
	//if intManYesNo=0-> mandatory
	//if intManYesNo=1->optional
	//intSplYesNo->special characters allowed or not
	//if intSplYesNo=0 -> special characters allowed
	//if intSplYesNo=1 -> special characters not allowed
	//sLength -> specify length or blank

	var js_strText,js_intIndex
	js_strText=objName.value
	js_strText=js_strText + ""
	
	if (js_strText == "undefined" || js_strText+"" == "null")
		return false;
	if(intManYesNo==1 && js_strText=="")
		return true
	else if(intManYesNo==0 && js_strText=="")
	{
		if(boolCustomMessage==true)
		   alert(strCustomMessage)
		else
		   alert(strMessage + " cannot be blank")
		objName.focus();	
		return false;
	}
    else
	{
		for (js_intIndex = 0; js_intIndex < js_strText.length; js_intIndex++)
		{
			if(intSplYesNo==1)
			{
				if (!( ((js_strText.charAt(js_intIndex) >= "0") && (js_strText.charAt(js_intIndex) <= "9")) || (js_strText.charAt(js_intIndex) == "_") ||
						((js_strText.charAt(js_intIndex) >= "a") && (js_strText.charAt(js_intIndex) <= "z")) ||
						((js_strText.charAt(js_intIndex) >= "A") && (js_strText.charAt(js_intIndex) <= "Z"))
						) )
					{
						alert("Only alphanumeric characters are allowed")
						objName.focus();
						return false;
					}
			}
			else
			{
			   if(sSlash=="slash")
			      {
				if(js_strText.charAt(js_intIndex)=="'" || js_strText.charAt(js_intIndex)=="\"")
					{
						alert("Single quotes, double quotes and slash are not allowed")
						objName.focus();
						return false;
					}
			      }
			    else 
			      {
				if(js_strText.charAt(js_intIndex)=="'" || js_strText.charAt(js_intIndex)=="\"" || js_strText.charAt(js_intIndex)=="\\")
					{
						alert("Single quotes, double quotes and slash are not allowed")
						objName.focus();
						return false;
					}
			      }
			}
		}
	}
	if(sLength!="")
		{
		if(js_strText.length<parseInt(sLength))
			{
				alert("Password cannot be less than "+sLength+" characters")
				objName.focus();
				return false;
			}
		}
	 return true;
}
//function to check domain extensions
function js_fnDomainExt(myobj,obj)
{
	
	var xtnNams = ""
	var splxtn = ""
	var notVal = 1
	var idx
	var valOfobj = ""
	valOfobj = myobj.value
	valOfobj = myobj.substring(myobj.indexOf("@")+1,myobj.length)
	valOfobj = valOfobj.substring(valOfobj.indexOf(".")+1,valOfobj.length)
	
	xtnNams = xtnNams + "COM'ORG'NET'EDU'GOV'MIL'AC'AD'AE'AG'AI'AL'AM'AN'AP'AQ'"
	xtnNams = xtnNams + "AR'AS'AT'AU'AZ'BA'BB'BE'BF'BG'BH'BI'BM'BN'BO'BR'BT'BY'BZ"
	xtnNams = xtnNams + "'CA'CC'CD'CF'CG'CH'CK'CL'CM'CN'CO'CR'CU'CX'CY'CZ'DE'DJ'"
	xtnNams = xtnNams + "DK'DO'DZ'EC'EE'EG'ES'FI'FJ'FK'FM'FR'FO'GB'GE'GF'GG'GH'GI'"
	xtnNams = xtnNams + "GL'GM'GN'GR'GS'GT'GU'HK'HM'HN'HR'HU'ID'IE'IL'IM'IN'INT'IO'"
	xtnNams = xtnNams + "IR'IS'IT'JE'JO'JP'KE'KG'KH'KR'KW'KY'KZ'LB'LC'LI'LK'LR'LT'"
	xtnNams = xtnNams + "LU'LV'LY'MC'MD'MG'MH'MK'MM'MN'MO'MP'MQ'MR'MS'MT'MU'MX'MY'"
	xtnNams = xtnNams + "MW'NA'NC'NF'NI'NL'NO'NP'NU'NZ'OM'PA'PE'PG'PH'PK'QA'RE'RO'RU'"
	xtnNams = xtnNams + "RW'SA'SB'SE'SG'SH'SI'SK'SM'SN'SO'ST'SU'SV'SZ'TC'TD'TF'TH'TJ'"
	xtnNams = xtnNams + "TM'TN'TO'TP'TR'TT'TV'TW'TZ'UA'UG'UK'UM'US'UY'VE'VG'VI'VU'WF'"
	xtnNams = xtnNams + "WS'YT'YU'ZA'ZM'"

	xtnNams = xtnNams + "com'org'net'edu'gov'mil'ac'ad'ae'ag'ai'al'am'an'ap'aq'"
	xtnNams = xtnNams + "ar'as'at'au'az'ba'bb'be'bf'bg'bh'bi'bm'bn'bo'br'bt'by'bz"
	xtnNams = xtnNams + "'ca'cc'cd'cf'cg'ch'ck'cl'cm'cn'co'cr'cu'cx'cy'cz'de'dj'"
	xtnNams = xtnNams + "dk'do'dz'ec'ee'eg'es'fi'fj'fk'fm'fr'fo'gb'ge'gf'gg'gh'gi'"
	xtnNams = xtnNams + "gl'gm'gn'gr'gs'gt'gu'hk'hm'hn'hr'hu'id'ie'il'im'in'int'io'"
	xtnNams = xtnNams + "ir'is'it'je'jo'jp'ke'kg'kh'kr'kw'ky'kz'lb'lc'li'lk'lr'lt'"
	xtnNams = xtnNams + "lu'lv'ly'mc'md'mg'mh'mk'mm'mn'mo'mp'mq'mr'ms'mt'mu'mx'my'"
	xtnNams = xtnNams + "mw'na'nc'nf'ni'nl'no'np'nu'nz'om'pa'pe'pg'ph'pk'qa're'ro'ru'"
	xtnNams = xtnNams + "rw'sa'sb'se'sg'sh'si'sk'sm'sn'so'st'su'sv'sz'tc'td'tf'th'tj'"
	xtnNams = xtnNams + "tm'tn'to'tp'tr'tt'tv'tw'tz'ua'ug'uk'um'us'uy've'vg'vi'vu'wf'"
	xtnNams = xtnNams + "ws'yt'yu'za'zm'"

	splxtn = xtnNams.split("'")
	
	for(idx=0;idx<(splxtn.length)-1;idx++)
		{		
			if(splxtn[idx]==valOfobj)
				notVal = 0
		}
	
	if(notVal == 1)
	{
		alert("Enter valid domain name")
		obj.focus();
		return false;
	}
	return true;
}

//function to validate the email address
function js_fnEmail(objName,intManYesNo)
	{
		//parameter description
		//objName -> name of the object
		//if intManYesNo=0-> mandatory
		//if intManYesNo=1-> optional
		
		if(objName.value=="" && intManYesNo==1)
			return true;
			
		else if(objName.value=="" && intManYesNo==0)
			{
				//alert("Please enter an email address")
				objName.focus()
				return false;
			}
		else if(objName.value=="" && intManYesNo==3)
			{
			//	alert("Please enter the referee's Email address")
				objName.focus()
				return false;
			}
		else if(objName.value=="" && intManYesNo==2)
			{
				//alert("Please confirm the referee's Email address")
				objName.focus()
				return false;
			}
		else
		{
			var js_intIndex,js_chrText,js_bolDot,js_bolAt,js_intAtPos,js_intDotPos
			js_bolDot = "false";
			js_bolAt = "false";
			js_intAtPos=0;
			js_intDotPos=0;
			for(js_intIndex=0;js_intIndex<objName.value.length; js_intIndex++)
			{
				js_chrText=objName.value.charAt(js_intIndex)
			
				if(js_chrText==" ")
						{
							//alert("The email address should be in the standard format, e.g admin@refplanner.com")
							objName.focus()
							return false;
						}
				else if(js_chrText=="'" || js_chrText=="\"" || js_chrText=="\\")
						{
							//alert("The email address should be in the standard format, e.g admin@refplanner.com")
							objName.focus()
							return false;
						}
				else if(js_intIndex==0 && (js_chrText == "@" || js_chrText == "."))
						{
							//alert("The email address should be in the standard format, e.g admin@refplanner.com")
							objName.focus()
							return false;
						}
				else if (js_intIndex!=0 && js_chrText == "@")
						{
							js_intAtPos=js_intIndex
							js_bolAt="true"
						}
				else if (js_intIndex!=0 && js_chrText == ".")
						{
							js_intDotPos=js_intIndex
							js_bolDot="true"
						}
			}
			if(objName.value.length<5 || js_bolAt!="true" || js_bolDot!="true" || (parseFloat(js_intDotPos)-parseFloat(js_intAtPos+1))<1 || (parseFloat(objName.value.length)-parseFloat(js_intDotPos+1))<1)
			{
				///alert("The email address should be in the standard format, e.g admin@refplanner.com")
				objName.focus()
				return false;
			}
			//if(!js_fnDomainExt(objName.value,objName))
			//	return false;


			return true;
		}
	}


//function to replace space with plus sign
function js_fnReplaceSpace(strText)
{
		
	var js_intIndex=0;
	var js_charText,strText1
	strText1=""
	if(strText.length==0 || strText =="null")
		return "";
	else
	{
		for(js_intIndex=0;js_intIndex<strText.length;js_intIndex++)
		{
			js_charText = strText.substring(js_intIndex,js_intIndex+1)
			if(js_charText==" ")
				js_charText = "+"
			strText1 += js_charText
		}
		return strText1;
	}
}


//this function validates the input date against the current date and it should be less than the current date
function js_fnCompareCurrentDate1(objMonth,objDay,objYear,datCurDate,strMessage)
{
	//parameter description
	//objMonth->Object name of month
	//objDay->object name of the day
	//objYear->object name of the year
	//strMessage-> message to be displayed

	var js_datInput,js_datCurDate
	js_datInput=objMonth.options[objMonth.selectedIndex].text + "/" + objDay.options[objDay.selectedIndex].text + "/" + objYear.options[objYear.selectedIndex].text
	js_datInput=new Date(js_datInput)
	js_datCurDate=new Date(datCurDate)
	if(js_datInput.getTime()>js_datCurDate.getTime())
	{
		alert(strMessage + " Should be less than current date")
		objMonth.focus()
		return false
	}
	return true
}

//this function validates the input date against the current date and it should not be less than the current date
function js_fnCompareCurrentDate(objMonth,objDay,objYear,datCurDate,strMessage)
{
	//parameter description
	//objMonth->Object name of month
	//objDay->object name of the day
	//objYear->object name of the year
	//strMessage-> message to be displayed

	var js_datInput,js_datCurDate
	js_datInput=objMonth.options[objMonth.selectedIndex].text + "/" + objDay.options[objDay.selectedIndex].text + "/" + objYear.options[objYear.selectedIndex].text
	js_datInput=new Date(js_datInput)
	js_datCurDate=new Date(datCurDate)
	/*if(js_datInput.getMonth()<js_datCurDate.getMonth())
	{		
		alert(strMessage + " Should not be less than current date(month)")
		objMonth.focus()
		return false
	}
	else if(js_datInput.getDate()<js_datCurDate.getDate())
	{		
		alert(strMessage + " Should not be less than current date(day)")
		objDay.focus()
		return false
	}
	if(js_datInput.getYear()<js_datCurDate.getYear())
	{		
		alert(strMessage + " Should not be less than current date(year)")
		objYear.focus()
		return false
	}*/
	if(js_datInput.getTime()<js_datCurDate.getTime())
	{
		alert(strMessage + " Should be greater than current date")
		objMonth.focus()
		return false
	}
	return true
}

//this function will compare two dates
//if first date is greater than second date than it will return false other wise true
function js_fnCompareDates(objMonth1,objDay1,objYear1,objMonth2,objDay2,objYear2)
{
	//parameter description
	//objMonth1->Object name of month for the first date
	//objDay1->object name of the day for the first date
	//objYear1->object name of the year for the first date
	//objMonth2->Object name of month for the second date
	//objDay2->object name of the day for the second date
	//objYear2->object name of the year for the second date
	var js_datInput1,js_datInput2
	js_datInput1=new Date(objMonth1[objMonth1.selectedIndex].text + " /" + objDay1[objDay1.selectedIndex].text + "/" + objYear1[objYear1.selectedIndex].text)
	js_datInput2=new Date(objMonth2[objMonth2.selectedIndex].text + " /" + objDay2[objDay2.selectedIndex].text + "/" + objYear2[objYear2.selectedIndex].text)

	if(js_datInput1.getTime()>js_datInput2.getTime())
	{
		alert("From date must be less than or equal to to date")
		objMonth1.focus()
		return false
	}
	return true
}

//this function will compare two values for the combo box if they match then 
//it will return index which need to be selected
function js_fnSelected(objName,strComstring)
{
	//parameter description
	//objName->Name of the object which need to checked
	//strComstring->the string which is to be compare with the combo value
	var js_intIndex=new String()
	for(js_intIndex=0;js_intIndex<objName.length;js_intIndex++)
	{
		if(objName.options[js_intIndex].value==strComstring)
			return js_intIndex
	}
}


//function to show and hide the layers
function MM_showHideLayers()
{
	//v3.0
	var i,p,v,obj,args=MM_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null)
	{
		v=args[i+2];
		if (obj.style)
			obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v;
		obj.visibility=v;
	}
}


//function to find the objects in the form
function MM_findObj(n, d)
{
	//v3.0
	var p,i,x;  if(!d) d=document;
	if((p=n.indexOf("?"))>0&&parent.frames.length)
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
	if(!(x=d[n])&&d.all) x=d.all[n];
	for (i=0;!x&&i<d.forms.length;i++)
		x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++)
		x=MM_findObj(n,d.layers[i].document);
	return x;
}

function MM_preloadImages()
{
	//v3.0
	var d=document;
	if(d.images)
	{
		if(!d.MM_p)
			d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0)
		{
			d.MM_p[j]=new Image; 
			d.MM_p[j++].src=a[i];
		}
	}
}

//function to show current date on the listbox
function js_fnCurrentDate(objMonth,iMonth,objDay,iDay,objYear,iYear)
	{
		//parameter description
		//objMonth->month lstbox
		//objDay->day lstbox
		//objYear->year lstbox
		//iMonth->current server month
		//iDay->current server day
		//iYear->current server year

		objMonth.selectedIndex=parseInt(iMonth)-1
		objDay.selectedIndex=parseInt(iDay)-1
		objYear.selectedIndex=parseInt(iYear)-1
	}
	
//function to navigate
function js_fnNavigate(sUrl)
	{
		document.forms[0].method = "post";
		document.forms[0].action = sUrl;	
		document.forms[0].submit();
	}	
function fnNewWin1(winUrl)
	{
		var newWin=window.open(winUrl,"","toolbar=0,location=0,menubar=0,scrollbars=1,width=450,height=200")
	}
//function is Only for Forecast
function js_fnValidateStringFC(objName,strMessage,intManYesNo,intSplYesNo)
{
	//parameter description
	//objName->Name of the object
	//intManYesNo-> mandatory or optional
	//if intManYesNo=0-> mandatory
	//if intManYesNo=1->optional
	//intSplYesNo->special characters allowed or not
	//if intSplYesNo=0 -> special characters allowed
	//if intSplYesNo=1 -> special characters not allowed
	var js_strText,js_intIndex
	js_strText=objName
	js_strText=js_strText + ""
	if (js_strText == "undefined" || js_strText+"" == "null")
		return false;
	if(intManYesNo==1 && js_strText=="")
		return true
	else if(intManYesNo==0 && js_strText=="")
	{
		alert(strMessage + " cannot be blank")	;		
		return false;
	}
    else
    	
	{
		for (js_intIndex = 0; js_intIndex < js_strText.length; js_intIndex++)
		{
			if(intSplYesNo==1)
			{
				if (!( ((js_strText.charAt(js_intIndex) >= "0") && (js_strText.charAt(js_intIndex) <= "9")) || (js_strText.charAt(js_intIndex) == "_") ||
						((js_strText.charAt(js_intIndex) >= "a") && (js_strText.charAt(js_intIndex) <= "z")) ||
						((js_strText.charAt(js_intIndex) >= "A") && (js_strText.charAt(js_intIndex) <= "Z"))
						) )
					{
						alert("Only alphanumeric characters are allowed")
						return false;
					}
			}
			else
			{
				if(js_strText.charAt(js_intIndex)=="'" || js_strText.charAt(js_intIndex)=="\"")
				{
					alert("Single quotes, double quotes and slash are not allowed")
					return false;
				}
			}
		}
	}
	return true;
}

function checkNulls(txtObj1,txtName1,txtObj2,txtName2)
{
	var obj1 = txtObj1;
	var obj2 = txtObj2;
	var dotindex;
	if(js_fnTrim(obj1.value)=="" && js_fnTrim(obj2.value)=="")
		return true;

	if(js_fnTrim(obj1.value)=="" && js_fnTrim(obj2.value)!="")
	{
	 alert("You must enter " + txtName1 + " when "+txtName2 + " is entered");
	 txtObj1.focus();
	 return false;
	}
	if(js_fnTrim(obj1.value)!="" && js_fnTrim(obj2.value)=="")
	{
	 alert("You must enter " + txtName2 + " when "+txtName1+ " is entered");
	 txtObj2.focus();
	 return false;
	}
	return true;
}


function openwin(winUrl)
		{
	my_window = window.open(winUrl,"",config="toolbar=1,location=1,top="+parseInt(window.screen.height)* (1/100)+",left="+parseInt(window.screen.width)* (1/100)+",menubar=1,scrollbars=1,width=770,height=400,resizable=1")
		}
		
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
//alert("swap")
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function FnLink(Path)
{
	
	document.forms[0].action=Path
	document.forms[0].method="post"
	document.forms[0].submit()	
	return false;
}

function FnCancels(Path)
{
	var Msg = confirm("Are you sure to cancel the membership ?")
	if(Msg)	
	document.forms[0].action=Path
	document.forms[0].method="post"
	document.forms[0].submit()
	return false;
}
	
function js_fnClearFormObjects1()
{
	//This function will list all the objects in the form
	//if the objects are of type textbox/textarea/select/checkbox then it will be cleared
	for (intIndex=0;intIndex<document.forms[0].elements.length;intIndex++)
		{
			if(document.forms[0].elements[intIndex].type=="text" || document.forms[0].elements[intIndex].type=="textarea")
				document.forms[0].elements[intIndex].value=""
			else if(document.forms[0].elements[intIndex].type=="select-one")
				document.forms[0].elements[intIndex].selectedIndex=0
			else if(document.forms[0].elements[intIndex].type=="checkbox")
				document.forms[0].elements[intIndex].checked=false
		 }		
}

function js_fnCallDate()
{
var valDay,valMonth,valYear
valDay=document.forms[0].lstDay.value
valMonth=document.forms[0].lstMonth.value
valYear=document.forms[0].lstYear.value

js_fnChkMonth(valDay,valMonth,valYear);

}

function js_fnChkMonth(valDay,valMonth,valYear)
{
	// This function will check the number of days a month should have
	// It requires three arguments the value of selected month ,day and year
	// Written By Praveen Nayak Dt: 11-09-2003
	
	var leapTest
	
	leapTest = parseInt(valYear)/4
	leapTest = leapTest - Math.round(leapTest)

	if ((leapTest != 0) && (valDay > 28) && (valMonth==2))
	{
		alert("Day can not be greater than 28")
		document.forms[0].lstDay.selectedIndex=27
		return false;
	}
	else
	{
		if((leapTest==0) && (valDay > 29) && (valMonth==2))
		{
			alert("Day can not be greater than 29")
			document.forms[0].lstDay.selectedIndex=28
			return false;
		}
	}

	if (((valMonth==4) || (valMonth==6) || (valMonth==9) || (valMonth==11)) && (valDay==31))
	{
		alert("Day can not be greater than 30")
		document.forms[0].lstDay.selectedIndex=29
		return false;
	}
	return true;
}

function js_fnCallDate1()
{
	var valDay,valMonth,valYear
	valDay=document.forms[0].lstDay.value
	valMonth=document.forms[0].lstMonth.value
	valYear=document.forms[0].lstYear.value
	//alert()
	js_fnChkMonth1(valDay,valMonth,valYear);

}

function roundNum(Num,Places)
{	if(Places>0)
		if((Num.toString().length-Num.toString().lastIndexOf('.'))>(Places+1))
			return Math.round(Num*(Math.pow(10,Places)))/(Math.pow(10,Places));
		else return Num;
	else return Math.round(Num);
}

function roundCurrency(Num,Places)
{
	if(Places>0)
	{
		if((Num.toString().length-Num.toString().lastIndexOf('.'))>(Places+1))
		{
			var Rounder=Math.pow(10,Places);
			Num = Math.round(Num*Rounder)/Rounder
		}
		temp = Num.toString().split(".") 
		if(temp.length > 1 && temp[1].toString().length == 1) Num = (Num.toString()+"0")
		else if(temp.length == 1) Num=(Num.toString()+".00")
		return Num
	}
	else return Math.round(Num);
	Rounder=null
}

function js_fnChkMonth1(valDay,valMonth,valYear)
{
	// This function will check the number of days a month should have
	// It requires three arguments the value of selected month ,day and year
	// Written By Praveen Nayak Dt: 11-09-2003
	
	var leapTest

	leapTest = parseInt(valYear)/4
	leapTest = leapTest - Math.round(leapTest)
	
	if (document.forms[0].lstDay.selectedIndex != 0 && document.forms[0].lstMonth.selectedIndex != 0 && document.forms[0].lstYear.selectedIndex != 0)
	{
		if ((leapTest != 0) && (valDay > 28) && (valMonth==2))
		{
			alert("Day can not be greater than 28")
			document.forms[0].lstDay.selectedIndex=28
			return false;
		}
		else
		{
			if((leapTest==0) && (valDay > 29) && (valMonth==2))
			{
				alert("Day can not be greater than 29")
				document.forms[0].lstDay.selectedIndex=29
				return false;
			}
		}

		if (((valMonth==4) || (valMonth==6) || (valMonth==9) || (valMonth==11)) && (valDay==31))
		{
			alert("Day can not be greater than 30")
			document.forms[0].lstDay.selectedIndex=30
			return false;
		}
	}
	return true;
}

//===============================25/09/2003===============================
function myValid(objName,objName1,strMessage,intStrLen,intZeroYesNo,intNegYesNo,intDecYesNo,intManYesNo)
{
	if(objName=="" && intManYesNo==1)
		return true;
	else if(objName.length<intStrLen)
	{
		alert(strMessage+ " cannot be less than "+ intStrLen+ " characters");
		objName1.focus();
		return false;
	}

	else if(isNaN(objName)==true)
	{
		alert(strMessage+"  is not a valid number");
		objName1.focus();
		return false;
	}
	else if(parseFloat(objName)==0 && objName.indexOf("-")>-1)
	{
		alert("Negative numbers not allowed");
		objName1.focus();
		return false;
	}
	else if(intZeroYesNo==1 && parseFloat(objName)==0)
	{
		alert(strMessage+" cannot be zero");
		objName1.focus();
		return false;
	}
	else if(intDecYesNo==1 && objName.indexOf(".")>-1)
	{
		alert("Decimal numbers not allowed");
		objName1.focus();
		return false;
	}
	else if(intNegYesNo==1 && parseFloat(objName)<0)
	{
		alert("Negative numbers not allowed");
		objName1.focus();
		return false;
	}
	else if(objName.indexOf("+")>-1)
	{
		alert("+ sign is not allowed");
		objName1.focus();
		return false;
	}
	else if(objName.indexOf("e")>-1)
	{
		alert("e (exponential) is not allowed");
		objName1.focus();
		return false;
	}
	return true;
}



function js_fnDatNavigate(path)
{
	if(document.forms[0].txtDatSch.value=="")
	{
		alert("Enter Date [format : MM/YYYY]")
		document.forms[0].txtDatSch.focus();
		return false;
	}
	if(document.forms[0].txtDatSch.value.indexOf("/")=="-1")
	{
		alert("Date Format should be MM/YYYY")
		document.forms[0].txtDatSch.focus();
		return false;
	}
	var splTxt = document.forms[0].txtDatSch.value.split("/")
	if(!myValid(splTxt[0],document.forms[0].txtDatSch,"Month",1,0,1,1,0))
		return false;
	if(splTxt[0].length > 2)
	{
		alert("Month cannot be greater than 2 characters");
		document.forms[0].txtDatSch.focus();
		return false;
	}
	if(splTxt[0] > 12 )
	{
		alert("Month cannot be greater than 12");
		document.forms[0].txtDatSch.focus();
		return false;
	}
	if(!myValid(splTxt[1],document.forms[0].txtDatSch,"Year",4,0,1,1,0))
		return false;
	if(splTxt[0].length > 4)
	{
		alert("Year cannot be greater than 4 characters");
		document.forms[0].txtDatSch.focus();
		return false;
	}
	if(splTxt[1] > 2099 )
	{
		alert("Year cannot be greater than 2099");
		document.forms[0].txtDatSch.focus();
		return false;
	}
	path=path+"month="+splTxt[0]+"&year="+splTxt[1]
	document.forms[0].action=path
	document.forms[0].method="Post"
	document.forms[0].submit()
	return false;
}


function fnClr()
{
	document.forms[0].txtDatSch.value=""
	return false;
}
function fnArrow(path,strDate,intval)
{	
	path=path+"?month="+strDate+"&year="+intval
	document.forms[0].action=path
	document.forms[0].method="Post"
	document.forms[0].submit()	
	return false;
}

//This Function automatically tabs to the next control
//---Parameter description
//input -- Object of the control
//len -- Length 
//e -- Event

var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function js_autoTab(input,len, e)
{
	 var keyCode = (isNN) ? e.which : e.keyCode;
	 var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
		
	 if(input.value.length >= len && !containsElement(filter,keyCode))
	 {
	   input.value = input.value.slice(0, len);
	   input.form[(getIndex(input)+1) % input.form.length].focus();
	 }

	 function containsElement(arr, ele)
	 {
		var found = false, index = 0;
		while(!found && index < arr.length)
		  if(arr[index] == ele)
			 found = true;
		  else
			 index++;
			 return found;
	 }
	 function getIndex(input)
	 {
		   var index = -1, i = 0, found = false;
			while (i < input.form.length && index == -1)
			  if (input.form[i] == input)
			  	index = i;
			   else 
			   	i++;
			 return index;
	 }
	 return true;
}

//******************************************
//Custom Alert Message
// aTitle:- Name of the Program Like, Game, Schedule etc. 
// aMessage:- Error Message
// iOption: - What Kind of caption should be displayed? Pass 0, 1 etc. You can define your new caption in fnMessage 

function js_CustomAlert(aTitle,aMessage,iOption)
{
	if (iOption == 'return' && aMessage == '')
	{
		document.getElementById('alertLayer').style.visibility = "hidden";
		return aTitle;
	}
	else
	{
		var Code = "<table border=0 width=100% height=100%>" +
		"<tr height=5><td colspan=3 class=headerleft>&nbsp;" + " " + fnMessage(aTitle,iOption) + "</td><td class=headerright><img src='../images/closeicon.gif' onClick=js_CustomAlert('','','return')></td></tr>" +
		"<tr height=5><td width=5></td></tr>" +
		"<tr><td width=5></td><td width=20 align=right><img src='../images/red2.gif'></td><td class=ntext>&nbsp;" + aMessage + "<BR></td><td width=5></td></tr>" +
		"<tr height=5><td width=5></td></tr>" +	
		"<tr><td colspan=4 align=center><input type=button value='OK' onClick=js_CustomAlert('','','return') class=okButton><BR></td></tr>" +	
		"<tr height=5><td width=5></td></tr></table>";
		
		document.getElementById('alertLayer').innerHTML = Code
		var thisText = aMessage.length;
		if (aTitle.length > aMessage.length){ thisText = aTitle.length; }
		aWidth= aMessage.length	
		
		aWidth = (aWidth * 4.9) + 80;
		
		aHeight = 100;
		if (aWidth < 150){ aWidth = 200; }
		if (aWidth > 350){ aWidth = aWidth; }
		if (thisText > 60){ aHeight = 110; }
		if (thisText > 120){ aHeight = 130; }
		if (thisText > 180){ aHeight = 150; }
		if (thisText > 240){ aHeight = 170; }
		if (thisText > 300){ aHeight = 190; }
		if (thisText > 360){ aHeight = 210; }
		if (thisText > 420){ aHeight = 230; }
		if (thisText > 490){ aHeight = 250; }
		if (thisText > 550){ aHeight = 270; }
		if (thisText > 610){ aHeight = 290; }

		document.getElementById('alertLayer').style.width = aWidth;
		document.getElementById('alertLayer').style.height = aHeight;
		document.getElementById('alertLayer').style.left = (document.body.clientWidth - aWidth)/2;
		document.getElementById('alertLayer').style.top = (document.body.clientHeight - aHeight)/2;
		document.getElementById('alertLayer').style.visibility = "visible";					
		document.getElementById('alertLayer').parentElement.focus();
	}	
} 

//sMsg:- Name of the program, Should be blank for iOption - 1
//iOption:- Which message should be displayed

function fnMessage(sMsg,iOption)
{
	var Message = 'Error!! '
	if(iOption == '0')	
	{
		Message = Message + sMsg + ' Not Selected'
		return Message;
	}
	if(iOption == '1')	
	{
		Message = Message + 'Deletion Not Permitted'
		return Message;
	}
	if(iOption == '2')	
	{
		return sMsg;
	}
}	
//******************************************
function fnCheckDate(fday, fmon, fyear, Optional)
{
		var fday,fmon,fyear, Optional
		
		//fday = document.forms[0].CmbFromday.value
		//fmon = document.forms[0].CmbFromMonth.value
		//fyear = document.forms[0].CmbFromYear.value
		
		if (Optional == 0)
		{
			if(fmon == "")
			{
				alert("From month not selected")
				//document.form1.CmbFromMonth.focus()
				return false
			}
			if(fday == "")
			{
				alert("From day not selected")
				//document.forms[0].CmbFromday.focus()
				return false
			}
			if(fyear == "")
			{
				alert("From year not selected")
				//document.forms[0].CmbFromYear.focus()
				return false
			}
		}

		
		if(fmon == "4" || fmon == "6" || fmon == "9" || fmon == "11")
		{
			if(fday > 30)
			{
				alert("From Day Cannot be 31")
				//document.forms[0].CmbFromday.focus()
				return false
			}
		}

		if(fmon == "2")
		{
			var modval
			modval = parseInt(fyear)%4
			if(modval == 0)
			{
				if(parseInt(fday) > 29)
				{
					alert("From month cannot be greater than 29")
					//document.forms[0].CmbFromday.focus()
					return false
				}
			}
			else
			{
				if(parseInt(fday) > 28)
				{
					alert("From month cannot be greater than 28")
					//document.forms[0].CmbFromday.focus()
					return false
				}
			}
		}
}		
	
	function  FilterSpl(txt) 
	{
		
		var val = txt
		rep = /\$|,|#|~|`|\%|\@|\.|\*|\^|\&|\(|\)|\+|\=|\[|\-|\_|\]|\[|\}|\{|\;|\:|\'|\"|\<|\>|\?|\||\\|\!|\$|\/|/g;
		var tmp = val.replace(rep, "")
		return tmp
	}
	function  Filter_Add(txt) 
		{
			var val = txt
			rep = /\$|,|~|`|\%|\@|\.|\*|\^|\&|\(|\)|\+|\=|\[|\-|\_|\]|\[|\}|\{|\;|\:|\'|\"|\<|\>|\?|\||\\|\!|\$|\/|/g;
			var tmp = val.replace(rep, "")
			return tmp
		}
	function  Chk_Emailchar(txt) 
	{
		var val = txt
		rep = /\$|,|~|`|\%|\*|\^|\&|\(|\)|\+|\=|\[|\-|\]|\[|\}|\{|\;|\:|\'|\"|\<|\>|\?|\||\\|\!|\$|\/|/g;
		var tmp = val.replace(rep, "")
		return tmp
	}
		
	function validate(field)
	 {
			var valid = "0123456789"
			var ok = "yes";
			var temp;
			for (var i=0; i<field.value.length; i++)
				{
				temp = "" + field.value.substring(i, i+1);
				if (valid.indexOf(temp) == "-1")
					ok = "no";
				}
				if (ok == "no")
					{
				 		field.value = ""
				 		return field.value
					}
				else
				{
					return field.value
				}	
		}

function TrimText(TrimString)
{	var tempObj;
	if(TrimString){tempObj = TrimString;TrimString = tempObj.value;}
	if(TrimString == "undefined" || TrimString == null) return null;
	if(TrimString.length == 0)TrimString="";
	else
	{	var Lcont=0,TempStrArray=TrimString.split(" "),Rcont=TempStrArray.length-1;
		while(TempStrArray[Lcont] == "")Lcont++;while(TempStrArray[Rcont] == "")Rcont--;
		if(Rcont<Lcont)TrimString="";else
		for(TrimString = TempStrArray[Lcont], Lcont++ ; Lcont <= Rcont ; Lcont++) TrimString += " " + TempStrArray[Lcont];
	}
	if(tempObj)if(TrimString != "undefined" && TrimString != null)tempObj.value = TrimString;
	else return TrimString;
}
	function Trim(str)
	{
		
		var resultStr = "";
		resultStr = TrimLeft(str);
		resultStr = TrimRight(resultStr);
		return resultStr;
	}

	function TrimLeft(str)
		{
			var resultStr = "";
			var i = len = 0;
			if (str+"" == "undefined" || str == null)
			return null;
			str += "";

		if (str.length == 0)
			resultStr = "";
		else
		 {
			len = str.length - 1;
			len = str.length;
			while ((i <= len) && (str.charAt(i) == " "))
				i++;
				resultStr = str.substring(i, len);
		}
		return resultStr;
	}

	function TrimRight(str)
	 {
		var resultStr = "";
		var i = 0;
		if (str+"" == "undefined" || str == null)
			return null;
		str += "";

		if (str.length == 0)
			resultStr = "";
		else {
			i = str.length - 1;
			while ((i >= 0) && (str.charAt(i) == " "))
			i--;
			resultStr = str.substring(0, i + 1);
			}
		return resultStr;
	}

function disableRightClick(e)
	{
		var message = "Right click disabled";
		
		if(!document.rightClickDisabled) // initialize
		{
		if(document.layers) 
		{
			document.captureEvents(Event.MOUSEDOWN);
			document.onmousedown = disableRightClick;
		}
		else document.oncontextmenu = disableRightClick;
		return document.rightClickDisabled = true;
		}
		if(document.layers || (document.getElementById && !document.all))
		{
		if (e.which==2||e.which==3)
		{
			//alert(message);
			return false;
		}
		}
		else
		{
		//alert(message);
		return false;
		}
	}
	//disableRightClick();
				
function filterUserid(str) 
	 {
          re = /\$|,|#|~|`|\%|\@|\.|\*|\^|\&|\(|\)|\+|\=|\[|\-|\]|\[|\}|\{|\;|\:|\'|\"|\ |\<|\>|\?|\||\\|\!|\$|/g;
    	  var tmp = str.replace(re, "");
		  return tmp
     }
function IsUserid(str) 
{     re = /\$|,|#|~|`|\%|\@|\.|\*|\^|\&|\(|\)|\+|\=|\[|\-|\]|\[|\}|\{|\;|\:|\'|\"|\ |\<|\>|\?|\||\\|\!|\$|/g;
    	return str.replace(re, "");
} 
     function getQueryVariable(variable)
	{
	
				var query = window.location.search.substring(1);
				var vars = query.split("&");
			
				for (var i=0;i<vars.length;i++)
				{
						var pair = vars[i].split("=");
					if (pair[0] == variable)
						{
							return pair[1];
						}
				}
	}
     
function fnPassAnswer()
			{
				re = /\$|,|#|~|`|\%|\@|\.|\*|\^|\&|\(|\)|\+|\=|\[|\-|\]|\[|\}|\{|\;|\:|\'|\"|\ |\<|\>|\?|\||\\|\!|\$|/g;
    			//document.forms(0).elements(F.elements[i].id).value
				var temp = document.forms(0).elements("txtAnswer").value 
    			document.forms[0].elements("txtAnswer").value = temp.replace(re, "");
    		}     				
   function js_fnTrim(strText)
{
	//parameter description
	//strText -> text which needs to be trim the spaces
	
	
	var js_intIndex,js_strLen;
	js_intIndex=0
	strText += "";
	
	if(strText== "undefined" || strText == null)
		return null;
		
	else if(strText.length == 0)
		strText = "";
		
	else
		{
			js_strLen= strText.length;
			
			//this loop will trim the left side spaces
			
			while ((js_intIndex <= js_strLen) && (strText.charAt(js_intIndex) == " "))
				js_intIndex++;
				
			strText = strText.substring(js_intIndex, js_strLen);
			
			if(strText.length>0)
				{
					//this loop will trim the right side spaces
					js_intIndex= strText.length - 1;
					
					while ((js_intIndex >= 0) && (strText.charAt(js_intIndex) == " "))
						js_intIndex--;
					strText = strText.substring(0, js_intIndex + 1);
				}
		}
	return strText
}




function fnCheckDateWithCurrrent(ddlDayId,ddlMonthId,ddlYearId,currdateWithServerFormat)
{
	
	var currdate = new Date(currdateWithServerFormat)// Chaging date to javascript format
	
	var ddlDay = document.getElementById(ddlDayId).value
	var ddlMonth = document.getElementById(ddlMonthId).value
	var ddlYear = document.getElementById(ddlYearId).value
	
	
	var currDay;
	var selDay;
	var currMonth;
	var selMonth;
	var currYear;
	var selYear;
	
	currDay = parseInt(currdate.getDate());
	selDay = parseInt(ddlDay);
	currMonth = parseInt(currdate.getMonth())+1;
	selMonth = parseInt(ddlMonth);
	currYear = parseInt(currdate.getFullYear());
	selYear = parseInt(ddlYear);
	
	
	if (selYear < currYear)
	{
		fnPrintErrMsg("Year should not be Less than Current Year!");
   		//document.getElementById(ddlYearId).focus(); 
   		return false;
	}
	if (selYear == currYear)
	{
		if(selMonth < currMonth)
		{
			fnPrintErrMsg("Month should not be Less than Current Month!");
   			//document.getElementById(ddlMonthId).focus(); 
   			return false;
		}
		if (selMonth == currMonth)
		{	
			if (selDay < currDay)
			{
				fnPrintErrMsg("Day should not be Less than Current Day!");
   				//document.getElementById(ddlDayId).focus(); 
   				return false;
			}	
		}
	}
	
	
	return true;
}


			//****************************   date validattion ***********************************************************
		
		//var ValidateFromDate = new Boolean()
		//ValidateFromDate = Fn_Validate_RecurringeDate('DrpFromMon','DrpFromDay','DrpFromYear','lblMessage')
		//if(ValidateFromDate == false)
		//return false
				
		function Fn_Validate_RecurringeDate(DrpRMonth,DrpRDay,DrpRYear,lblMessage)
		{
				var Bool = new Boolean()
				Bool = true
				var DrpMonth = document.getElementById(DrpRMonth).value
				var DrpDay = document.getElementById(DrpRDay).value
				var DrpYear = document.getElementById(DrpRYear).value
				if (DrpYear%4==0)
				{
					if(parseInt(DrpMonth) == 2)
					{
						if (DrpDay>29)
						{
							var lblMessage = document.getElementById(lblMessage)
							lblMessage.innerHTML = "Select valid date of leap year"
							//document.getElementById(DrpRDay).focus()
							Bool = false
						}

					}
				}
				else
				{
					if (parseInt(DrpMonth)== 2)
					{
						if (DrpDay > 28 )
						{
							var lblMessage = document.getElementById(lblMessage)
							lblMessage.innerHTML = "Invalid Day"
							//document.getElementById(DrpRDay).focus()
							Bool = false
						}

					}
				}

				if (parseInt(DrpMonth)==4 || parseInt(DrpMonth)==6 || parseInt(DrpMonth)==9 ||parseInt(DrpMonth)==11)
				{
					if (DrpDay>30)
					{
						var lblMessage = document.getElementById(lblMessage)
						lblMessage.innerHTML = "Invalid Day"
						//document.getElementById(DrpRDay).focus()
						Bool = false
					}

				}
				if(Bool == false)
					return false
				else
					return true


		}
		///**************************************************************************************************
		
		
			///*******************8 from date cannot be greater than to date ************************************************
		///var VarCheckDate = new Boolean()
		//VarCheckDate=Validate_FromDate('DrpFromYear','DrpFromMon','DrpFromDay','DrpToYear','DrpToMon','DrpToDay','lblMessage')
		//if(VarCheckDate==false)
		//return false
					
		function Validate_FromDate(CmbFromyy,CmbFrommm,CmbFromdd,CmbToyy,CmbTomm,CmbTodd,lblerror)
		{
				if (parseInt(document.getElementById(CmbFromyy).value) >  parseInt(document.getElementById(CmbToyy).value))
				{	
					lblerror = document.getElementById(lblerror)
					lblerror.innerHTML = "From date cannot be greater than To date."; 
					//document.getElementById(CmbFromyy).focus(); 
					return false;
				}
				if (parseInt(document.getElementById(CmbFromyy).value) ==  parseInt(document.getElementById(CmbToyy).value))
				{
					if (parseInt(document.getElementById(CmbFrommm).value) > parseInt(document.getElementById(CmbTomm).value))
					{
						lblerror = document.getElementById(lblerror)
						lblerror.innerHTML = "From date cannot be greater than  To date."; 
						//document.getElementById(CmbFrommm).focus();
						return false;
					}  
				}

				if (parseInt(document.getElementById(CmbFromyy).value) ==  parseInt(document.getElementById(CmbToyy).value))
				{	
					if (parseInt(document.getElementById(CmbFrommm).value) ==  parseInt(document.getElementById(CmbTomm).value))
					{
						if (parseInt(document.getElementById(CmbFromdd).value) >= parseInt(document.getElementById(CmbTodd).value))
						{
							lblerror = document.getElementById(lblerror)
							lblerror.innerHTML = "From date cannot be greater than To date."; 
							//document.getElementById(CmbFromdd).focus(); 
							return false;
						}	
					}
				}
		}

		function js_fnTrim(strText)
{
	//parameter description
	//strText -> text which needs to be trim the spaces
	
	
	var js_intIndex,js_strLen;
	js_intIndex=0
	strText += "";
	
	if(strText== "undefined" || strText == null)
		return null;
		
	else if(strText.length == 0)
		strText = "";
		
	else
		{
			js_strLen= strText.length;
			
			//this loop will trim the left side spaces
			
			while ((js_intIndex <= js_strLen) && (strText.charAt(js_intIndex) == " "))
				js_intIndex++;
				
			strText = strText.substring(js_intIndex, js_strLen);
			
			if(strText.length>0)
				{
					//this loop will trim the right side spaces
					js_intIndex= strText.length - 1;
					
					while ((js_intIndex >= 0) && (strText.charAt(js_intIndex) == " "))
						js_intIndex--;
					strText = strText.substring(0, js_intIndex + 1);
				}
		}
	return strText
}
	
	
	function filterall(str) 
	 {
          re = /\$|,|#|~|`|\%|\@|\.|\*|\^|\&|\(|\)|\+|\=|\[|\-|\_|\]|\[|\}|\{|\;|\:|\'|\"|\ |\<|\>|\?|\||\\|\!|\$|/g;
    	  var tmp = str.replace(re, "");
		  return tmp
     }
 function filtergridval(str) 
	 {
          re = /\$|,|#|~|`|\%|\@|\.|\*|\^|\&|\(|\)|\+|\=|\[|\-|\_|\]|\[|\}|\{|\;|\:|\'|\"|\<|\>|\?|\||\\|\!|\$|/g;
    	  var tmp = str.replace(re, "");
		  return tmp
     }
 function generalFilter(str) 
	 {
          re = /\$|,|#|~|`|\%|\@|\*|\^|\&|\(|\)|\+|\=|\[|\-|\_|\]|\[|\}|\{|\;|\:|\'|\"|\<|\>|\?|\||\\|\!|\$|/g;
    	  var tmp = str.replace(re, "");
		  return tmp
     }
      function generalEmailFilter(str) 
	 {
          re = /\$|,|#|~|`|\%|\*|\^|\&|\(|\)|\+|\=|\[|\-|\]|\[|\}|\{|\;|\:|\'|\"|\<|\>|\?|\||\\|\!|\$|/g;
    	  var tmp = str.replace(re, "");
		  return tmp
     }
     
     function isFutureDate(drpMon,drpDay,drpYear,currMonth,currDay,currYear)
     {
		drpMon = parseInt(drpMon)
		drpDay = parseInt(drpDay)
		drpYear = parseInt(drpYear)
		currMonth = parseInt(currMonth)
		currDay = parseInt(currDay)
		currYear = parseInt(currYear)
		
		if(drpYear > currYear)
		{
			return true;
		}
		else if(drpYear == currYear)
		{
			if(drpMon > currMonth)
			{
				return true;
			}
			else if(drpMon == currMonth)
			{
				if(drpDay > currDay)
				{
					return true;
				}
				else
				{
					return false;
				}
			}
			else
			{
				return false;
			}							
		}
		else
		{
			return false;
		}
     }
     
     function isPreviousDate(drpMon,drpDay,drpYear,currMonth,currDay,currYear)
     {
		drpMon = parseInt(drpMon)
		drpDay = parseInt(drpDay)
		drpYear = parseInt(drpYear)
		currMonth = parseInt(currMonth)
		currDay = parseInt(currDay)
		currYear = parseInt(currYear)
		
		if(drpYear < currYear)
		{
			return true;
		}
		else if(drpYear == currYear)
		{
			if(drpMon < currMonth)
			{
				return true;
			}
			else if(drpMon == currMonth)
			{
				if(drpDay < currDay)
				{
					return true;
				}
				else
				{
					return false;
				}
			}
			else
			{
				return false;
			}							
		}
		else
		{
			return false;
		}
     }
     function CompareFromToDate(yyFrom,mmFrom,ddFrom,yyTo,mmTo,ddTo)
     {
		if(parseInt(yyFrom) > parseInt(yyTo))
		{
			return false;
		}
		else if (parseInt(yyFrom) == parseInt(yyTo))
		{		
			if(parseInt(mmFrom) > parseInt(mmTo))
			{					
				return false;
			}
			else if (parseInt(mmFrom) == parseInt(mmTo))
			{
				if(parseInt(ddFrom) > parseInt(ddTo))
				{					
					return false;
				}
			}		
		}
     }
     
	
	function IsValidDate(ObjMM, ObjDD, ObjYY,DateSrc)
	{//alert(ObjMM.value + ":" + ObjDD.value + ":" + ObjYY.value +":" + DateSrc)
		if(ObjMM.value == "4" || ObjMM.value == "6" || ObjMM.value == "9" || ObjMM.value == "11")
		{	
			if(ObjDD.value > 30)
			{	alert("Date Cannot be greater than 30 in '"+DateSrc+"' Date"); ObjDD.focus(); return false; }
		}
		if(ObjMM.value == "2")
		{	
			var modval
			modval = parseInt(ObjYY.value)%4
			if(modval == 0)
			{	
				if(parseInt(ObjDD.value) > 29)
				{	alert("Date cannot be greater than 29 in '"+DateSrc+"' Date");	ObjDD.focus();	return false; }
			}
			else
			{	
				if(parseInt(ObjDD.value) > 28)
				{	alert("Date cannot be greater than 28 in '"+DateSrc+"' Date"); ObjDD.focus(); return false; }
			}
		}
	}
	function getMonthName(ind)
	{ 
		var Arr = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec") 
		if(ind != 0)
		return Arr[ind-1]
	}
	function IsPersonnelPhoneNumber(objPhoneNumber,lblMessage)
	{
		//Note : Phone Number Begining with 888,800,866,877 are considered as Bussiness Phone Number
		if(objPhoneNumber.value != "")
		{	
			if(objPhoneNumber.value == "800" || objPhoneNumber.value == "866" || objPhoneNumber.value == "877" || objPhoneNumber.value == "888")
			{	//alert(objPhoneNumber.value)	
				lblMessage.innerHTML = "The phone number should be a personal number"				
				objPhoneNumber.focus()				
				return false
			}
			else
			{
				return true
			}
		}
	}
	function FnSearchMSG(Obj, Msg,objError)	
    {	
        objError.innerHTML = Msg
        objError.style.color="red"
        if (Obj) Obj.focus()
        return false
    }
    function IsValid_DateRange(FromMM, FromDD, FromYY,ToMM, ToDD, ToYY,objError)
    {
        yyFrom = FromYY.value
        mmFrom = FromMM.value
        ddFrom = FromDD.value
        yyTo = ToYY.value
        mmTo = ToMM.value
        ddTo = ToDD.value        
        
        if(eval(yyFrom) > eval(yyTo))
		{
			return FnSearchMSG(ToYY, "To Date must be greater than From Date ",objError) 
		}
		else if (eval(yyFrom) == eval(yyTo))
		{		
			if(eval(mmFrom) > eval(mmTo))
			{					
				return FnSearchMSG(ToMM, "To Date must be greater than From Date ",objError) 
			}
			else if (eval(mmFrom) == eval(mmTo))
			{
				if(eval(ddFrom) > eval(ddTo))
				{					
					return FnSearchMSG(ToDD, "To Date must be greater than From Date ",objError) 
				}
			}		
		}
    	
        if(ToDD.selectedIndex != 0 && ToMM.selectedIndex != 0 && ToYY.selectedIndex != 0)
        {
	        if(FromDD.selectedIndex == 0 || FromMM.selectedIndex == 0 || FromYY.selectedIndex == 0)
	        {
		        FnSearchMSG(FromMM, "From Month Cannot be blank")
		        return false;
	        }
        }
    }
    function SetWindowSize(Width,Height,MoveLeftTop)
	{	
		SetWidth = Width			
		SetHeight = Height											
		if(SetWidth >= window.screen.width)
		{
			SetWidth = window.screen.width-200
		}
		
		if(SetHeight >= window.screen.height)
		{
			SetHeight = window.screen.height-200
		}
		
		/*alert(window.screen.width); alert(window.screen.height);alert(SetWidth);alert(SetHeight)*/
		//alert(parseInt(Math.abs(window.screen.width/2) - Math.abs(SetWidth/2)))
		//alert(parseInt(Math.abs(window.screen.height/2) - Math.abs(SetHeight/2)))
		
		SetLeft = parseInt(Math.abs(window.screen.width/2) - Math.abs(SetWidth/2))
		SetTop = parseInt(Math.abs(window.screen.height/2) - Math.abs(SetHeight/2))
		if(MoveLeftTop == "1") { SetLeft += 20;SetTop += 20; }
	} 
	
	//************* In AJAX Function Date Field is in the format Mon Oct 1 00:00:00 UTC+0530 2007
	//************* when date in the format Mon Oct 1 00:00:00 UTC+0530 2007 is passes as argument *******
	//************* This Function Return Complete Date(i.e. Oct 1 2007 12:00 AM) **************************
    function GetDateFormat(strDate)
    {
		var d = new Date(strDate)	
		/*alert(strDate)	
		alert("getDate() : " + d.getDate())
		alert("getMonth() : " + d.getMonth())
		alert("getFullYear() : " + d.getFullYear())
		alert("getDay() : " + d.getDay())
		alert("getHours() : " + d.getHours())
		alert("getMinutes() : " + d.getMinutes())*/
		var MonthName = ""
		var Hour = ""
		var Minutes = ""
		var AMORPM = ""
		
		MonthName = getMonthName(parseInt(d.getMonth())+1)
		Hour = d.getHours()
		Minutes = d.getMinutes()
		
		if(d.getHours() > 12) 
		{
			AMORPM = "PM" 
			Hour = Hour - 12
		}	
		else if(d.getHours() < 12)
		{
			AMORPM = "AM"
			if(d.getHours() == 0) Hour = 12
		}
		if(Hour < 10) { Hour = "0" + Hour }
		if(Minutes < 10) { Minutes = "0" + Minutes }
		
		return MonthName + " " + d.getDate() + " " + d.getFullYear() + " " + Hour + ":" + Minutes + " " + AMORPM
	}
	
	//************* In AJAX Function Date Field is in the format Mon Oct 1 00:00:00 UTC+0530 2007
	//************* when date in the format Mon Oct 1 00:00:00 UTC+0530 2007 is passes as argument *******
	//************* This Function Return Date Only (i.e. Oct 1 2007) **************************
	function GetDateOnlyFormat(strDate)
    {
		var d = new Date(strDate)	
		/*alert(strDate)	
		alert("getDate() : " + d.getDate())
		alert("getMonth() : " + d.getMonth())
		alert("getFullYear() : " + d.getFullYear())
		alert("getDay() : " + d.getDay())
		alert("getHours() : " + d.getHours())
		alert("getMinutes() : " + d.getMinutes())*/
		var MonthName = ""
		var Hour = ""
		var Minutes = ""
		var AMORPM = ""
		
		MonthName = getMonthName(parseInt(d.getMonth())+1)
		Hour = d.getHours()
		Minutes = d.getMinutes()
		
		if(d.getHours() > 12) 
		{
			AMORPM = "PM" 
			Hour = Hour - 12
		}	
		else if(d.getHours() < 12)
		{
			AMORPM = "AM"
			if(d.getHours() == 0) Hour = 12
		}
		if(Hour < 10) { Hour = "0" + Hour }
		if(Minutes < 10) { Minutes = "0" + Minutes }
		
		return MonthName + " " + d.getDate() + " " + d.getFullYear()
	}
	function ValidateFromORToEmpty(objFrom,objTo,objError,Msg)
	{
		if(objFrom.value == "" && objTo.value != "") 
		{
			objError.innerHTML = Msg
			objFrom.focus()
			return false
		}
		if(objFrom.value != "" && objTo.value == "") 
		{
			objError.innerHTML = Msg
			objTo.focus()
			return false
		}
		
	}
	function ValidateFromToRange(objFrom,objTo,objError,Msg)
	{
		if(objFrom.value != "" && objTo.value != "")
		{
			if(parseFloat(objFrom.value) > parseFloat(objTo.value))
			{
				objError.innerHTML = Msg
				objTo.focus()
				return false
			}
		}
	}
	
	/******  New Time Gets **/
	function GetTimeOnlyFormat(strDate)
    {
		var d = new Date(strDate)	
		/*alert(strDate)	
		alert("getDate() : " + d.getDate())
		alert("getMonth() : " + d.getMonth())
		alert("getFullYear() : " + d.getFullYear())
		alert("getDay() : " + d.getDay())
		alert("getHours() : " + d.getHours())
		alert("getMinutes() : " + d.getMinutes())*/
		var MonthName = ""
		var Hour = ""
		var Minutes = ""
		var AMORPM = ""
		
		MonthName = getMonthName(parseInt(d.getMonth())+1)
		Hour = d.getHours()
		Minutes = d.getMinutes()
		
		if(d.getHours() > 12) 
		{
			AMORPM = "PM" 
			Hour = Hour - 12
		}	
		else if(d.getHours() < 12)
		{
			AMORPM = "AM"
			if(d.getHours() == 0) Hour = 12
		}
		if(Hour < 10) { Hour = "0" + Hour }
		if(Minutes < 10) { Minutes = "0" + Minutes }
		
		return Hour + ":" + Minutes + " " + AMORPM
	}
	
	function PatientPhoneType(type)
	{
		if(type == "0") return "My Cell"
		if(type == "1") return "My Home"
		if(type == "2") return "My Personal Fax"
		if(type == "3") return "Direct Phone at work"
	}
	
	function MeterTestStrips(dbvalue)
	{
		if(dbvalue == "1") return "EZ"
		if(dbvalue == "2") return "Accucheck Active" 
	} 
	
	
	
	function ReplaceHyphen(str)
	{
		var re = ""
		re = /\-/g;
		//re = /^\-$/g;
		str=str.replace(re, ", ");
		return str
	}
	
	// New Codings
	
	 function IsActiveXControlEnable()
    {
        var MyFSO;
        var Enabled = new Boolean
        Enabled = true
        try { MyFSO = new ActiveXObject("Scripting.FileSystemObject"); }	
        catch(e) {	Enabled = false; }
        return Enabled
    }
