// JavaScript Document
function validate_admin_login()
{
    var username=document.getElementById("txt_username").value;
    var password=document.getElementById("txt_password").value;
    if(username=="")
    {
        alert("Please enter username");
        return false;
    }else if(password=="")
    {
        alert("Please enter password");
        return false;
    }else
    {
        return true;
    }

}

function ChkHomPageRate()
{
    if(document.getElementById("locationid").value == "")
    {
        alert("Please select location");
        document.getElementById("locationid").focus();
        return false;
    }
}

function Validate_SearchPin()
{
    if(document.getElementById("Pinnumber").value == 0)
    {
        alert("Please enter PIN Number");
        document.getElementById("Pinnumber").focus();
        return false;
    }
}
function Validate_RechargePin()
{
    var operatation_status = 0;
    var operation_length = document.anifrm.operation.length;
    for(var i=0; i<operation_length; i++)
    {
        if(document.anifrm.operation[i].checked==true)
        {
            operatation_status =1;
            break;
        }
    }

    if(document.getElementById("Pinnumber").value == 0)
    {
        alert("Please enter PIN Number");
        document.getElementById("Pinnumber").focus();
        return false;
    }else if(document.getElementById("recharge_amount_cc").value == 0 && document.getElementById("recharge_amount_cash").value == 0)
    {
        alert("Please enter recharge amount");
        document.getElementById("recharge_amount").focus();
        return false;
    }else if(document.getElementById("comments").value == 0)
    {
        alert("Please enter your comments");
        document.getElementById("comments").focus();
        return false;
    }else if(operatation_status == 0)
    {
        alert("Please select at least one mode of operation");
        return false;
    }else
    {
        return true;
    }
}
function Validate_UploadPin()
{
    if(document.getElementById("file_upload1").value == 0)
    {
        alert("Please select a file");
        document.getElementById("file_upload1").focus();
        return false;
    }
    
}
function Validate_AddPin()
{
    if(document.getElementById("product").value == "")
    {
        alert("Please select a product");
        document.getElementById("product").focus();
        return false;
    }else if(document.getElementById("noofpins").value == "")
    {
        alert("Please enter quantity");
        document.getElementById("noofpins").focus();
        return false;
    }
}
function Validate_AddNewPin()
{
    if(document.getElementById("product").value == "")
    {
        alert("Please select a product");
        document.getElementById("product").focus();
        return false;
    }else if(document.getElementById("pinnumber").value == 0)
    {
        alert("Please enter PIN Number");
        document.getElementById("pinnumber").focus();
        return false;
    }else if(isNaN(document.getElementById("pinnumber").value))
    {
        alert("Please enter numeric PIN Number");
        document.getElementById("pinnumber").focus();
        return false;
    }else if(document.getElementById("pinnumber").value.length < 5)
    {
        alert("Please enter atleast 5 digits PIN Number");
        document.getElementById("pinnumber").focus();
        return false;
    }
}

function AddLocalAccessNumber()
{
    if(document.getElementById("product").value == "")
    {
        alert("Please select a plan");
        document.getElementById("product").focus();
        return false;
    }else if(document.getElementById("selcountry").value == "")
    {
        alert("Please select country");
        document.getElementById("selcountry").focus();
        return false;
    }else if(document.getElementById("selstate").value == "")
    {
        alert("Please select state");
        document.getElementById("selstate").focus();
        return false;
    }else if(document.getElementById("city").value == 0)
    {
        alert("Please enter city");
        document.getElementById("city").focus();
        return false;
    }else if(document.getElementById("localaccess").value == 0)
    {
        alert("Please enter local access number");
        document.getElementById("localaccess").focus();
        return false;
    }else if(isNaN(document.getElementById("localaccess").value))
    {
        alert("Please enter numeric local access number");
        document.getElementById("localaccess").focus();
        return false;
    }else if(document.getElementById("localaccess").value.length != 10)
    {
        alert("Please enter 10 digit local access number");
        document.getElementById("localaccess").focus();
        return false;
    }
}


function openPopup(path, height, width)
{
    var min = 10000;
    var max = 99999;
    var num = Math.floor(Math.random() * (max - min + 1)) + min;

    window.open(path,num,"menubar=no,width="+width+",height="+height+",Top=150,Left=50,toolbar=no,resizable=yes, scrollbars=1");
}


function delconfirm(did,path)
 {

     var che = confirm("Are you sure, you want to delete this record");
    var url= path+"?delid="+did;
    if(che == true)
    {
        window.location.href = url;
    }
 }

function getre()
{
    tl = document.searchpinfrm;
    var permission = "";
    for (i = 0; i < tl.length; i++)
    {
        if(tl.elements[i].name == 'actionid')
        {
            if(tl.elements[i].checked == true)
            {
                permission = permission+tl.elements[i].value+", ";
            }
        }
    }
    document.searchpinfrm.idaction.value = permission;
}


function checkAll()
{
    var idval = '';
    for (i = 0; i < document.searchpinfrm.actionid.length; i++)
    {
        document.searchpinfrm.actionid[i].checked = true;
        idval = idval+""+document.searchpinfrm.actionid[i].value+", ";
    }
    document.searchpinfrm.idaction.value = idval;
}

function uncheckAll()
{
    var idval = '';
    for (i = 0; i < document.searchpinfrm.actionid.length; i++)
    {
        document.searchpinfrm.actionid[i].checked = false;
    }
    document.searchpinfrm.idaction.value = '';
}
function ManuallyValidation()
{
    if(document.searchpinfrm.idaction.value == '')
    {
        alert("Please select a record");
        return false;
    }else
    {
        return true;
    }
}

function ConfirmRecords()
 {
    if(document.searchpinfrm.idaction.value != '')
    {
        document.searchpinfrm.submit();
    }else
    {
        alert("No records selected");
        return false;
    }
 }

function ValidateChangePassword()
{
    var fieldpath = document.changepasswordfrm;
    if(fieldpath.oldpassword.value==0)
    {
        alert('Please Enter Old Password');
        fieldpath.oldpassword.focus();
        return false;
    }else if(fieldpath.newpassword.value==0)
    {
        alert('Please Enter New Password');
        fieldpath.newpassword.focus();
        return false;
    }else if(fieldpath.confirmpassword.value==0)
    {
        alert('Please Enter Confirm Password');
        fieldpath.confirmpassword.focus();
        return false;
    }else if(fieldpath.newpassword.value != fieldpath.confirmpassword.value)
    {
        alert('New Password & Confirm Password must be same');
        fieldpath.confirmpassword.focus();
        return false;
    }else
    {
        return true;
    }
}
function GetPhoneCardAmountBoucher(UserId)
{
    var PinNumber = document.getElementById('pinnumber').value;
    var randomnumber = Math.floor(Math.random()*110);
    var url = "getpinboucher.php?userid="+UserId+"&pinnumber="+PinNumber+"&randno="+randomnumber;
    xmlHttp = GetXmlHttpObject(handleresponsephoneboucher)
    xmlHttp.open("GET",url, true);
    xmlHttp.send(null);
    return true;
}

function handleresponsephoneboucher()
{

    if(xmlHttp.readyState == 4 || xmlHttp.readyState=="complete")
    {
        document.getElementById("ajaxphonecardamount").innerHTML = xmlHttp.responseText;
    }
    else
    {
        document.getElementById("ajaxphonecardamount").innerHTML= "<img src='images/ajax_loading.gif'>";
    }
}

function GetAdminRechargeAmount()
{
    var productid = document.getElementById('productid').value;
    var randomnumber = Math.floor(Math.random()*110);
    var url = "getrechargeamount.php?productid="+productid+"&randno="+randomnumber;
    xmlHttp = GetXmlHttpObject(handleresponseamount)
    xmlHttp.open("GET",url, true);
    xmlHttp.send(null);
    return true;
}

function handleresponseamount()
{
    if(xmlHttp.readyState == 4 || xmlHttp.readyState=="complete")
    {
        document.getElementById("calculationajax").innerHTML = xmlHttp.responseText;
    }
    else
    {
        document.getElementById("calculationajax").innerHTML= "<img src='images/ajax_loading.gif'>";
    }
}

function GetPhoneCardAmountNew()
{
    var description = document.getElementById('description').value;
    document.getElementById('surcharge').innerHTML="0.00";
    document.getElementById('totalAmountcharged').innerHTML="0.00";
    var randomnumber = Math.floor(Math.random()*110);
    var url = "getproducts.php?description="+description+"&randno="+randomnumber;
    xmlHttp = GetXmlHttpObject(handleresponsephonecardamount)
    xmlHttp.open("GET",url, true);
    xmlHttp.send(null);
    return true;
}

function handleresponsephonecardamount()
{
    if(xmlHttp.readyState == 4 || xmlHttp.readyState=="complete")
    {
        document.getElementById("ajaxphonecardamount").innerHTML = xmlHttp.responseText;
    }
    else
    {
        document.getElementById("ajaxphonecardamount").innerHTML= "<img src='images/ajax_loading.gif'>";
    }
}

function GetXmlHttpObject(handler)
{
var objXmlHttp=null
if (navigator.userAgent.indexOf("Opera")>=0)
   {
    alert("This example doesn't work in Opera")
    return
   }
if (navigator.userAgent.indexOf("MSIE")>=0)
   {
   var strName="Msxml2.XMLHTTP"
   if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
      {
      strName="Microsoft.XMLHTTP"
      }
   try
      {
          objXmlHttp=new ActiveXObject(strName)
          objXmlHttp.onreadystatechange=handler
          return objXmlHttp
      }
   catch(e)
      {
          alert("Error. Scripting for ActiveX might be disabled")
          return
      }
    }
if (navigator.userAgent.indexOf("Mozilla")>=0)
   {
       objXmlHttp=new XMLHttpRequest()
       objXmlHttp.onload=handler
       objXmlHttp.onerror=handler
       return objXmlHttp
   }
}

function AdminRechargeValidation()
{
     var dummy = new Date("December, 31, 2003");
         intMonth = dummy.getMonth();
         if(intMonth != 12)
     {
               intMonth = 1;
     }else
     {
               intMonth = 0;
     }
         var now = new Date();
         var expmon= parseInt(document.getElementById('month').value);
         var thismonth= now.getMonth() + intMonth;
         var expyear= parseInt(document.getElementById('year').value);
         var thisyear=now.getFullYear();

    if(document.getElementById('pinnumber').value=='')
    {
        alert("Select PIN Number");
        document.getElementById('pinnumber').focus();
        return false;
    }else if(document.getElementById('productid').value==0)
    {
        alert("Select Recharge Amount");
        document.getElementById('productid').focus();
        return false;
    }else if(document.getElementById('ccholdername').value=="")
    {
        alert("Enter Credit Card Owner Name");
        document.getElementById('ccholdername').focus();
        return false;
    }else if(document.getElementById('cardtype').value=="")
    {
        alert("Select Credit Card Type");
        document.getElementById('cardtype').focus();
        return false;
    }else if(document.getElementById('cardnumber').value=="")
    {
        alert("Enter Credit Card Number");
        document.getElementById('cardnumber').focus();
        return false;
    }else if(!validateCreditCard(document.getElementById('cardnumber').value, document.getElementById('cardtype').value.toLowerCase()))
    {
        alert("Check the \"Credit Card Number\" and try again.");
        document.getElementById('cardnumber').focus();
        return false;
    }else if(document.getElementById('month').value == "")
    {
        alert("Select Credit Card Expiry Month");
        document.getElementById('month').focus();
        return false;
    }else if(document.getElementById('year').value == "")
    {
        alert("Select Credit Card Expiry Year");
        document.getElementById('year').focus();
        return false;
    }else if(document.getElementById('year').value == "" || parseInt(document.getElementById('year').value) < now.getFullYear())
        {
           alert("Expiration year must be greater than or equal to " + now.getFullYear() + " ");
           document.getElementById('year').focus();
           return false;
        }else if(document.getElementById('month').value == "" || ( expyear == thisyear && expmon < thismonth ) )
        {
           alert("Select correct Expiration Month value");
           document.getElementById('month').focus();
           return false;
        }else if(document.getElementById('cvv').value==0)
        {
        alert('Enter CVV Number');
        document.getElementById('cvv').focus();
        return false;
    }
}

function AdminNewPinValidation()
{
     var dummy = new Date("December, 31, 2003");
         intMonth = dummy.getMonth();
         if(intMonth != 12)
     {
               intMonth = 1;
     }else
     {
               intMonth = 0;
     }
         var now = new Date();
         var expmon= parseInt(document.getElementById('month').value);
         var thismonth= now.getMonth() + intMonth;
         var expyear= parseInt(document.getElementById('year').value);
         var thisyear=now.getFullYear();

    if(document.getElementById('description').value=='')
    {
        alert("Select phone card type");
        document.getElementById('description').focus();
        return false;
    }else if(document.getElementById('productid').value==0)
    {
        alert("Select phone card amount");
        document.getElementById('productid').focus();
        return false;
    }else if(document.getElementById('ccholdername').value=="")
    {
        alert("Enter Credit Card Owner Name");
        document.getElementById('ccholdername').focus();
        return false;
    }else if(document.getElementById('cardtype').value=="")
    {
        alert("Select Credit Card Type");
        document.getElementById('cardtype').focus();
        return false;
    }else if(document.getElementById('cardnumber').value=="")
    {
        alert("Enter Credit Card Number");
        document.getElementById('cardnumber').focus();
        return false;
    }else if(!validateCreditCard(document.getElementById('cardnumber').value, document.getElementById('cardtype').value.toLowerCase()))
    {
        alert("Check the \"Credit Card Number\" and try again.");
        document.getElementById('cardnumber').focus();
        return false;
    }else if(document.getElementById('month').value == "")
    {
        alert("Select Credit Card Expiry Month");
        document.getElementById('month').focus();
        return false;
    }else if(document.getElementById('year').value == "")
    {
        alert("Select Credit Card Expiry Year");
        document.getElementById('year').focus();
        return false;
    }else if(document.getElementById('year').value == "" || parseInt(document.getElementById('year').value) < now.getFullYear())
        {
           alert("Expiration year must be greater than or equal to " + now.getFullYear() + " ");
           document.getElementById('year').focus();
           return false;
        }else if(document.getElementById('month').value == "" || ( expyear == thisyear && expmon < thismonth ) )
        {
           alert("Select correct Expiration Month value");
           document.getElementById('month').focus();
           return false;
        }else if(document.getElementById('cvv').value==0)
        {
        alert('Enter CVV Number');
        document.getElementById('cvv').focus();
        return false;
    }
}

//Check if entered digits are a valid number for the Credit Card
function validateCreditCard(cardNumber,cardType)
{
    var isValid = false;
    var ccCheckRegExp = /[^\d ]/;
    isValid = !ccCheckRegExp.test(cardNumber);

    if (isValid)
    {
        var cardNumbersOnly = cardNumber.replace(/ /g,"");
        var cardNumberLength = cardNumbersOnly.length;
        var lengthIsValid = false;
        var prefixIsValid = false;
        var prefixRegExp;

        switch(cardType)
        {
            case "mastercard":
            lengthIsValid = (cardNumberLength == 16);
            prefixRegExp = /^5[1-5]/;
            break;

            case "visa":
            lengthIsValid = (cardNumberLength == 16 || cardNumberLength == 13);
            prefixRegExp = /^4/;
            break;

            case "amex":
            lengthIsValid = (cardNumberLength == 15);
            prefixRegExp = /^3(4|7)/;
            break;

            case "discover":
            lengthIsValid = (cardNumberLength == 16);
            prefixRegExp = /^6011/;
            break;

            default:
            prefixRegExp = /^$/;
            alert("Card type not found");
        }

        prefixIsValid = prefixRegExp.test(cardNumbersOnly);
        isValid = prefixIsValid && lengthIsValid;
    }
    if (isValid)
    {
        var numberProduct;
        var numberProductDigitIndex;
        var checkSumTotal = 0;

        for (digitCounter = cardNumberLength - 1;       digitCounter >= 0;       digitCounter--)
        {
            checkSumTotal += parseInt (cardNumbersOnly.charAt(digitCounter));
            digitCounter--;
            numberProduct = String((cardNumbersOnly.charAt(digitCounter) * 2));
            for (var productDigitCounter = 0;
            productDigitCounter < numberProduct.length;         productDigitCounter++)
            {
                checkSumTotal += parseInt(numberProduct.charAt(productDigitCounter));
            }
        }
        isValid = (checkSumTotal % 10 == 0);
    }

    return isValid;
}

function couponValidation()
{
    if(document.getElementById('start_date').value=='')
    {
        alert("Please select start date");
        document.getElementById('start_date').focus();
        return false;
    }
    if(document.getElementById('end_date').value=='')
    {
        alert("Please select end date");
        document.getElementById('end_date').focus();
        return false;
    }
    if(document.getElementById('dis_amount').value=='' || document.getElementById('dis_amount').value==0)
    {
        alert("Please fill discount amount");
        document.getElementById('dis_amount').focus();
        return false;
    }
    if(document.getElementById('dis_type').value=='')
    {
        alert("Please select discount type");
        document.getElementById('dis_type').focus();
        return false;
    }
    if(document.getElementById('min_purchase').value=='' || document.getElementById('min_purchase').value=='')
    {
        alert("Please fill minimum purchase amount");
        document.getElementById('min_purchase').focus();
        return false;
    }
    if(document.getElementById('email1').value != '')
       {
           if(!isEmail_check(document.getElementById('email1').value))
        {
            alert("Please enter a valid First Email Id");
            document.getElementById('email1').focus();
            return false;
        }
       }

    if(document.getElementById('email2').value != '')
    {
        if(!isEmail_check(document.getElementById('email2').value))
        {
            alert("Please enter a valid Second Email Id");
            document.getElementById('email2').focus();
            return false;
        }
    }
    if(document.getElementById('email3').value != '')
    {
        if(!isEmail_check(document.getElementById('email3').value))
        {
            alert("Please enter a valid Third Email Id");
            document.getElementById('email3').focus();
            return false;
        }
    }
    if(document.getElementById('email4').value != '')
    {
        if(!isEmail_check(document.getElementById('email4').value))
        {
            alert("Please enter a valid Fourth Email Id");
            document.getElementById('email4').focus();
            return false;
        }
    }
    if(document.getElementById('email5').value != '')
    {
        if(!isEmail_check(document.getElementById('email5').value))
        {
            alert("Please enter a valid Fifth Email Id");
            document.getElementById('email5').focus();
            return false;
        }
    }
    if(document.getElementById('email6').value != '')
    {
        if(!isEmail_check(document.getElementById('email6').value))
        {
            alert("Please enter a valid Sixth Email Id");
            document.getElementById('email6').focus();
            return false;
        }
    }
    if(document.getElementById('email7').value != '')
    {
        if(!isEmail_check(document.getElementById('email7').value))
        {
            alert("Please enter a valid Seven Email Id");
            document.getElementById('email7').focus();
            return false;
        }
    }
    if(document.getElementById('email8').value != '')
    {
        if(!isEmail_check(document.getElementById('email8').value))
        {
            alert("Please enter a valid Eight Email Id");
            document.getElementById('email8').focus();
            return false;
        }
       }
    if(document.getElementById('email9').value != '')
    {
        if(!isEmail_check(document.getElementById('email9').value))
        {
            alert("Please enter a valid Ninth Email Id");
            document.getElementById('email9').focus();
            return false;
        }
    }
    if(document.getElementById('email10').value != '')
    {
        if(!isEmail_check(document.getElementById('email10').value))
        {
            alert("Please enter a valid Tenth Email Id");
            document.getElementById('email10').focus();
            return false;
        }
    }
    if(document.getElementById('email1').value == "" && document.getElementById('email2').value == "" && document.getElementById('email3').value == "" && document.getElementById('email4').value == "" && document.getElementById('email5').value == "" && document.getElementById('email6').value == "" && document.getElementById('email7').value == "" && document.getElementById('email8').value == "" && document.getElementById('email9').value == "" && document.getElementById('email10').value == "")
    {
        alert("Please enter at least one friend's email id");
        document.getElementById('email1').focus();
        return false;
    }
}

function unique(arrayName)
{
var newArray=new Array();
label:for(var i=0; i<arrayName.length;i++ )
{
    for(var j=0; j<newArray.length;j++ )
    {
        if(newArray[j]==arrayName[i])
            continue label;
    }
    newArray[newArray.length] = arrayName[i];
}
return newArray;
}

function PinlessSetupValidation()
{
    var AllANI = new Array();
    if(document.getElementById('Pinnumber_ani').value == '')
    {
        alert("Please enter Pinnumber");
        document.getElementById('Pinnumber_ani').focus();
        return false;
    }

    if(document.getElementById('pinless_setup1').checked == false && document.getElementById('pinless_setup2').checked == false && document.getElementById('pinless_setup3').checked == false && document.getElementById('pinless_setup4').checked == false && document.getElementById('pinless_setup5').checked == false && document.getElementById('pinless_setup6').checked == false && document.getElementById('pinless_setup7').checked == false && document.getElementById('pinless_setup8').checked == false && document.getElementById('pinless_setup9').checked == false && document.getElementById('pinless_setup10').checked == false)
    {
        alert("Please provide atleast one Phone number");
        return false;
    }


    for(i=1;i<10;i++) {
      var strElemID = 'pinless_setup' + i;
      var strPhoneID = 'phone' + i;
      var strPhoneMsg = 'Enter Phone Numbers as numerics only, thanks!';

        if(document.getElementById(strElemID).checked == true) {
            if(document.getElementById(strPhoneID).value == 0) {
                alert(strPhoneMsg);
                document.getElementById(strPhoneID).focus();
                return false;
            } else if(isNaN(document.getElementById(strPhoneID).value)) {
                alert(strPhoneMsg);
                document.getElementById(strPhoneID).focus();
                return false;
            } else if(document.getElementById(strPhoneID).value.length == 0) {
                alert('Enter Phone Numbers as numerics only, thanks!');
                document.getElementById(strPhoneID).focus();
                return false;
            } else {
                AllANI[i] = document.getElementById(strPhoneID).value;
            }
        } //end if-checked=true
    }//end-for

    var a =new Array();
    var k=0;
    for(var i=0; i<AllANI.length;i++ )
         {
        if(AllANI[i]!=undefined)
        {
                    a[k]=AllANI[i];
            k++;
        }
    }
    var b = unique(a);
    if(a.length != b.length)
    {
        alert("You can not enter same phone number more than one time.");
        return false;
    }
}

function SelectAll()
{
    for(i=0; i<document.pinlesssetupfrm.elements.length; i++)
    {
        if(document.pinlesssetupfrm.elements[i].type=="checkbox")
        {
            document.pinlesssetupfrm.elements[i].checked=true;
        }
    }
}

function UnselectAll()
{
    for(i=0; i<document.pinlesssetupfrm.elements.length; i++)
    {
        if(document.pinlesssetupfrm.elements[i].type=="checkbox")
        {
            document.pinlesssetupfrm.elements[i].checked=false;
        }
    }
}


function isEmail(str)
{
    var regex = /^[-_.a-z0-9]+@(([-_a-z0-9]+\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i;
    return regex.test(str);
}

function isEmail_check(str)
{
    var regex = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
    return regex.test(str);
}

function validateAddPrice()
{
    if(document.addprcfrm.product_id.value=="")
    {
        alert("please enter product id");
        document.addprcfrm.product_id.focus();
        return false;
    }
    if(document.addprcfrm.list_price.value=="")
    {
        alert("please enter list price");
        document.addprcfrm.list_price.focus();
        return false;
    }
    if(document.addprcfrm.list_price.value==0)
    {
        alert("Enter list price greater than 0");
        document.addprcfrm.list_price.focus();
        return false;
    }
    if(document.addprcfrm.sale_price.value=="")
    {
        alert("please enter sale price");
        document.addprcfrm.sale_price.focus();
        return false;
    }
    if(document.addprcfrm.sale_price.value==0)
    {
        alert("Enter sale price greater than 0");
        document.addprcfrm.sale_price.focus();
        return false;
    }

}

function validateEditPrice(counter)
{
       var tot_fld= document.updprcfrm.elements.length;
       var list_prc = new Array();
       var list_value = new Array();
       var sale_prc = new Array();
       var sale_value = new Array();
       var x=0;
       var y=0;
       for(var i=0; i<tot_fld; i++)
       {
           if(document.updprcfrm.elements[i].type == "text" && document.updprcfrm.elements[i].title =='list_price')
           {
           list_prc[x] =document.updprcfrm.elements[i].name;
           list_value[x] = document.updprcfrm.elements[i].value;
                   x++;
           }
           }
       for(var j=0; j<tot_fld; j++)
       {
           if(document.updprcfrm.elements[j].type == "text" && document.updprcfrm.elements[j].title =='sale_price')
           {
           sale_prc[y] =document.updprcfrm.elements[j].name;
           sale_value[y] = document.updprcfrm.elements[j].value;
                   y++;
           }
           }
       for(var k=0; k<list_prc.length; k++)
       {
            if(list_prc[k] && list_prc[k]!="" && list_value[k]=="")
        {
            alert("please enter list price");
            return false;
        }
        if(list_prc[k] && list_prc[k]!="" && list_value[k]=="0")
        {
            alert("Enter list price greater than 0");
            return false;
        }
       }
       for(var m=0; m<sale_prc.length; m++)
       {
            if(sale_prc[m] && sale_prc[m]!="" && sale_value[m]=="")
        {
            alert("please enter sale price");
            return false;
        }
        if(sale_prc[m] && sale_prc[m]!="" && sale_value[m]=="0")
        {
            alert("Enter sale price greater than 0");
            return false;
        }
       }
}

function validatePlan()
{
    if(document.updateproductfrm.product_id.value == 0)
    {
        alert("Please enter Product Id");
        document.updateproductfrm.product_id.focus();
        return false;
    }
    if(document.updateproductfrm.description.value==0)
    {
        alert("Please enter titile");
        document.updateproductfrm.description.focus();
        return false;
    }
    if(document.updateproductfrm.message.value=="")
    {
        alert("Please enter selling pitch");
        document.updateproductfrm.message.focus();
        return false;
    }
    if(document.updateproductfrm.category.value=="")
    {
        alert("Please select plan type");
        document.updateproductfrm.category.focus();
        return false;
    }
    if(document.updateproductfrm.customerservicetelephones.value=="")
    {
        alert("Please enter customer service number");
        document.updateproductfrm.customerservicetelephones.focus();
        return false;
    }
    if(document.updateproductfrm.accesstelephones.value=="")
    {
        alert("Please enter main access number");
        document.updateproductfrm.accesstelephones.focus();
        return false;
    }
    if(document.updateproductfrm.calling_from.value=="")
    {
        alert("Please enter calling from");
        document.updateproductfrm.calling_from.focus();
        return false;
    }
    if(document.updateproductfrm.connectionfee.value=="")
    {
        alert("Please enter connection fee");
        document.updateproductfrm.connectionfee.focus();
        return false;
    }
    if(document.updateproductfrm.internationalcallstocellphones.value=="")
    {
        alert("Please enter charge for international cell phones");
        document.updateproductfrm.internationalcallstocellphones.focus();
        return false;
    }
    if(document.updateproductfrm.maintenancefee.value=="")
    {
        alert("Please enter charge for maintainance fee");
        document.updateproductfrm.maintenancefee.focus();
        return false;
    }
}

function deleteLocalities() {
    var iTotal = document.getElementById("used_loc_counter").value;

    for(i = 0; i < iTotal; i++) {
      if(document.getElementById("chk_save_"+i).checked) {
        alert("Elem i ["+i+"], is checked!");
      }
    }

return false;
}

function checkAllLocalities()
{
    for(i=0; i<document.mng_localitiesfrm.elements.length; i++) {
        if(document.mng_localitiesfrm.elements[i].type == "checkbox") {
            document.mng_localitiesfrm.elements[i].checked = true;
        }
    }
}

function uncheckAllLocalities()
{
    for(i=0; i<document.mng_localitiesfrm.elements.length; i++) {
  //alert("elem typ [" + document.mng_localitiesfrm.elements[i].type + "]");
        if(document.mng_localitiesfrm.elements[i].type == "checkbox") {
            document.mng_localitiesfrm.elements[i].checked = false;
        }
    }
}

function ValidateAffiliateRegistrationEditProfile()
{
    if(document.affiliateregistrationfrm.firstname.value == 0)
    {
        alert("Please enter First name");
        document.affiliateregistrationfrm.firstname.focus();
        return false;
    }else if(document.affiliateregistrationfrm.lastname.value == 0)
    {
        alert("Please enter Last name");
        document.affiliateregistrationfrm.lastname.focus();
        return false;
    }else if(document.affiliateregistrationfrm.emailid.value == 0)
    {
        alert("Please enter Email Id");
        document.affiliateregistrationfrm.emailid.focus();
        return false;
    }else if(!isEmail_check(document.affiliateregistrationfrm.emailid.value))
    {
        alert("Please enter a valid Email Id");
        document.affiliateregistrationfrm.emailid.focus();
        return false;
    }else if(document.affiliateregistrationfrm.phonenumber.value == 0)
    {
        alert("Please enter Phone Number");
        document.affiliateregistrationfrm.phonenumber.focus();
        return false;
    }else if(isNaN(document.affiliateregistrationfrm.phonenumber.value))
    {
        alert("Please enter Numeric Phone Number");
        document.affiliateregistrationfrm.phonenumber.focus();
        return false;
    }else if(document.affiliateregistrationfrm.phonenumber.value.length != 10)
    {
        alert("Please enter 10 digits Phone Number");
        document.affiliateregistrationfrm.phonenumber.focus();
        return false;
    }
    else
    {
        return true;
    }
}
function ValidateAffiliateRegistration()
{
    if(document.affiliateregistrationfrm.firstname.value == 0)
    {
        alert("Please enter First name");
        document.affiliateregistrationfrm.firstname.focus();
        return false;
    }else if(document.affiliateregistrationfrm.lastname.value == 0)
    {
        alert("Please enter Last name");
        document.affiliateregistrationfrm.lastname.focus();
        return false;
    }else if(document.affiliateregistrationfrm.emailid.value == 0)
    {
        alert("Please enter Email Id");
        document.affiliateregistrationfrm.emailid.focus();
        return false;
    }else if(!isEmail_check(document.affiliateregistrationfrm.emailid.value))
    {
        alert("Please enter a valid Email Id");
        document.affiliateregistrationfrm.emailid.focus();
        return false;
    }else if(document.affiliateregistrationfrm.phonenumber.value == 0)
    {
        alert("Please enter Phone Number");
        document.affiliateregistrationfrm.phonenumber.focus();
        return false;
    }else if(isNaN(document.affiliateregistrationfrm.phonenumber.value))
    {
        alert("Please enter Numeric Phone Number");
        document.affiliateregistrationfrm.phonenumber.focus();
        return false;
    }else if(document.affiliateregistrationfrm.phonenumber.value.length != 10)
    {
        alert("Please enter 10 digits Phone Number");
        document.affiliateregistrationfrm.phonenumber.focus();
        return false;
    }else if(document.affiliateregistrationfrm.username.value == 0)
    {
        alert("Please enter Username");
        document.affiliateregistrationfrm.username.focus();
        return false;
    }else if(document.affiliateregistrationfrm.password.value == 0)
    {
        alert("Please enter Password");
        document.affiliateregistrationfrm.password.focus();
        return false;
    }
    else if(document.affiliateregistrationfrm.txt_securitycode.value == 0){
        alert("Please enter Security code");
        document.affiliateregistrationfrm.txt_securitycode.focus();
        return false;
    }
    else if(document.affiliateregistrationfrm.txt_securitycode.value != document.affiliateregistrationfrm.hid_securitycode.value){
        alert("Please enter right security code");
        document.affiliateregistrationfrm.txt_securitycode.focus();
        return false;
    }
    /*else if(document.affiliateregistrationfrm.dateestablished.value == 0)
    {
        alert("Please enter Established Date");
        document.affiliateregistrationfrm.dateestablished.focus();
        return false;
    }
     var dt=document.affiliateregistrationfrm.dateestablished
    if (isDate(dt.value)==false){
        dt.focus()
        return false
    }
      else if(document.affiliateregistrationfrm.federaltax.value == 0)
    {
        alert("Please enter Federal Tax Id");
        document.affiliateregistrationfrm.federaltax.focus();
        return false;
    }else if(document.affiliateregistrationfrm.stateofincorporation.value == 0)
    {
        alert("Please enter State of Incorporation");
        document.affiliateregistrationfrm.stateofincorporation.focus();
        return false;
    }else if(document.affiliateregistrationfrm.dun.value == 0)
    {
        alert("Please enter Dun and Bradstreet Dun");
        document.affiliateregistrationfrm.dun.focus();
        return false;
    }else if(document.affiliateregistrationfrm.typeofbusiness.value == 0)
    {
        alert("Please enter Type of Business");
        document.affiliateregistrationfrm.typeofbusiness.focus();
        return false;
    }else if(document.affiliateregistrationfrm.seltype.value == 0)
    {
        alert("Please enter Company Type");
        document.affiliateregistrationfrm.seltype.focus();
        return false;
    }else if(document.affiliateregistrationfrm.businessstructure.value == 0)
    {
        alert("Please enter Business Structure");
        document.affiliateregistrationfrm.businessstructure.focus();
        return false;
    }else if(document.affiliateregistrationfrm.bankname.value == 0)
    {
        alert("Please enter Bank Name");
        document.affiliateregistrationfrm.bankname.focus();
        return false;
    }else if(document.affiliateregistrationfrm.bankaddress.value == 0)
    {
        alert("Please enter Bank Address");
        document.affiliateregistrationfrm.bankaddress.focus();
        return false;
    }else if(document.affiliateregistrationfrm.accountnumber.value == 0)
    {
        alert("Please enter Bank Account Number");
        document.affiliateregistrationfrm.accountnumber.focus();
        return false;
    }else if(document.affiliateregistrationfrm.bankfax.value == 0)
    {
        alert("Please enter Bank Fax Number");
        document.affiliateregistrationfrm.bankfax.focus();
        return false;
    }else if(isNaN(document.affiliateregistrationfrm.bankfax.value))
    {
        alert("Please enter Numeric Bank Fax Number");
        document.affiliateregistrationfrm.bankfax.focus();
        return false;
    }else if(document.affiliateregistrationfrm.banktelephone.value == 0)
    {
        alert("Please enter Bank Telephone Number");
        document.affiliateregistrationfrm.banktelephone.focus();
        return false;
    }else if(isNaN(document.affiliateregistrationfrm.banktelephone.value))
    {
        alert("Please enter Numeric Bank Telephone Number");
        document.affiliateregistrationfrm.banktelephone.focus();
        return false;
    }else if(document.affiliateregistrationfrm.managercontact.value == 0)
    {
        alert("Please enter Bank Manager Contact Number");
        document.affiliateregistrationfrm.managercontact.focus();
        return false;
    }else if(document.affiliateregistrationfrm.name1.value == 0)
    {
        alert("Please enter Partner1 Name");
        document.affiliateregistrationfrm.name1.focus();
        return false;
    }else if(document.affiliateregistrationfrm.title1.value == 0)
    {
        alert("Please enter Partner1 Title");
        document.affiliateregistrationfrm.title1.focus();
        return false;
    }else if(document.affiliateregistrationfrm.homeaddress1.value == 0)
    {
        alert("Please enter Partner1 Home Address");
        document.affiliateregistrationfrm.homeaddress1.focus();
        return false;
    }else if(document.affiliateregistrationfrm.security1.value == 0)
    {
        alert("Please enter Partner1 Social Security Number");
        document.affiliateregistrationfrm.security1.focus();
        return false;
    }else if(document.affiliateregistrationfrm.licency1.value == 0)
    {
        alert("Please enter Partner1 Drivers License");
        document.affiliateregistrationfrm.licency1.focus();
        return false;
    }else if(document.affiliateregistrationfrm.telephone1.value == 0)
    {
        alert("Please enter Partner1 Telephone Number");
        document.affiliateregistrationfrm.telephone1.focus();
        return false;
    }else if(isNaN(document.affiliateregistrationfrm.telephone1.value))
    {
        alert("Please enter Numeric Partner1 Telephone Number");
        document.affiliateregistrationfrm.telephone1.focus();
        return false;
    }else if((document.affiliateregistrationfrm.telephone2.value != '') && isNaN(document.affiliateregistrationfrm.telephone2.value))
    {
        alert("Please enter Numeric Partner2 Telephone Number");
        document.affiliateregistrationfrm.telephone2.focus();
        return false;
    }else if((document.affiliateregistrationfrm.telephone3.value != '') && isNaN(document.affiliateregistrationfrm.telephone3.value))
    {
        alert("Please enter Numeric Partner3 Telephone Number");
        document.affiliateregistrationfrm.telephone3.focus();
        return false;
    }
    else if(document.affiliateregistrationfrm.uscompany1.value == 0)
    {
        alert("Please enter US Trade References Company Name");
        document.affiliateregistrationfrm.uscompany1.focus();
        return false;
    }else if(document.affiliateregistrationfrm.usaddress1.value == 0)
    {
        alert("Please enter US Trade References Address");
        document.affiliateregistrationfrm.usaddress1.focus();
        return false;
    }else if(document.affiliateregistrationfrm.ustelephone1.value == 0)
    {
        alert("Please enter US Trade References Telephone Number");
        document.affiliateregistrationfrm.ustelephone1.focus();
        return false;
    }else if(isNaN(document.affiliateregistrationfrm.ustelephone1.value))
    {
        alert("Please enter Numeric US Trade References Telephone Number");
        document.affiliateregistrationfrm.ustelephone1.focus();
        return false;
    }else if(document.affiliateregistrationfrm.usfax1.value == 0)
    {
        alert("Please enter US Trade References FAX Number");
        document.affiliateregistrationfrm.usfax1.focus();
        return false;
    }else if(isNaN(document.affiliateregistrationfrm.usfax1.value))
    {
        alert("Please enter Numeric US Trade References FAX Number");
        document.affiliateregistrationfrm.usfax1.focus();
        return false;
    }
    else if((document.affiliateregistrationfrm.ustelephone2.value !='') && isNaN(document.affiliateregistrationfrm.ustelephone2.value))
    {
        alert("Please enter Numeric US Trade References2 Telephone Number");
        document.affiliateregistrationfrm.ustelephone2.focus();
        return false;
    }else if((document.affiliateregistrationfrm.usfax2.value !='') && isNaN(document.affiliateregistrationfrm.usfax2.value))
    {
        alert("Please enter Numeric US Trade References2 FAX Number");
        document.affiliateregistrationfrm.usfax2.focus();
        return false;
    }else if((document.affiliateregistrationfrm.ustelephone3.value !='') && isNaN(document.affiliateregistrationfrm.ustelephone3.value))
    {
        alert("Please enter Numeric US Trade References3 Telephone Number");
        document.affiliateregistrationfrm.ustelephone3.focus();
        return false;
    }else if((document.affiliateregistrationfrm.usfax3.value !='') && isNaN(document.affiliateregistrationfrm.usfax3.value))
    {
        alert("Please enter Numeric US Trade References3 FAX Number");
        document.affiliateregistrationfrm.usfax3.focus();
        return false;
    }*/
    else
    {
        return true;
    }
}

function assignCommision()
{
    if(document.assigncommissionfrm.selcommission.value == 0)
    {
        alert("Please select commision type");
        document.assigncommissionfrm.selcommission.focus();
        return false;
    }else if(document.assigncommissionfrm.rate.value == 0)
    {
        alert("Please enter commision rate");
        document.assigncommissionfrm.rate.focus();
        return false;
    }else if(document.assigncommissionfrm.status.value == 0)
    {
        alert("Please select status");
        document.assigncommissionfrm.status.focus();
        return false;
    }
}


// start code to check for date format

/**
 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
    var i;
    for (i = 0; i < s.length; i++){
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
    var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
    // February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
    for (var i = 1; i <= n; i++) {
        this[i] = 31
        if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
        if (i==2) {this[i] = 29}
   }
   return this
}

function isDate(dtStr){
    var daysInMonth = DaysArray(12)
    var pos1=dtStr.indexOf(dtCh)
    var pos2=dtStr.indexOf(dtCh,pos1+1)
    var strMonth=dtStr.substring(0,pos1)
    var strDay=dtStr.substring(pos1+1,pos2)
    var strYear=dtStr.substring(pos2+1)
    strYr=strYear
    if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
    if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
    for (var i = 1; i <= 3; i++) {
        if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
    }
    month=parseInt(strMonth)
    day=parseInt(strDay)
    year=parseInt(strYr)
    if (pos1==-1 || pos2==-1){
        alert("The date format should be : mm/dd/yyyy")
        return false
    }
    if (strMonth.length<1 || month<1 || month>12){
        alert("Please enter a valid month")
        return false
    }
    if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
        alert("Please enter a valid day")
        return false
    }
    if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
        alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
        return false
    }
    if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
        alert("Please enter a valid date")
        return false
    }
return true
}

// end code to check for date format



function validateBankInfo()
{
    if(document.getElementById("bankname").value==0)
    {
        alert("Please enter bank name");
        document.getElementById("bankname").focus();
        return false;
    }
    if(document.getElementById("chequeno").value==0)
    {
        alert("Please enter cheque no");
        document.getElementById("chequeno").focus();
        return false;
    }
     if(isNaN(document.getElementById('chequeno').value))
    {
        alert("Please enter numeric cheque no");
        document.getElementById("chequeno").focus();
        return false;
    }

}

function delete_pins(fileId, totalPin)
{
    if(totalPin > 0)
    {
        if(confirm("Are you sure, you want to delete this record"))
        {
            window.location.href = 'process_delete_pins.php?fileId='+fileId;
        }
        else{
            return false;
        }
    }
    else{
        return false;
    }
}

function deactiveAffiliate(id){
    if(confirm("Do you want to inactivate this affiliate?")){
    var randomnumber = Math.floor(Math.random()*110);
    var url = "activateDeactivateAffiliate.php?userid="+id+"&randno="+randomnumber+"&status=deactivate";
    xmlHttp = GetXmlHttpObject(refreshPage)
    xmlHttp.open("GET",url, true);
    xmlHttp.send(null);
    return true;
    }
    else{

    }
}

function activeAffiliate(id){
    if(confirm("Do you want to activate this affiliate?")){
    var randomnumber = Math.floor(Math.random()*110);
    var url = "activateDeactivateAffiliate.php?userid="+id+"&randno="+randomnumber+"&status=activate";
    xmlHttp = GetXmlHttpObject(refreshPage)
    xmlHttp.open("GET",url, true);
    xmlHttp.send(null);
    return true;
    }
    else{

    }
}

function refreshPage(){
    window.location.reload();
}


function IsNumeric(strString)
   {
   var strValidChars = "0123456789.";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;
    var reg= /^(([0-9]*[1-9][0-9]*([.][0-9]+)?)|([0]+[.][0-9]*[1-9][0-9]*))$/;
     if(!reg.test(strString)){
                alert("Please enter valid amount!");
                return false;
     }
   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }

function validateAffiliatePaymentForm()
{
    if(document.paymentfrm.from_date.value=="")
    {
        alert("Please select 'From Date''");
        document.paymentfrm.from_date.focus();
        return false;
    }
    if(document.paymentfrm.to_date.value=="")
    {
        alert("Please select 'To Date''");
        document.paymentfrm.to_date.focus();
        return false;
    }
     if(document.paymentfrm.amount.value=="")
    {
        alert("Please enter Amount");
        document.paymentfrm.amount.focus();
        return false;
    }
   if (IsNumeric(document.paymentfrm.amount.value) == false)
    {
     // alert("Please enter valid amount!");
      document.paymentfrm.amount.focus();
        return false;
    }
     if(document.paymentfrm.comments.value=="")
    {
        alert("Please add comments.");
        document.paymentfrm.comments.focus();
        return false;
    }

}

function delete_promotional_pins(fileId,totalPin)
{
    if(totalPin > 0)
    {
        if(confirm("Are you sure, you want to delete this record"))
        {
            window.location.href = 'process_delete_promotional_pins.php?fileId='+fileId;
        }
        else{
            return false;
        }
    }
    else{
        return false;
    }
}

function Validate_PromotionalUploadPin()
{
    if(document.getElementById("file_upload1").value == 0)
    {
        alert("Please select a file");
        document.getElementById("file_upload1").focus();
        return false;
    }
     if(document.getElementById("from_date").value == "")
    {
        alert("Please select 'Valid From' date.");
        document.getElementById("from_date").focus();
        return false;
    }
     if(document.getElementById("to_date").value == "")
    {
        alert("Please select 'Valid To' date.");
        document.getElementById("to_date").focus();
        return false;
    }
    if(document.getElementById("initial_balance").value == "")
    {
        alert("Please enter initial balance.");
        document.getElementById("initial_balance").focus();
        return false;
    }
    if(document.getElementById("product_id").value == "")
    {
        alert("Please select product id.");
        document.getElementById("product_id").focus();
        return false;
    }
}

function Validate_RechargePinDeduct()
{
 if(document.getElementById("amt_cc").value == "" && document.getElementById("amt_cash").value == "")
    {
        alert("Please enter amount");
        document.getElementById("amt_cc").focus();
        return false;
    }
    
    if(document.getElementById("amt_cc").value != "" || document.getElementById("amt_cash").value != "")
    { 
        if(document.getElementById("amt_cc").value != "")
        {
            val=document.getElementById("amt_cc").value;
        }
        else
        {
             val=document.getElementById("amt_cash").value;
        }
     var reg = /^[0-9.]+$/;
            if(!reg.test(val)){
                alert("Please use some positive Amount more than 0");
                return false;
            }
            else{
                if(val == 0){
                    alert("Please use some positive Amount more than 0");
                    return false;
                }
            }
    }      
    
    if((parseInt(document.getElementById("amt_cc").value) > parseInt(document.getElementById("bal").value)) || (parseInt(document.getElementById("amt_cash").value) > parseInt(document.getElementById("bal").value))) 
    {
        alert("Entered amount should not be greater than the existing amount of the Pin. ");
        return false;
    }
}
