﻿// JScript File
function ValidateTextArea(textboxID, divID)
{
    text = $("#"+textboxID).val().replace(/\s*/g,''); //remove spaces
    if (text == "")
    {
        $("#"+textboxID).focus();
        $("#"+divID).show();
        return false;
    } 

    return true;
}

//Captures the enter key and clicks the specified button as default button        
function clickButton(e, buttonid){
    var evt = e ? e : window.event;
    var bt = document.getElementById(buttonid);
    if (bt){
        if (evt.keyCode == 13){
            bt.click();
            return false;
        }
    }
}

function isValidEmailAddress(emailAddress) {
    var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
    return pattern.test(emailAddress);
}

function displayToolTip()
{
    $('[tooltip]').each(function() // Select all elements with the "tooltip" attribute
    {
       $(this).qtip({ 
            content: $(this).attr('tooltip'),
            style: { 
                name: 'dark', 
                tip: 'bottomLeft',
                border: {
                    width: 1,
                    radius: 5
                },
                font: 'bold 12px Verdana,sans-serif'
            },
            position: {
                corner: {
                    target: 'topRight',
                    tooltip: 'bottomLeft'
                },
                adjust: { screen: true }
            }
       });
    });
}
