﻿
function MaskedTextBox(e) {
    e.value = ''; 
}

function showArea(e) 
{
    var style2 = document.getElementById(e).style;
    style2.display = "block";

}

function ShowAreaHighlight(e, highlight, image) 
{
    var link = document.getElementById(image).style;
    var selected = document.getElementById(image + 'Selected').style;
    if (image == 'imgPressLink') 
    {
        link.display = "none";
        selected.display = "block";
    }
    else if (image == 'imgTVLink') 
    {
        link.display = "none";
        selected.display = "block";
    }
    else if (image == 'imgRadioLink') 
    {
        link.display = "none";
        selected.display = "block";
    }
    var style1 = document.getElementById(e).style;
    style1.display = "block";

}

function hideArea(i) {
    var style2 = document.getElementById(i).style;
    style2.display = "none";
}

function HideAreaHighlight(i, highlight2, image2) 
{
    var link = document.getElementById(image2).style;
    var selected = document.getElementById(image2 + 'Selected').style;
    if (image2 == 'imgPressLink') {
        link.display = "block";
        selected.display = "none";
    }
    else if (image2 == 'imgTVLink') {
    link.display = "block";
        selected.display = "none";
    }
    else if (image2 == 'imgRadioLink') {
        link.display = "block";
        selected.display = "none";
    }
    var style2 = document.getElementById(i).style;
    style2.display = "none";
}

function ChangeTextArea(id, text) {
    var element = document.getElementById(id);
    element.innerHTML = text;
}

function HideTextArea(id) {
    var element = document.getElementById(id);
    element.innerHTML = '&nbsp;';
}

function Previous() {
    if (currentMedia > 0) {
        currentMedia--;

        var theDiv = document.getElementById('WorkGallery');
        theDiv.innerHTML = media[currentMedia];

        var galleryCount = document.getElementById('GalleryCount');
        galleryCount.innerHTML = (currentMedia + 1) + '/' + media.length;

        SetMediaType();
    }

    ChangeArrows();
}

function Next() {
    if (currentMedia < media.length-1) {
        currentMedia++;

        if (mediaType[currentMedia] != 'tvc') {
            var theDiv = document.getElementById('WorkGallery');
            theDiv.innerHTML = media[currentMedia];
        }

        var galleryCount = document.getElementById('GalleryCount');
        galleryCount.innerHTML = (currentMedia + 1) + '/' + media.length;

        SetMediaType();
    }

    ChangeArrows();
}

function SetMediaType() {
    if (mediaType[currentMedia] == 'tvc') 
    {
        ShowElement(false, 'WorkGallery');
        ShowElement(false, 'FlashContent');
        ShowElement(true, 'FlashContent');

        var workGalleryTD = document.getElementById('WorkGalleryTD').style;
        workGalleryTD.backgroundImage = 'url(../../images/item_client_tvc.jpg)';
        workGalleryTD.width = '296';
        workGalleryTD.height = '172';
        var galleryCountTD = document.getElementById('GalleryCountTD').style;
        galleryCountTD.backgroundImage = 'url(../../images/item_client_tvc_shadow.jpg)';
        galleryCountTD.width = '100%';
        galleryCountTD.height = '65';
        galleryCountTD.align = 'center';
    }
    else if (mediaType[currentMedia] == 'press_horizontal') {
        ShowElement(false, 'WorkGallery');
        ShowElement(true, 'WorkGallery');
        ShowElement(false, 'FlashContent');
        
        var workGalleryTD = document.getElementById('WorkGalleryTD').style;
        workGalleryTD.width = '296';
        workGalleryTD.height = '172';
        var galleryCountTD = document.getElementById('GalleryCountTD').style;
        galleryCountTD.backgroundImage = 'url(../../images/item_client_tvc_shadow.jpg)';
        galleryCountTD.width = '100%';
        galleryCountTD.height = '65';
        galleryCountTD.align = 'center';
    }
    else {
        ShowElement(false, 'WorkGallery');
        ShowElement(true, 'WorkGallery');
        ShowElement(false, 'FlashContent');

        var workGalleryTD = document.getElementById('WorkGalleryTD').style;
        workGalleryTD.width = '197';
        workGalleryTD.height = '212';
        var galleryCountTD = document.getElementById('GalleryCountTD').style;
        galleryCountTD.backgroundImage = 'url(../../images/item_client_press_shadow.jpg)';
        galleryCountTD.width = '100%';
        galleryCountTD.height = '65';
    }
}

function ShowElement(show, element) {
    var theDivElement = document.getElementById(element).style;
    var theDivStyle = document.getElementById(element).style;
    if (theDivStyle.display == '' && theDivElement.offsetWidth != undefined && theDivElement.offsetHeight != undefined) {
        theDivStyle.display = (theDivElement.offsetWidth != 0 && theDivElement.offsetHeight != 0) ? 'block' : 'none';
    }
    else {    
        theDivStyle.display = (theDivStyle.display == '' || theDivStyle.display == 'block' || !show) ? 'none' : 'block';
    }
}

function ChangeArrows() {
    if (currentMedia > 0) {
        var arrowLeft = document.getElementById('arrowleft');
        arrowLeft.src = "../../images/arrowleft.gif";
        arrowLeft.alt = "Previous";
    }
    else {
        var arrowLeft = document.getElementById('arrowleft');
        arrowLeft.src = "../../images/arrow_left2.gif";
        arrowLeft.alt = "";
    }

    if (currentMedia == media.length-1) {
        var arrowRight = document.getElementById('arrowright');
        arrowRight.src = "../../images/arrow_right2.gif";
        arrowRight.alt = "";
    }
    else {
        var arrowRight = document.getElementById('arrowright');
        arrowRight.src = "../../images/arrowright.gif";
        arrowRight.alt = "Next";
    } 
}