﻿/// <reference path="/Admin/js/CommonUtilities.js" />
/// <reference path="../AdRotator/AdRotator.js" /> 
  /// <reference path="../Admin/js/CommonUtilities.js" />

var mintCurrentYear = 0;


function LoadRoutines() {
    FixFooterLogo();    
    SetActiveLinkStyle();
}

var AuthorizeDotLogo = {};

AuthorizeDotLogo.FixAttempts = 0;

AuthorizeDotLogo.Fixit = function() {
    var arrAs = document.getElementsByTagName("A");
    var a = null;
    var bolFoundIt = false;

    for (var x = 0; x <= arrAs.length - 1; x++) {
        a = arrAs[x];
        if (a.innerHTML.toString().indexOf("authorize.net") > -1) {
            //alert("Found it");
            document.getElementById("divAuthorizeNetSeal").insertBefore(a, document.getElementById("divAuthorizeNetSeal").childNodes[0]);
            bolFoundIt = true;
            break;
        }
    }
    if (bolFoundIt == false) {
        AuthorizeDotLogo.FixAttempts += 1;
        if (AuthorizeDotLogo.FixAttempts <= 15) {
            setTimeout("AuthorizeDotLogo.Fixit();", 1000);
        }
    }
}

function FixFooterLogo() {
//    var logo = document.getElementById('imgLogo');
//    var spanInfo = document.getElementById('spanDevelInfo');
//    var intLogoVmiddle = 0;
//    var intSpanInfoHeight = spanInfo.offsetHeight;

//    spanInfo.parentNode.style.position = 'relative';
//    spanInfo.style.position = 'absolute';
//    spanInfo.style.whiteSpace = 'nowrap';
//    spanInfo.style.left = (logo.offsetLeft - (spanInfo.offsetWidth + 5)) + 'px';
//    intLogoVmiddle = (logo.offsetTop + parseInt(logo.offsetHeight / 2));
//    spanInfo.style.top = intLogoVmiddle - parseInt(intSpanInfoHeight / 2) + 'px';

    var divFooter = document.getElementById("divFooter");
    var docHeight = 0;
    var footerTop = divFooter.offsetTop;
    var footerHeight = divFooter.offsetHeight;
    var intTargetFooterHeight = 200;

    if (document.all) {
        docHeight = document.body.scrollHeight;
        this.docHeight = GetClientHeight();
        if (this.docHeight > docHeight) {
            docHeight = this.docHeight;
        }
    }
    else {
        docHeight = document.documentElement.scrollHeight;
        this.docHeight = GetClientHeight();
        if (this.docHeight > docHeight) {
            docHeight = this.docHeight;
        }        
    }

    if ((footerTop + intTargetFooterHeight) < docHeight) {
        divFooter.style.height = String(docHeight - footerTop) + 'px';
    }
    else {
        divFooter.style.height = String(intTargetFooterHeight) + 'px';
    }

    setTimeout("AuthorizeDotLogo.Fixit();", 1000);
}

function SetActiveLinkStyle() {
    var links = document.getElementById("BoxNav").getElementsByTagName("A");
    var currentPage = String(window.location).split("?")[0];
    var strLinkHref = "";
    
    currentPage = currentPage.split("/")[currentPage.split("/").length - 1].toLowerCase();

    for (var x = 0; x <= links.length - 1; x++) {
        strLinkHref = links[x].href.toString().toLowerCase();
        if (strLinkHref.split("/")[strLinkHref.split("/").length - 1].toLowerCase() == currentPage.toLowerCase()) {
            links[x].style.color = "#FF6633";
            break;        
        }
    }
}

function CheckToAddSiteAdminLink() {
    try {
        if (OpulentSource.SiteLogin == true) {
            document.write("<div class=\"divSiteAdminLink\"><a href=\"/admin\" title=\"Site Admin\">Site Admin</a></div>");
        }
    }
    catch (e) { }
}
