function formatCurrency(num) {
    num = num.toString().replace(/\$|\,/g,'');
    if(isNaN(num)){
        num = "0";
    }
    sign = (num == (num = Math.abs(num)));
    num = Math.floor(num*100+0.50000000001);
    cents = num%100;
    num = Math.floor(num/100).toString();
    if(cents<10){
        cents = "0" + cents;
    }
    for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++){
        num = num.substring(0,num.length-(4*i+3))+','+num.substring(num.length-(4*i+3));
    }
    return (((sign)?'':'-')  + num + '.' + cents);
}

function popImage(imageURL,imageTitle){
    PositionX = 100;
    PositionY = 100;
    defaultWidth  = 500;
    defaultHeight = 500;

    var AutoClose = true;

    if (parseInt(navigator.appVersion.charAt(0))>=4){
        var isNN=(navigator.appName=="Netscape")?1:0;
        var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;
    }
    var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
    var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;


    if (isNN){
        imgWin=window.open('about:blank','',optNN);
    }
    if (isIE){
        imgWin=window.open('about:blank','',optIE);
    }
    with (imgWin.document){
        writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
        writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
        writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
        writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(300,300);');
        writeln('width=300-(document.body.clientWidth-document.images[0].width);');
        writeln('height=300-(document.body.clientHeight-document.images[0].height);');
        writeln('window.resizeTo(width,height);}');writeln('if (isNN){');
        writeln('window.innerWidth=document.images["Mindsmack"].width;');writeln('window.innerHeight=document.images["Mindsmack"].height;}}');
        writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
        if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
        else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
        writeln('<img id="Mindsmack" name="Mindsmack" src='+imageURL+' style="display:block"></body></html>');
        close();
        }
}
function popImage(imageURL,imageTitle){
    PositionX = 100;
    PositionY = 100;
    defaultWidth  = 500;
    defaultHeight = 500;

    var AutoClose = true;

    if (parseInt(navigator.appVersion.charAt(0))>=4){
        var isNN=(navigator.appName=="Netscape")?1:0;
        var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;
    }
    var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
    var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;


    if (isNN){
        imgWin=window.open('about:blank','',optNN);
    }
    if (isIE){
        imgWin=window.open('about:blank','',optIE);
    }
    with (imgWin.document){
        writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
        writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
        writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
        writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(300,300);');
        writeln('width=300-(document.body.clientWidth-document.images[0].width);');
        writeln('height=300-(document.body.clientHeight-document.images[0].height);');
        writeln('window.resizeTo(width,height);}');writeln('if (isNN){');
        writeln('window.innerWidth=document.images["Mindsmack"].width;');writeln('window.innerHeight=document.images["Mindsmack"].height;}}');
        writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
        if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
        else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
        writeln('<img id="Mindsmack" name="Mindsmack" src='+imageURL+' style="display:block"></body></html>');
        close();
        }
}

/**
 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
    var i;
    for (i = 0; i < s.length; i++){
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
    var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
    // February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
    for (var i = 1; i <= n; i++) {
        this[i] = 31
        if (i==4 || i==6 || i==9 || i==11) {
            this[i] = 30
        }
        if (i==2) {
            this[i] = 29
        }
    }
    return this
}

function isDate(dtStr){
    var daysInMonth = DaysArray(12)
    var pos1=dtStr.indexOf(dtCh)
    var pos2=dtStr.indexOf(dtCh,pos1+1)
    var strMonth=dtStr.substring(0,pos1)
    var strDay=dtStr.substring(pos1+1,pos2)
    var strYear=dtStr.substring(pos2+1)
    strYr=strYear
    if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
    if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
    for (var i = 1; i <= 3; i++) {
        if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
    }
    month=parseInt(strMonth)
    day=parseInt(strDay)
    year=parseInt(strYr)
    if (pos1==-1 || pos2==-1)
        return false;
    if (strMonth.length<1 || month<1 || month>12)
        return false;
    if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month])
        return false;
    if (strYear.length != 4 || year==0 || year<minYear || year>maxYear)
        return false;
    if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false)
        return false;
    return true
}

function validateDate(fec) {
	fec = fec.split("/"); 
	day = fec[2];
	month = fec[1];
	year = fec[0];

	if(day == '' || month == '' || year == '' || day > 31 || month > 12)
		return false;
	if(yearbi(year))
		febrero=29;
	else
		febrero=28;
	if (month==02){
		if(day > febrero){
			return false;
		}
	}
	if (((month==4) || (month==6) || (month==9) || (month==11)) && (day>30)){
		return false;
	}
return true;
} 

function yearbi(year){
	if (year % 4 != 0)
		return false;
	else{
		if (year % 100 == 0){
			if (year % 400 == 0){
				return true;
		}else{
			return false;
		}
		}else{
			return true;
		}
	}
}

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1)
		   return false;
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
		   return false;
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
		    return false;
		 if (str.indexOf(at,(lat+1))!=-1)
		    return false;
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
		    return false;
		 if (str.indexOf(dot,(lat+2))==-1)
		    return false;
		 if (str.indexOf(" ")!=-1)
		    return false;
 		 return true
	}

function calculateAge(yy, mm, dd) {
days = new Date();
gdate = days.getDate();
gmonth = days.getMonth();
gyear = days.getFullYear();
if (gyear < 2000) gyear += 1900;
age = gyear - yy;
if ((mm == (gmonth + 1)) && (dd <= parseInt(gdate))) 
	{
	age = age; 
	} 
else 
	{
	if (mm <= (gmonth)) 
		{
		age = age;
		} 
	else 
		{
		age = age - 1; 
   		}
	}
if (age == 0) age = age;
return age;
}

