<!--
var alphabet = "abcdefghijklmnopqrstuvwxyz";
var numeric  = "0123456789";

function isValidwithBag(name,Bag)
{
	var i;
	name = name.toLowerCase();
	for(i=0;i<name.length;++i)
		if (Bag.indexOf(name.charAt(i)) == -1) 
			return false;
	return true;
}		

function isEmpty(s)
{
	// if the string is null or having the length of zero
	// the function will return true
	return((s==null) || (s.length==0));
}

function isWhitespace(s)
{
	// 	Check if s is empty

	if (isEmpty(s)) return true;	

	// Checks for whitespace. If there is atleast a non-whitespace character
	// the function will return false.

	var spaces = " \n\t\r"
	var i;
	for(i=0;i<s.length;++i)
		if (spaces.indexOf(s.charAt(i)) == -1) 
			return false;
	return true;
}

function isLogin(s)
{
	if (s.length < 5)
	{
		alert("min. length of Login ID is 5");
		return false;
	}

	if (!isValidwithBag(s,alphabet + numeric + "-._"))

	{
		alert("Login ID should contain only the characters from alphabet, numbers and '-._'");
		return false;
	}
	if (!isValidwithBag(s.charAt(s.length-1),alphabet + numeric))
	{
		alert("Login ID should end with an alphanumeric characters.");
		return false;
	}
	if (!isValidwithBag(s.charAt(0),alphabet + numeric))
	{
		alert("Login ID should start with an alphanumeric characters.");
		return false;
	}
	return true;
}

function isPassword(s)
{
	if (s.length < 5)
	{
		alert("min. length of password is 5");
		return false;
	}

	if (isWhitespace(s))
	{
		alert("please enter the password without spaces");
		return false;
	}
	return true;
}


function isEmail(s)
{
	var i = 1,Length = s.length,result;

	while((i<Length) && (s.charAt(i) != '@')) i++;
	
	if ((i == Length) || (s.charAt(i) != '@'))
	{
		alert("Please enter a valid email address.");
		return false;
	}
	
	i+=2;
	
	while((i<Length) && (s.charAt(i) != '.')) i++;

	if ((i == Length) || (s.charAt(i) != '.'))
	{
		alert("Please enter a valid email address. ");
		return false;
	}

	if (i+1 >= Length)
	{
		alert("Please enter a valid email address. ");
		return false;
	}
	
	return true;
}




function validateDB(objForm)
{
	var i,j;
	with(objForm)
	{	
		for(i=0;i < elements.length;i++)
		{
			if(elements[i].name.substr(0,2) == "_1" || (elements[i].name.substr(0,2) == "_0" && elements[i].value != ""))
			{
				j = elements[i].name.charAt(2);
				
				switch(j)
				{
					case "1" :
							if (isWhitespace(elements[i].value))
							{
								alert("please, enter value for " + elements[i].name.substr(4))
								elements[i].focus();
								return false;
							}
							break;

					case "2" :
							if (isNaN(elements[i].value) || isWhitespace(elements[i].value))
							{
								alert("please, enter numeric value for " + elements[i].name.substr(4))
								elements[i].focus();
								return false;
							}
							break;

					case "3" :
							if (isNaN(elements[i].value))
							{
								alert("please, select yes/no for " + elements[i].name.substr(4))
								elements[i].focus();
								return false;
							}
							break;

					case "4" :
							if (isDate(elements[i]))
							{
								alert("please, enter a valid date value for " + elements[i].name.substr(4))
								return false;
							}
							break;
					case "5" :
						if(!IsaCardno(elements[i]))
						{
							return false;	
						}
						break;	
					case "9" :
							if (isWhitespace(elements[i].value))
							{
								alert("please, select a file for " +  elements[i].name.substr(4))
								elements[i].focus();
								return false;
							}	
							elements[elements[i].name.substr(4)].value = elements[i].value;
				}
				
			}
			else if(elements[i].name.substr(0,3) == "_09")
				elements[elements[i].name.substr(4)].value = elements[i].value;
			
		}
	}
	return true;
}

	function isDate(obj)
	{

		var curDate,cal = obj.value;
		var calMode = 0;
		curDate = true;
		if (cal.length == 10)
		{
			if(calMode == 0)
			{
				Day = cal.substr(3,2)
				Month = cal.substr(0,2);
			}
			else
			{
				Day = cal.substr(0,2)
				Month = cal.substr(3,2);
			}
			Year = cal.substr(6,4);

			if (!isNaN(Day) && !isNaN(Month) && !isNaN(Year))
			{
					if((Month >= 1 && Month <= 12) && Year.length == 4)
					{
						Date1 = new Date(Year,Month-1,1);
						var tMonth = Date1.getMonth();
						var tYear = Date1.getFullYear();
						if(tMonth == 11)
						{
							tMonth = 0;
							tYear = tYear + 1;
						}
						else
							tMonth++;
						var Date2= new Date(tYear,tMonth,Date1.getDate())
						monthDays = (Date2 - Date1) / 86400000;
						if (Day >= 1 && Day <= monthDays)
							curDate = false;
					}
			}
					
		}
		return curDate;
	}

function DateDiff(obj2,obj1)
{
// obj2 is Date object
// obj1 is the text object having the date value
// will return + value if obj2 < obj1
// will return - value if obj2 > obj1
// will return 0 if both are equal.

		var cal1 = obj1.value;
		var Date1;
		var calMode = 0;

		if (cal1.length == 10)
		{
			if(calMode == 0)
			{
				Day1 = cal1.substr(3,2)
				Month1 = cal1.substr(0,2);
			}
			else
			{
				Day1 = cal1.substr(0,2)
				Month1 = cal1.substr(3,2);
			}
			Year1 = cal1.substr(6,4);

			Date1 = new Date(Year1,Month1-1,Day1);

			return (Date1 - obj2);
		}

}

function validateDB1(objForm)
{
	var i,j;
	with(objForm)
	{	
		for(i=0;i < elements.length;i++)
		{
			if(elements[i].name.substr(0,2) == "_1")
			{
				j = elements[i].name.charAt(2);
				
				switch(j)
				{
					case "1" :
							if (isWhitespace(elements[i].value))
							{
								alert("Please, Enter value for " + elements[i].name.substr(4))
								return false;
							}
							break;
							
					case "2" :
							if (isNaN(elements[i].value) || isWhitespace(elements[i].value))
							{
								alert("Please, Enter numeric value for " + elements[i].name.substr(4))
								return false;
							}
							break;
							
					case "3" :
							if (isNaN(elements[i].value))
							{
								alert("Please, Enter select Yes/No for " + elements[i].name.substr(4))
								return false;
							}
							break;
							
					case "4" :
							if (isDate(elements[i]))
							{
								alert("Please, Enter a valid date value for " + elements[i].name.substr(4))
								return false;
							}
							break;
							
					case "9" :
							if (isWhitespace(elements[i].value))
							{
								alert("Please, Select a file for " +  elements[i].name.substr(4))
								return false;
							}	
							elements[elements[i].name.substr(4)].value = elements[i].value;
				}
				
			}
			
			else if(elements[i].name.substr(0,3) == "_09")
			{
					elements[elements[i].name.substr(4)].value = elements[i].value;
			}
			
		}
	}
	return true;
}


function IsaCardno(fld)
{
	var result=true
	var st=fld.value

	if(!isNaN(st) && st.length>12 && st.length<17)
	{
	
		var adig=parseInt(st.charAt(0))
		var twodig=parseInt(st.substring(0,2))
		var fourdig=parseInt(st.substring(0,4)) 
		
		if(st.length==13) {if(adig==4){result=false}}
		else if(st.length==15)
		{
			if(!(twodig==34 || twodig==37)){result=false}
		}
		else if(st.length==16)
		{
		if(!(adig==4 || fourdig==6011 || twodig==16 || (twodig>50 && twodig<55)))
			{result=false}
		}
		else 
		{
			result=false
			alert(fld.name.substr(4)+" incorrect number of digits")    
		}
		if(!result){alert(fld.name.substr(4)+" incorrect prefix")}
		else
		{
			var sum=0
			var v=0
			for(var i=1; i<st.length+1; i++)
			{
				v=parseInt(st.charAt(st.length-i))
				if(i % 2 ==0)
					{sum=sum+(v*2) % 10 + Math.floor((v*2)/10)}
				else
				{sum=sum+v}
			}//for i
			if(sum % 10)
			{
				result=false
				alert(fld.name.substr(4)+" fails LUHN check")
			}
		}//luhn check
	}//if correct length
	else
	{
		result=false
		alert(fld.name.substr(4)+" incorrect number of digits")
	}
	if(!result)
	{
		fld.select()
	}
	return result
}


function win_open(location, width, height)
{
	//determine browser type
	var ns4up = (document.layers) ? 1 : 0;  
	var ie4up = (document.all) ? 1 : 0;
	
	//if compatable browser
	if (ns4up || (ie4up))
	{
		//if netscape 4 or up
		if (ns4up)
		{
			//width & height X% of client's current brower
			if (width.indexOf("%") > -1)
			{
				var win_width = Math.round(self.innerWidth * (parseFloat(width)*.01));
			}
			else
			{
				var win_width = parseFloat(width)
			}
			if (height.indexOf("%")  > -1)
			{
				var win_height = Math.round(self.innerHeight * (parseFloat(height)*.01));
			}
			else
			{
				var win_height = parseFloat(height)
			}
			
		}
		//if internet explorer 4 or up
		else if (ie4up)
		{
			//width & height X% of client's current brower
			if (width.indexOf("%")  > -1)
			{ 
				var win_width = Math.round(document.body.clientWidth * (parseFloat(width) *.01))
			}
			else
			{
				var win_width = parseFloat(width)
			}
			if (height.indexOf("%")  > -1)
			{
				var win_height = Math.round(document.body.clientHeight * (parseFloat(height)*.01))
			}
			else
			{
				var win_height = parseFloat(height)
			}
		}
			//parm string
			var win_size = "scrollbars=no,width=" + win_width + ",height=" + win_height +",top=0,left=0,"
			//open window
			MM_openBrWindow(location,"", win_size)
	}
	//else incompatable broswer, open window to default size
	else
	{
		//open window with default settings
		window.open(location, "", "scrollbars=no,menubar=yes,top=0,left=0")
	}
}


function MM_openBrWindow(theURL,winName,features) 
{ 
	var hWnd =   window.open(theURL,winName,features);
	if ((document.window != null) && (!hWnd.opener))
		hWnd.opener = document.window;
}


function tierMenu(objMenu,objImage)    // Menu level display
{ 
//  if(document.all){
   if (document.getElementById(objMenu).style.display == "none")
   {
       document.getElementById(objMenu).style.display = "";
       document.getElementById(objImage).src = "minus.gif";
   }
   else
   {
       document.getElementById(objMenu).style.display = "none";
       document.getElementById(objImage).src = "plus.gif";
   }
/*   }
   else
   {
	if(document.getElementById(objMenu).style.display=="none")
	{
	document.getElementById(objMenu).style.display = "";
	document.getElementById(objImage).src='minus.gif';
	}else
	{
	document.getElementById(objMenu).style.display = "none";
	document.getElementById(objImage).src='plus.gif';
	
	}

	}*/
  }
/*
function tierMenu(objMenu,objImage)    // Menu level display
{ 
   if (objMenu.style.display == "none")
   {
       objMenu.style.display = "";
       objImage.src = "minus.gif";
   }
   else
   {
       objMenu.style.display = "none";
       objImage.src = "plus.gif";
   }
  }
*/

function ShowErrOptions(objForm)
{
	if(objForm.ErrTypes.value != "")
	{
		objForm.ErrResponsibility.disabled = false;
		objForm.ErrResolution.disabled = false;
	}
	else
	{
		objForm.ErrResponsibility.disabled = true;
		objForm.ErrResponsibility.options[0].selected = true
		objForm.ErrResolution.disabled = true;
		objForm.ErrResolution.options[0].selected = true
	}
}

function win_open(location, width, height)
{
	//determine browser type
	var ns4up = (document.layers) ? 1 : 0;  
	var ie4up = (document.all) ? 1 : 0;	
	//if compatable browser
	if (ns4up || (ie4up))
	{
		//if netscape 4 or up
		if (ns4up)
		{
			//width & height X% of client's current brower
			if (width.indexOf("%") > -1)
			{
				var win_width = Math.round(self.innerWidth * (parseFloat(width)*.01));
			}
			else
			{
				var win_width = parseFloat(width)
			}
			if (height.indexOf("%")  > -1)
			{
				var win_height = Math.round(self.innerHeight * (parseFloat(height)*.01));
			}
			else
			{
				var win_height = parseFloat(height)
			}
			
		}
		//if internet explorer 4 or up
		else if (ie4up)
		{
			//width & height X% of client's current brower
			if (width.indexOf("%")  > -1)
			{ 
				var win_width = Math.round(document.body.clientWidth * (parseFloat(width) *.01))
			}
			else
			{
				var win_width = parseFloat(width)
			}
			if (height.indexOf("%")  > -1)
			{
				var win_height = Math.round(document.body.clientHeight * (parseFloat(height)*.01))
			}
			else
			{
				var win_height = parseFloat(height)
			}
		}
			//parm string
			var win_size = "scrollbars=yes,width=" + win_width + ",height=" + win_height +",top=0,left=0"
			//open window
			window.open(location,"", win_size)
	}
	//else incompatable broswer, open window to default size
	else
	{
		//open window with default settings
		window.open(location, "", "scrollbars=yes,menubar=yes,top=0,left=0")
	}
}
//-->