function validateIbase()
{
	if(document.getElementById("id_JBOSSHOME").value.length <= 0)
	{
		alert(" JBOSS HOME IS EMPTY,PLEASE FILL THE VALUE");
		return false ;
	}
	else if(document.getElementById("id_TOMCATHOME").value.length <= 0)
	{
		alert(" TOMCAT HOME IS EMPTY,PLEASE FILL THE VALUE");
		return false ;
	}
	else if(document.getElementById("id_SMTPHOST").value.length <= 0)
	{
		alert(" SMTP HOST IS EMPTY,PLEASE FILL THE VALUE");
		return false ;
	}
	else if(document.getElementById("id_MAILFROM").value.length <= 0)
	{
		alert(" MAIL FROM IS EMPTY,PLEASE FILL THE VALUE");
		return false ;
	}
	else
	{
		
		//alert(document.getElementById("id_SAVE_STRING").value);
		var value;
		//alert("value1 ::\n"+value);
		value=document.getElementById("id_JBOSSHOME").value;
		//alert("value ::\n"+value);
		document.getElementById("id_SAVE_STRING").value = "<?xml version=\"1.0\"?>\r\n" 
														+"<IBASE>\r\n"
														+ "<JBOSSHOME>"+document.getElementById("id_JBOSSHOME").value+"</JBOSSHOME>\r\n"	+"<TOMCATHOME>"+document.getElementById("id_TOMCATHOME").value+"</TOMCATHOME>\r\n"+"<SMTPHOST>"+document.getElementById("id_SMTPHOST").value+"</SMTPHOST>\r\n";
		if(document.getElementById("id_SMTPUSERNAME").value.length > 0)
		{
			document.getElementById("id_SAVE_STRING").value = document.getElementById("id_SAVE_STRING").value + "<SMTPUSERNAME>"+document.getElementById("id_SMTPUSERNAME").value+"</SMTPUSERNAME>\r\n";
		}
		if(document.getElementById("id_SMTPPASSWORD").value.length > 0)
		{
			document.getElementById("id_SAVE_STRING").value = document.getElementById("id_SAVE_STRING").value +"<SMTPPASSWORD>"+document.getElementById("id_SMTPPASSWORD").value+"</SMTPPASSWORD>\r\n";
		
		}
		if(document.getElementById("id_POP3HOST").value.length > 0)
		{
			document.getElementById("id_SAVE_STRING").value = document.getElementById("id_SAVE_STRING").value + "<POP3HOST>"+document.getElementById("id_POP3HOST").value+"</POP3HOST>\r\n";
		
		}
		if(document.getElementById("id_POP3USERNAME").value.length > 0)
		{
			document.getElementById("id_SAVE_STRING").value = document.getElementById("id_SAVE_STRING").value + "<POP3USERNAME>"+document.getElementById("id_POP3USERNAME").value+"</POP3USERNAME>\r\n";
		
		}
		if(document.getElementById("id_POP3PASSWORD").value.length > 0)
		{
			document.getElementById("id_SAVE_STRING").value = document.getElementById("id_SAVE_STRING").value + "<POP3PASSWORD>"+document.getElementById("id_POP3PASSWORD").value+"</POP3PASSWORD>\r\n";
		}
		if(document.getElementById("id_MAILFROM").value.length > 0)
		{
			document.getElementById("id_SAVE_STRING").value = document.getElementById("id_SAVE_STRING").value + "<MAILFROM>"+document.getElementById("id_MAILFROM").value+"</MAILFROM>\r\n";
		}

		if(document.getElementById("id_J2EE_VERSION").value.length > 0)
		{
			document.getElementById("id_SAVE_STRING").value = document.getElementById("id_SAVE_STRING").value + "<J2EE_VERSION>"+document.getElementById("id_J2EE_VERSION").value+"</J2EE_VERSION>\r\n";
		}

		if(document.getElementById("id_DBNAME").value.length > 0)
		{
			document.getElementById("id_SAVE_STRING").value = document.getElementById("id_SAVE_STRING").value + "<DBNAME>"+document.getElementById("id_DBNAME").value+"</DBNAME>\r\n";
		}
		if(document.getElementById("id_CONTENT_ENCODING").value.length > 0)
		{
			document.getElementById("id_SAVE_STRING").value = document.getElementById("id_SAVE_STRING").value + "<CONTENT_ENCODING>"+document.getElementById("id_CONTENT_ENCODING").value+"</CONTENT_ENCODING>\r\n";
		}
		if(document.getElementById("id_DOWNLOAD_PATH").value.length > 0)
		{
			document.getElementById("id_SAVE_STRING").value = document.getElementById("id_SAVE_STRING").value + "<DOWNLOAD_PATH>"+document.getElementById("id_DOWNLOAD_PATH").value+"</DOWNLOAD_PATH>\r\n";
		}

		if(document.getElementById("id_READ_MSG_PATH").value.length > 0)
		{
			document.getElementById("id_SAVE_STRING").value = document.getElementById("id_SAVE_STRING").value + "<READ_MSG_PATH>"+document.getElementById("id_READ_MSG_PATH").value+"</READ_MSG_PATH>\r\n";
		}
		document.getElementById("id_SAVE_STRING").value = document.getElementById("id_SAVE_STRING").value + "</IBASE>\r\n";
	//*/
		//alert(document.getElementById("id_SAVE_STRING").value);
	}

}

function validate()
{
	if((!(IsValidHour(document.getElementById("id_MIN_HR").value))) || (!(IsValidHour(document.getElementById("id_MAX_HR").value)))  )
	{
		alert("Invalid entry in 'Min Hour' or 'Max Hour' field");
		return false;
		
	}
	else if(!(IsNumeric(document.getElementById("id_MSG_TRACE_LVL").value)) || ((document.getElementById("id_MSG_TRACE_LVL").value) == "" ))
	{
		alert("Enter Number field in 'Msg Trace' Lvl ");
		return false;
		
	}
	else if ((!(IsValidTime(document.getElementById("id_TIMER_DELAY").value)))||(!(IsValidTime(document.getElementById("id_IDLE_TIME").value))))
	{
		alert("Invalid entry in 'Timer Delay' or 'Idle Time' field");
		return false;
	}
	else if((!(IsValidDay(document.getElementById("id_COLLECTION_DAY").value))) || (!(IsValidDay(document.getElementById("id_OPENING_DAY").value))) || (!(IsValidDay(document.getElementById("id_MIN_DAY").value))) || (!(IsValidDay(document.getElementById("id_MAX_DAY").value))))
	{
		alert("Invalid entry in 'Min Day/Max Day/Collection Day/Opening Day' field");
		return false;
	}
	else if((document.getElementById("id_REC_SEP").value) == "" )
	{
		alert(" 'Rec Sep' field should not be Empty");
		return false;
	}
	else if (((document.getElementById("id_FIELD_SEP").value) == "" ))
	{
		alert(" 'Field Sep' field should not be Empty");
		return false;
	}
	else if ((document.getElementById("id_FIELD_SEP").value) == (document.getElementById("id_REC_SEP").value) )
	{
		alert(" 'Field Sep' field Should not be same as 'Rec Sep'");
		return false;	
	}
	else 
	{
		document.getElementById("id_SAVE_STRING").value =  "<?xml version=\"1.0\"?>\r\n" 
													+ "<SYSTEM_PARAMS>\r\n"
													+ "<MULTI_CTX>N</MULTI_CTX>\r\n"
													+ "<DEF_CTX>JNJ</DEF_CTX>\r\n"
													+ "<REC_SEP>"+document.getElementById("id_REC_SEP").value+"</REC_SEP>\r\n"
													+ "<FIELD_SEP>"+document.getElementById("id_FIELD_SEP").value+"</FIELD_SEP>\r\n"
													+ "<IDLE_TIME>"+document.getElementById("id_IDLE_TIME").value+"</IDLE_TIME>\r\n"
													+ "<MSG_TRACE_LVL>"+document.getElementById("id_MSG_TRACE_LVL").value+"</MSG_TRACE_LVL>\r\n"
													+ "<PRD_CD_LEN>4</PRD_CD_LEN>\r\n"
													+ "<MIN_DAY>"+document.getElementById("id_MIN_DAY").value+"</MIN_DAY>\r\n"
													+ "<MIN_HR>"+document.getElementById("id_MIN_HR").value+"</MIN_HR>\r\n"
													+ "<MAX_DAY>"+document.getElementById("id_MAX_DAY").value+"</MAX_DAY>\r\n"
													+ "<MAX_HR>"+document.getElementById("id_MAX_HR").value+"</MAX_HR>\r\n"
													+ "<PSTMT_FLAG>false</PSTMT_FLAG>\r\n"
													+ "<TIMER_DELAY>"+document.getElementById("id_TIMER_DELAY").value+"</TIMER_DELAY>\r\n"
													+ "<DB_NAME>SEQUEL</DB_NAME>\r\n"
													+ "<COLLECTION_DAY>"+document.getElementById("id_COLLECTION_DAY").value+"</COLLECTION_DAY>\r\n"
													+ "<OPENING_DAY>"+document.getElementById("id_OPENING_DAY").value+"</OPENING_DAY>\r\n"
													+ "</SYSTEM_PARAMS>";

	}
	
}

function IsNumeric(sText)
{
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;
	for (i = 0; i < sText.length && IsNumber == true; i++) 
	{ 
		Char = sText.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) 
		{
			IsNumber = false;
		}
	}
	return IsNumber;
}
function IsValidHour(val)
{
	if(!(IsNumeric(val)) ||(val == "")|| ((parseInt(val)< 0) || (parseInt(val) > 23)) )
	{
		alert("Invalid entry in hour field,(0-23)");
		return false;
	}
	else
	{
		return true;
	}
	
}

function IsValidDay(val)
{
	if(!(IsNumeric(val)) ||(val == "")|| ((parseInt(val)<= 0) || (parseInt(val) > 7)) )
	{
		alert("Invalid Entry in day  Field,(1-7)");
		return false;
	}
	else
	{
		return true;
	}
	
}
function IsValidTime(val)
{
	if(!(IsNumeric(val)) ||(val == "")|| (parseInt(val)<= 0))
	{
		alert("Invalid entry in Time field");
		return false;
	}
	else
	{
		return true;
	}
}