maxchildren = 6;
var globalTakeFocus=null;

function setFocus(ref) {
    globalTakeFocus=ref;
    setTimeout("globalTakeFocus.focus();globalTakeFocus.select()",100);
}

function nval (c) { // return Numeric VALue of a control with a text value
	var v = sval(c);
	if (0 == v.length) return 0;
	return(parseFloat(v));
} // function nval

function sval (c) { // return String VALue of a control
	if (c.type=="text" || c.type=="textarea" || c.type=="hidden") return c.value;
	if (c.type=="select-one") {
		var v = c.options[c.selectedIndex].value;
		if (v == '') v = c.options[c.selectedIndex].text;
		return v;
	}
	return null;
} // function sval

function abort (c, m) { window.alert(m); if (c) c.focus(); return false; }
function abort2 (c, m) { window.alert(m); if (c) setFocus(c); return false; }

function date_is_valid(yyyy, mm, dd) {
// returns false if date is invalid
// returns true otherwise

        yyyy = parseInt(yyyy,10); mm = parseInt(mm,10); dd = parseInt(dd,10);

	if (yyyy == NaN || yyyy <1753 || 9999 <yyyy) return false;
	if (mm   == NaN ||   mm <1 ||   12 <mm) return false;
	if (dd   == NaN ||   dd <1 ||   31 <dd) return false;

	if (dd <29) return true;
	if (mm==1||mm==3||mm==5||mm==7||mm==8||mm==10||mm==12) return true;
	if (mm==2) {
		if (dd==29 && (yyyy%4?0:(yyyy%400?(yyyy%100?1:0):1)))
			return true;
	} else if (dd <31) return true;
	return false;

} // function date_is_valid

function days_in_future(yyyy, mm, dd) {

// returns false if date is invalid
// returns number of days in the future if valid (negative for past dates)

	yyyy = parseInt(yyyy,10); mm = parseInt(mm,10); dd = parseInt(dd,10);
	if (!date_is_valid(yyyy, mm, dd)) return false;
	var then = new Date(yyyy, mm-1, dd, 0,0,0,0);
	var d = new Date();
	var today = new Date(d.getFullYear(),d.getMonth(),d.getDate(),0,0,0,0);
	var msdiff = then.getTime() - today.getTime(); // milliseconds
	var daydiff = Math.floor(msdiff / 86400000 + 0.5);
	return daydiff;

} // function days_in_future

function bf()
{
  if ((top.location != location) &&
      (location.hostname != "vacations-in-hawaii.com") &&
      (location.hostname != "secure-travel.com") &&
      (location.hostname != "thawaii.com")
     ) {
    top.location.href = document.location.href ;
  }
}
function CheckDate (c) {
// Given a date-containing html form element, does basic checks on the validity
// of the date, returns false if not valid. Else returns a (true) Date object
    v = sval(c);
    return String2Date(v);
}
function String2Date (s) {
// Given a date (string) mm/dd/yyyy or yyyy/mm/dd, does basic checks on the
// validity of the date and returns false if not valid. Else returns a (true)
// Date object.
    var m, d, y;
    var pat, result;
    pat = /^(\d\d?)\/(\d\d?)\/(\d\d\d\d)$/;
    result = v.match(pat);
    if (result) { // mm/dd/yyyy
        m = result[1]; d = result[2]; y = result[3];
    } else {
        pat = /^(\d\d\d\d)\/(\d\d?)\/(\d\d?)$/;
        result = v.match(pat);
        if (result) { // yyyy/mm/dd
            y = result[1]; m = result[2]; d = result[3];
        } else {
            return false;
        }
    }
    if (date_is_valid(y, m, d))
        return new Date(y, m-1, d);
    else
        return false;
}
function GetChildCount(fob) {

// This function should be passed a single object already known to be an
// HTML form object.

var n = 0;
if (fob && fob.Num_Children) {
	n = parseInt(fob.Num_Children.value, 10);
	n = isNaN(n) ? 0 : Math.round(n);
	if (maxchildren && maxchildren <n) n = maxchildren;
	if (n <0) n = 0;
} // if
return n;
} // function GetChildCount

function HandleChildren(scope) {

// If called from an onChange handler, the input is the HTML form element,
// and we confine ourselves to the surrounding form.
// Otherwise, probably called from the body onLoad routine...ignore input and
// init all document forms.

var i;
if (scope && scope.form)
	SetChildAgeVisibility(scope.form);
else if (document.forms && 0 <document.forms.length) {
	for (i = 0; i <document.forms.length; ++i)
		SetChildAgeVisibility(document.forms[i]);
} else {
	; // no forms at all, do nothing
}
} // function Handlechildren

function VerifyChildren(fob) {

// This function should be passed a single object already known to be an
// HTML form object.

var nchildren;
var idx;
var c;
if (fob) {
	nchildren = GetChildCount(fob);
	for (idx = 1; idx <= nchildren; ++idx)
		if ((c = fob["ChildAge"+idx]) && c.value.match(/\D/))
			return abort(c, "You must select an age for child number " + idx + ".");
}
return true;
} // function VerifyChildren

function SetChildAgeVisibility(fob) {

// This function should be passed a single object already known to be an
// HTML form object. It doesn't have to contain children counters or ages,
// but if it does have a Num_Children element in it, this routine will try
// to set the .disabled and .style.visibility properties of any ChildAge*
// elements according to the current value of the Num_Children element.

var nchildren;
var idx;
var c;
if (fob && fob.Num_Children) {
	nchildren = GetChildCount(fob);
	idx = 1;
	while (c = fob["ChildAge"+idx]) {
		if (idx <= nchildren) {
			if (c.disabled != null) c.disabled = "";
			if (c.style && (c.style.visibility != null))
				c.style.visibility = "";
		} else {
			if (c.disabled != null) c.disabled = "disabled";
			if (c.style && (c.style.visibility != null))
				c.style.visibility = "hidden";
		}
		++idx;
	}
} // if
} // function SetChildAgeVisibility

function CarOptionVisibility (fob) {
	var f = fob;
    f.Car_Option.visibility="hidden";
}

function FieldExists(fname) {

// Looks through all forms in the current document for a given field name
// Returns true if such a field can be found, false otherwise
// tested on Win(FFox,IE6), PPC-OSX(Ffox,Safari,IE5), Intel-OSX(Ffox,Safari)

    var retval = 0;
    var i, curform;

    if (document.forms && 0 <document.forms.length) {
        for (i = 0; i <document.forms.length; ++i) {
            curform = document.forms[i];
            if (curform[fname]) {
                retval = 1;
                break;
            }
        }
    }
    return retval;
}

function GetStateSelector(f,myfield) {
var index; var country; var state;
if (myfield == "Country") {
    index=f.Country.selectedIndex;
    country=f.Country.options[index].value;
    state=f.State;
} else if (myfield == "CC_Country") {
    index=f.CC_Country.selectedIndex;
    country=f.CC_Country.options[index].value;
    state=f.CC_Billing_State;
}

if (country == "USA") {
state.length=52;
state.options[0].text="STATE"
state.options[0].value="XX";
state.options[1].text="Alabama AL"
state.options[1].value="AL";
state.options[2].text="Alaska AK"
state.options[2].value="AK"
state.options[3].text="Arizona AZ"
state.options[3].value="AZ"
state.options[4].text="Arkansas AR"
state.options[4].value="AR"
state.options[5].text="Armed Forces Americas"
state.options[5].value="AA"
state.options[6].text="Armed Forces Europe"
state.options[6].value="AE"
state.options[7].text="Armed Forces Pacific"
state.options[7].value="AP"
state.options[8].text="California CA"
state.options[8].value="CA"
state.options[9].text="Colorado CO"
state.options[9].value="CO"
state.options[10].text="Connecticut CT"
state.options[10].value="CT"
state.options[11].text="Delaware DE"
state.options[11].value="DE"
state.options[12].text="Dist of Columbia DC"
state.options[12].value="DC"
state.options[13].text="Florida FL"
state.options[13].value="FL"
state.options[14].text="Georgia GA"
state.options[14].value="GA"
state.options[15].text="Hawaii HI"
state.options[15].value="HI"
state.options[16].text="Idaho ID"
state.options[16].value="ID"
state.options[17].text="Illinois IL"
state.options[17].value="IL"
state.options[18].text="Indiana IN"
state.options[18].value="IN"
state.options[19].text="Iowa IA"
state.options[19].value="IA"
state.options[20].text="Kansas KS"
state.options[20].value="KS"
state.options[21].text="Kentucky KY"
state.options[21].value="KY"
state.options[22].text="Louisiana LA"
state.options[22].value="LA"
state.options[23].text="Maine ME"
state.options[23].value="ME"
state.options[24].text="Maryland MD"
state.options[24].value="MD"
state.options[25].text="Massachusetts MA"
state.options[25].value="MA"
state.options[26].text="Michigan MI"
state.options[26].value="MI"
state.options[27].text="Minnesota MN"
state.options[27].value="MN"
state.options[28].text="Mississippi MS"
state.options[28].value="MS"
state.options[29].text="Missouri MO"
state.options[29].value="MO"
state.options[30].text="Montana MT"
state.options[30].value="MT"
state.options[31].text="Nebraska NE"
state.options[31].value="NE"
state.options[32].text="Nevada NV"
state.options[32].value="NV"
state.options[33].text="New Hampshire NH"
state.options[33].value="NH"
state.options[34].text="New Jersey NJ"
state.options[34].value="NJ"
state.options[35].text="New Mexico NM"
state.options[35].value="NM"
state.options[36].text="New York NY"
state.options[36].value="NY"
state.options[37].text="North Carolina NC"
state.options[37].value="NC"
state.options[38].text="North Dakota ND"
state.options[38].value="ND"
state.options[39].text="Ohio OH"
state.options[39].value="OH"
state.options[40].text="Oklahoma OK"
state.options[40].value="OK"
state.options[41].text="Oregon OR"
state.options[41].value="OR"
state.options[42].text="Pennsylvania PA"
state.options[42].value="PA"
state.options[43].text="Rhode Island RI"
state.options[43].value="RI"
state.options[44].text="South Carolina SC"
state.options[44].value="SC"
state.options[45].text="South Dakota SD"
state.options[45].value="SD"
state.options[46].text="Tennessee TN"
state.options[46].value="TN"
state.options[47].text="Texas TX"
state.options[47].value="TX"
state.options[48].text="Utah UT"
state.options[48].value="UT"
state.options[49].text="Virginia VA"
state.options[49].value="VA"
state.options[50].text="Vermont VT"
state.options[50].value="VT"
state.options[51].text="Washington WA"
state.options[51].value="WA"
state.options[52].text="West Virginia WV"
state.options[52].value="WV"
state.options[53].text="Wisconsin WI"
state.options[53].value="WI"
state.options[54].text="Wyoming WY"
state.options[54].value="WY"
}
else if (country == "Canada") {
state.length=14;
state.options[0].text="PROVINCE"
state.options[0].value="XX";
state.options[1].text="Alberta AB"
state.options[1].value="AB"
state.options[2].text="British Columbia BC"
state.options[2].value="BC"
state.options[3].text="Labrador LB"
state.options[3].value="LB"
state.options[4].text="Manitoba MB"
state.options[4].value="MB"
state.options[5].text="New Brunswick NB"
state.options[5].value="NB"
state.options[6].text="Newfoundland NF"
state.options[6].value="NF"
state.options[7].text="Northwest Territories NT"
state.options[7].value="NT"
state.options[8].text="Nova Scotia NS"
state.options[8].value="NS"
state.options[9].text="Ontario ON"
state.options[9].value="ON"
state.options[10].text="Prince Edward Island PE"
state.options[10].value="PE"
state.options[11].text="Quebec QC"
state.options[11].value="QC"
state.options[12].text="Saskatchewan SK"
state.options[12].value="SK"
state.options[13].text="Yukon Territory YT"
state.options[13].value="YT"
}
else if (country == "Japan") {
state.length=48;
state.options[0].text="PREFECTURE"
state.options[0].value="XX";
state.options[1].text="Hokkaido (Hokkaido)"
state.options[1].value="Hokkaido"
state.options[2].text="Aomori (Aomori)"
state.options[2].value="Aomori"
state.options[3].text="Iwate (Iwate)"
state.options[3].value="Iwate"
state.options[4].text="Miyagi (Miyagi)"
state.options[4].value="Miyagi"
state.options[5].text="Akita (Akita)"
state.options[5].value="Akita"
state.options[6].text="Yamagata (Yamagata)"
state.options[6].value="Yamagata"
state.options[7].text="Fukushima (Fukushima)"
state.options[7].value="Fukushima"
state.options[8].text="Ibaraki (Ibaraki)"
state.options[8].value="Ibaraki"
state.options[9].text="Tochigi (Tochigi)"
state.options[9].value="Tochigi"
state.options[10].text="Gumma (Gumma)"
state.options[10].value="Gumma"
state.options[11].text="Saitama (Saitama)"
state.options[11].value="Saitama"
state.options[12].text="Chiba (Chiba)"
state.options[12].value="Chiba"
state.options[13].text="Tokyo (Tokyo)"
state.options[13].value="Tokyo"
state.options[14].text="Kanagawa (Kanagawa)"
state.options[14].value="Kanagawa"
state.options[15].text="Niigata (Niigata)"
state.options[15].value="Niigata"
state.options[16].text="Toyama (Toyama)"
state.options[16].value="Toyama"
state.options[17].text="Ishikawa (Ishikawa)"
state.options[17].value="Ishikawa"
state.options[18].text="Fukui (Fukui)"
state.options[18].value="Fukui"
state.options[19].text="Yamanashi (Yamanashi)"
state.options[19].value="Yamanashi"
state.options[20].text="Nagano (Nagano)"
state.options[20].value="Nagano"
state.options[21].text="Gifu (Gifu)"
state.options[21].value="Gifu"
state.options[22].text="Shizuoka (Shizuoka)"
state.options[22].value="Shizuoka"
state.options[23].text="Aichi (Aichi)"
state.options[23].value="Aichi"
state.options[24].text="Mie (Mie)"
state.options[24].value="Mie"
state.options[25].text="Shiga (Shiga)"
state.options[25].value="Shiga"
state.options[26].text="Kyoto (Kyoto)"
state.options[26].value="Kyoto"
state.options[27].text="Osaka (Osaka)"
state.options[27].value="Osaka"
state.options[28].text="Hyogo (Hyogo)"
state.options[28].value="Hyogo"
state.options[29].text="Nara (Nara)"
state.options[29].value="Nara"
state.options[30].text="Wakayama (Wakayama)"
state.options[30].value="Wakayama"
state.options[31].text="Tottori (Tottori)"
state.options[31].value="Tottori"
state.options[32].text="Shimane (Shimane)"
state.options[32].value="Shimane"
state.options[33].text="Okayama (Okayama)"
state.options[33].value="Okayama"
state.options[34].text="Hiroshima (Hiroshima)"
state.options[34].value="Hiroshima"
state.options[35].text="Yamaguchi (Yamaguchi)"
state.options[35].value="Yamaguchi"
state.options[36].text="Tokushima (Tokushima)"
state.options[36].value="Tokushima"
state.options[37].text="Kagawa (Kagawa)"
state.options[37].value="Kagawa"
state.options[38].text="Ehime (Ehime)"
state.options[38].value="Ehime"
state.options[39].text="Kochi (Kochi)"
state.options[39].value="Kochi"
state.options[40].text="Fukuoka (Fukuoka)"
state.options[40].value="Fukuoka"
state.options[41].text="Saga (Saga)"
state.options[41].value="Saga"
state.options[42].text="Nagasaki (Nagasaki)"
state.options[42].value="Nagasaki"
state.options[43].text="Kumamoto (Kumamoto)"
state.options[43].value="Kumamoto"
state.options[44].text="Oita (Oita)"
state.options[44].value="Oita"
state.options[45].text="Miyazaki (Miyazaki)"
state.options[45].value="Miyazaki"
state.options[46].text="Kagoshima (Kagoshima)"
state.options[46].value="Kagoshima"
state.options[47].text="Okinawa (Okinawa)"
state.options[47].value="Okinawa"
}
else if (country  == "Australia") {
state.length=9;
state.options[0].text="STATE"
state.options[0].value="XX";
state.options[1].text="New South Wales"
state.options[1].value="NSW"
state.options[2].text="Victoria"
state.options[2].value="VIC"
state.options[3].text="Queensland"
state.options[3].value="QLD"
state.options[4].text="Western Australia"
state.options[4].value="WA"
state.options[5].text="South Australia"
state.options[5].value="SA"
state.options[6].text="Tasmania"
state.options[6].value="TAS"
state.options[7].text="Australian Capital Territory"
state.options[7].value="ACT"
state.options[8].text="Northern Territory"
state.options[8].value="NT"
}
else if (country  == "XX") {
state.length=1;
state.options[0].text="ENTER COUNTRY FIRST"
state.options[0].value="XX";
}
else {
state.length=1;
state.options[0].text="ENTER STATE (IF ANY) IN CITY FIELD"
state.options[0].value="XX";
}
}
function Check_Name_Field (c) {
    v = sval(c);
    pattern = /^[a-zA-Z .\-\&\'\/]+$/;
    return checkstring(c,v,"The name you entered contains characters that we cannot recognize. Please enter name in English only.", pattern);
}

function Check_Address_Field (c) {
    v = sval(c);
    pattern = /^[a-zA-Z0-9 .,#();:"\-\&\'\/]+$/;
	if (0 == v.length) return true; // Blank OK
    return checkstring(c,v,"The address you entered contains characters that we cannot recognize. Please enter address in English only.", pattern);
}
function Check_Resid_Field (c) {
    v = sval(c);
    pattern = /^[0-9 ,#\-]+$/;
	if (0 == v.length) return true; // Blank OK
    return checkstring(c,v,"The reservation number you entered contains characters that we cannot recognize. Please enter numbers only. Reservation numbers are 5 or 6 digits in length.", pattern);
}
function Check_PhoneNumber_Field (c) {
    v = sval(c);
    pattern = /^[0-9 ,#\-]+$/;
	if (0 == v.length) return true; // Blank OK
    return checkstring(c,v,"The phone number you entered contains characters that we cannot recognize. Please enter numbers and dashes only.", pattern);
}

function Check_Comment_Field (c) {
    v = sval(c);
    pattern = /^[a-zA-Z0-9 \n\t.,#();:"\-\&\?\'\/\!\@\$\%]+$/;
	if (0 == v.length) return true; // Blank OK
    return checkstring(c,v,"The comments you entered contain characters that we cannot recognize. Please enter your comments or questions in English only.", pattern);
}

function Check_EmailAddress_Field (c) {
    v = sval(c);
    pattern = /^([a-zA-Z0-9\+])+([.a-zA-Z0-9_\+-])*@([a-zA-Z0-9-])+(.[a-zA-Z0-9-]+)+/;
    return checkstring(c,v,"The email address you entered appears to be incorrect. Please check it.", pattern);
}

function Check_Client_Contact_Info1 (fob) {
	var f = fob;
	var c,m,v;

	if (c = f.clientfirstname) {
		c.value = c.value.replace(/^\s+|\s+$/g,"");
        v = sval(c);
        if (v == "") { return abort(c, "You must enter a name in this field"); }
        if (!Check_Name_Field(c)) { return false; };
	}
	if (c = f.clientlastname) {
		c.value = c.value.replace(/^\s+|\s+$/g,"");
        v = sval(c);
        if (v == "") { return abort(c, "You must enter a name in this field"); }
        if (!Check_Name_Field(c)) { return false; };
	}
	if (c = f.clientphone) {
		msg = "Please enter one or more phone numbers using digits, spaces, or dashes.";
		c.value = c.value.replace(/^\s+|\s+$/g,"");
		v = sval(c);
		if (v.match(/[-0-9 ]+$/)) ; // ok, continue
		else return abort(c, msg);
	}
	if (c = f.clientemail) {
		c.value = c.value.replace(/^\s+|\s+$/g,"");
        v = sval(c);
        if (v == "") { return abort(c, "You must enter your email address"); }
	    if (!Check_EmailAddress_Field(c)) { return false; };
	}
	for (idx = 1; idx <= 6; ++idx) {
		if (c = f["AdultFirst" + idx]) {
		    c.value = c.value.replace(/^\s+|\s+$/g,"");
            v = sval(c);
            if (v == "") { return abort(c, "You must enter a first name for adult " + idx + "."); }
            if (!Check_Name_Field(c)) { return false; };
		}
		if (c = f["AdultLast" + idx]) {
		    c.value = c.value.replace(/^\s+|\s+$/g,"");
            v = sval(c);
            if (v == "") { return abort(c, "You must enter a last name for adult " + idx + "."); }
            if (!Check_Name_Field(c)) { return false; };
		}
		if (c = f["AdultGender" + idx]) {
		    c.value = c.value.replace(/^\s+|\s+$/g,"");
            v = sval(c);
            if (v == "XX") { return abort(c, "You must enter the gender for adult " + idx + "."); }
        }
		if (c = f["AdultDOBmonth" + idx]) {
		    c.value = c.value.replace(/^\s+|\s+$/g,"");
            v = sval(c);
            if (v == "XX") { return abort(c, "You must enter month, day, and year for the date of birth for adult " + idx + "."); }
        }
		if (c = f["AdultDOBday" + idx]) {
		    c.value = c.value.replace(/^\s+|\s+$/g,"");
            v = sval(c);
            if (v == "XX") { return abort(c, "You must enter month, day, and year for the date of birth for adult " + idx + "."); }
        }
		if (c = f["AdultDOByear" + idx]) {
		    c.value = c.value.replace(/^\s+|\s+$/g,"");
            v = sval(c);
            if (v == "XX") { return abort(c, "You must enter month, day, and year for the date of birth for adult " + idx + "."); }
		}
		if (c = f["ChildFirst" + idx]) {
		    c.value = c.value.replace(/^\s+|\s+$/g,"");
            v = sval(c);
            if (v == "") { return abort(c, "You must enter a first name for child " + idx + "."); }
            if (!Check_Name_Field(c)) { return false; };
		}
		if (c = f["ChildLast" + idx]) {
		    c.value = c.value.replace(/^\s+|\s+$/g,"");
            v = sval(c);
            if (v == "") { return abort(c, "You must enter a last name for child " + idx + "."); }
            if (!Check_Name_Field(c)) { return false; };
		}
		if (c = f["ChildGender" + idx]) {
		    c.value = c.value.replace(/^\s+|\s+$/g,"");
            v = sval(c);
            if (v == "XX") { return abort(c, "You must enter the gender for child" + idx + "."); }
        }
		if (c = f["ChildDOBmonth" + idx]) {
		    c.value = c.value.replace(/^\s+|\s+$/g,"");
            v = sval(c);
            if (v == "XX") { return abort(c, "You must enter month, day, and year for the date of birth for child " + idx + "."); }
        }
		if (c = f["ChildDOBday" + idx]) {
		    c.value = c.value.replace(/^\s+|\s+$/g,"");
            v = sval(c);
            if (v == "XX") { return abort(c, "You must enter month, day, and year for the date of birth for child " + idx + "."); }
        }
		if (c = f["ChildDOByear" + idx]) {
		    c.value = c.value.replace(/^\s+|\s+$/g,"");
            v = sval(c);
            if (v == "XX") { return abort(c, "You must enter month, day, and year for the date of birth for child " + idx + "."); }
		}
	}
    return true;
}
// Check a string to see if contains valid characters, as defined by pattern
function checkstring(field,string,errormsg,pattern) {
    if (!pattern.test(string))  {
		//return abort2(field, errormsg + " You Entered: " + string + ". Pattern is: " + pattern);
		return abort2(field, errormsg);
    }
    return (true);
}
function HHMM2min(HHMML) {

// given a time like this:
// 12:00A, 12:30A, 1:00A, ... , 11:30A, 12:00N, 12:30P, 1:00P, ... , 11:30P
// returns number of minutes since midnight
// returns -1 on format error, other negative integers for other errors

	var hh = -1;
	var mm = -1;
	var anp = "";

	if (! HHMML.match(/^\d\d?:\d\d[ANP]$/)) return -1;
	hh  = parseInt(HHMML.substring(0,HHMML.indexOf(':')), 10);
	mm  = parseInt(HHMML.substr(1+HHMML.indexOf(':'), 2), 10);
	anp = HHMML.substr(-1, 1);
	anp = anp.toLowerCase();
	if (anp == "a") {
		if (hh == 12) hh = 0;
	}
	else if (anp == "p") {
		if (hh <12) hh += 12;
	}
	return hh * 60 + mm;

} // function HHMM2min

function numonly(field) {
    var w = "";
    var onlyNumbers = "0123456789";
    for (i=0; i <field.value.length; i++) {
        x = field.value.charAt(i);
        if (onlyNumbers.indexOf(x,0) != -1) {
        w += x;
        }
    }
    field.value = w;
}

function MM_swapImgRestore() {  
  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() {  
  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_findObj(n, d) {  
  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 && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() {  
  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];}
}
function blogentryvalidate(fob) {
	var f = fob;
	var c,v;
	if (c = f.author) {
		c.value = c.value.replace(/^\s+|\s+$/g,"");
        v = sval(c);
        if (v == "") { return abort(c, "You must enter a name in this field"); }
        if (!Check_Name_Field(c)) { return false; };
	}
	if (c = f.email) {
		c.value = c.value.replace(/^\s+|\s+$/g,"");
        v = sval(c);
        if (v == "") { return abort(c, "You must enter your email address"); }
	    if (!Check_EmailAddress_Field(c)) { return false; };
	}
	if (c = f.blogcomment) {
		c.value = c.value.replace(/^\s+|\s+$/g,"");
        v = sval(c);
        if (v == "") { return abort(c, "You must enter a comment"); }
        if (!Check_Comment_Field(c)) { return false; };
	}
	if (c = f.recaptcha_response_field) {
		c.value = c.value.replace(/^\s+|\s+$/g,"");
        v = sval(c);
        if (v == "") { return abort(c, "You must enter the coded words as best you can. This helps us make sure we accept only valid, human-entered comments."); }
	}
    v = sval(f.msg);
    window.alert(v);
}
