// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 
// 
//  Fill Date Combos
//
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 

/*
function load_date(day,month,year) 
{

//@ TODO - obtain minimum registration age from persistence layer
var currentTime = new Date();
var MAXBIRTHYEAR = currentTime.getFullYear() - 13;
var MINBIRTHYEAR = 1900;
var dayHTML = "<option value=\'Dia\' >Dia</option>";
var monthHTML = "<option value=\'Mes\' >M&ecirc;s</option>";
var yearHTML = "<option value=\'9999\' >Ano</option>";
var i;

// Dia
for (i = 1; i < 32; i++)
    if(day == i){
        dayHTML = dayHTML + "<option value=\'" + i + "\' selected>" + i + "</option>";
    }else{
        dayHTML = dayHTML + "<option value=\'" + i + "\'>" + i + "</option>";
    }

// Mes
for (i = 1; i < 13; i++)
    if(month == i){
        monthHTML = monthHTML + "<option value=\'" + i + "\' selected>" + i + "</option>";
    }else{
        monthHTML = monthHTML + "<option value=\'" + i + "\'>" + i + "</option>";
    }

// Ano
for (i = MAXBIRTHYEAR; i >= MINBIRTHYEAR; i--)
    if(year == i){
        yearHTML = yearHTML + "<option value=\'" + i + "\' selected>" + i + "</option>";
    } else {
        yearHTML = yearHTML + "<option value=\'" + i + "\'>" + i + "</option>";
    }

var doc = document.InputRegistrationForm;

    doc.birthDay.innerHTML = dayHTML;
    doc.birthMonth.innerHTML = monthHTML;
    doc.birthYear.innerHTML = yearHTML;

return

} */
 

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 

//Copyright (C) 1996 - 2000 Vignette Corporation. All rights reserved. 

//THIS PROGRAM IS AN UNPUBLISHED WORK AND IS CONSIDERED A TRADE SECRET AND 

//CONFIDENTIAL INFORMATION BELONGING TO VIGNETTE CORPORATION. ANY 

//UNAUTHORIZED USE IS STRICTLY PROHIBITED. 

// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 

function updateMonth(month, day, year) {
	var iIndex = month.selectedIndex;


	if (month.options[iIndex].value == "2") {
		day.options[31] = null;
		day.options[30] = null;

		var yearSelected = year.selectedIndex;
                
                // Default gets 28 days case year is not selected
                if (yearSelected == 0){
                    day.options[29] = null;
                }
                else
                {

                    var yearValue = eval(year[yearSelected].value);

                    if (((yearValue % 400) == 0) || (((yearValue % 100) != 0) && 
                        ((yearValue % 4) == 0)) ) {
                            if (day.options[29] == null) {
                                    day.options[29] = new Option("29", "29");
                            }
                    } else {
                            day.options[29] = null;
                    }
               }
	}

	if (month.options[iIndex].value == "1" ||
		month.options[iIndex].value == "3" ||
		month.options[iIndex].value == "5" ||
		month.options[iIndex].value == "7" ||
		month.options[iIndex].value == "8" ||
		month.options[iIndex].value == "10" ||
		month.options[iIndex].value == "12")
	{
		if (day.options[29] == null) {
			day.options[29] = new Option("29", "29");
		}

		if (day.options[30] == null) {
			day.options[30] = new Option("30", "30");
		}

        	if (day.options[31] == null) {
			day.options[31] = new Option("31", "31");
		}
	}

        if (month.options[iIndex].value == "4" ||
		month.options[iIndex].value == "6" ||
		month.options[iIndex].value == "9" ||
		month.options[iIndex].value == "11")
	{
		if (day.options[29] == null) {
			day.options[29] = new Option("29", "29");
		}

		if (day.options[30] == null) {
			day.options[30] = new Option("30", "30");
		}

		day.options[31] = null;
	}

	if (day.selectedIndex == -1)
	{
		day.selectedIndex = 0;
	}
}


function parseDateString(mdy, dateStr) {
	var mStr, dStr, yStr

	// month
	slash1_idx = dateStr.indexOf('/', 0)
	if (slash1_idx <= 0) {
		return "";
	}
	mStr = dateStr.substring(0, slash1_idx)

	slash2_idx = dateStr.indexOf('/', slash1_idx + 1)
	if (slash1_idx <= 0) {
		return "";
	}
	dStr = dateStr.substring(slash1_idx + 1, slash2_idx)
	yStr = dateStr.substring(slash2_idx + 1, dateStr.length)

	if (mdy == "month") return mStr
	if (mdy == "day") return dStr
	return yStr
}

//--------------------------------------------------------------------------------------------------------------------

<!-- Vignette V6 Fri Jan 05 18:19:38 2007 -->
// -------------------------------------------------

// VARIABLE DECLARATIONS



// Specific functions

// non-digit characters which are allowed in phone numbers

var phoneNumberDelimiters = "()- ";

// characters which are allowed in US phone numbers

var validUSPhoneChars = digits + phoneNumberDelimiters;

// characters which are allowed in international phone numbers

// (a leading + is OK)

var validWorldPhoneChars = digits + phoneNumberDelimiters + "+";

// non-digit characters which are allowed in 

// Social Security Numbers

var SSNDelimiters = "- ";

// characters which are allowed in Social Security Numbers

var validSSNChars = digits + SSNDelimiters;

// U.S. Social Security Numbers have 9 digits.

// They are formatted as 123-45-6789.

var digitsInSocialSecurityNumber = 9;

// non-digit characters which are allowed in ZIP Codes

var ZIPCodeDelimiters = "-";

// our preferred delimiter for reformatting ZIP Codes

var ZIPCodeDelimeter = "-"

// characters which are allowed in Social Security Numbers

var validZIPCodeChars = digits + ZIPCodeDelimiters

// non-digit characters which are allowed in credit card numbers

var creditCardDelimiters = " "



var daysInMonth = makeArray(12);

daysInMonth[1] = 31;

daysInMonth[2] = 29;   // must programmatically check this

daysInMonth[3] = 31;

daysInMonth[4] = 30;

daysInMonth[5] = 31;

daysInMonth[6] = 30;

daysInMonth[7] = 31;

daysInMonth[8] = 31;

daysInMonth[9] = 30;

daysInMonth[10] = 31;

daysInMonth[11] = 30;

daysInMonth[12] = 31;





// CONSTANT STRING DECLARATIONS

// (grouped for ease of translation and localization)



var defaultEmptyOK = false



// Attempting to make this library run on Navigator 2.0,

// so I'm supplying this array creation routine as per

// JavaScript 1.0 documentation.  If you're using 

// Navigator 3.0 or later, you don't need to do this;

// you can use the Array constructor instead.



//-------------------------------

// FUNCTIONS



// Generic vars
var digits = "0123456789";
var lowercaseLetters = "abcdefghijklmnopqrstuvwxyz"
var uppercaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
var whitespace = " tnr";
var decimalPointDelimiter = "."

function makeArray(n) {
//*** BUG: If I put this line in, I get two error messages:
//(1) Window.length can't be set by assignment
//(2) daysInMonth has no property indexed by 4
//If I leave it out, the code works fine.
//   this.length = n;
   for (var i = 1; i <= n; i++) {
      this[i] = 0
   } 
   return this
}
// Check whether string s is empty.
function isEmpty(s) {
   return ((s == null) || (s.length == 0))
}
function cb_parseInt(s) {
	return parseInt(s, 10);
}
function isWhitespace (s) {
    var i;
    if (isEmpty(s)) return true;
    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if (whitespace.indexOf(c) == -1) return false;
    }
    // All characters are whitespace.
    return true;
}
// Removes all characters which appear in string bag from string s.
function stripCharsInBag (s, bag) {
    var i;
    var returnString = "";
    for (i = 0; i < s.length; i++) {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}
// Removes all whitespace characters from s.
// Global variable whitespace (see above)
// defines which characters are considered whitespace.
function stripWhitespace (s)
{   return stripCharsInBag (s, whitespace)
}
function charInString (c, s){
    for (i = 0; i < s.length; i++)
    {   if (s.charAt(i) == c) return true;
    }
    return false
}
function stripInitialWhitespace (s) {
   var i = 0;
    while ((i < s.length) && charInString (s.charAt(i), whitespace))
       i++;
    return s.substring (i, s.length);
}
function isLetter (c)
{   return ( ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) )
}
function isDigit (c)
{   return ((c >= "0") && (c <= "9"))
}
function isLetterOrDigit (c)
{   return (isLetter(c) || isDigit(c))
}

function isSpecialChar (c) {
	return ( (c == ".") || (c == "_"))
}

function isSpecialChar2 (c) {
	return ( (c == ".") || (c == "_") || (c == "-"))
}

function disableSubmits (form) { 
 for (var i = 0; i < form.elements.length; i++) 
	if (form.elements[i].type.toLowerCase() == 'submit') 
		form.elements[i].disabled = true; 
}

function reformat (s)
{   var arg;
    var sPos = 0;
    var resultString = "";
    for (var i = 1; i < reformat.arguments.length; i++) {
       arg = reformat.arguments[i];
       if (i % 2 == 1) resultString += arg;
       else {
           resultString += s.substring(sPos, sPos + arg);
           sPos += arg;
       }
    }
    return resultString;
}

	function isPortuguesePhoneNumber (s)
	{   if (isEmpty(s)) 
	       if (isPortuguesePhoneNumber.arguments.length == 1) return defaultEmptyOK;
	       else return (isPortuguesePhoneNumber.arguments[1] == true);
		if (s.length != 9)
			return false;
		// Checks if a PortuguesePhoneNumber is valid   
		return (isInteger (s));
	}

	function isString (s)
	{  
		if (isEmpty(s)) 
	       if (isString.arguments.length == 1) return defaultEmptyOK;
	       else return (isString.arguments[1] == true);
		
		// All characters are considered valid for now.
	    return true;
	}

	function isInteger (s)
	{   var i;
	
	    if (isEmpty(s)) 
	       if (isInteger.arguments.length == 1) return defaultEmptyOK;
	       else return (isInteger.arguments[1] == true);
	
	    // Search through string's characters one by one
	    // until we find a non-numeric character.
	    // When we do, return false; if we don't, return true.
	
	    for (i = 0; i < s.length; i++)
	    {   
	        // Check that current character is number.
	        var c = s.charAt(i);
	
	        if (!isDigit(c)) return false;
	    }
	
	    // All characters are numbers.
	    return true;
	}

	function isSignedInteger (s)
	{   if (isEmpty(s)) 
	       if (isSignedInteger.arguments.length == 1) return defaultEmptyOK;
	       else return (isSignedInteger.arguments[1] == true);
	    else {
	        var startPos = 0;
	        var secondArg = defaultEmptyOK;
	        if (isSignedInteger.arguments.length > 1)
	            secondArg = isSignedInteger.arguments[1];
	        // skip leading + or -
	        if ( (s.charAt(0) == "-") || (s.charAt(0) == "+") )
	           startPos = 1;    
	        return (isInteger(s.substring(startPos, s.length), secondArg))
	    }
	}

	function isPositiveInteger (s)
	{   var secondArg = defaultEmptyOK;
	    if (isPositiveInteger.arguments.length > 1)
	        secondArg = isPositiveInteger.arguments[1];
	    return (isSignedInteger(s, secondArg)
	         && ( (isEmpty(s) && secondArg)  || (cb_parseInt (s) > 0) ) );
	}

	function isSpecialAlphanumeric (s)
	{   var i;
	    if (isEmpty(s)) 
	       if (isSpecialAlphanumeric.arguments.length == 1) return defaultEmptyOK;
	       else return (isSpecialAlphanumeric.arguments[1] == true);
	    for (i = 0; i < s.length; i++) 
	    {   
	        var c = s.charAt(i);
	        if (! (isLetter(c) || isDigit(c) || isSpecialChar(c) ) )
	        return false;
	    }
	    return true;
	}

	function isSpecialAlphanumericEmail (s)
	{   var i;
	    if (isEmpty(s)) 
	       if (isSpecialAlphanumericEmail.arguments.length == 1) return defaultEmptyOK;
	       else return (isSpecialAlphanumericEmail.arguments[1] == true);
	    for (i = 0; i < s.length; i++) 
	    {   
	        var c = s.charAt(i);
	        if (! (isLetter(c) || isDigit(c) || isSpecialChar2(c)))
	        return false;
	    }
	    return true;
	}

/*---------------------------------------------------------------------------------
Image Utils
----------------------------------------------------------------------------------*/

function MM_swapImgRestore() { //v3.0
        var i,x,a=document.MM_sr; for(i=0;a&&i < a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
        var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
        var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i < a.length; i++)
        if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
        window.open(theURL,winName,features);
}
function MM_findObj(n, d) { //v4.0
        var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
        if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i < d.forms.length;i++) x=d.forms[i][n];
        for(i=0;!x&&d.layers&&i < d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
        if(!x && document.getElementById) x=document.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
        var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i < (a.length-2);i+=3)
        if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


