function Expand(item) {
   obj=document.getElementById(item);
   visible=(obj.style.display!="none")
   if (visible) {
     obj.style.display="none";
   } else {
      obj.style.display="block";
   }
}

function Display(item) {
   obj=document.getElementById(item);
   visible=(obj.style.display!="none")
   if (visible) {

   } else {
      obj.style.display="block";
   }
}

function hideMe(name) {
    var obj = document.getElementById(name);
    obj.style.display = "none";
    }

function showMe(name) {
    var obj = document.getElementById(name);
    obj.style.display = "block";
    }    
    
function CheckCity() {
            var cityValue = document.Upload.City.options.selectedIndex;

                obj1=document.getElementById('cityinfo1');

                // alert(cityValue);

            if (cityValue == '0') { // Cork City

                obj1.style.display="block";

                return;

            }
}


function CheckUS() {
            var countryValue = document.Upload.Country.options.selectedIndex;
            var districtValue = document.Upload.District.value;

                obj1=document.getElementById('stateinfo1');
                obj2=document.getElementById('stateinfo2');

                // alert(countryValue);

            if (countryValue == '222') { // US United States

                obj1.style.display="none";
                obj2.style.display="block";

                return;

            } else {

                obj2.style.display="none";
                obj1.style.display="block";

                return;

            }
}


function checkuserid() {
                // alert(thisuserid);

            if (document.Upload.userid.value.length < 3) {
                alert("Used ID must be at least 3 characters");
                return ;
            }
}


function checkpassword() {
            var thispassword = document.Upload.setpassword.value;
            var thispasswordField = document.Upload.setpassword;

                // alert(thispassword);

            if (thispassword.length < 3) {

                alert("Password must be at least 3 characters");
                thispasswordField.focus();
                return;
            }
}

function checkEmail() {
    var emailField = document.Upload.Email;
    var emailValue = emailField.value;
    if (emailValue == '') {
        alert("You must enter your email address!");
        emailField.focus();
        return;
    } else if (emailValue.indexOf("@") == -1) {
        alert("You must enter a valid email address!\n\n(i.e. address@company.com)");
        emailField.focus();
        emailField.select();
        return;
    }
}

function submitandcheck() {

        if (document.Upload.userid.value.length < 3) {
            alert("Used ID must be at least 3 characters");
            document.Upload.userid.focus();
            document.Upload.userid.select();
            return ;
        } else if (document.Upload.setpassword.value.length < 3) {
            alert("Password must be at least 3 characters");
            document.Upload.setpassword.focus();
            document.Upload.setpassword.select();
            return ;
        } else if (document.Upload.Email.value == '') {
            alert("You must enter your email address!");
            document.Upload.Email.focus();
            return;
        } else if (document.Upload.Email.value.indexOf("@") == -1) {
            alert("You must enter a valid email address!\n\n(i.e. address@company.com)");
            document.Upload.Email.focus();
            document.Upload.Email.select();
            return;
        } else {
        document.forms.Upload.submit();
        }
}


function companysubmitandcheck() {

        if (document.Upload.userid.value.length < 3) {
            alert("Used ID must be at least 3 characters");
            document.Upload.userid.focus();
            document.Upload.userid.select();
            return ;
        } else if (document.Upload.setpassword.value.length < 3) {
            alert("Password must be at least 3 characters");
            document.Upload.setpassword.focus();
            document.Upload.setpassword.select();
            return ;
        } else if (document.Upload.listingtype[0].checked == 0) {    // not "Basic"
                for (var i=1; i < document.Upload.listingtype.length; i++) {
                
                        if (document.Upload.listingtype[i].checked) {                
                               
                               checkindex = "document.Upload.paymentplan" + i;
                               
                                if (eval(checkindex)[0].checked == 0 && eval(checkindex)[1].checked == 0){

                            alert("You must select a payment plan for the " + document.Upload.listingtype[i].value + " account.");  
                            return;
                            }else {
                            document.forms.Upload.submit();

                            }
                        } 
                
                } 

           
        } else {
        document.forms.Upload.submit();
        }
}


function checkForm() {
    var emailField = document.CustomerRegistrationForm.PrimaryEmail;
    var emailValue = emailField.value;
    if (emailValue == '') {
        alert("You must enter your email address!");
        emailField.focus();
        return;
    } else if (emailValue.indexOf("@") == -1) {
        alert("You must enter a valid email address!\n\n(i.e. address@company.com)");
        emailField.focus();
        emailField.select();
        return;
    }
    var fieldValue = "";
    var len = 2;
    for (var n=1; n <= len; n++) {
        var dml = eval("document.CustomerRegistrationForm.ItemID" + n);
        for (var p=0; p < dml.length; p++) {
            if (dml[p].checked) {
                if (fieldValue != "") {
                    fieldValue += ",";
                }
                fieldValue += dml[p].value;
            }
        }
    }
    document.CustomerRegistrationForm.ItemID.value = fieldValue;
    document.CustomerRegistrationForm.submit();
}

var isNav, isIE;
var coll = "";
var styleObj = "";
var x=0
var y=0    

if (parseInt(navigator.appVersion) >= 4) {
    if (navigator.appName == "Netscape") {
        isNav = true;
    } else {
        isIE = true;
        coll = "all.";
        styleObj = ".style";           

    }
}


function showMeCenter(name,linkid,anchorid) {


            var obj = document.getElementById(name).style;
            var linkobj = document.getElementById(linkid);
            var objt = document.getElementById(name);
    
        if (document.body.scrollTop < 200) {

        location.hash=anchorid;
        }

       //    linkobj.onclick=getEvent

       //    linkobj.onmouseover=centerMe


            //    x=event.x; //relative to currently viewable area
            //    y=event.y;

                var a= document.body.clientWidth // the window
                var b= document.body.clientHeight

                var r= objt.clientWidth  // BUG: the div starts at 0 because display:none
                var s= objt.clientHeight  // BUG: the div starts at 0 because display:none

                var l= document.body.scrollLeft  // the scrollbar
                var m= document.body.scrollTop


         //    alert('x is ' + x +'y is ' + y);
          //   alert('a is ' + a +'b is ' + b);
           //  alert('r is ' + r +'s is ' + s);
          //   alert('l is ' + l +'m is ' + m);


            toppos = Math.round((b/2)-(s/2)+(m))
            leftpos = Math.round((a/2)-(r/2)+(l))


                if (isIE) {
                obj.pixelLeft = leftpos
                obj.pixelTop = toppos
                } else {
                obj.left = leftpos
                obj.top = toppos
                }

                obj.display = "block";

        x=0;
        y=0;

        return false;



}
    
    

function showMe2(name,linkid,anchorid) {


            var obj = document.getElementById(name).style;
            var linkobj = document.getElementById(linkid);
            var objt = document.getElementById(name);
            var shimname = name + "shim"
            var objshim=document.getElementById(shimname).style;

            linkobj.onmousedown=getEvent

       //    linkobj.onmouseover=centerMe


            //    x=event.x; //relative to currently viewable area
            //    y=event.y;

                var a= document.body.clientWidth // the window
                var b= document.body.clientHeight

           //     var r= objt.clientWidth  // the div
           //     var s= objt.clientHeight

                var l= document.body.scrollLeft  // the scrollbar
                var m= document.body.scrollTop


           //  alert('x is ' + x +'y is ' + y);
          //   alert('a is ' + a +'b is ' + b);
          //   alert('r is ' + r +'s is ' + s);
          //   alert('l is ' + l +'m is ' + m);

if (x > 1) {

            var s= document.body.scrollTop

            toppos = y + 10 + s;
            leftpos = x

                if (isIE) {
                obj.pixelLeft = leftpos
                obj.pixelTop = toppos
                } else {
                obj.left = leftpos
                obj.top = toppos
                }
                // obj.visibility = "visible";
                // obj.overflow = "visible";

                obj.display = "block";

                if (isIE) {
                objshim.pixelLeft = leftpos
                objshim.pixelTop = toppos
                } else {                
                objshim.left = leftpos
                objshim.top = toppos
                }
                // objshim.visibility = "visible";
                // objshim.overflow = "visible";
                objshim.display = "block";
                
            }
x=0;
y=0;

return;

}


    //used when there is no shim
function showMe3(name,linkid,anchorid) {


            var obj = document.getElementById(name).style;
            var linkobj = document.getElementById(linkid);
            var objt = document.getElementById(name);


            linkobj.onmousedown=getEvent

       //    linkobj.onmouseover=centerMe


            //    x=event.x; //relative to currently viewable area
            //    y=event.y;

                var a= document.body.clientWidth // the window
                var b= document.body.clientHeight

         //       var r= objt.clientWidth  // the div
         //       var s= objt.clientHeight

                var l= document.body.scrollLeft  // the scrollbar
                var m= document.body.scrollTop


           //  alert('x is ' + x +'y is ' + y);
          //   alert('a is ' + a +'b is ' + b);
          //   alert('r is ' + r +'s is ' + s);
          //   alert('l is ' + l +'m is ' + m);

if (x > 1) {

            var s= document.body.scrollTop

                      if (isIE) {
                            toppos = y + 60 + s;
                            
                      } else {
                            toppos = y + 60
                      }
                            leftpos = x

                if (isIE) {
                obj.pixelLeft = leftpos
                obj.pixelTop = toppos
                } else {
                obj.left = leftpos
                obj.top = toppos
                }

                obj.display = "block";
                location.hash=anchorid;

            }
x=0;
y=0;

return;

}


function getEvent(evt) {


    if (isIE) {
   //     x=event.x; // returns the coords within an image if on an image
   //     y=event.y; // returns the coords within an image if on an image
   
          x=event.clientX;
          y=event.clientY;
   
    } 
    else {


      x=evt.pageX; 
      y=evt.pageY;
    }


      //  alert('x is ' + x + ' y is ' + y);
    return false;

}



function centerMe(name) {

//alert('foo');
    var obj = document.getElementById(name).style;
    var objt = document.getElementById(name);

    var r= objt.clientWidth  // the div
    var s= objt.clientHeight

    var l= document.body.scrollLeft  // the scrollbar
    var m= document.body.scrollTop

    toppos = Math.round((b/2)-(s/2)+(m))
    leftpos = Math.round((a/2)-(r/2)+(l))

obj.pixelLeft = leftpos  
obj.pixelTop = toppos
                

}  

    
// the remaining are not used


function getXY(e) {
    if (isNav) {

        x=e.pageX; 
        y=e.pageY;
    }
    if (isIE&&document.all) {


        x=event.x; 
        y=event.y;
        alert('x is ' + x +'y is ' + y);
        
        
        
    }
    
    if (isIE&&!document.all) {

        x=e.pageX; 
        y=e.pageY;
    }


}    

// CheckRequiredFields
//  Checks that the user entered something in the given required fields.
//  The first argument is the form and the remaining arguments (as many as
//  needed) are the names of the required fields.
//  Use as on submit routine for the form. Example:
//      <form action="scripts/client_input.cgi" method="POST"
//          onSubmit='return CheckRequiredFields(this, "firstname", "lastname", "Title");'>
// Author: Joan Walton, Specific Impulse Inc. December 1999

function CheckRequiredFields(theForm) {
    for (var i=1; i < CheckRequiredFields.arguments.length; i++) {
        if (eval("theForm." + CheckRequiredFields.arguments[i] +
                ".value.length") == 0) {
            alert("Please enter your " + CheckRequiredFields.arguments[i]);
            return false;
        }
    }
    return true;
}


function delayRedirect() {
    setTimeout('document.location.href="index.cfm"', '4000');
}

function hiLite(imgName,imgArrayName) {
        document.images[imgName].src = eval(imgArrayName + ".src");
}

function fillIn(this_field_name, target_field_name)  {
        target_field_name.value = this_field_name.value
}

var newWindow

 function openWin(myWin)  {
    if (!newWindow || newWindow.closed) {
    newWindow = window.open(myWin,"Mywindow","scrollbars,resizable=yes,height=550,width=650")
    } else {
    newWindow.focus();
    newWindow.location.href=myWin;
    }
    return true;
}

//<!-- Original:  Martin Webb (martin@irt.org) -->

// <!-- This script and many more are available free online at -->
// <!-- The JavaScript Source!! http://javascript.internet.com -->

//  function right(e) {
//  if (navigator.appName == 'Netscape' &&
//  (e.which == 3 || e.which == 2))
//  return false;
//  else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3)) {/ alert("Sorry, you do not have permission to right click."); return false; } return true; }

//  document.onmousedown=right;
//  document.onmouseup=right;
//  if (document.layers) window.captureEvents(Event.MOUSEDOWN);
//  if (document.layers) window.captureEvents(Event.MOUSEUP);
//  window.onmousedown=right;
//  window.onmouseup=right;


function showMeCenterOLD(name,linkid,anchorid) {

    if (isIE&&document.all) {

            var obj = document.getElementById(name).style;
            var linkobj = document.getElementById(linkid);
            var objt = document.getElementById(name);
    
        if (document.body.scrollTop < 200) {

        location.hash=anchorid;
        }

       //    linkobj.onclick=getEvent

       //    linkobj.onmouseover=centerMe


            //    x=event.x; //relative to currently viewable area
            //    y=event.y;

                var a= document.body.clientWidth // the window
                var b= document.body.clientHeight

                var r= objt.clientWidth  // the div
                var s= objt.clientHeight

                var l= document.body.scrollLeft  // the scrollbar
                var m= document.body.scrollTop


         //    alert('x is ' + x +'y is ' + y);
          //   alert('a is ' + a +'b is ' + b);
          //   alert('r is ' + r +'s is ' + s);
          //   alert('l is ' + l +'m is ' + m);


            toppos = Math.round((b/2)-(s/2)+(m))
            leftpos = Math.round((a/2)-(r/2)+(l))

                obj.pixelLeft = leftpos  
                obj.pixelTop = toppos

                obj.display = "block";

        x=0;
        y=0;

        return false;

    }
    
    else {
    
    location.href='directory_source.cfm';
    
//    alert('not ie')
    return true;
    
    }
}
    

