﻿



// Function openGenericWindow
// Opens the generic window.
// Parameters
// URL - string that contains the URL to open
// w - int that contains the width of the window to open
// h - int that contains the height of the window to open
// winName - string containing the name of the new window to open
// showMenus - string that show contain either Yes or No, and 
// that determines if the menus are shown on the newly opened window
// showStatusBar - string that show contain either Yes or No, and 
// that determines if the status bar is shown on the newly opened window
function openGenericWindow(url, w, h, winName, showMenus, showStatusBar ) 
{
if (navigator.appName.substring(0, 5) == 'WebTV') return true;
     
//Determine the left and top position of the window
var l = (screen.width - w) / 2;
var t = (screen.height - h) / 2;
//Build the parameter list of features to be displayed on the new window
var params = "toolbar=no,location=no,directories=no,status=" + showStatusBar + ",menubar=" + showMenus + ",scrollbars=yes,resizable=yes,copyhistory=no,width=" + w + ",height=" + h + ",top=" + t + ",left=" + l + ",screenX=" + l + ",screenY=" + t + "";
     
//Open a new window and set focus to it
genericWindow = window.open(url, winName, params);
genericWindow.focus();
return false;
}

//--------------------------------------------------------------------------------
//    Function: isCreditCard(strInput)
// Description: Checks to see that the number passes the Luhn Mod-10 test
//       Input: strInput - the credit card number to be checked
//     Returns: true  - if field only contains proper characters
//              false - if credit card failed test
//  Disclaimer:	Skipjack Financial Services grants you a nonexclusive copyright license to use
//		this sample code from which you can generate similar function tailored to your own
//		specific needs.
//
//		This sample is provided by Skipjack Financial Services for illustrative purposes
//		only. It has not been thoroughly tested under all conditions. Skipjack, therefore,
//		cannot guarantee or imply reliability, serviceability, or function.
//
//		The sample code contained herein is provided to you "AS IS" without any	warranties 
//		of any kind. The implied warranties of non-infringement, merchantability and 
//		fitness for a particular purpose are expressly disclaimed.
//--------------------------------------------------------------------------------
function isCreditCard(strInput)
{
	// Encoding only works on cards with less than 19 digits	
	if (strInput.length > 19) return (false);  
	
	var sum = 0; 
	var mul = 1; 
	var l = strInput.length;
	
	for (i = 0; i < l; i++)
	{
		var digit    = strInput.substring(l-i-1,l-i);
    		var tproduct = parseInt(digit ,10) * mul;

	    	if (tproduct >= 10) 
		{ sum += (tproduct % 10) + 1; }
    		else
		{ sum += tproduct; }

    		if (mul == 1)       
		{ mul++; }
	    	else
		{ mul--; }
  	}	

  	if ((sum % 10) == 0)  return (true);
  	else                  return (false);
}

function CheckCardNumber(strInput)
{
    if(!isCreditCard(strInput))
    {
        alert('Card number is not valid. Please check the number.');
    }
}
