$(document).ready(function () {
    $("ul.subnav").parent().append("<span></span>");
    $("ul.topnav li span").click(function () {
        $(this).parent().find("ul.subnav").slideDown('fast').show();
        $(this).parent().hover(
                        function () { },
                        function () {
                            $(this).parent().find("ul.subnav").slideUp('slow');
                        });
    }
             ).hover(function () {$(this).addClass("subhover"); }, function () {  //On Hover Out  
                 $(this).removeClass("subhover"); //On hover out, remove class "subhover"  
             });
});
var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
function validate() {
    if (form1.yourname.value != "") {
        if (form1.practicename.value != "") {
            if (form1.practiceid.value != "") {
                if (form1.email.value != "") {
                    em = form1.email.value;
                    if (em.indexOf("@") < 0) {
                        alert('You have not entered a valid email address');
                        return false;
                    }
                    return true;
                }
            }
        }
    }
    alert('Please fill out all contact details before sending this form');
    return false;
}
function domainwantedChanged() {
    dw = form1.domainwanted.value;
    if (dw == "yes")
        form1.domain.value = " --- type your preferred domain name here ---";
    else
        form1.domain.value = "";
}
function contactChanged() {
    cw = form1.contactwanted.value;
    if (cw == "email") {
        form1.contacttime.value = "";
        form1.contactday.value = "";
    }
    else {
        form1.contacttime.value = "Any time";
        form1.contactday.value = "Any day";
    }
}
function timeChanged() {
    cw = form1.contactwanted.value;
    if (cw == "email") {
        ct = form1.contacttime.value;
        cd = form1.contactday.value;
        if ((ct != "") || (cd != "")) {
            form1.contactwanted.value = "call";
            if (ct == "")
                form1.contacttime.value = "Any time";
            if (cd == "")
                form1.contactday.value = "Any day";
        }
    }
}
function Cover(bottom, top, ignoreSize) {
    var location = Sys.UI.DomElement.getLocation(bottom);
    top.style.position = 'absolute';
    top.style.display = 'block';
    top.style.top = location.y + 'px';
    top.style.left = location.x + 'px';
    if (!ignoreSize) {
        top.style.height = bottom.offsetHeight + 'px';
        top.style.width = bottom.offsetWidth + 'px';
    }
}
//****//
function findOutMore(infoField, fadeField, infoButton, w, h) {
    var vInfo = $get(infoField);
    if (vInfo.style.display == "block")
        return;
    var vFade = $get(fadeField);
    Cover($get(infoButton), vFade);
    moveItem(vFade, vInfo, -200, 100, w, h, false);
}
function closeFindOutMore(infoField) {
    var vInfo = $get(infoField);
    moveItem(vInfo, null, 200, -100, 0, 0, true);
}
function moveItem(vItem, vInfo, top, left, width, height, bHide) {
    var t = vItem.offsetTop;
    var tInc = 10;
    if (top < 0)
        tInc = -10;
    if (bHide)
        tInc *= 2;
    top = top + t;

    var l = vItem.offsetLeft;
    var lInc = 5;
    if (left < 0)
        lInc = -5;
    if (bHide)
        lInc *= 2;
    left = left + l;

    var h = vItem.offsetHeight;
    var hInc = 10;
    if (height < h)
        hInc = -50;

    var w = vItem.offsetWidth;
    var wInc = 10;
    if (width < w)
        wInc = -50;

    function doMove() {
        var bTop = Math.abs(top - t) > Math.abs(tInc);
        var bLeft = Math.abs(left - l) > Math.abs(lInc);
        var bWidth = (width >= 0) && (Math.abs(width - w) > Math.abs(wInc));
        var bHeight = (height >= 0) && (Math.abs(height - h) > Math.abs(hInc));
        if (bTop || bLeft || bHeight || bWidth) {
            if (bTop) {
                t = t + tInc;
                vItem.style.top = t + "px";
            }

            if (bLeft) {
                l = l + lInc;
                vItem.style.left = l + "px";
            }

            if (bWidth) {
                w = w + wInc;
                vItem.style.width = w + "px";
            }

            if (bHeight) {
                h = h + hInc;
                vItem.style.height = h + "px";
            }
        }
        else {
            clearInterval(intId1);
            if (bHide) {
                vItem.style.display = "none";
                vItem.style.top = top + "px";
                vItem.style.left = left + "px";
                vItem.style.width = width + "px";
                vItem.style.height = height + "px";
            }
            else {
                vItem.style.top = top + "px";
                vItem.style.left = left + "px";
                Cover(vItem, vInfo);
                vItem.style.display = "none";
            }
        }
    }
    var intId1 = setInterval(doMove, 10);
}

