function validateEmailold(email)
{
//    var regExpObj = /^\w{1,}@\w{1,}[.]\w{2,}/;
    var regExpObj = /^\w{1,}@\w{1,}/;
    if (regExpObj.exec(email.value) == null)
    {
     alert ("'"+email.value + "' is not valid email address. Please enter valid value");
    email.select();
    email.focus();
    return (false);
    }
    else
    {
    return (true);
    }
}

function validateEmail(email)
{
    return (true);
}

function validatePin(pin)
{
    var regExpObj = /^[0-9]{6}/;
    if (regExpObj.exec(pin.value) == null)
    {
     alert (pin.id +" is too short or too long. Please enter valid value");
    pin.select();
    pin.focus();
    return (false);
    }
    else
    {
    return (true);
    }
};  
function validateAccountNo(pin)
{
    var regExpObj = /^[0-9]{4,6}/;
    if (regExpObj.exec(pin.value) == null)
    {
     alert ("'"+pin.value + "' is not valid " +pin.id +" . Please enter valid value");
    pin.select();
    pin.focus();
    return (false);
    }
    else
    {
    return (true);
    }
}
function validateVirtualNumber(pin)
{
    var regExpObj = /^[0-9]{10,12}/;
    if (regExpObj.exec(pin.value) == null)
    {
     alert ("'"+pin.value + "' is not valid " +pin.id +" . Please type valid value");
    pin.select();
    pin.focus();
    return (false);
    }
    else
    {
    return (true);
    }
}
function validateAuthorizationPin(pin)
{
    var regExpObj = /^\w{16}/;
    if (regExpObj.exec(pin.value) == null)
    {
     alert (pin.id +" is not valid. Please type valid value(Must be 16 characters long)");
    pin.select();
    pin.focus();
    return (false);
    }
    else
    {
    return (true);
    }
};    	
function validateSelect(select)
{
//    alert(select.options[select.selectedIndex].text);
if (select.options[select.selectedIndex].value == 'Please select...')
    {
    alert (' Please select ' + select.id + ' value');
    select.focus();
    return (false);       
    }
    else
    {
    return (true);
    }	
};
function validateDate(form)
{
    if ((form.yyyy.value == '--'))
	{
	alert (" Please select valid year of your birthday");
	//form.yyyy.select();
	form.yyyy.focus();
	return (false);	
	}
    if ((form.mm.value == '--'))
	{
	alert (" Please type select valid month of your birthday");
	//form.mm.select();
	form.mm.focus();
	return (false);	
	}	
    if (form.dd.value == '--') 
	{
	alert (" Please select valid day of your birthday");
	//form.dd.select();
	form.dd.focus();
	return (false);	
	}	
    return (true);	
	    
};
function validateText(text)
{
    if (text.value == '')
    {
    alert('Please enter valid value into ' + text.id +' field' );
    return (false);
    }
    return (true);
}    
function validateForm(form)
{
    if (!(validateAccountNo(form.account_number)))		{ return (false);}
    if (!(validatePin(form.account_pin)))		{ return (false);}
    if (!(validateText(form.name)))		{ return (false);}
    if (!(validateText(form.first_name)))		{ return (false);}
    if (!(validateText(form.last_name)))		{ return (false);}
    if (!(validateEmail(form.email)))		{ return (false);}
    if (!(validateSelect(form.country)))	{ return (false);}
    if (!(validateSelect(form.gender)))		{ return (false);}
    if (!(validateDate(form)))		{ return (false);}
    if (!(validateSelect(form.hobby)))		{ return (false);}
    return (true);	
    	
}
function validateFreeForm(form)
{
    if (!(validateText(form.name)))		{ return (false);}
    if (!(validateText(form.first_name)))		{ return (false);}
    if (!(validateText(form.last_name)))		{ return (false);}
    if (!(validateEmail(form.email)))		{ return (false);}
    if (!(validateSelect(form.country)))	{ return (false);}
    if (!(validateSelect(form.gender)))		{ return (false);}
    if (!(validateDate(form)))		{ return (false);}
    if (!(validateSelect(form.hobby)))		{ return (false);}
    return (true);	
    	
}

function numToString(number)
{
    number += '';
    return number;
} 
function createOptions(id,st,en)
{
    var tbody = document.getElementById(id);
    
    while (tbody.firstChild)
    {
    tbody.removeChild(tbody.firstChild);
    }
    	
    var newOption = document.createElement("option");											
    var newText = document.createTextNode("--");
    var ValueAttr = document.createAttribute("value")
    ValueAttr.value = "--";
    newOption.appendChild(newText);
    newOption.setAttributeNode(ValueAttr);
    tbody.appendChild(newOption);
    
    for (var i=st;i<=en;i++)
    {
        var newOption = document.createElement("option");											
        var newText = document.createTextNode(numToString(i));
        var ValueAttr = document.createAttribute("value")
	ValueAttr.value = i;
	newOption.appendChild(newText);
	newOption.setAttributeNode(ValueAttr)
        tbody.appendChild(newOption);
    }
}
function getSelectedValue(selectObject)
{
    return selectObject.options[selectObject.selectedIndex].text;
}       
