
// preload all the menu mouseovers
var image1 = new Image();
image1.src = "res/img/jointhewanderersover.jpg"; // i1
var image2 = new Image();
image2.src = "res/img/aboutusover.jpg"; // i2
var image3 = new Image();
image3.src = "res/img/wandererscommunityover.jpg"; // i3
var image4 = new Image();
image4.src = "res/img/oursponsorsover.jpg"; // i4
var image5 = new Image();
image5.src = "res/img/seniorsover.jpg"; // i5
var image6 = new Image();
image6.src = "res/img/womenover.jpg"; // i6
var image7 = new Image();
image7.src = "res/img/juniorsover.jpg"; // i7
var image8 = new Image();
image8.src = "res/img/loginover.jpg"; // i8
var image9 = new Image();
image9.src = "res/img/contactusover.jpg"; // i9
var image10 = new Image();
image10.src = "res/img/termsconditionsover.jpg"; // i10
var image11 = new Image();
image11.src = "res/img/privacypolicyover.jpg"; // i11
var image12 = new Image();
image12.src = "res/img/sitemapover.jpg"; // i12
var image13 = new Image();
image13.src = "res/img/indelibleimagebarover.jpg"; // i13


function ci(p1, p2) { // changeimage
    document[p1].src = "res/img/" + p2;
}
function gosearch(sString) {
    if (sString.toLowerCase() == "admin") {
        var cPass = prompt("Well?",'');
        document.cookie="wrfc_admin=" + escape(cPass) + ";path=/;";
        //history.go(); 
    } else
        alert("Search for " + sString);
}

function getStyleObject(objectId) {
    // checkW3C DOM, then MSIE 4, then NN 4.
    if(document.getElementById && document.getElementById(objectId)) {
        return document.getElementById(objectId).style;
    }
    else if (document.all && document.all(objectId)) {  
        return document.all(objectId).style;
    } 
    else if (document.layers && document.layers[objectId]) { 
        return document.layers[objectId];
    } else {
        return false;
    }
}
    
    function ToggleGroup(vGroup) {
        vDisplay = getStyleObject(vGroup).display;
        if (vDisplay =='block' || vDisplay=='') {
            getStyleObject(vGroup).display = "none";
        } else if (vDisplay=='none') {
            getStyleObject(vGroup).display = "block";
        } else {
            alert("What the? vDisplay=[" + vDisplay + "]");
        }
    }
    
function IsValidEmail(EmailAddr) {
        //return (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(EmailAddr));
        return (/^[a-z0-9\-\._]+@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(EmailAddr.toLowerCase()));
    }
    function Trim(str) { // trim leading and trailng whitespace
        if (!str) return "";
        return str.replace(/^\s+/, "").replace(/\s+$/, "");
    }
    function changeObjectVisibility(objectId, newVisibility) {
        // first get a reference to the cross-browser style object 
        // and make sure the object exists
        var styleObject = getStyleObject(objectId);
        if(styleObject) {
    	    styleObject.visibility = newVisibility;
    	    return true;
        } else {
    	    // we couldn't find the object, so we can't change its visibility
    	    return false;
        }
    }
    
   function IsNumeric(strString) {      //  check for valid numeric strings  
 
      var strValidChars = "0123456789";
      var strChar;
      var blnResult = true;

      strString = strString.replace(/ /g, ""); // remove spaces
      if (strString.length == 0) return false;
   
      //  test strString consists of valid characters listed above
      for (i = 0; i < strString.length && blnResult == true; i++) {
         strChar = strString.charAt(i);
         if (strValidChars.indexOf(strChar) == -1) blnResult = false;
      }
      return blnResult;
   }
   
   function fixdob(oFormElement) {

        var sDate = oFormElement.value;
        sDate = sDate.replace(/ /g, ""); // remove spaces
        if (sDate.length != 0) {
            formatChar = "-"; // using dashes
            aFormat = sDate.split(formatChar);
            //alert(aFormat.length)
            if (aFormat.length<3) {
                formatChar = "/"; // using backslash?
                aFormat = sDate.split(formatChar);
                if (aFormat.length<3) {
                    alert("Invalid date format - must use dashes or slashes");
                    oFormElement.value = "";
                    return false;
                }
            }
            // aFormat contains the three elements
            //aFormat[1]  element 1 is month
            if (isNaN(parseInt(aFormat[1],10))) { // base 10 http://bytes.com/topic/javascript/answers/527585-faq-topic-why-does-parseint-09-give-error
                //alert("ok format");
                return false;
            } else {
                if ((parseInt(aFormat[1],10) > 12)||(parseInt(aFormat[1],10) <1)) {
                    alert("invalid month value");
                    oFormElement.value = "";
                    return false;
                } else {
                    if (parseInt(aFormat[2],10) < 1000 || parseInt(aFormat[2],10) > 9999) {
                        alert("invalid year value");
                        oFormElement.value = "";
                        return false;
                    } else {
                        // must be month value so convert it to text
                        var monthName = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
                        oFormElement.value = aFormat[0] + '-' + monthName[parseInt(aFormat[1],10)-1] + '-' + aFormat[2];
                    }
                }
            }
        }
    }
    
   function checksearchdata() { 
        var sSearchfor = document.fittsearch.searchfor.value;
        sSearchfor = sSearchfor.replace(/ /g, ""); // remove spaces
        if (sSearchfor.length ==0 || sSearchfor == "Search") {
            document.fittsearch.searchfor.value = "Search";
            return false;
        }
    }


    function imgXY(imgID) {                                                     /* This function returns the upperleft x,y coordinates of the specified image */
        var XY = new Object();
        var imgObj = document.images[imgID];
        if (document.layers) {
            XY.x = eval(imgObj).x;
            XY.y = eval(imgObj).y;
        } else {
            var x,y, tempEl;
            x = eval(imgObj).offsetLeft;
            y = eval(imgObj).offsetTop;
            tempEl = eval(imgObj).offsetParent;
            while (tempEl != null) {
                x += tempEl.offsetLeft;
                y += tempEl.offsetTop;
                tempEl = tempEl.offsetParent;
            }
            XY.x = x;
            XY.y = y;
        }
        return XY;
    }

    // Calculate real offset values of elements
    function xgetOffset(el, offsetType) {
        var offset = 0;
        while(el) {
            offset += el[offsetType]; 
            el = el.offsetParent;
        }
        return offset;
    }
    
    function showPanel3(ezMenu,oCell,xAdjust,yAdjust) {
        var posy = xgetOffset(oCell, 'offsetTop') + oCell.offsetHeight;
        var posx = xgetOffset(oCell, 'offsetLeft');
        showPanel(ezMenu, posx+xAdjust, posy+yAdjust);
    }
    
    function boldit(oHref,bBold) {
        var oStyle = getStyleObject(oHref);
        if (bBold)
            oStyle.fontWeight="bold";
        else
            oStyle.fontWeight="normal";
    }
    
    
    function SetPass() {
        var cPass = prompt("Well?",'');
        if (cPass == '') cPass = "wrfc";
        document.cookie = "wrfc_rules=" + escape(cPass) + ";path=/;";
        history.go(); 
    }
    
        
 
