﻿

function init() {

    $(".menu a").hover(function() {
        $(this).next("em").animate({ opacity: "show", top: "-75" }, "slow");
    }, function() {
        $(this).next("em").animate({ opacity: "hide", top: "-85" }, "fast");
    });

    $('#NavMenu tr td a').hover(function() {
        $(this).animate({ paddingTop: '15px' }, 250);
    }, function() {
        $(this).animate({ paddingTop: '0px' }, 500);
    });

}

function ShowFaqAnswer(linkId) {
    var itemid = 'Show' + linkId;

    if ($('#' + itemid).is(':visible')) {
        $('#' + itemid).hide('1000');
    }
    else {
        $("div[id^=Show]").hide();
        $('#' + itemid).show('2000');
        var clickElementy = getAbsoluteTop(linkId) + 20; //set y position
        //var clickElementx = getAbsoluteLeft(linkId) + 20; //set x position
        var clickElementx = 100;
        $('#' + itemid).css({ left: clickElementx + "px", top: clickElementy + "px" });
    }

}

function getElementWidth(objectId) {
    x = document.getElementById(objectId);
    return x.offsetWidth;
}

function getAbsoluteLeft(objectId) {
    // Get an object left position from the upper left viewport corner
    o = document.getElementById(objectId)
    oLeft = o.offsetLeft            // Get left position from the parent object
    while (o.offsetParent != null) {   // Parse the parent hierarchy up to the document element
        oParent = o.offsetParent    // Get parent object reference
        oLeft += oParent.offsetLeft // Add parent left position
        o = oParent
    }
    return oLeft
}

function getAbsoluteTop(objectId) {
    // Get an object top position from the upper left viewport corner
    o = document.getElementById(objectId)
    oTop = o.offsetTop            // Get top position from the parent object
    while (o.offsetParent != null) { // Parse the parent hierarchy up to the document element
        oParent = o.offsetParent  // Get parent object reference
        oTop += oParent.offsetTop // Add parent top position
        o = oParent
    }
    return oTop
}

function handleToolTip(evt, element, offset) {
    switch (evt.type) {
        case 'focus':
            if ($('#' + 'tooltip-' + element.id).length)
                $('#' + 'tooltip-' + element.id).show();
            else
                CreateToolTip(element, offset);
            break;
        case 'blur':
            $('#' + 'tooltip-' + element.id).hide();
            break;
    }
}

var placeholder = {
    'txtFName': "First Name",
    'txtLName': "Last Name",
    'txtAddress': "Address",
    'txtCity': "City",
    'txtState': "State/Province",
    'txtPostalCode': "Postal Code",
    'txtCountry': "Country",
    'txtEmail1': "Email Address",
    'txtEmail2': "Confirm Email"
};

function CreateToolTip(element, offset) {
    var body = document.body || document.getElementsByTagName('body')[0];
    var msg = element.title;
    
    var t = document.createElement('span');
    t.className = 'tooltip';
    t.id = 'tooltip-' + element.id;
    t.innerHTML = '<div class="tipmessage">' + msg + '</div>';
    t.style.left = getAbsoluteLeft(element.id) + $("#" + element.id).width() + offset + 'px';
    t.style.top = getAbsoluteTop(element.id) - 1 + 'px';

    body.appendChild(t);
}



