﻿// JScript File

function replaceAll(str,from,to ) {
    var idx = str.indexOf( from );
    while ( idx > -1 ) {
        str = str.replace( from, to ); 
        idx = str.indexOf( from );
    }
    return str;
}
function editclose(gridname,page)
{
    var grid=gridname;
    grid = replaceAll(grid.id,"_", "$");
    var pageno='Page$' + page;
    javascript:__doPostBack(grid,pageno);
}
function doVal(form)
{
        var elm;        
        for(i = 0; i < form.elements.length; i++) 
		{	
			elm = form.elements[i];
			if (elm.type == "text" && elm.id=="ctl00_MainContent_txtpcountry") 
			{
		        //elm = form.ctl00_MainContent_txtpcountry;//form.elements[i];		
	            if(!elm.value=="")
	            {
	                if(!elm.value.match(/^([0-9])+$/))
	                {
		                alert("Please Enter Phone Digit In Number Format");
		                //elm.value="";
		                elm.focus();
		                return false;
	                }
	            }
	        }
	        if (elm.type == "text" && elm.id=="ctl00_MainContent_txtparea") 
			{
	                //elm=form.ctl00_MainContent_txtparea;
                    if(elm.value=="")
                    {
	                    alert("Please Enter Phone");
	                    elm.focus();
	                    return false;
                    }
                    if(!elm.value.match(/^([0-9]{3})+$/))
                    {
	                    alert("Please Enter Second 3 Phone Digit In Number Format");
	                    //elm.value="";
	                    elm.focus();
	                    return false;
                    }
	        }
	        if (elm.type == "text" && elm.id=="ctl00_MainContent_txtpstd") 
			{
	                //elm=form.ctl00_MainContent_txtpstd;
                    if(elm.value=="")
                    {
	                    alert("Please Enter Phone");
	                    elm.focus();
	                    return false;
                    }
                    if(!elm.value.match(/^([0-9]{3})+$/))
                    {
	                    alert("Please Enter Third 3 Phone Digit In Number Format");
	                    //elm.value="";
	                    elm.focus();
	                    return false;
                    }
            }
            if (elm.type == "text" && elm.id=="ctl00_MainContent_txtpno") 
			{
                     //elm=form.ctl00_MainContent_txtpno;
                    if(elm.value=="")
                    {
	                    alert("Please Enter Phone");
	                    elm.focus();
	                    return false;
                    }
                    if(!elm.value.match(/^([0-9]{4})+$/))
                    {
	                    alert("Please Enter Last 4 Phone Digit In Number Format");
	                    //elm.value="";
	                    elm.focus();
	                    return false;
                    }
            }
            if (elm.type == "text" && elm.id=="ctl00_MainContent_txtpext") 
			{
                     //elm=form.ctl00_MainContent_txtpext; 

                    if(!elm.value=="")
                    {
	                    if(!elm.value.match(/^([0-9])+$/))
	                    {
		                    alert("Please Enter Phone Digit In Number Format");
		                    //elm.value="";
		                    elm.focus();
		                    return false;
	                    }
                    }	
            }
       }
	return true;
}
function doVal1(form)
{

        var elm;        
        for(i = 0; i < form.elements.length; i++) 
		{	
			elm = form.elements[i];
			if (elm.type == "text" && elm.id=="txtMUSRXvarPco0") 
			{
		        //elm = form.ctl00_MainContent_txtpcountry;//form.elements[i];		
	            if(!elm.value=="")
	            {
	                if(!elm.value.match(/^([0-9])+$/))
	                {
		                alert("Please Enter Phone Digit In Number Format");
		                //elm.value="";
		                elm.focus();
		                return false;
	                }
	            }
	        }
	        if (elm.type == "text" && elm.id=="txtMUSRXvarPar0") 
			{
	                //elm=form.ctl00_MainContent_txtparea;
                    if(elm.value=="")
                    {
	                    alert("Please Enter Phone");
	                    elm.focus();
	                    return false;
                    }
                    if(!elm.value.match(/^([0-9]{3})+$/))
                    {
	                    alert("Please Enter Second 3 Phone Digit In Number Format");
	                    //elm.value="";
	                    elm.focus();
	                    return false;
                    }
	        }
	        if (elm.type == "text" && elm.id=="txtMUSRXvarPst0") 
			{
	                //elm=form.ctl00_MainContent_txtpstd;
                    if(elm.value=="")
                    {
	                    alert("Please Enter Phone");
	                    elm.focus();
	                    return false;
                    }
                    if(!elm.value.match(/^([0-9]{3})+$/))
                    {
	                    alert("Please Enter Third 3 Phone Digit In Number Format");
	                    //elm.value="";
	                    elm.focus();
	                    return false;
                    }
            }
            if (elm.type == "text" && elm.id=="txtMUSRXvarPno0") 
			{
                     //elm=form.ctl00_MainContent_txtpno;
                    if(elm.value=="")
                    {
	                    alert("Please Enter Phone");
	                    elm.focus();
	                    return false;
                    }
                    if(!elm.value.match(/^([0-9]{4})+$/))
                    {
	                    alert("Please Enter Last 4 Phone Digit In Number Format");
	                    //elm.value="";
	                    elm.focus();
	                    return false;
                    }
            }
            if (elm.type == "text" && elm.id=="txtMUSRXvarPex0") 
			{
                     //elm=form.ctl00_MainContent_txtpext; 

                    if(!elm.value=="")
                    {
	                    if(!elm.value.match(/^([0-9])+$/))
	                    {
		                    alert("Please Enter Phone Digit In Number Format");
		                    //elm.value="";
		                    elm.focus();
		                    return false;
	                    }
                    }	
            }
       }
	return true;
}
function dokey(first,next,len)
{
	if(first.value.length == len)
	{
		if(next!=null)
		    next.focus();
	}
}

