/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */



function showLoaderImage(imageId){
    //alert('Show loader Called');
    document.getElementById(imageId).style.display = 'block';
}


function checkManagedBillPayment(fromAccount, payeeId, serviceAttribute, serviceAmount, remarkAttribute, fundTransferPassword,imageId){
    if(fromAccount == '' || payeeId == '' || serviceAmount == '' || serviceAttribute == '' || fundTransferPassword == '' ||remarkAttribute == ''){
        alert('Some required field(s) are missing');
        return false;
    }

    var payeeOptions = payeeId.options;
    var payeeText = payeeOptions[payeeOptions.selectedIndex].text;


    if(confirm('confirm transfer of Rs.'+serviceAmount+ ' for '+payeeText)){
        showLoaderImage(imageId);
        return true;
    }else
        return false;
}

function fundTransfer(transferFrom,amount, transferTo,fundTransferPassword,imageId, passwordRequirement){

    //    alert("checking password requirement field:>>"+passwordRequirement);
    if(passwordRequirement == true){
        if(transferFrom == '' || transferTo == '' || amount == '' || transferFrom == 'select') {
            alert("Some required field(s) are missing.");
            return false;
        }
    }
    if(passwordRequirement == false){
        if(transferFrom == '' || transferTo == '' || fundTransferPassword == ''|| amount == '' || transferFrom == 'select') {
            alert("Some required field(s) are missing.");
            return false;
        }
    }
    

    //if(btnVal == 'Transfer'){
    if(confirm('Confirm transfer of Rs.'+ amount + ' to A/C No ' + transferTo)){
        showLoaderImage(imageId);
        return true;
    } else
        return false;
//}

/*if(btnVal == 'Schedule Transfer'){
        if(confirm('Confirm Schedule transfer')){
            showLoaderImage(imageId);
            return true;
        } else
            return false;
    }*/

//return false;
}

/** Prepaid **/
function buyPrepaid(cardType,rechargeAmt,fromAccount,fundtTransferPassword,imageId){

    if(cardType == '' || rechargeAmt == '' || fundtTransferPassword  == '' || fromAccount == '') {
        alert("Some required field(s) are missing.");
        return false;
    }
    if(confirm('Confirm NTC Prepaid Recharge Operation ?')) {
        showLoaderImage(imageId);
        return true;
    }else{
        return false;
    }
}

/** PostPaid **/
function payPostpaidBill(transferFrom,rechargeAmt,mobileNum,fundTransferPassword,imageId){

    if(transferFrom == '' || rechargeAmt == '' || fundTransferPassword == "" || mobileNum== '') {
        alert("Some required field(s) are missing.");
        return false;
    }
    if(confirm('Confirm NTC Postpaid Bill Payment of Rs. ' + rechargeAmt + ' for mobile no. ' + mobileNum)) {
        showLoaderImage(imageId);
        return true;
    }else{
        return false;
    }
}

/** LandLine **/
function payLandLineBill(transferFrom,rechargeAmt,phoneNum,fundTransferPassword,imageId){

    if(transferFrom == '' || rechargeAmt == '' || fundTransferPassword == '' || phoneNum== '') {
        alert("Some required field(s) are missing.");
        return false;
    }
    if(confirm('Confirm NTC Telephone Bill Payment of Rs. ' + rechargeAmt + ' for mobile no. ' + phoneNum)) {
        showLoaderImage(imageId);
        return true;
    }else{
        return false;
    }
}
/**rechargeEsewa**/
function rechargeEsewa(transferFrom,rechargeAmt,esewaId,fundTransferPassword,imageId){

    if(transferFrom == '' || rechargeAmt == '' || fundTransferPassword == '' || esewaId== '') {
        alert("Some required field(s) are missing.");
        return false;
    }
    if(confirm('Confirm recharge of Rs. ' + rechargeAmt + ' for eSewa Id ' + esewaId)) {
        showLoaderImage(imageId);
        return true;
    }else{
        return false;
    }
}

/** Login Validation **/
function loginCheck(username, password,imageId){
    if(username == '' || password== '') {
        alert("Some required field(s) are missing.");
        return false;
    }
    else{
        showLoaderImage(imageId);
        return true;
    }
}

/**verifyDateDifff**/
var js_fromDate = '';
var js_toDate = '';
function setFromDate(fromDate){
    //alert('fromDate: '+fromDate);
    js_fromDate = new Date(fromDate);
}
function setToDate(toDate){
    //alert('toDate: '+toDate);
    js_toDate = new Date(toDate);
}
function verifyDateDiff(accountNum){
    /*alert('jsdatefrom:'+js_fromDate);
       alert('jsdateto:'+js_toDate);
       alert('accountnum:'+accountNum);*/
    if(js_fromDate == '' || js_toDate == '' || accountNum == ''){
        alert('Some required field(s) are missing.')
        return  false;
    }else if(Date.parse(js_toDate)<Date.parse(js_fromDate)){
        alert('To date must be greate than From date');
        return false;
    }else{
        return true;
    }
}

/*for printing transaction*/
function verifyDateDiff(accountNum,appType){
    var count = 0;
    for(i=0;i<appType.length;i++){
        if(appType[i].checked){
            count = count +1;
        }
    }

    //    if(count == 0){
    //        alert('count:0'+count);
    //    }else{
    //        alert('count::'+count);
    //    }
    /*alert('jsdatefrom:'+js_fromDate);
       alert('jsdateto:'+js_toDate);
       alert('accountnum:'+accountNum);*/
    if(js_fromDate == '' || js_toDate == '' || accountNum == '' || appType == '' || count == 0){
        alert('Some required field(s) are missing.')
        return  false;
    }else if(Date.parse(js_toDate)<Date.parse(js_fromDate)){
        alert('To date must be greate than From date');
        return false;
    }else{
        return true;
    }
}

function checkPassword(oldPwd,newPwd,confirmPwd){
    if(oldPwd == '' || newPwd=='' || confirmPwd==''){
        alert('Some required field(s) are missing.');
        return false;
    }else{
        return true;
    }
}



  

