﻿// JScript File
function showMessage(txt) {
	var divsuccess = document.getElementById('successmsg1'); 
	divsuccess.innerHTML = txt;
	$(divsuccess).stop(true, true);
	divsuccess.style.visibility = 'visible';
	divsuccess.style.display = 'block';
	$(document).ready(function() {
		$(divsuccess).fadeOut(6000)
	});

}
function showErrorMessage(txt) {
	var diverror = document.getElementById('errormsg1');
	diverror.innerHTML = txt;
	$(diverror).stop(true, true);
	diverror.style.visibility = 'visible';
	diverror.style.display = 'block';

	$(document).ready(function() {
		$(diverror).fadeOut(7500)
	});

}
function gotoTop() { $("html, body").animate({ scrollTop: 0 }, "slow"); }

function validateNumber(txtbox1) {
	var str = txtbox1.value;
	var str1 = "0123456789";
	var i = 0;
	for (i = 0; i < str.length; i++) {
		if (str1.indexOf(str.substring(i, i + 1)) < 0 || str1.indexOf(str.substring(i, i + 1)) > str1.length) {
			var nTheNumber = (str.match(/\d+/));
			if (nTheNumber == null)
				nTheNumber = '';
			txtbox1.value = nTheNumber;
			alert("Enter Only Number");
			txtbox1.focus();
			break;
		}
	}
}

function validateDecimal(txtbox1) {
	var str = txtbox1.value;
	var str1 = "0123456789.";
	var i = 0;
	for (i = 0; i < str.length; i++) {
		if (str1.indexOf(str.substring(i, i + 1)) < 0 || str1.indexOf(str.substring(i, i + 1)) > str1.length) {
			var nTheNumber = (str.match(/\d+/));
			if (nTheNumber == null)
				nTheNumber = '';
			txtbox1.value = nTheNumber;
			alert("Enter Only Number");
			txtbox1.focus();
			break;
		}
	}
}
function CheckName_EN(txtbox1) {
	var str = txtbox1.value;
	var str1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz. ";
	var i = 0;
	for (i = 0; i < str.length; i++) {
		if (str1.indexOf(str.substring(i, i + 1)) < 0 || str1.indexOf(str.substring(i, i + 1)) > str1.length) {
			txtbox1.value = "";
			alert("Name Must Be Alphabets.");
			txtbox1.focus();
			break;
		}

	}

}
function checkEmail(txtbox1) {
var email =txtbox1;
var filter = /^.+@.+\..{2,3,4,6}$/;
if (!filter.test(email.value)) {
alert('Please provide a valid email address');
email.focus;
return false;
}
}
function checkAlertpayEmail(txtbox1) {
var email =txtbox1;
var filter = /^.+@.+\..{2,3,4,6}$/;
if (!filter.test(email.value)) {
alert('Please provide a valid Alertpay account');
email.focus;
return false;
}
}
function checkPaypalEmail(txtbox1) {
var email =txtbox1;
var filter = /^.+@.+\..{2,3,4,6}$/;
if (!filter.test(email.value)) {
alert('Please provide a valid Paypal account');
email.focus;
return false;
}
}
function checkName(txtbox1) {
var email =txtbox1;
var filter = /^[a-zA-Z0-9_\.\-]{2,20}/;
if (!filter.test(email.value)) {
alert('Please provide a valid Full Name. Allow only letters, numbers, and underscores');
email.focus;
return false;
}
}
function checkWholeForm(alertpayaccount,paypalaccount,fullname) {

    var why = verifyName(fullname);
	var why1 = verifyAlertpayEmail(alertpayaccount);
    var why2 = verifyPaypalEmail(paypalaccount);
    if (why == false || why1== false  || why2== false ) {
       return false;
    }
	else
		return true;
}
function verifyAlertpayEmail(email){
var status = true;     
var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
     if (email.value.search(emailRegEx) == -1) {
          alert("Please enter a valid alertpay account.");
	    status=false; 
     }
     //else if (document.myform.email1.value != document.myform.email2.value) {
     //     alert("Email addresses do not match.  Please retype them to make sure they are the same.");
     //}
     //else {
     //     alert("Woohoo!  The email address is in the correct format and they are the same.");
     //     status = true;
     //}
     return status;
}
function verifyPaypalEmail(email){
var status = true;     
var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
     if (email.value.search(emailRegEx) == -1) {
          alert("Please enter a valid Paypal account.");
			status=false; 
     }
     //else if (document.myform.email1.value != document.myform.email2.value) {
     //     alert("Email addresses do not match.  Please retype them to make sure they are the same.");
     //}
     //else {
     //     alert("Woohoo!  The email address is in the correct format and they are the same.");
     //     status = true;
     //}
     return status;
}
function verifyName(fname){
var status = true;     
var emailRegEx = /^[A-Z0-9 ._%+-]{2,30}$/i;
     if (fname.value.search(emailRegEx) == -1) {
          alert("Please enter a valid Full Name.");
			status=false; 
     }
     //else if (document.myform.email1.value != document.myform.email2.value) {
     //     alert("Email addresses do not match.  Please retype them to make sure they are the same.");
     //}
     //else {
     //     alert("Woohoo!  The email address is in the correct format and they are the same.");
     //     status = true;
     //}
     return status;
}
