/*global window, parent, document */
var windoc = window.parent.document;

/*function openExternal() {
    var anchors = windoc.getElementsByTagName("a"); 
    for (var i = 0; i < anchors.length; i++) { 
        var anchor = anchors[i]; 
        if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "externalLink") {
            anchor.target = "_blank";
        }
    } 
} */

function openExternal() {
    var anchors = windoc.getElementsByTagName("a");
    for (var i = 0; i < anchors.length; i++) {
        var anchor = anchors[i];
        if (anchor.getAttribute("href") && anchor.getAttribute("rel") && anchor.getAttribute("rel") === "externalLink") {
            anchor.onclick = function() {
                return showLink(this);
            }
        anchor.onkeypress = anchor.onclick;
        }
    }
}

function showLink(whichlink) {
    var externalHref = whichlink.getAttribute("href");
    window.open(externalHref, "_blank");

    return false;
}

window.onload = openExternal;

var ststyle = windoc.createElement("link");
    ststyle.setAttribute("type", "text/css");
    ststyle.setAttribute("rel", "stylesheet");
    ststyle.setAttribute("href", "http://www.sadtrombone.com/widget/ststyle.css");
    ststyle.setAttribute("media", "screen");
var head = windoc.getElementsByTagName("head")[0];
    head.appendChild(ststyle);

if (!sadtrombone_width) {
    var sadtrombone_width = 180;
}

var sadtrombone_height = Math.ceil((sadtrombone_width * 84)/180);
document.write('<div id="flashHolder">');
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + sadtrombone_width + '" height="' + sadtrombone_height + '" accesskey="s" tabindex="1" title="Sad Trombone">');
document.write('<param name="movie" value="http://www.sadtrombone.com/sad_trombone_widget.swf" />');
document.write('<param name="quality" value="high" />');
document.write('<param name="wmode" value="transparent" />');
document.write('<param name="bgcolor" value="#ffffff" />');
document.write('<embed src="http://www.sadtrombone.com/sad_trombone_widget.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + sadtrombone_width + '" height="' + sadtrombone_height + '">');
document.write('</embed>');
document.write('</object>');
document.write('</div>');

document.write('<div id="centerSTLink"><a href="http://www.sadtrombone.com" title="please visit sadtrombone.com" rel="externalLink">www.sadtrombone.com</a></div>');

