//ajax related
function urlEncode( text3s )
{
	// The javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" + // Numeric
	"ABCDEFGHIJKLMNOPQRSTUVWXYZ" + // Alphabetic 
	"abcdefghijklmnopqrstuvwxyz" +
	"-_.!~*'()"; // RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";
	var plaintext = text3s;
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
		if (ch == " ") {
			encoded += "+"; // x-www-urlencoded, rather than %20
		} 
		else if (SAFECHARS.indexOf(ch)!= -1) {
			encoded += ch; 
		} 
		else {
			var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
			} 
			else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt (charCode & 0xF);
			}
		}
	} 
	return encoded;
} 

function collectFormData(myForm, myFormArray){			
	var els = myForm.elements;
	var str = "";
	var name = "";
	for(var i=0; i<els.length; i++){				
		if(els[i].type!="submit" && els[i].type!="button"){
			if( els[i].name!="" || els[i].id!=""){
				name = (els[i].name!=""?els[i].name:els[i].id);						
				if(els[i].type == "radio"){
					if(els[i].checked){								
						if(str.length > 0)str += "&";
						if( myFormArray==undefined)
							str += name + "=" + urlEncode(els[i].value);								
						else
							str += name + "=" + urlEncode(myFormArray[name]);														
					}
				}
				else{												
					if(myFormArray && myFormArray[name]){								
						if(str.length > 0)str += "&";	
						str += name + "=" + urlEncode(myFormArray[name]);																	
					}	
					else{
						if(str.length > 0)str += "&";	
						str += name + "=" + urlEncode(els[i].value);									
					}	
				}
			}
		}
	}		    
	return str;
}

function cancelDirectSubmission(){
	return false;
}

//updating options in the html listbox
function updateOption( selectBox, value, text){
	for(var i=0; i<selectBox.options.length; ++i){
		if(selectBox.options[i].value == value ){
		//alert(value);
			selectBox.options[i].text = text;
			return true;
		}
	}
	return false;
}


function makeRequest(url, responseHandler, postData) {

	var http_request = false;
	
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
			// See note below about this line
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	
	if (!http_request) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	
	http_request.onreadystatechange = function() { responseHandler(http_request); };

	if( postData == null ){		
			http_request.open('GET', url, true);
		http_request.send(null);					
	}
	else {					//to be corrected for posting data
			http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http_request.open('POST', url, true);
		http_request.send( postData );
	}
}

//     **********************************************************
//     These javascript routines are used for form validation    
//     **********************************************************
function isEmpty(sTextField)
{
  if ((sTextField.value.length == 0) ||
      (sTextField.value == null))
  {
    return true;
  }
  else
  {
    return false;
  }
}

function isNumeric(sText, valueFrom, valueTo)
{
  var validChars = "-0123456789.";
  var isNumber = true;
  var testChar;

  for (i=0; i < sText.length && isNumber == true; i++)
  {
    testChar = sText.charAt(i);
    if (validChars.indexOf(testChar) == -1)
    {
      isNumber = false;
    }
  }
    
  var value = parseFloat(sText);   
  if( isNumber && valueFrom!=undefined ){		
	if( value < valueFrom )
		isNumber = false;
  }
  
  if( isNumber && valueTo!=undefined ){	
	if( value > valueTo )
		isNumber = false;
  }
 
  return isNumber;
}

function isInteger(sText, valueFrom, valueTo)
{
  var validChars = "-0123456789";
  var isNumber = true;
  var testChar;

  for (i=0; i < sText.length && isNumber == true; i++)
  {
    testChar = sText.charAt(i);
    if (validChars.indexOf(testChar) == -1)
    {
      isNumber = false;
    }
  }
    
  var value = parseInt(sText);   
  if( isNumber && valueFrom!=undefined ){		
	if( value < valueFrom )
		isNumber = false;
  }
  
  if( isNumber && valueTo!=undefined ){	
	if( value > valueTo )
		isNumber = false;
  }
 
  return isNumber;
}


function isEmailAddress(txtEmail)
  {	 
    if (txtEmail.value.length != 0)
    { 
	var e_check  = txtEmail.value;

	if(txtEmail.value.indexOf(" ") != -1)	
	{
	alert("Please enter correct E-Mail ID without any spaces in it.");
	txtEmail.focus(); 
	return false;
	}

	if(txtEmail.value.indexOf("@") == -1)	
	{
	alert("Invalid E-Mail ID! Please enter correct E-Mail ID.");
	txtEmail.focus(); 
	return false;
	}
   	validarr = txtEmail.value.split("@");
   
   	if(validarr[0].length==0)   	
   	{
   	alert("Invalid E-Mail ID! Please enter the correct E-mail ID.");
   	txtEmail.focus(); 
   	return false;
   	}
  	if(validarr[1].indexOf("@") >=0)   	
  	{
   	alert("Invalid E-Mail ID! Please enter the correct E-mail ID.");
   	txtEmail.focus(); 
   	return false;
   	}
   	if(validarr[1].length==0)   	
   	{
   	alert("Invalid E-Mail ID! Please enter the correct E-mail ID.");
   	txtEmail.focus(); 
   	return false;
   	}
   	if(validarr[1].length != 0)   	
   	 { 

		if(validarr[1].indexOf(".") == -1)     	
		{
		alert("Invalid E-Mail ID! Please enter the correct E-mail ID.");
		txtEmail.focus(); 
		return false;
		}
		validemail = validarr[1].split(".");
		 if(validemail[0].length==0)   		
		 { 
		 alert("Invalid E-Mail ID! Please enter the correct E-mail ID.");
		 txtEmail.focus(); 
		 return false;
		}
		if(validemail[1].length==0)  		
		{
		alert("Invalid E-Mail ID! Please enter the correct E-mail ID.");
		txtEmail.focus(); 
		return false;
		}
	}   // end of of validemail
	return true;
}
}
     


var myDateSeparator;
myDateSeparator = "/";
function mySQLToUSDate( argDate){
	var mySQLDate = new String(argDate);
	var yyyy = mySQLDate.substring(0, 4);
	var mm = mySQLDate.substring(5, 7);
	var dd = mySQLDate.substring(8,10);
	
	return (mm + myDateSeparator + dd + myDateSeparator + yyyy);
}

function USDateToMySQL( argDate){
	var usDate = new String(argDate);
	var yyyy = usDate.substring(6, 10);
	var mm = usDate.substring(0, 2);
	var dd = usDate.substring(3,5);
	
	return (yyyy + "-" + mm + "-" + dd);
}

function USDateToMySQL( argDate){
	var usDate = new String(argDate);
	var yyyy = usDate.substring(6, 10);
	var mm = usDate.substring(0, 2);
	var dd = usDate.substring(3,5);
	
	return (yyyy + "-" + mm + "-" + dd);
}

function addToDate( argDate, argDays ){
	var mySQLDate = new String(argDate);
	var yyyy = mySQLDate.substring(0, 4);
	var mm = mySQLDate.substring(5, 7);
	var dd = mySQLDate.substring(8,10);
	
	var vouchDate = new Date();
	vouchDate.setFullYear(yyyy);
	vouchDate.setMonth( parseFloat(mm) - 1);
	vouchDate.setDate( parseFloat(dd) + argDays);
	
	//alert(vouchDate);
	
	var vouchDay = new String(vouchDate.getDate());
	var vouchMonth = new String(vouchDate.getMonth()+1);
	var vouchYear = new String(vouchDate.getFullYear());
  
	if (vouchDay.length <2) vouchDay = "0" + vouchDay;
	if (vouchMonth.length<2) vouchMonth = "0" + vouchMonth;
	strDate = vouchMonth + myDateSeparator + vouchDay + myDateSeparator + vouchYear;
	return strDate;		
}

function validateForUSDate(strDate)
{ 	strDate = strDate.replace("-",myDateSeparator);
	strDate = strDate.replace(".",myDateSeparator);
	
	var regexp1, regexp2, regexp3, regexp4;														  
	regexp1 = /^(\d{2}\/\d{2}\/\d{4})$/;
	regexp2 = /^(\d{1}\/\d{2}\/\d{4})$/;
	regexp3 = /^(\d{2}\/\d{1}\/\d{4})$/;
	regexp4 = /^(\d{1}\/\d{1}\/\d{4})$/;	
		
	if( regexp1.test(strDate) == false && regexp2.test(strDate) == false && regexp3.test(strDate) == false && regexp4.test(strDate) == false )
	{   alert("Incorrect date format, please specify dates in 'mm/dd/yyyy' format.");									
		return false;
	}						
	
	else
	{	var str = new String(strDate);											
		var arrDate = str.split(myDateSeparator);
		
		if( arrDate[0]< 1 || arrDate[0] >12 )
		{ alert("Invalid month");
			return false;
		}
		
		if( arrDate[1]< 1 || arrDate[1] >31 )
		{ alert("Invalid day");
			return false;
		}					
											
		var vouchDate = new Date();
		vouchDate.setFullYear(arrDate[2]);
		vouchDate.setMonth(arrDate[0]-1);
		vouchDate.setDate(arrDate[1]);
		
		var vouchDay = new String(vouchDate.getDate());
		var vouchMonth = new String(vouchDate.getMonth()+1);
		var vouchYear = new String(vouchDate.getFullYear());
	  
		if (vouchDay.length <2) vouchDay = "0" + vouchDay;
		if (vouchMonth.length<2) vouchMonth = "0" + vouchMonth;
		strDate = vouchMonth + myDateSeparator + vouchDay + myDateSeparator + vouchYear;
		return strDate;									
	}		
}

function validateForIndianDate(strDate)
{ 	
	while(strDate.indexOf(" ")!=-1 ){
		strDate = strDate.replace(" ", "");
	}	
	
	while( strDate.indexOf("-")!=-1 ){
		strDate = strDate.replace("-", myDateSeparator);
	}
	
	while( strDate.indexOf(".")!=-1 ){
		strDate = strDate.replace(".", myDateSeparator);
	}
	
	
	var regexp1, regexp2, regexp3, regexp4;														  
	regexp1 = /^(\d{2}\/\d{2}\/\d{4})$/;
	regexp2 = /^(\d{1}\/\d{2}\/\d{4})$/;
	regexp3 = /^(\d{2}\/\d{1}\/\d{4})$/;
	regexp4 = /^(\d{1}\/\d{1}\/\d{4})$/;		
	regexp5 = /^(\d{2}\/\d{2}\/\d{2})$/;
	regexp6 = /^(\d{1}\/\d{2}\/\d{2})$/;
	regexp7 = /^(\d{2}\/\d{1}\/\d{2})$/;
	regexp8 = /^(\d{1}\/\d{1}\/\d{2})$/;
	
		
	if( regexp1.test(strDate) == false && regexp2.test(strDate) == false && regexp3.test(strDate) == false && regexp4.test(strDate) == false &&  regexp5.test(strDate) == false && regexp6.test(strDate) == false && regexp7.test(strDate) == false && regexp8.test(strDate) == false )
	{   
		alert("Incorrect date format, please specify dates in 'dd/mm/yyyy' format.");									
		return false;
	}	
	else
	{	var str = new String(strDate);											
		var arrDate = str.split(myDateSeparator);
				
		if( arrDate[0]< 1 || arrDate[0] >31 )
		{ 
			alert("Invalid day.");
			return false;
		}					
		
		if( arrDate[1]< 1 || arrDate[1] >12 )
		{ 
			alert("Invalid month.");
			return false;
		}
		
		/*
		var vouchDate = new Date();
		vouchDate.setDate(arrDate[0]);
		vouchDate.setMonth(arrDate[1]-1);
		vouchDate.setFullYear(arrDate[2]);
		
		var vouchDay = new String(vouchDate.getDate());
		var vouchMonth = new String(vouchDate.getMonth()+1);
		var vouchYear = new String(vouchDate.getFullYear());
	  
		if (vouchDay.length <2) vouchDay = "0" + vouchDay;
		if (vouchMonth.length<2) vouchMonth = "0" + vouchMonth;
		strDate = vouchMonth + myDateSeparator + vouchDay + myDateSeparator + vouchYear;
		*/
		
		return strDate;									
	}		
}


function formatNumber(myNum, numOfDec) 
{ 
  var decimal = 1 ;
  for(i=1; i<=numOfDec;i++) 
	 decimal = decimal * 10; 

  var myFormattedNum = (Math.round( myNum * decimal)/decimal) ;
    
  return( myFormattedNum.toFixed(numOfDec) ) ;
}


function ceilNumber( myNum )
{
	var i;
	i=0;
	while(true)
	{
		if( i>= myNum ) 
			return i;
		++i;
	}	
}

//inline pop up related
function showInlineForm() {
	for (var i=0; i<showInlineForm.arguments.length; i++) {
		var element = document.getElementById(showInlineForm.arguments[i]);
		element.style.display = "block";
	}
}

function hideInlineForm() {
	for (var i=0; i<hideInlineForm.arguments.length; i++) {
		var element = document.getElementById(hideInlineForm.arguments[i]);
		element.style.display = "none";
	}
}



// JavaScript Document
/******************************************************/
//begin - adding and removing options in the html listbox 

function selectOptionByValue( selectBox, value){
	for(var i=0; i<selectBox.options.length; ++i){
		if(selectBox.options[i].value == value ){
			selectBox.options[i].selected = true;
			return true;
		}
	}
	return false;
}

//function to dynamically add an option to A html listbox
function addOption(selectBox, value, text) {
	var optn = document.createElement("OPTION");
	optn.text = text;
	optn.value = value;
	selectBox.options.add(optn);
}

function addOptionsToList(selectBox, arrayOptions) {	
	var i ;
	for(i=0; i<arrayOptions.length; ++i)
		addOption(selectBox, arrayOptions[i][0], arrayOptions[i][1]);
}

//removing all options
function removeAllOptions(selectBox)
{
	var i;
	for(i=selectBox.options.length-1;i>=0;i--)
	{	selectBox.remove(i);
	}
}

//removing selected option
function removeOptions(selectBox)
{
	var i;
	for(i=selectBox.options.length-1;i>=0;i--)
	{
		if(selectBox.options[i].selected)
		selectBox.remove(i);
	}
}

//removing a specified option
function removeOption(selectBox, index)
{
	if(index < selectBox.options.length)
		selectBox.remove(index);
}

//end - adding and removing options in the html listbox ******
/******************************************************/

//convert string to proper case
function ConvertToProperCase(str)
{
	strTemp = str;
	strTemp = strTemp.toLowerCase();
	var test="";
	var isFirstCharOfWord = 1;
	for (var intCount = 0; intCount < strTemp.length; intCount++)
	{
	var temp = strTemp.charAt(intCount);
	if (isFirstCharOfWord == 1){
	temp = temp.toUpperCase();
	}
	test = test + temp;
	if (temp == " "){
	isFirstCharOfWord = 1;
	}
	else 
	isFirstCharOfWord = 0;
	}
	str = test;
	//alert(str);
	return str;
}









//javascript code for color change on focus and blur field  and moving using enter key button 
function onFocusControl(e){
	this.style.backgroundColor = "lightyellow";
	//this.style.border = "5px";
}

function onLooseFocusControl(e){
	this.style.backgroundColor = "";
	//this.style.border = "1px";
}

var nav_browser = window.Event ? true : false;
var keyCode

if( nav_browser ){
	window.captureEvents(Event.KEYDOWN);
	window.onkeydown = NetscapeEventHandler_KeyDown;
} else {
	document.onkeydown = MicrosoftEventHandler_KeyDown;
}

function NetscapeEventHandler_KeyDown(e){
	keyCode = e.which;
}

function MicrosoftEventHandler_KeyDown(){
	keyCode = event.keyCode;
}


function autotabToNextField(textbox){
	if( keyCode==13 ) {
		getNextControlInForm(textbox).focus();
	}
}

function getNextControlInForm(textbox) {
	var i = 0;
	while (i < textbox.form.elements.length-1){
		if( textbox.form.elements[i] == textbox ){			
			while( true ){
				if( textbox.form.elements[i+1].disabled==false && (textbox.form.elements[i+1].readOnly==false ) && textbox.form.elements[i+1].type!="hidden" )
					return textbox.form.elements[i+1];
				else {
					++i;
					if(  !(i<textbox.form.elements.length-1) )
						return;							
				}	
			}
		} else {
			i++;
		}
	}

	//I use a link to send the page... so after al textboxes are filled I move to the send link
	return;
}

function onKeyUpControl(e){		
	autotabToNextField( this );
}

function attachOnFocusHighlightFields( myForm, exceptions ){
	return;	
    
	var els = myForm.elements;
	var str = "";
	var name = "";
	for(var i=0; i<els.length; i++){				
		if(els[i].type!="submit" && els[i].type!="button"  ){
			if( els[i].name!="" || els[i].id!=""){
				name = (els[i].name!=""?els[i].name:els[i].id);						
				YAHOO.util.Event.addListener(els[i], "focus", onFocusControl);
				YAHOO.util.Event.addListener(els[i], "blur", onLooseFocusControl);								
			}
		}
	}	
}

function attachOnEnterMoveToNextField( myForm, exceptions ){	
	return ;		
	var els = myForm.elements;
	var str = "";
	var name = "";
	for(var i=0; i<els.length; i++){				
		if( els[i].type!="submit" && els[i].type!="button" && els[i].type != "textarea" && els[i].type != "hidden" ){
			if( els[i].name!="" || els[i].id!=""){
				name = ( els[i].name!=""?els[i].name:els[i].id );										
				YAHOO.util.Event.addListener(els[i], "keyup", onKeyUpControl);				
			}
		}
	}		
}

 var myDateSeparator;
    myDateSeparator = "-";
    		
		function validateEnglishDate(strDate)
			{ 			
							var regexp1, regexp2, regexp3, regexp4;														  
							regexp1 = /^(\d{2}-\d{2}-\d{4})$/;
							regexp2 = /^(\d{1}-\d{2}-\d{4})$/;
							regexp3 = /^(\d{2}-\d{1}-\d{4})$/;
							regexp4 = /^(\d{1}-\d{1}-\d{4})$/;							
														
							if( regexp1.test(strDate) == false && regexp2.test(strDate) == false && regexp3.test(strDate) == false && regexp4.test(strDate) == false )
							{   alert("Invalid date, please give correct date in dd-mm-yyyy format.");									
									return false;
							}						
							
							else
							{		var str = new String(strDate);									
									var mySeparator = "-";
									var arrDate = str.split(mySeparator);
									
									if( arrDate[0]< 1 || arrDate[0] >31 )
									{ alert("Invalid day");
										return false;
									}
															
									if( arrDate[1]< 1 || arrDate[1] >12 )
									{ alert("Invalid month");
										return false;
									}						
																		
									var vouchDate = new Date();
									vouchDate.setFullYear(arrDate[2]);
									vouchDate.setMonth(arrDate[1]-1);
									vouchDate.setDate(arrDate[0]);
									
									var vouchDay = new String(vouchDate.getDate());
									var vouchMonth = new String(vouchDate.getMonth()+1);
									var vouchYear = new String(vouchDate.getFullYear());
								  
								  if (vouchDay.length <2) vouchDay = "0" + vouchDay;
								  if (vouchMonth.length<2) vouchMonth = "0" + vouchMonth;
									strDate = vouchDay + myDateSeparator + vouchMonth + myDateSeparator + vouchYear;
									return strDate;									
							}		
			}
//end of this functionality
//Calender
function displayCalender(calenderId, textBoxName, container, showId){

		YAHOO.util.Event.onDOMReady(function(){
		
		var Event = YAHOO.util.Event,
			Dom = YAHOO.util.Dom,
			dialog,
			calendar;

		var showBtn = Dom.get(showId);
			
		Event.on(showBtn, "click", function() {
			// Lazy Dialog Creation - Wait to create the Dialog, and setup document click listeners, until the first time the button is clicked.
			if (!dialog) {
				// Hide Calendar if we click anywhere in the document other than the calendar
				Event.on(document, "click", function(e) {
					var el = Event.getTarget(e);
					var dialogEl = dialog.element;
					if (el != dialogEl && !Dom.isAncestor(dialogEl, el) && el != showBtn && !Dom.isAncestor(showBtn, el)) {
						dialog.hide();
					}
				});
				
				dialog = new YAHOO.widget.Dialog(container, {
					visible:false,
					width : "200px",
					context:[showId, "tl", "bl"],
					//buttons:[ {text:"Reset", handler: resetHandler, isDefault:true}, {text:"Close", handler: closeHandler}],
					draggable:false,
					close:true
				});
				dialog.setHeader('Pick A Date');
				dialog.setBody('<div id='+ calenderId +'></div>');
				dialog.render(document.body);

				dialog.showEvent.subscribe(function() {
					if (YAHOO.env.ua.ie) {
						// Since we're hiding the table using yui-overlay-hidden, we 
						// want to let the dialog know that the content size has changed, when
						// shown
						dialog.fireEvent("changeContent");
					}
				});
			}
			// Lazy Calendar Creation - Wait to create the Calendar until the first time the button is clicked.

			if (!calendar) {
				calendar = new YAHOO.widget.Calendar(calenderId, {
					iframe:false,          // Turn iframe off, since container has iframe support.
					hide_blank_weeks:true  // Enable, to demonstrate how we handle changing height, using changeContent
				});
				calendar.render();

				calendar.selectEvent.subscribe(function() {
					if (calendar.getSelectedDates().length > 0) {

						var selDate = calendar.getSelectedDates()[0];

						// Pretty Date Output, using Calendar's Locale values: Friday, 8 February 2008
					   // var wStr = calendar.cfg.getProperty("WEEKDAYS_LONG")[selDate.getDay()];
						var dStr = selDate.getDate();
					   //var mStr = calendar.cfg.getProperty("MONTHS_LONG")[selDate.getMonth()];
						var mStr = selDate.getMonth();
						var mStr1=mStr+1;
						var yStr = selDate.getFullYear();
						
						Dom.get(textBoxName).value =   dStr + "/" + mStr1 + "/" + yStr;
					
					} else {
						Dom.get(textBoxName).value = "";
					}
					dialog.hide();
				
				});

				calendar.renderEvent.subscribe(function() {
					// Tell Dialog it's contents have changed, which allows 
					// container to redraw the underlay (for IE6/Safari2)
					dialog.fireEvent("changeContent");
				});
			}

			var seldate = calendar.getSelectedDates();
			
			if (seldate.length > 0) {
				//// Set the pagedate to show the selected date if it exists
				calendar.cfg.setProperty("pagedate", seldate[0]);
				calendar.render();
			}

			dialog.show();
			});
		});
		
	//return;
}

function displayCalender1(calenderId, textBoxName, container, showId){

		YAHOO.util.Event.onDOMReady(function(){
		
		var Event = YAHOO.util.Event,
			Dom = YAHOO.util.Dom,
			dialog,
			calendar;

		var showBtn = Dom.get(showId);
			
		Event.on(showBtn, "click", function() {
			// Lazy Dialog Creation - Wait to create the Dialog, and setup document click listeners, until the first time the button is clicked.
			if (!dialog) {
				// Hide Calendar if we click anywhere in the document other than the calendar
				Event.on(document, "click", function(e) {
					var el = Event.getTarget(e);
					var dialogEl = dialog.element;
					if (el != dialogEl && !Dom.isAncestor(dialogEl, el) && el != showBtn && !Dom.isAncestor(showBtn, el)) {
						dialog.hide();
					}
				});
				
				dialog = new YAHOO.widget.Dialog(container, {
					visible:false,
					width : "200px",
					context:[showId, "tl", "bl"],
					//buttons:[ {text:"Reset", handler: resetHandler, isDefault:true}, {text:"Close", handler: closeHandler}],
					draggable:false,
					close:true
				});
				dialog.setHeader('Pick A Date');
				dialog.setBody('<div id='+ calenderId +'></div>');
				dialog.render(document.body);

				dialog.showEvent.subscribe(function() {
					if (YAHOO.env.ua.ie) {
						// Since we're hiding the table using yui-overlay-hidden, we 
						// want to let the dialog know that the content size has changed, when
						// shown
						dialog.fireEvent("changeContent");
					}
				});
			}
			// Lazy Calendar Creation - Wait to create the Calendar until the first time the button is clicked.

			if (!calendar) {
				calendar = new YAHOO.widget.Calendar(calenderId, {
					iframe:false,          // Turn iframe off, since container has iframe support.
					hide_blank_weeks:true  // Enable, to demonstrate how we handle changing height, using changeContent
				});
				calendar.render();

				calendar.selectEvent.subscribe(function() {
					if (calendar.getSelectedDates().length > 0) {

						var selDate = calendar.getSelectedDates()[0];

						// Pretty Date Output, using Calendar's Locale values: Friday, 8 February 2008
					   // var wStr = calendar.cfg.getProperty("WEEKDAYS_LONG")[selDate.getDay()];
						var dStr = selDate.getDate();
					   //var mStr = calendar.cfg.getProperty("MONTHS_LONG")[selDate.getMonth()];
						var mStr = selDate.getMonth();
						var mStr1=mStr+1;
						var yStr = selDate.getFullYear();
						
						Dom.get(textBoxName).value =   dStr + "-" + mStr1 + "-" + yStr;
					
					} else {
						Dom.get(textBoxName).value = "";
					}
					dialog.hide();
				
				});

				calendar.renderEvent.subscribe(function() {
					// Tell Dialog it's contents have changed, which allows 
					// container to redraw the underlay (for IE6/Safari2)
					dialog.fireEvent("changeContent");
				});
			}

			var seldate = calendar.getSelectedDates();
			
			if (seldate.length > 0) {
				//// Set the pagedate to show the selected date if it exists
				calendar.cfg.setProperty("pagedate", seldate[0]);
				calendar.render();
			}

			dialog.show();
			});
		});
		
	//return;
}

function isValidateIFSCCode(strIFSCCode){
    
    var IFSCCode_length = (new String(strIFSCCode)).length;
    if( IFSCCode_length != 11){                   
        return false;		
    }	
    
    var sLetter=new Array();
    sLetter = strIFSCCode;
    var ASCCODE = "";
    
    for(i=0;i<4;i++){        
        ASCCODE = sLetter.charCodeAt([i]);
        if( !((ASCCODE >= 65 && ASCCODE <= 90) || (ASCCODE >= 97 && ASCCODE <= 122)))
			return false;
    }
    
    ASCCODE = sLetter.charCodeAt([4]);
    if( ASCCODE != 48 ){ 
        return false;        
    }
        
    for( i=5; i<IFSCCode_length;i++)
	{       
		ASCCODE = sLetter.charCodeAt([i]);
		if( !(ASCCODE >= 48 && ASCCODE <= 57))
			return false;
	} 
    
    return true;
    // var isChar = true;
    
    // var mySplitResult = strIFSCCode.substring(0,4);
    // var regexp1 = /[^a-zA-Z]/g;
  
    // if (regexp1.test(mySplitResult) == true){
       // isChar = false;
       // alert("Please provide a valid IFSC Code."); 
       // return false;
    // }
      
    // if(isChar==true)
    // {
        // var IFSCCode_length = (new String(strIFSCCode)).length;
        // if( IFSCCode_length != 11){
            // alert("Please provide a valid IFSC Code.");            
            // return false;		
        // }		    
    // }    
}  

function isValidatePANNumber(strPANNumber){
    
    var PANNo_length = (new String(strPANNumber)).length;
    if( PANNo_length != 10){                   
        return false;		
    }		   
    var sLetter=new Array();
    sLetter = strPANNumber;
    var ASCCODE = "";
    
    for(i=0;i<5;i++){
        
        ASCCODE = sLetter.charCodeAt([i]);
        if( !((ASCCODE >= 65 && ASCCODE <= 90) || (ASCCODE >= 97 && ASCCODE <= 122)))
			return false;
    }
    
    for(i=5;i<9;i++){            
        ASCCODE = sLetter.charCodeAt([i]);
        if( !(ASCCODE >= 48 && ASCCODE <= 57))
			return false;
    }
    
    ASCCODE = sLetter.charCodeAt([9]);
    if( !((ASCCODE >= 65 && ASCCODE <= 90) || (ASCCODE >= 97 && ASCCODE <= 122))){
		return false;
    }
    return true;
}

function isValidateMobileNumber(strMobileNumber){

    var mobile_num_length = (new String(strMobileNumber)).length;   
    if( mobile_num_length != 10 && mobile_num_length != 11 ){
        alert("Please provide a valid mobile number");        
        return false;		
    }	
}



