﻿//JScript file for AllStar Technologies.
//Created By Matt Ruggio
//PraXis, Inc.  2006.

var currentPageLink;

function openURL(url) {
    window.open(url);
}

function changeFeatureTo() {
    source = event.srcElement;
    if (source.tagName == "TR" || source.tagName == "TABLE") return;
    while (source.tagName != "TD") source = source.parentElement;
    if (source.id != "ignore") {
        source.style.borderRight = 'black 1px solid';
        source.style.borderLeft = 'black 1px solid';
        source.style.borderTop = 'black 1px solid';
        source.style.borderBottom = 'black 1px solid';
        source.style.color = 'blue';
    }
}

function changeFeatureBack() {
    if (event.fromElement.contains(event.toElement) || source.contains(event.toElement) || source.id == "ignore") return;
    if (source == currentPageLink) return;
    if (event.toElement != source) {
        source.style.borderRight = 'gray 1px solid';
        source.style.borderLeft = 'gray 1px solid';
        source.style.borderTop = 'gray 1px solid';
        source.style.borderBottom = 'gray 1px solid';
        source.style.color = 'black';
    }
}


function changeServiceTo() {
    source = event.srcElement;
    if (source.tagName == "TR" || source.tagName == "TABLE") return;
    while (source.tagName != "TD") source = source.parentElement;
    if (source.id != "ignore") {
        source.style.borderRight = 'black 1px solid';
        source.style.borderLeft = 'black 1px solid';
        source.style.borderTop = 'black 1px solid';
        source.style.borderBottom = 'black 1px solid';
        source.style.color = 'blue';
    }
}

function changeServiceBack() {
    if (event.fromElement.contains(event.toElement) || source.contains(event.toElement) || source.id == "ignore") return;
    if (source == currentPageLink) return;
    if (event.toElement != source) {
        source.style.borderRight = 'white 1px solid';
        source.style.borderLeft = 'white 1px solid';
        source.style.borderTop = 'white 1px solid';
        source.style.borderBottom = 'white 1px solid';
        source.style.color = 'black';
    }
}


function changeto(obj) {
    if (obj.id == 'linkindex')
        document.getElementById('imgHome').src = 'images/home_hover.jpg';
    else if (obj.id == 'linkquote')
        document.getElementById('imgQuote').src = 'images/quote_hover.jpg';
    else if (obj.id == 'linkcontact')
        document.getElementById('imgContact').src = 'images/contact_hover.jpg';
    else if (obj.id == 'linkabout') {
        document.getElementById('imgAbout').src = 'images/about_hover.jpg';
        document.getElementById('linkabout_right').style.backgroundImage = 'url(images/top_right_over.gif)';
    } else if (obj.id == 'linkabout_right') {
        document.getElementById('imgAbout').src = 'images/about_hover.jpg';
        document.getElementById('linkabout').style.backgroundColor = '#cc9966';
        document.getElementById('linkabout').style.color = 'white';
        obj.style.backgroundImage = 'url(images/top_right_over.gif)';
    }


    obj.style.backgroundColor = '#cc9966';
    obj.style.color = 'white';
}

function changeback(obj, backColor) {
    if (obj.id == 'linkindex')
        document.getElementById('imgHome').src = 'images/home.jpg';
    else if (obj.id == 'linkquote')
        document.getElementById('imgQuote').src = 'images/quote.jpg';
    else if (obj.id == 'linkcontact')
        document.getElementById('imgContact').src = 'images/contact.jpg';
    else if (obj.id == 'linkabout') {
        document.getElementById('imgAbout').src = 'images/about.jpg';
        document.getElementById('linkabout_right').style.backgroundImage = 'url(images/top_right.gif)';
    } else if (obj.id == 'linkabout_right') {
        document.getElementById('imgAbout').src = 'images/about.jpg';
        document.getElementById('linkabout').style.backgroundColor = backColor;
        document.getElementById('linkabout').style.color = 'blue';
        obj.style.backgroundImage = 'url(images/top_right.gif)';
    }

    obj.style.backgroundColor = backColor;
    obj.style.color = 'blue';
}

function getFileName() {
    var fullPath = window.location.pathname;
    var fileNameWithExt = fullPath.substring(fullPath.lastIndexOf('\\') + 1);
    var fileName = fileNameWithExt.substring(0, fileNameWithExt.indexOf('.'));
    return fileName;
}

function load() {
    switch (getFileName()) {
    case 'index':
        currentPageLink = linkindex;
        imgHome.src = 'images/home_hover.jpg';
        break;
    case 'audio':
        currentPageLink = linkaudio;
        break;
    case 'video':
        currentPageLink = linkvideo;
        break;
    case 'telecom':
        currentPageLink = linktelecom;
        break;
    case 'homecontrols':
        currentPageLink = linkhomecontrols;
        break;
    case 'environmental':
        currentPageLink = linkenvironmental;
        break;
    case 'computer':
        currentPageLink = linkcomputer;
        break;
    case 'wiring':
        currentPageLink = linkwiring;
        break;
    case 'contact':
        currentPageLink = linkcontact;
        imgContact.src = 'images/contact_hover.jpg';
        break;
    case 'about':
        currentPageLink = linkabout;
        imgAbout.src = 'images/about_hover.jpg';
        break;
    case 'news':
        currentPageLink = null;
        break;
    case 'quote':
        currentPageLink = linkquote;
        imgQuote.src = 'images/quote_hover.jpg';
        break;
    default:
        currentPageLink = null;
        break;
    }

    if (currentPageLink != null) {
        currentPageLink.style.backgroundColor = '#cc9966';
        currentPageLink.style.borderRight = '#cc9966 1px solid';
        currentPageLink.style.borderLeft = '#cc9966 1px solid';
        currentPageLink.style.color = 'white';
    }
}

function gotoLink(obj) {
    var pageTo = '';

    switch (obj.id) {
    case 'linkindex':
        pageTo = 'Default.aspx';
        break;
    case 'linkaudio':
        pageTo = 'audio.aspx';
        break;
    case 'linkvideo':
        pageTo = 'video.aspx';
        break;
    case 'linktelecom':
        pageTo = 'telecom.aspx';
        break;
    case 'linkhomecontrols':
        pageTo = 'homecontrols.aspx';
        break;
    case 'linkenvironmental':
        pageTo = 'environmental.aspx';
        break;
    case 'linkcomputer':
        pageTo = 'computer.aspx';
        break;
    case 'linkwiring':
        pageTo = 'wiring.aspx';
        break;
    case 'linkcontact':
        pageTo = 'contact.aspx';
        break;
    case 'linkabout':
        pageTo = 'about.aspx';
        break;
    case 'linkquote':
        pageTo = 'quote.aspx';
        break;
    default:
        currentPageLink = null;
        break;            
    }

    window.location = pageTo;

}
