/* functions for hiding elements*/
function doHide(elementId)
{
document.getElementById(elementId).style.display = 'none';
}
function doShow(elementId)
{
document.getElementById(elementId).style.display = 'block';
}
function doHideNeeds(elementId)
{
document.getElementById(elementId).style.display = 'none';
}
function doShowNeeds(elementId)
{
document.getElementById(elementId).style.display = 'block';
}
function doHideAttractions(elementId)
{
document.getElementById(elementId).style.display = 'none';
document.getElementById('hideCheckAttract').innerHTML = '<img src="/images/symbols/check-mark.jpg">';

}
function doShowAttractions(elementId)
{
document.getElementById(elementId).style.display = 'block';
document.getElementById('hideCheckAttract').innerHTML = '<img src="/images/symbols/check-mark.jpg">';
}
function doHideRestaurants(elementId)
{
document.getElementById(elementId).style.display = 'none';
document.getElementById('hideCheckFood').innerHTML = '<img src="/images/symbols/check-mark.jpg">';

}
function doShowRestaurants(elementId)
{
document.getElementById(elementId).style.display = 'block';
document.getElementById('hideCheckFood').innerHTML = '<img src="/images/symbols/check-mark.jpg">';
}
function doHideEvents(elementId)
{
document.getElementById(elementId).style.display = 'none';
document.getElementById('hideCheckEvent').innerHTML = '<img src="/images/symbols/check-mark.jpg">';

}
function doShowEvents(elementId)
{
document.getElementById(elementId).style.display = 'block';
document.getElementById('hideCheckEvent').innerHTML = '<img src="/images/symbols/check-mark.jpg">';
}
function doHideShops(elementId)
{
document.getElementById(elementId).style.display = 'none';
document.getElementById('hideCheckShops').innerHTML = '<img src="/images/symbols/check-mark.jpg">';

}
function doShowShops(elementId)
{
document.getElementById(elementId).style.display = 'block';
document.getElementById('hideCheckShops').innerHTML = '<img src="/images/symbols/check-mark.jpg">';
}
function doHideCreate(elementId)
{
document.getElementById(elementId).style.display = 'none';
}
function doShowCreate(elementId)
{
document.getElementById(elementId).style.display = 'block';
}
function doHidePark(elementId)
{
document.getElementById(elementId).style.display = 'none';


}
function doShowPark(elementId)
{
document.getElementById(elementId).style.display = 'block';

}
function doHideBack(elementId)
{
document.getElementById(elementId).style.display = 'none';
}
function doShowBack(elementId)
{
document.getElementById(elementId).style.display = 'block';
}
function doHideCheck(elementId)
{
document.getElementById(elementId).style.display = 'none';
}
function doShowCheck(elementId)
{
if (elementId=='hideCheckPark')
	{
	document.getElementById('hideCheckPark').innerHTML = '<img src="/images/symbols/check-mark.jpg">';
	}
if (elementId=='hideCheckMap')
	{
	document.getElementById('hideCheckMap').innerHTML = '<img src="/images/symbols/check-mark.jpg">';
	}
}
 /* DHTML date validation script. */
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1985;
var maxYear=1991;

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){
		alert("The date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		//alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		alert("You must be 13 - 18 years old to join this program.  Verify you have entered the date in the proper format - mm/dd/yyyy")
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
return true
}


 
 //end of date validation


function emailvalidation(entered, alertbox)
{
	with (entered)
	{
	apos=value.indexOf("@");
	dotpos=value.lastIndexOf(".");
	lastpos=value.length-1;
	if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) 
		{
		if (alertbox) 
		{
		alert(alertbox);
		} 
		return false;
		}
		else 
		{
		return true;
		}
	}
}

function valuevalidation(entered, min, max, alertbox, datatype)
{
with (entered)
{
checkvalue=parseFloat(value);
if (datatype)
  {smalldatatype=datatype.toLowerCase();
   if (smalldatatype.charAt(0)=="i") {checkvalue=parseInt(value)};
  }
if ((parseFloat(min)==min && checkvalue<min) || (parseFloat(max)==max && checkvalue>max) || value!=checkvalue)
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}

function digitvalidation(entered, min, max, alertbox, datatype)
{
with (entered)
{
checkvalue=parseFloat(value);
if (datatype)
  {smalldatatype=datatype.toLowerCase();
   if (smalldatatype.charAt(0)=="i") {checkvalue=parseInt(value); if (value.indexOf(".")!=-1) {checkvalue=checkvalue+1}};
  }
if ((parseFloat(min)==min && value.length<min) || (parseFloat(max)==max && value.length>max) || value!=checkvalue)
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}

function emptyvalidation(entered, alertbox)
{
with (entered)
{

if (value==null || value=="")

{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}

function open_win(what_link,the_x,the_y,toolbar,addressbar,directories,statusbar,menubar,scrollbar,resize,history,pos,wname){ 
var the_url = what_link;
the_x -= 0;
the_y -= 0;

var how_wide = screen.availWidth;
var how_high = screen.availHeight;
if(toolbar == "0"){var the_toolbar = "no";}else{var the_toolbar = "yes";}
if(addressbar == "0"){var the_addressbar = "no";}else{var the_addressbar = "yes";}
if(directories == "0"){var the_directories = "no";}else{var the_directories = "yes";}
if(statusbar == "0"){var the_statusbar = "no";}else{var the_statusbar = "yes";}
if(menubar == "0"){var the_menubar = "no";}else{var the_menubar = "yes";}
if(scrollbar == "0"){var the_scrollbars = "no";}else{var the_scrollbars = "yes";}
if(resize == "0"){var the_do_resize =  "no";}else{var the_do_resize = "yes";}
if(history == "0"){var the_copy_history = "no";}else{var the_copy_history = "yes";}
if(pos == 1){top_pos=0;left_pos=0;}
if(pos == 2){top_pos = 0;left_pos = (how_wide/2) -  (the_x/2);}
if(pos == 3){top_pos = 0;left_pos = how_wide - the_x;}
if(pos == 4){top_pos = (how_high/2) -  (the_y/2);left_pos = 0;}
if(pos == 5){top_pos = (how_high/2) -  (the_y/2);left_pos = (how_wide/2) -  (the_x/2);}
if(pos == 6){top_pos = (how_high/2) -  (the_y/2);left_pos = how_wide - the_x;}
if(pos == 7){top_pos = how_high - the_y;left_pos = 0;}
if(pos == 8){top_pos = how_high - the_y;left_pos = (how_wide/2) -  (the_x/2);}
if(pos == 9){top_pos = how_high - the_y;left_pos = how_wide - the_x;}
if (window.outerWidth ){
var option = "toolbar="+the_toolbar+",location="+the_addressbar+",directories="+the_directories+",status="+the_statusbar+",menubar="+the_menubar+",scrollbars="+the_scrollbars+",resizable="+the_do_resize+",outerWidth="+the_x+",outerHeight="+the_y+",copyhistory="+the_copy_history+",left="+left_pos+",top="+top_pos;
wname=window.open(the_url, wname, option);
wname.focus();
}
else
{
var option = "toolbar="+the_toolbar+",location="+the_addressbar+",directories="+the_directories+",status="+the_statusbar+",menubar="+the_menubar+",scrollbars="+the_scrollbars+",resizable="+the_do_resize+",Width="+the_x+",Height="+the_y+",copyhistory="+the_copy_history+",left="+left_pos+",top="+top_pos;
if (!wname.closed && wname.location){
wname.location.href=the_url;
}
else
{
wname=window.open(the_url, wname, option);
//wname.resizeTo(the_x,the_y);
wname.focus();
wname.location.href=the_url;
}
}
} 
