﻿/// <reference path="jquery-1.2.6.pack.debug.js" />
$(document).ready(function() {
    
    // hover function on doclist item
    $(".doclist-item").hover(function(){
        $(this).addClass("doclist-item-over");
    },function() {
        $(this).removeClass("doclist-item-over");
    });

    // replace each H1 tag with flash text alternative
    $("h1").each(function(i) {
        var textcolor = "0xC35328"; // color that text gets.
        var width = $(this).width();
        var height = ($(this).height()) - 5;
        var text = $(this).text();
        text = text.replace(/"/g, "'");
        text = text.replace("&", "%26");
        text = text.replace("%", "%25");

        var so = new SWFObject("swf/LocatorDisplayLight.swf", "h1_flashtext_" + i, width, height, "9", "");

        so.addVariable("sTitle", text.toUpperCase());
        so.addVariable("sColor", textcolor);
        so.addVariable("sSize", "32");
        so.addVariable("nX", "-3");
        so.addVariable("nY", "0");
        so.addVariable("nWidth", width);
        so.addVariable("nHeight", height);
        so.addVariable("nLeading", 5);
        so.addVariable("id", "h1_flashtext_" + i);
        so.addParam("wmode", "transparent");

        // If tag within link, make flash clickable.
        if ($(this).find("a").is("a")) {
            var a = $(this).find("a");
            so.addVariable("nUnderline", "1");
            so.addVariable("sURL", escape(a.attr("href")));
        }
        so.write(this);
        $(this).css("margin-bottom", "0px");
        //$(this).parent().find(".horizontal-dots:first-child").css("margin-top", "0");
    });

    // replace each H2 tag with flash text alternative
    $("h2").each(function(i) {
        var textcolor = "0xC35328"; // color that text gets.
        var width = $(this).width();
        var height = ($(this).height()) - 5;
        var text = $(this).text();
        text = text.replace(/"/g, "'");
        text = text.replace("&", "%26");
        text = text.replace("%", "%25");
        
        var so = new SWFObject("swf/LocatorDisplayLight.swf", "h2_flashtext_" + i, width, height, "9", "");

        so.addVariable("sTitle", text.toUpperCase());
        so.addVariable("sColor", textcolor);
        so.addVariable("sSize", "18");
        so.addVariable("nX", "-3");
        so.addVariable("nY", "0");
        so.addVariable("nWidth", width);
        so.addVariable("nHeight", height);
        so.addVariable("nLeading", 5);
        so.addVariable("id", "h2_flashtext_" + i);
        so.addParam("wmode", "transparent");

        // If tag within link, make flash clickable.
        if ($(this).find("a").is("a")) {
            var a = $(this).find("a");
            so.addVariable("nUnderline", "1");
            so.addVariable("sURL", escape(a.attr("href")));
        }
        so.write(this);
        $(this).css("margin-bottom", "0px");
    });

});

// lets flash adjust size of self
function changeSize(id, w, h) {
    var o = $("#" + id);
    o.width(w);
    o.height(h);
}

// receive search variables from flash
function search(woot) {
    document.SEARCH.search.value = woot;
    document.SEARCH.submit();
}