﻿// START Radio Button Fix Script (EK)
$(document).ready(function() {
    $("input").each(function(i){
        if (this.type.toLowerCase() == "radio")
        {
            $(this).addClass("radioButtonGlobal");
        }
    });
});
// END Radio Button Fix Script
// START Copy to Clip Board Fix Script (EK)
// Note: This only works in IE, and will not show up in other browsers
$(document).ready(function() {
    if (window.clipboardData)    //If browser supports copying to clipboard
    {
        $("p,div").filter(".templateCode").each(function(i){
            $(this).after("<div style='vertical-align: middle;' align='right'><a class='nounderline' href='#' onClick='copyToClipboard(this); return false;'><img src='/test_images/icon_copy.gif' style='vertical-align: middle; margin-right:5px;'/></a><a href='#' onClick='copyToClipboard(this); return false;'>Copy To Clipboard</a></div>");
        });
    }
});
function copyToClipboard(linkElement)
{
    var text = getElementText(linkElement.parentNode.previousSibling);
    if (window.clipboardData) 
    {
        window.clipboardData.setData("Text", text);
    }
}
function getElementText(element)
{
    var result = "";
    var childNodes = element.childNodes;
    for (var i=0; i<childNodes.length; i++)
    {
        var node = childNodes[i];
        if (node.nodeType == 3)            //Is Text Node
        {
            result += node.nodeValue;
        }
        else if (node.nodeType == 1)    //Is Element Node
        {
            result += getElementText(node);
            if ((node.nodeName.toLowerCase() == "br") || (node.nodeName.toLowerCase() == "p"))
            {
                result += "\n";
            }
        }
    }
    return result;
}
// END Copy to Clip Board Fix Script