function langChange(lang)
	{
	url = window.location.href;
	
	if(url.indexOf("?") == -1)
		{
		url = url + "?lang=" + lang;
		}
	else
		{
		var temp = new Array();
		temp = url.split('?');
		url = temp[0] + "?lang=" + lang + "&" + temp[1];
		}
	location.href = url;
	}
	
function checkCreditCard(cardnumber, cardname)
	{ 
	var cards = new Array();
  
	cards [0] = {name: "Visa", 
               length: "13,16", 
               prefixes: "4",
               checkdigit: true};
	cards [1] = {name: "MasterCard", 
               length: "16", 
               prefixes: "51,52,53,54,55",
               checkdigit: true};
	           
	// Establish card type
	var cardType = -1;
	for (var i=0; i<cards.length; i++)
		{
		// See if it is this card (ignoring the case of the string)
		if (cardname.toLowerCase () == cards[i].name.toLowerCase())
			{
			cardType = i;
			break;
			}
		}
  
	// If card type not found, report an error
	if (cardType == -1)
		return 2;
		
	// Ensure that the user has provided a credit card number
	if (cardnumber.length == 0)
		return 3;
		
	// Now remove any spaces from the credit card number
	cardnumber = cardnumber.replace (/\s/g, "");
  
	// Check that the number is numeric
	var cardNo = cardnumber
	var cardexp = /^[0-9]{13,19}$/;
	if (!cardexp.exec(cardNo))
		return 4; 
       
	// Now check the modulus 10 check digit - if required
	if (cards[cardType].checkdigit)
		{
		var checksum = 0;                                  // running checksum total
		var mychar = "";                                   // next char to process
		var j = 1;                                         // takes value of 1 or 2
  
		// Process each digit one by one starting at the right
		var calc;
		for (i = cardNo.length - 1; i >= 0; i--)
			{
			// Extract the next digit and multiply by 1 or 2 on alternative digits.
			calc = Number(cardNo.charAt(i)) * j;
    
			// If the result is in two digits add 1 to the checksum total
			if (calc > 9)
				{
				checksum = checksum + 1;
				calc = calc - 10;
				}
    
			// Add the units element to the checksum total
			checksum = checksum + calc;
    
			// Switch the value of j
			if (j ==1) {j = 2} else {j = 1};
			} 
  
		// All done - if checksum is divisible by 10, it is a valid modulus 10.
		// If not, report an error.
		if (checksum % 10 != 0)
			return 4; 
		}  

	// The following are the card-specific checks we undertake.
	var LengthValid = false;
	var PrefixValid = false; 
	var undefined; 

	// We use these for holding the valid lengths and prefixes of a card type
	var prefix = new Array ();
	var lengths = new Array ();
    
	// Load an array with the valid prefixes for this card
	prefix = cards[cardType].prefixes.split(",");
      
	// Now see if any of them match what we have in the card number
	for (i=0; i<prefix.length; i++)
		{
		var exp = new RegExp ("^" + prefix[i]);
		if (exp.test (cardNo)) PrefixValid = true;
		}
      
	// If it isn't a valid prefix there's no point at looking at the length
	if (!PrefixValid)
		return 5; 
    
	// See if the length is valid for this card
	lengths = cards[cardType].length.split(",");
	for (j=0; j<lengths.length; j++)
		{
		if (cardNo.length == lengths[j]) LengthValid = true;
		}
  
	// See if all is OK by seeing if the length was valid. We only check the 
	// length if all else was hunky dory.
	if (!LengthValid)
		return 6;
  
	// The credit card is in the required format.
	return 1;
	}