﻿// JScript File
//Changes the layers of the information section of item detail
function infoDetailLayer(whichLayer, layer1, layer2, layer3) {
    var activeLayer = ""; //holds the active Layer	
    var style2 = ""; //holds the style of layer1
    var style3 = ""; //holds the style of layer2
    var style4 = ""; //holds the style of layer3

    // this is the way the standards work
    if (whichLayer != '') { activeLayer = getDocID(whichLayer); }
    if (layer1 != '') { style2 = getDocID(layer1); }
    if (layer2 != '') { style3 = getDocID(layer2); }
    if (layer3 != '') { style4 = getDocID(layer3); }

    //Checks if there is an active layer
    if (activeLayer != null) {
        //checks if the activeLayer is already active and if so then skips code
        //since the layer cannot be turn off and leave a hole in the review layer
        if (activeLayer.style.display == "") {
            //removes the block from the display in order to make the layer to disapper	
            if (style2 != '')
                style2.style.display = style2.style.display ? "" : "";

            //checks if there is a style3
            if (style3 != '')
                style3.style.display = style3.style.display ? "" : "";

            //checks if there is a style3
            if (style4 != '')
                style4.style.display = style4.style.display ? "" : "";

            //displays the new active Layer and updates its id
            activeLayer.style.display = activeLayer.style.display ? "" : "block";
        } //end of if
    } //end of if
} //end of infoDetailLayer()
function getDocID(tagLayer) {
    var tagProp = ""; //holds the proerties of tagLayer

    //gets the whichLayer Properties depending of the differnt bowers the user is using
    if (document.getElementById)//this is the way the standards work
        tagProp = document.getElementById(tagLayer);
    else if (document.all)//this is the way old msie versions work
        tagProp = document.all[tagLayer];
    else if (document.layers)//this is the way nn4 works
        tagProp = document.layers[tagLayer];

    return tagProp;
} //end of getDocID()
//shoes and hides a <div> using display:block/none from the CSS
function toggleLayer(tagLayer, tagGrayOut, tagMedia) {
    var tagStyle = ''; //holds the style of tagLayer

    //gets the tagLayer and tagGrayOut Properties
    tagStyle = getDocID(tagLayer);
    tagGrayOut = getDocID(tagGrayOut);
    tagMedia = getDocID(tagMedia);
   
    if (tagStyle != null) { tagStyle.style.display = tagStyle.style.display ? "" : "block"; }
    if (tagGrayOut != null) {
        tagGrayOut.style.display = tagGrayOut.style.display ? "" : "block";

        //for IE
        if (navigator.userAgent.indexOf('MSIE') != -1) {
            tagGrayOut.attachEvent('onclick', function() {
                //specal case pleace remove when REUSING THIS FUNCTION UNLESS YOU ARE USING IT Email TO A FRIEND
                infoDetailLayer('divShareFriendsBody', 'divShareMessage', '', '');

                toggleLayer(tagStyle.id, tagGrayOut.id)
            });
        } //end of if
        //for the other browsers
        else {
            tagGrayOut.addEventListener('click', function() {
                //specal case pleace remove when REUSING THIS FUNCTION UNLESS YOU ARE USING IT Email TO A FRIEND
                infoDetailLayer('divShareFriendsBody', 'divShareMessage', '', '');

                toggleLayer(tagStyle.id, tagGrayOut.id);
            }, false);
        } //end of else
    } //end of if
    
} //end of toggleLayer()

//changes the Text Header and the Image in order for Picture Gallery can display the image fully
function changeImageLightBox(tagImage, tagLightBoxTitle, strImage, strLightBoxTitle, tagTitleBar, strStyleName) {
    //gets the properties of the tags
    tagImage = getDocID(tagImage);
    tagLightBoxTitle = getDocID(tagLightBoxTitle);
    tagTitleBar = getDocID(tagTitleBar);

    //checks if there is a tagTarget on the page
    if (tagImage != null && tagLightBoxTitle != null && tagTitleBar != null) {
        //sets the style to be the new iamge
        if (strImage != "") {
            var intTitleBarStyle = 0;

            tagImage.src = strImage;
            tagLightBoxTitle.innerHTML = strLightBoxTitle;

            //checks if the form is IE or the other broswers this is to see if it is need to grow th size to
            //fit the boarder and removes the px at the end of the area
            if (tagTitleBar.currentStyle)
            //IE
                intTitleBarStyle = parseInt(tagTitleBar.currentStyle[strStyleName].substring(0, tagTitleBar.currentStyle[strStyleName].length - 2));
            else
            //other broswers
                intTitleBarStyle = parseInt(document.defaultView.getComputedStyle(tagTitleBar, null).getPropertyValue(strStyleName).substring(0, document.defaultView.getComputedStyle(tagTitleBar, null).getPropertyValue(strStyleName).length - 2));

            //checks if it is need size needs to grow
            if (tagImage.width > intTitleBarStyle)
                tagTitleBar.style.width = (tagImage.width) + "px";
            else
            //removes the style
                tagTitleBar.style.width = '';
        } //end of if
    } //end of if
} //end of changeDymaicLightBox()


function removeDivContent(targetDiv) {
    var div = document.getElementById(targetDiv);   
    div.style.display = "none";
}
function showDivContent(targetDiv) {
    var div = document.getElementById(targetDiv);
    div.style.display = "block";
    div.focus();
    return false;
}
function changeTabImage(targetTab,classname) {
    
    var tab = document.getElementById(targetTab);
   
    tab.setAttribute("class", classname);
}

function replaceDivContent(targetDiv, newContent)
{   
    var div = document.getElementById(targetDiv);
    div.innerHTML = newContent;
}

function replaceDiv(targetDiv, newContent)
{   
    var div = document.getElementById(targetDiv);
  //  div.innerHTML = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0' width='360' height='225'><param name='wmode' value='transparent'><param name='movie' value='" + newContent + "' /><param name='quality' value='high' /><embed wmode='transparent' src='" + newContent + "' quality='high' pluginspage='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='360' height='225'></embed></object>";
    div.innerHTML = "<img src='assets/images/" + newContent + "'>";

}


//Bottom Banner Autoscroll
function removeVideo(strVideoFile) {
    if (strVideoFile == null)
        strVideoFile = "videoFilePH";

    var resultHolder = getDocID(strVideoFile);
    if (resultHolder != null) {
        resultHolder.innerHTML = '';
    }
    var lbNow = document.getElementById('lblNowPlaying');
    if (lbNow != null)
        lbNow.innerHTML = '';

    var lnks = getDocID('divLinks');
    if (lnks != null)
        lnks.innerHTML = '';
}

function toggleLayerMedia2(tagLayer, tagGrayOutt, tagMedia) {
    var tagStyle = ''; //holds the style of tagLayer

    //gets the tagLayer and tagGrayOut Properties
    tagStyle = getDocID(tagLayer);
    tagGrayOut = getDocID(tagGrayOutt);
    tagMedia = getDocID(tagMedia);

    if (tagStyle != null)
    { tagStyle.style.display = tagStyle.style.display ? "" : "block"; }

    if (tagGrayOut != null) {
        tagGrayOut.style.display = tagGrayOut.style.display ? "" : "block";

        //for IE
        if (navigator.userAgent.indexOf('MSIE') != -1) {
            tagGrayOut.attachEvent('onclick', function() {
                removeVideo();
                toggleLayer(tagStyle.id, tagGrayOut.id)

                //checks if there is any Media to stop also pleace remove when REUSING THIS FUNCTION 
                if (tagMedia != null)
                    tagMedia.Stop();
            });
        } //end of if
        //for the other browsers
        else {
            tagGrayOut.addEventListener('click', function() {
                removeVideo(); //
                toggleLayer(tagStyle.id, tagGrayOut.id);
            }, false);
        } //end of else
    } //end of if
} //end of toggleLayer()
function setupCurrentName(newName) {
    var lbNow = document.getElementById('lblNowPlaying');
    if (lbNow != null)
        lbNow.innerText = 'Now playing: ' + newName;
}
function CreateXmlHttp() {
    // IE
    try {
        XmlHttp = new ActioveXObject("Msxml2.XMLHTTP");
    }
    catch (e) {
        try {
            XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (os) {
            XmlHttp = null;
        }
    }
    // Mozilla and Safari	
    if (!XmlHttp && typeof XMLHttpRequest != "undefined") {
        XmlHttp = new XMLHttpRequest();
    }
}
function setupLinks(resultDoc) {
    if (resultDoc != null) {
        try {
            var resultHolder = getDocID('divLinks');
            if (resultHolder != null) {
                resultHolder.innerHTML = resultDoc;
            }
        }
        catch (e) {
            window.alert(ErrMsg);
        }
    }
    else {
        window.alert(ErrMsg);
    }
}

function HandleUpdateLinksResponse() {
    if (XmlHttp.readyState == 4) {
        if (XmlHttp.status == 200) {
          
            setupLinks(XmlHttp.responseText);
        }
        else {
            alert(ErrMsg);
        }
    }
}
var XmlHttp;
var ErrMsg = 'There was a problem retrieving data from the server.';
var linksHolderObj = null;

function reloadLinks(catId, prodId) {
    try {
        var requestUrl = 'AddLinks.ashx?productId=' + prodId;
        requestUrl += '&categoryId=' + catId;
       
        CreateXmlHttp();
        if (XmlHttp) {
            XmlHttp.onreadystatechange = HandleUpdateLinksResponse;
            XmlHttp.open("GET", requestUrl, true);
            XmlHttp.send(null);
        }
    }
    catch (e) {
        alert(e);
    }
}


function reloadVideo(videoObject, titleTxt, item, strVideoFile, strMovieTitle, strMainHolder) {
    //sets the default if there is no strVideo or strMovie
    if (strVideoFile == null)
        strVideoFile = "videoFilePH";

    if (strMovieTitle == null)
        strMovieTitle = "movieTitle";

    if (strMainHolder == null)
        strMainHolder = "divTOMGirlsMovie";

    var resultHolder = getDocID(strVideoFile);
    if (resultHolder != null) {
        resultHolder.innerHTML = videoObject;

    }
    var title = getDocID(strMovieTitle);
    if (title != null) {
        title.innerHTML = titleTxt;
    }
    var mainHolder = getDocID(strMainHolder);
    if (mainHolder != null) {
        if (strVideoFile == "videoFilePH")
            mainHolder.style.top = parseInt(item) * 200 + 280 + 'px';

        mainHolder.style.position = 'absolute';
    }
}
function reloadVideo2(videoObject) {

    var resultHolder = getDocID('videoFilePH');
    if (resultHolder != null) {
        resultHolder.innerHTML = videoObject;

    }
}

function removeVideo2() {

    var resultHolder = getDocID('videoFilePH');
    if (resultHolder != null) {
        resultHolder.innerHTML = '';
    }
}


