function initNavigation()
{
	var shop= document.getElementById('nav-shop');
	var about= document.getElementById('nav-about');
	var aboutSub= document.getElementById('nav-about-sub');
	var visit= document.getElementById('nav-visit');
	var visitSub= document.getElementById('nav-visit-sub');
	var learn= document.getElementById('nav-learn');
	var learnSub= document.getElementById('nav-learn-sub');
	var whatsnew= document.getElementById('nav-whats-new');
	var whatsnewSub= document.getElementById('nav-whats-new-sub');
	var specialevents= document.getElementById('nav-special-events');
	var specialeventsSub= document.getElementById('nav-special-events-sub');
	var links= document.getElementById('nav-links');
	var linksSub= document.getElementById('nav-links-sub');
	var membership= document.getElementById('nav-membership');
	var donate= document.getElementById('nav-donate');
	shop.onmouseover = function(){
		this.firstChild.src="http://cwc.dreamhosters.com/_include/img/nav-shop-over.gif";
	};
	shop.onmouseout = function(){
		this.firstChild.src="http://cwc.dreamhosters.com/_include/img/nav-shop-up.gif";
	};
	about.onmouseover = function(){
		this.firstChild.src="http://cwc.dreamhosters.com/_include/img/nav-about-over.gif";
	};
	about.onmouseout = function(){
		this.firstChild.src="http://cwc.dreamhosters.com/_include/img/nav-about-up.gif";
	};
	aboutSub.onmouseover = function(){
		about.firstChild.src="http://cwc.dreamhosters.com/_include/img/nav-about-over.gif";
	};
	aboutSub.onmouseout = function(){
		about.firstChild.src="http://cwc.dreamhosters.com/_include/img/nav-about-up.gif";
	};
	visit.onmouseover = function(){
		this.firstChild.src="http://cwc.dreamhosters.com/_include/img/nav-visit-over.gif";
	};
	visit.onmouseout = function(){
		this.firstChild.src="http://cwc.dreamhosters.com/_include/img/nav-visit-up.gif";
	};
	visitSub.onmouseover = function(){
		visit.firstChild.src="http://cwc.dreamhosters.com/_include/img/nav-visit-over.gif";
	};
	visitSub.onmouseout = function(){
		visit.firstChild.src="http://cwc.dreamhosters.com/_include/img/nav-visit-up.gif";
	};
	learn.onmouseover = function(){
		this.firstChild.src="http://cwc.dreamhosters.com/_include/img/nav-learn-over.gif";
	};
	learn.onmouseout = function(){
		this.firstChild.src="http://cwc.dreamhosters.com/_include/img/nav-learn-up.gif";
	};
	learnSub.onmouseover = function(){
		learn.firstChild.src="http://cwc.dreamhosters.com/_include/img/nav-learn-over.gif";
	};
	learnSub.onmouseout = function(){
		learn.firstChild.src="http://cwc.dreamhosters.com/_include/img/nav-learn-up.gif";
	};
	whatsnew.onmouseover = function(){
		this.firstChild.src="http://cwc.dreamhosters.com/_include/img/nav-whats-new-over.gif";
	};
	whatsnew.onmouseout = function(){
		this.firstChild.src="http://cwc.dreamhosters.com/_include/img/nav-whats-new-up.gif";
	};
	whatsnewSub.onmouseover = function(){
		whatsnew.firstChild.src="http://cwc.dreamhosters.com/_include/img/nav-whats-new-over.gif";
	};
	whatsnewSub.onmouseout = function(){
		whatsnew.firstChild.src="http://cwc.dreamhosters.com/_include/img/nav-whats-new-up.gif";
	};
	specialevents.onmouseover = function(){
		this.firstChild.src="http://cwc.dreamhosters.com/_include/img/nav-special-events-over.gif";
	};
	specialevents.onmouseout = function(){
		this.firstChild.src="http://cwc.dreamhosters.com/_include/img/nav-special-events-up.gif";
	};
	specialeventsSub.onmouseover = function(){
		specialevents.firstChild.src="http://cwc.dreamhosters.com/_include/img/nav-special-events-over.gif";
	};
	specialeventsSub.onmouseout = function(){
		specialevents.firstChild.src="http://cwc.dreamhosters.com/_include/img/nav-special-events-up.gif";
	};
	links.onmouseover = function(){
		this.firstChild.src="http://cwc.dreamhosters.com/_include/img/nav-links-over.gif";
	};
	links.onmouseout = function(){
		this.firstChild.src="http://cwc.dreamhosters.com/_include/img/nav-links-up.gif";
	};
	linksSub.onmouseover = function(){
		links.firstChild.src="http://cwc.dreamhosters.com/_include/img/nav-links-over.gif";
	};
	linksSub.onmouseout = function(){
		links.firstChild.src="http://cwc.dreamhosters.com/_include/img/nav-links-up.gif";
	};
	membership.onmouseover = function(){
		this.firstChild.src="http://cwc.dreamhosters.com/_include/img/nav-membership-over.gif";
	};
	membership.onmouseout = function(){
		this.firstChild.src="http://cwc.dreamhosters.com/_include/img/nav-membership-up.gif";
	};
	donate.onmouseover = function(){
		this.firstChild.src="http://cwc.dreamhosters.com/_include/img/nav-donate-over.gif";
	};
	donate.onmouseout = function(){
		this.firstChild.src="http://cwc.dreamhosters.com/_include/img/nav-donate-up.gif";
	};
}


window.onload=function()
{
	initNavigation();
}


function makered(formfield) { 
//    var txtfield = formfield + "text";
    var ifield = formfield + "i";
    document.getElementById(formfield).style.borderStyle = "solid";
    document.getElementById(formfield).style.borderWidth = "1px";
    document.getElementById(formfield).style.borderColor = "#FF0000";
    document.getElementById(formfield).style.padding = "4px";
//    document.getElementById(txtfield).style.color = "#FF0000";
    document.getElementById(ifield).style.color = "#FF0000";
}

function makered2(formfield) {
    document.getElementById(formfield).style.borderStyle = "solid";
    document.getElementById(formfield).style.borderWidth = "1px";
    document.getElementById(formfield).style.borderColor = "#FF0000";
    document.getElementById(formfield).style.padding = "4px";
    document.getElementById(formfield).style.backgroundColor = "#FFDDDD";
}

function makenorm(formfield) {
//    var txtfield = formfield + "text";
    var ifield = formfield + "i";
    document.getElementById(formfield).style.backgroundColor= "#FAF6E8";
    document.getElementById(formfield).style.borderStyle = "solid";
    document.getElementById(formfield).style.borderWidth = "1px";
    document.getElementById(formfield).style.borderColor = "#CCCCCC";
    document.getElementById(formfield).style.padding = "5px";
//    document.getElementById(txtfield).style.color = "#666";
    document.getElementById(ifield).style.color = "#666";
}

function bad_email( field ) {
    with( field ) {
        apos = value.indexOf( "@" );
        dotpos = value.lastIndexOf( "." );
        if ( apos < 1 || dotpos - apos < 2 ) {
            return true;
        }
    }
    return false;
}

function is_empty(field) {
    with (field) {
        if ( value == null || value == "" ) {
            return true;
        }
    }
    return false;
}

function validate_optout_form( thisform ) {
    allgood = true;

    with(thisform) {
        if ( bad_email( f_email )) {
            makered( 'f-email' );
            allgood = false;
        }
        else {
            makenorm( 'f-email' );
        }

        if (! ( f_checkemail.checked || f_checkinfo.checked )) {
	    makered( 'f-checkemail' );
	    makered( 'f-checkinfo' );
	    allgood = false;
        }
	else {
	    makenorm( 'f-checkemail' );
	    makenorm( 'f-checkinfo' );
	}

	if ( is_empty( f_name)) {
	    makered( 'f-name' );
	    allgood = false;
        }
        else {
           makenorm( 'f-name' );
        }
	if ( is_empty( l_name )) {
	    makered( 'l-name' );
	    allgood = false;
        }
        else {
           makenorm( 'l-name' );
        }
	if ( is_empty( f_address )) {
	    makered( 'f-address' );
	    allgood = false;
        }
        else {
           makenorm( 'f-address' );
        }
	if ( is_empty( f_city )) {
	    makered( 'f-city' );
	    allgood = false;
        }
        else {
           makenorm( 'f-city' );
        }
	if ( is_empty( f_state )) {
	    makered( 'f-state' );
	    allgood = false;
        }
        else {
           makenorm( 'f-state' );
        }
	if ( is_empty( f_zip )) {
	    makered( 'f-zip' );
	    allgood = false;
        }
        else {
           makenorm( 'f-zip' );
        }
	if ( is_empty( f_country )) {
	    makered( 'f-country' );
	    allgood = false;
        }
        else {
           makenorm( 'f-country' );
        }
	if ( is_empty( f_phone )) {
	    makered( 'f-phone-number' );
	    allgood = false;
        }
        else {
           makenorm( 'f-phone-number' );
        }
    }
    return allgood;
}

function validate_tour_form( thisform ) {
    allgood = true;

    with(thisform) {
        if ( bad_email( f_email )) {
            makered( 'f-email' );
            allgood = false;
        }
        else {
            makenorm( 'f-email' );
        }

	if ( is_empty( f_name)) {
	    makered( 'f-name' );
	    allgood = false;
        }
        else {
           makenorm( 'f-name' );
        }
	if ( is_empty( l_name )) {
	    makered( 'l-name' );
	    allgood = false;
        }
        else {
           makenorm( 'l-name' );
        }
	if ( is_empty( f_address )) {
	    makered( 'f-address' );
	    allgood = false;
        }
        else {
           makenorm( 'f-address' );
        }
	if ( is_empty( f_city )) {
	    makered( 'f-city' );
	    allgood = false;
        }
        else {
           makenorm( 'f-city' );
        }
	if ( is_empty( f_state )) {
	    makered( 'f-state' );
	    allgood = false;
        }
        else {
           makenorm( 'f-state' );
        }
	if ( is_empty( f_date )) {
	    makered( 'f-date' );
	    allgood = false;
        }
        else {
           makenorm( 'f-date' );
        }
	if ( is_empty( f_zip )) {
	    makered( 'f-zip' );
	    allgood = false;
        }
        else {
           makenorm( 'f-zip' );
        }
	if ( is_empty( f_country )) {
	    makered( 'f-country' );
	    allgood = false;
        }
        else {
           makenorm( 'f-country' );
        }
	if ( is_empty( f_phone )) {
	    makered( 'f-phone-number' );
	    allgood = false;
        }
        else {
           makenorm( 'f-phone-number' );
        }
	if ( is_empty( f_numberpart )) {
	    makered( 'f-number-part' );
	    allgood = false;
        }
        else {
           makenorm( 'f-number-part' );
        }
	if ( is_empty( f_hearhow )) {
	    makered( 'f-hear-how' );
	    allgood = false;
        }
        else {
           makenorm( 'f-hear-how' );
        }
    }
    return allgood;
}

function validate_newsletter_form( thisform ) {
    allgood = true;

    with(thisform) {
        if ( bad_email( f_email )) {
            makered( 'f-email' );
            allgood = false;
        }
        else {
            makenorm( 'f-email' );
        }
	if ( is_empty( f_name)) {
	    makered( 'f-name' );
	    allgood = false;
        }
        else {
           makenorm( 'f-name' );
        }
	if ( is_empty( l_name )) {
	    makered( 'l-name' );
	    allgood = false;
        }
        else {
           makenorm( 'l-name' );
        }
	if ( is_empty( f_address )) {
	    makered( 'f-address' );
	    allgood = false;
        }
        else {
           makenorm( 'f-address' );
        }
	if ( is_empty( f_city )) {
	    makered( 'f-city' );
	    allgood = false;
        }
        else {
           makenorm( 'f-city' );
        }
	if ( is_empty( f_state )) {
	    makered( 'f-state' );
	    allgood = false;
        }
        else {
           makenorm( 'f-state' );
        }
	if ( is_empty( f_zip )) {
	    makered( 'f-zip' );
	    allgood = false;
        }
        else {
           makenorm( 'f-zip' );
        }
	if ( is_empty( f_country )) {
	    makered( 'f-country' );
	    allgood = false;
        }
        else {
           makenorm( 'f-country' );
        }
	if ( is_empty( f_phone )) {
	    makered( 'f-phone-number' );
	    allgood = false;
        }
        else {
           makenorm( 'f-phone-number' );
        }
    }
    return allgood;
}

