	function el(field)
	{
		return document.getElementById(field);
	}

	getFormId = function(strId)
	{
		var frms = document.forms;
		for(i=0;i<frms.length;i++)
		{
			if(frms[i].id == strId)
			{
				return i;
			}
		}
		return false;
	};

	getFormById = function(strId)
	{
		var frmId = getFormId(strId);

		if(frmId != false)
		{
			return document.forms[frmId];
		}
	};

	function msgBox_wait(msg, smlmsg)
	{
		strSmlMsg = "";
		if(smlmsg && smlmsg.length > 0)
		{
			strSmlMsg = '<br /><span style="font-size: 10px;">' + smlmsg + '</span>';
		}

		var html =  '<p style="text-align: center;"><img src="/images/spinner/swan.gif" /><br />Please Wait... ' + msg + '<br /><br />' +
					'<img src="/images/spinner/bar.gif" align="middle"/><br />' + strSmlMsg + '</p>';

		internalPopup(html);
	}

	function msgBox_alert(title, message)
	{
		var html =  '<div class="alert"><h4 class="default">' + title + '</h4>' +
					'<p>' + message + '<br /><br /><br /></p>' +
					'<input type="button" value="Close" onclick="closeInternalPopup();" id="clsIntP" /></div>';
		internalPopup(html);
		el('clsIntP').focus();
	}

	msgBox_confirm = function(title, message, confirmFunc, confirmText, cancelText)
	{
		if(!confirmFunc) return false;
		if(!confirmText) var confirmText = 'Confirm';
		if(!cancelText) var cancelText = 'Cancel';

		var html =  '<div class="alert"><h4 class="default">' + title + '</h4>' +
					'<p>' + message + '<br /><br /><br /></p>' +
					'<input type="button" value="'+confirmText+'" onclick="'+confirmFunc+'closeInternalPopup();" id="cnfFunc" /> ' +
					'<input type="button" value="'+cancelText+'" onclick="closeInternalPopup();" id="clsIntP" /></div>';
		internalPopup(html);
		el('clsIntP').focus();
	};

	function addInputSubmitEvent(form, input, func)
	{

	    if(!func) var func = function(){form.submit();};

	    input.onkeydown = function(e)
	    {
	        e = e || window.event;
	        if (e.keyCode == 13)
	        {
	            func();
	            return false;
	        }
	    };
	}

	function internalPopup(html)
	{
		hideSelectBoxes();
		hideFlash();

		var overlay = '<div id="pop_overlay"></div>' +
					  '<div id="pop_window">' +
					      '<div class="pop_top"></div>' +
					      '<div id="pop_content"></div>' +
					      '<div class="pop_footer"></div>' +
					  '</div>';

		el('intpopupdiv').innerHTML = overlay;
		el('pop_content').innerHTML = html;

		var POP_HEIGHT	= el('pop_window').offsetHeight;
		var POP_WIDTH	= el('pop_window').offsetWidth;

		resizeInternalPopup();

		positionInternalPopup();

		window.onscroll = function() { positionInternalPopup(); };
	}
	
	function bigInternalPopup(html)
	{
		hideSelectBoxes();
		hideFlash();

		var overlay = '<div id="pop_overlay"></div>' +
					  '<div id="pop_window">' +
				      '<div id="pop_content_big"></div>' +
					  '</div>';

		el('intpopupdiv').innerHTML = overlay;
		el('pop_content_big').innerHTML = html;

		resizeInternalPopup();

		positionInternalPopup();

		window.onscroll = function() { positionInternalPopup(); };
	}

	pip = function(){positionInternalPopup();};

	function positionInternalPopup(POP_WIDTH, POP_HEIGHT)
	{
		var POP_HEIGHT	= el('pop_window').offsetHeight;
		var POP_WIDTH	= el('pop_window').offsetWidth;

		var pagesize = getPageSize();

		var psTop = getPageScrollTop();
		var psLft = getPageScrollLeft();

		el('pop_window').style.left	= psLft + ((pagesize[2] - POP_WIDTH)  / 2 ) + 'px';
		el('pop_window').style.top	= psTop + ((pagesize[3] - POP_HEIGHT)  / 2 ) + 'px';
	}

	function resizeInternalPopup()
	{
		var pagesize = getPageSize();

		el('pop_overlay').style.height = pagesize[1] + 'px';
		el('pop_overlay').style.width = pagesize[0] + 'px';
	}

	function getPageScrollTop()
	{
		var dele = document.documentElement;
		if (self.pageYOffset || self.pageXOffset)
		{
			return self.pageYOffset;
		}
		else if (dele && dele.scrollTop || dele.scrollLeft )
		{
			return dele.scrollTop;
		}
		else if (document.body)
		{
			return document.body.scrollTop;
		}
		return false;
	}

	function getPageScrollLeft()
	{
		var dele = document.documentElement;
		if (self.pageYOffset || self.pageXOffset)
		{
			return self.pageXOffset;
		}
		else if (dele && dele.scrollTop || dele.scrollLeft )
		{     // Explorer 6 Strict
			return dele.scrollLeft;
		}
		else if (document.body)
		{     // all other Explorers
			return document.body.scrollLeft;
		}
		return false;
	}

	function getPageSize()
	{
		var xScroll, yScroll;

		if (window.innerHeight && window.scrollMaxY)
		{
			xScroll = window.innerWidth + window.scrollMaxX;
			yScroll = window.innerHeight + window.scrollMaxY;
		}
		else if (document.body.scrollHeight > document.body.offsetHeight)
		{     // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		}
		else
		{     // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}

		var windowWidth, windowHeight;

		if (self.innerHeight)
		{	// all except Explorer
			if(document.documentElement.clientWidth)
			{
				windowWidth = document.documentElement.clientWidth;
			}
			else
			{
				windowWidth = self.innerWidth;
			}
			windowHeight = self.innerHeight;
		}
		else if (document.documentElement && document.documentElement.clientHeight)
		{     // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		}
		else if (document.body)
		{     // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}

		if(yScroll < windowHeight)
		{
			pageHeight = windowHeight;
		}
		else
		{
			pageHeight = yScroll;
		}

		if(xScroll < windowWidth)
		{
			pageWidth = xScroll;
		}
		else
		{
			pageWidth = windowWidth;
		}

		arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
		return arrayPageSize;
	}

	function removeElement(obj)
	{
		var par = obj.parentNode;
		par.removeChild(obj);
	}

	function closeInternalPopup()
	{
		window.onscroll = '';
		new Effect.Puff(el('pop_window'), {duration: 0.5});
		var t = setTimeout("removeElement(el('pop_overlay'));removeElement(el('pop_window'));showSelectBoxes();showFlash();", 600);
	}
	
	function showSelectBoxes()
	{
		var selects = document.getElementsByTagName("select");
		for (i = 0; i != selects.length; i++)
		{
			selects[i].style.visibility = "visible";
		}
	}

	function hideSelectBoxes()
	{
		var selects = document.getElementsByTagName("select");
		for (i = 0; i != selects.length; i++)
		{
			selects[i].style.visibility = "hidden";
		}
	}

	function showFlash()
	{
		var flashObjects = document.getElementsByTagName("object");
		for (i = 0; i < flashObjects.length; i++)
		{
			flashObjects[i].style.visibility = "visible";
		}

		var flashEmbeds = document.getElementsByTagName("embed");
		for (i = 0; i < flashEmbeds.length; i++)
		{
			flashEmbeds[i].style.visibility = "visible";
		}
	}

	function hideFlash()
	{
		var flashObjects = document.getElementsByTagName("object");
		for (i = 0; i < flashObjects.length; i++)
		{
			flashObjects[i].style.visibility = "hidden";
		}

		var flashEmbeds = document.getElementsByTagName("embed");
		for (i = 0; i < flashEmbeds.length; i++)
		{
			flashEmbeds[i].style.visibility = "hidden";
		}

	}

	function selval(field)
	{
		obj = el(field);
		if(obj)
		{
			return obj.options[obj.selectedIndex].value;
		}
		else
		{
			return null;
		}
	}

	function radval(name)
	{

		var e = document.getElementsByName(name);
		if(!e) return false;

		for(i = 0; i < e.length; i++)
		{
			if(e[i].checked == true) return e[i].value;
		}
	}

	function setRadVal(name, val)
	{

		var e = document.getElementsByName(name);
		if(!e) return false;

		for(i = 0; i < e.length; i++)
		{
			e[i].checked = ((e[i].value == val) ? true : false);
		}
	}

	function ss_buildform(ref, dest, items)
	{
		var formobj = document.createElement('form');
		formobj.method = 'post';
		formobj.action = dest;
		formobj.id = ref;
		document.body.appendChild(formobj);

		for (i = 0; i<items.length;i++)
		{
			var html = '<input type="hidden" name="'+items[i].name+'" value="'+items[i].value+'" />';
			el(ref).innerHTML += html;
		}

		var html = '<input type="submit" id="'+ref+'submit" style="display: none;" />';
		el(ref).innerHTML += html;
	}

	function ss_reset_fields(items)
	{
		for(var item in items)
		{
			obj = el(item);
		}
	}

    var months = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');

    function carSearchChangeDoCtry(ctry)
    {
        var doctry = document.getElementById('doctry_id');
        for(i = 0; i < doctry.length; i++)
        {
            if(doctry[i].value==ctry) doctry[i].selected = true;
        }
    }

    searchDateResetDays = function(fieldid, year, month)
    {
        var field = el(fieldid);
        var dd = new Date(year, month, 0);
        var dim = dd.getDate();
        var sval = field.options[field.selectedIndex].value;
        for(i = field.length -1; i > 0; i--)
        {
            removeElement(field.options[i]);
        }
        for(i = 0; i < 31; i++)
        {
            field.options[i] = new Option((i + 1), (i + 1));
            if(sval==i+1)field.options[i].selected = true;
        }

        for(i = field.length -1; i >= 0; i--)
        {
            if(field.options[i].value > dim)
            {
                removeElement(field.options[i]);
            }
        }

        while(field.options[field.selectedIndex].value != sval)
        {
            sval--;
            if(field.options[sval -1]) field.options[sval -1].selected = true;
        }
    };

    function carSearchValidateHome(items)
    {
		return true;
    }

	document.getElementsByClassName = function(clsName)
	{
		var retVal = new Array();
		var elements = document.getElementsByTagName("*");
		for(var i = 0;i < elements.length;i++)
		{
			if(elements[i].className.indexOf(" ") >= 0)
			{
				var classes = elements[i].className.split(" ");
				for(var j = 0;j < classes.length;j++)
				{
					if(classes[j] == clsName) retVal.push(elements[i]);
				}
			}
			else if(elements[i].className == clsName) retVal.push(elements[i]);
		}
		return retVal;
	};

	setActive = function(btn)
	{
		var currAct = document.getElementsByClassName('active');

		if(currAct.length)
		{
			currAct[0].className = '';
		}
		var ele = $('nav_' + btn).parentNode;
		ele.className = 'active';
		setCookie('currnav', btn);
	};

	function findPos(obj)
	{
		var curleft = curtop = 0;
		if (obj.offsetParent)
		{
			curleft = obj.offsetLeft;
			curtop = obj.offsetTop;
			while (obj = obj.offsetParent)
			{
				curleft += obj.offsetLeft
				curtop += obj.offsetTop
			}
		}
		return [curleft,curtop];
	}

	function setCookie(name, value, days)
	{
		if(days)
		{
			var date = new Date();
			date.setTime(date.getTime() + (days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else
		{
			var expires = "";
		}

		document.cookie = name + "=" + value + expires + "; path=/";
	}

	function getCookie(name)
	{
		var ce = document.cookie.split(';');
		for(i=0;i<ce.length;i++)
		{
			var c = ce[i];
			var tmp = c.split('=');
			if(tmp[0] != name) continue;
			if(tmp[1] != "")
			{
				return tmp[1];
			}
			else
			{
				return null;
			}
		}
		return null;
	}

	function delCookie(name)
	{
		createCookie(name, "", -10);
	}

	var pageLoaded = false;

	function addDOMLoadEvent(func)
	{
		if(pageLoaded)
		{
			func();
		}
		else
		{
			if (!window.__load_events)
			{
			    var init = function ()
			    {
                    // quit if this function has already been called
                    if (arguments.callee.done) return;

                    // flag this function so we don't do the same thing twice
                    arguments.callee.done = true;
                    pageLoaded = true;

                    // kill the timer
                    if (window.__load_timer)
                    {
                        clearInterval(window.__load_timer);
                        window.__load_timer = null;
                    }

                    // execute each function in the stack in the order they were added
                    for (var i=0;i < window.__load_events.length;i++)
                    {
                        window.__load_events[i]();
                        //alert(window.__load_events[i]);
                    }
                    window.__load_events = null;
                };

                // for Mozilla/Opera9
                if (document.addEventListener)
                {
                    document.addEventListener("DOMContentLoaded", init, false);
                }

                // for Internet Explorer
                /*@cc_on @*/
                /*@if (@_win32)
                document.write("<scr"+"ipt id=__ie_onload defer src=//0><\/scr"+"ipt>");
                var script = document.getElementById("__ie_onload");
                script.onreadystatechange = function()
                {
                    if (this.readyState == "complete")
                    {
                        init(); // call the onload handler
                    }
                };
                /*@end @*/

                // for Safari
                if (/WebKit/i.test(navigator.userAgent))
                { // sniff
                    window.__load_timer = setInterval(function()
                    {
                        if (/loaded|complete/.test(document.readyState))
                        {
                            init(); // call the onload handler
                        }
                    }, 10);
                }

                // for other browsers
                window.onload = init;

                // create event function stack
                window.__load_events = [];
            }

            // add function to event stack
            window.__load_events.push(func);
        }
    }

	function preLoadImages()
	{
		var d = document;
		if(d.images)
		{
			if(!d.SSpre) d.SSpre=new Array();
			var i,j = d.SSpre.length;
			var a = preLoadImages.arguments;
			for(i=0; i<a.length; i++)
			{
				if (a[i].indexOf("#")!=0)
				{
					d.SSpre[j]=new Image;
					d.SSpre[j++].src=a[i];
				}
			}
		}
	}

	// Checks to make sure there was a response recieved in an ajax request.
	// If not, update the pop_content div with a nice friendly error message.
	function checkAjaxResponse(response)
	{
		if(response.length == 0)
		{
			var html =  '<div class="alert"><h4 class="default">Search Failed</h4>' +
						'<p>Sorry, it seems there was a problem performing your search. Please try again in a few minutes. If the problem continues, please email <a href="mailto:support@skyswan.com.au">support@skyswan.com.au</a>.<br /><br /><br /></p>' +
						'<input type="button" value="Close" onclick="closeInternalPopup();" id="clsIntP" /></div>';
			el('pop_content').innerHTML = html;
			el('clsIntP').focus();
		}
		else
		{
			return true;
		}
	}

	setDayName = function(field,y,m,d)
    {
        var weekday=new Array(7);
        weekday[0]='Sun';
        weekday[1]='Mon';
        weekday[2]='Tue';
        weekday[3]='Wed';
        weekday[4]='Thu';
        weekday[5]='Fri';
        weekday[6]='Sat';

        var date = new Date();
        date.setFullYear(y,(m - 1),d);
        $(field).innerHTML = weekday[date.getDay()];
    };

    setDayNameMonthYear = function(field, my, d)
    {
    	var weekday=new Array(7);
        weekday[0]='Sun';
        weekday[1]='Mon';
        weekday[2]='Tue';
        weekday[3]='Wed';
        weekday[4]='Thu';
        weekday[5]='Fri';
        weekday[6]='Sat';

    	var month_year = new Array();
    	var currentTime = new Date();

    	var start_year = currentTime.getFullYear();
    	var start_month = currentTime.getMonth();

    	for(var index = 0; index < 11; index++)
    	{
    		month_year[start_month + 1] = start_year;

    		currentTime.setMonth(currentTime.getMonth() + 1);

    	    start_year = currentTime.getFullYear();
    	    start_month = currentTime.getMonth();
    	}

    	month = my;
    	year = month_year[my];

    	var date = new Date();
    	date.setFullYear(year, (month -1), d);
    	$(field).innerHTML = weekday[date.getDay()];
    };

    function updateUsername(email)
	{
	    var username = "";

	    if(email != "")
	    {
	   		username = email;
	    }
	    else
	    {
	    	username = "Your Username is your E-mail";
	    }

	    el('theUserName').innerHTML = username;
	}

	function resetField(originalValue, field)
	{
		el(field).value = originalValue;
	}

	function resetGender()
	{
		if(radval('gender') == "F")
		{
			document.personalDetails.male.checked = true;
		}
		else
		{
			document.personalDetails.female.checked = true;
		}
    }

	function swTab(tab)
    {
        if(loaded && currNav != tab)
        {
        	new Effect.Fade('headNav', {duration:0.25, queue:'end'});
        	new Effect.Appear('hcLoad', {duration:0.25, queue:'end'});
        	new Ajax.Updater('headNav', '/Main/getNav/' + tab,
        	{
        		asynchronous:true,
        		evalScripts:true,
        		onComplete:function(request, json)
        		{
        			new Effect.Fade('hcLoad', {duration:0.25, queue:'end'});
        			new Effect.Appear('headNav', {duration:0.25, queue:'end'});
        			loaded=true;
        		}
        	});
        	currNav = tab;
        	setActive(tab);
        }
    }

    doNifty = function(niftyFunc)
    {
 		var btns = document.getElementsByClassName('btn_exp');
 		var btns_blue = document.getElementsByClassName('btn_exp_blue');
 		for(i = 0; i < btns_blue.length; i++)
 		{
 			btns.push(btns_blue[i]);
 		}
    	for (var i = 0; i < btns.length; i++)
    	{
	        var btn = btns[i];
        	btn.style.display = 'none';
    	}

    	niftyFunc();

    	for (var i = 0; i < btns.length; i++)
    	{
	        var btn = btns[i];
        	btn.style.display = '';
    	}
    };

    function msgBox_wait_large(msg, smlmsg)
	{
		strSmlMsg = "";
		if(smlmsg && smlmsg.length > 0)
		{
			strSmlMsg = '<br /><span style="font-size: 10px;">' + smlmsg + '</span>';
		}

		var html =  '<p style="text-align: center;"><img src="/images/spinner/swan.gif" /><br />Please Wait... ' + msg + '<br /><br />' +
					'<img src="/images/spinner/bar.gif" align="middle"/><br />' + strSmlMsg + '</p>';

		internalPopupLarge(html);
	}

	function internalPopupLarge(html)
	{
		hideSelectBoxes();
		hideFlash();

		var overlay = '<div id="pop_overlay"></div>' +
					  '<div id="pop_window">' +
					      '<div class="pop_top_large"></div>' +
					      '<div id="pop_content_large"></div>' +
					      '<div class="pop_footer_large"></div>' +
					  '</div>';

		el('intpopupdiv').innerHTML = overlay;
		el('pop_content_large').innerHTML = html;

		var POP_HEIGHT	= el('pop_window').offsetHeight;
		var POP_WIDTH	= el('pop_window').offsetWidth;

		resizeInternalPopup();

		positionInternalPopup();

		window.onscroll = function() { positionInternalPopup(); };
	}

	handleAjaxError = function(response)
	{
		var responseText = response.responseText;
		var pc = $('pop_content');

		alert(responseText);

		if(pc && pc.visible())
		{
			pc.innerHTML = responseText;
		}
		else
		{
			internalPopup(responseText);
		}
	};
	
	sortList = function(listObj)
	{
		var arrTexts = [];
		var arrValues = [];
		var arrOldTexts = [];
		
		for(i = 0; i < listObj.length; i++)
		{
			arrTexts[i] = listObj.options[i].text;
			arrValues[i] = listObj.options[i].value;
			arrOldTexts[i] = listObj.options[i].text;
		}

		arrTexts.sort();
		
		for(i = 0; i < listObj.length; i++)
		{
			listObj.options[i].text = arrTexts[i];
			for(j = 0; j < listObj.length; j++)
			{
				if(arrTexts[i] == arrOldTexts[j])
				{
					listObj.options[i].value = arrValues[j];
					j = listObj.length;
				}
			}
			
			if(i == 0) listObj.options[0].selected = true;
		}

	};/*============================================================================*/

/*

This routine checks the credit card number. The following checks are made:

1. A number has been provided
2. The number is a right length for the card
3. The number has an appropriate prefix for the card
4. The number has a valid modulus 10 number check digit if required

If the validation fails an error is reported.

The structure of credit card formats was gleaned from a variety of sources on 
the web, although the best is probably on Wikepedia ("Credit card number"):

  http://en.wikipedia.org/wiki/Credit_card_number

Parameters:
            cardnumber           number on the card
            cardname             name of card as defined in the card list below

Author:     John Gardner
Date:       1st November 2003
Updated:    26th Feb. 2005      Additional cards added by request
Updated:    27th Nov. 2006      Additional cards added from Wikipedia

*/

/*
   If a credit card number is invalid, an error reason is loaded into the 
   global ccErrorNo variable. This can be be used to index into the global error  
   string array to report the reason to the user if required:
   
   e.g. if (!checkCreditCard (number, name) alert (ccErrors(ccErrorNo);
*/

var ccErrorNo = 0;
var ccErrors = new Array ();

ccErrors [0] = "Unknown card type";
ccErrors [1] = "No card number provided";
ccErrors [2] = "Credit card number is in invalid format";
ccErrors [3] = "Credit card number is invalid";
ccErrors [4] = "Credit card number has an inappropriate number of digits";

function checkCreditCard (cardnumber, cardname) {
     
  // Array to hold the permitted card characteristics
  var cards = new Array();

  // Define the cards we support. You may add addtional card types.
  
  //  Name:      As in the selection box of the form - must be same as user's
  //  Length:    List of possible valid lengths of the card number for the card
  //  prefixes:  List of possible prefixes for the card
  //  checkdigit Boolean to say whether there is a check digit
  
  cards [0] = {name: "VI", 
               length: "13,16", 
               prefixes: "4",
               checkdigit: true};
  cards [1] = {name: "MS", 
               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) {
     ccErrorNo = 0;
     return false; 
  }
   
  // Ensure that the user has provided a credit card number
  if (cardnumber.length == 0)  {
     ccErrorNo = 1;
     return false; 
  }
    
  // 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))  {
     ccErrorNo = 2;
     return false; 
  }
       
  // 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)  {
     ccErrorNo = 3;
     return false; 
    }
  }  

  // 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) {
     ccErrorNo = 3;
     return false; 
  }
    
  // 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) {
     ccErrorNo = 4;
     return false; 
  };   
  
  // The credit card is in the required format.
  return true;
}

/*============================================================================*/
    doLogin = function()
    {
        msgBox_wait('');
        new Ajax.Updater('pop_content', '/Main/loginForm', {asynchronous:true, evalScripts:true})    };

    confirmLogin = function()
    {
        msgBox_wait('');
        new Ajax.Updater('pop_content', '/MyHome/loginconfirmation', {asynchronous:true, evalScripts:false})    };

   forgotPassword = function()
   {
        msgBox_wait('');
        new Ajax.Updater('pop_content', '/MyHome/forgotPassword', {asynchronous:true, evalScripts:false})    };


