﻿//Global variables
var _strUcId = "ctl00_ContentPlaceHolder1_ucProductSelector_";
var _strPgId = "ctl00_ContentPlaceHolder1_";

var _strProductSelectorId = "ctl00_ContentPlaceHolder1_ucProductSelector_dlSlideProductSelector_ctlIDNUM_divSlide";
var _strProductInformationId = "ctl00_ContentPlaceHolder1_ucProductSelector_dlSlideInformation_ctlIDNUM_tblSlideInfo";
var _strSlide = _strUcId + 'divSlideKudos';
var _strScene7Url = _strUcId + 'hidScene7';
var _blnMouseOver = false;





function resetQuickViewButton(extcode) {
    getElementId('imgQuickview_' + extcode).style.display="none";
}

function displayKudoItems(extcode,invtid) {
 var divSlide =  getElementId(_strSlide);
 
 if (divSlide != null) {
    divSlide.style.display = "inline";
    
    
    var strScene7ImgUrl = getElementId(_strScene7Url).value
    var hidExtCode = getElementId(_strUcId + 'hidExtCode');
 
 for (i=1;i<=5;i++) {
    getElementId('tdKudosProd' + i).style.display="inline";
    getElementId('imgKudosProd' + i).src = strScene7ImgUrl + invtid + '_' + i + '_ON?hei=140&wid=140&op_sharpen=1';
    getElementId('imgKudosProd' + i).style.display = "inline";
    var strCaption=""
    switch (i) {
        case 1:
            strCaption = "CHEERS NOTE: BUTTON";
            break;
        case 2:
            strCaption = "CHEERS NOTE: MAGNET";
            break;            
        case 3:
            strCaption = "CHEERS NOTE: FOLDER";
            break;            
        case 4:
            strCaption = "CHEERS NOTE: FRAME";
            break;            
        case 5:
            strCaption = "CHEERS NOTE: CLING";
            break;            
    }
    
    getElementId('spnKudosProdName'  + i).innerHTML = strCaption;
    getElementId('lnkKudosProd' + i).href="#"
    getElementId('lnkKudosProdName' + i).href="#"
    

        
 }

    var arrExtCode = new Array();
    arrExtCode = hidExtCode.value.split('|');
    for (i=0;i<arrExtCode.length;i++) {
        if (arrExtCode[i].length > 0) {
           
            getElementId('imgQuickview_' + arrExtCode[i]).style.display="none";
        }
    }
    
    getElementId('imgQuickview_' + extcode).style.display="inline"; 
 getElementId('spnKudosTitle').style.display="inline";
 getElementId('lnkKudosAll').style.display="inline";
 getElementId('lnkKudosAll').href = "/recognition-kits/kudos-kit-and-caboodle/productlisting/204/203";
  _blnMouseOver = true;
 
 }

}
function quickViewKudosKit(invtid,extcode) {
    openRadWindow('/qv/' + invtid + '/' + escape(extcode + "þ" + invtid) + '/kudoskit', 650, 850, 1, 0, 1, 1, '0');
}

/*
 * Name		      	:		displayHomePageSlideProducts
 * Purpose			:		Displays the products that go with the displayed slide on the home page.
 * Author			:		JohnD (Baudville) - 6/8/2009
 */
function displayHomePageSlideProducts(intSlideNum, strSlideType, strImgUrl, blnJumpTo){



    var intNumOfSlides = getElementId(_strUcId + 'hidNumOfSlides').value - 1;
    var strImg = strImgUrl
    var divTitleShortDesc = getElementId('divTitleShortDesc');
    var lnkLink1 = getElementId('lnkLink1');
    var lnkLink2 = getElementId('lnkLink2');
    var spnLink1 = getElementId('spnLink1');
    var spnLink2 = getElementId('spnLink2');
    

	intSlideNum = intSlideNum -1;
	if (intSlideNum < 0) {
	    intSlideNum =intNumOfSlides;
	}
	
    var arrSlideInfo = arrHPSlideInfo[intSlideNum].split("|");
    if (arrSlideInfo.length > 0) {
        divTitleShortDesc.innerHTML = arrSlideInfo[2] + ' | ' + arrSlideInfo[3]; //score beautiful
        lnkLink1.href = arrSlideInfo[5];
        spnLink1.innerHTML = arrSlideInfo[4];
        lnkLink2.href = arrSlideInfo[7];
        spnLink2.innerHTML = arrSlideInfo[6];
        
        if (arrHPSlideProdImgs.length > 0) {
        
            if (arrHPSlideProdImgs[0].length > 0) {
                getElementId(_strUcId + 'divSlideProducts').style.display = "inline";
                var intElement = 1;
                for (i = 0; i <= arrHPSlideProdImgs.length - 1; i++) {
                    var arrSlideProdImg = arrHPSlideProdImgs[i].split('|');
                    if (arrSlideProdImg.length > 0) {
                        if (arrSlideInfo[1] == arrSlideProdImg[3]) {
                      //      alert(intElement);
                            getElementId('tdHPProd' + intElement).style.display = "inline";
                            //Image
                            getElementId('imgHPProd' + intElement).src = arrSlideProdImg[2];
                            getElementId('imgHPProd' + intElement).style.display = "inline";
                            getElementId('imgHPProd' + intElement).alt = arrSlideProdImg[4] + ' - ' + arrSlideProdImg[1];
                            getElementId('imgHPProd' + intElement).className = "img-border";
                            //Link - Image
                            getElementId('lnkHPProd' + intElement).href = arrSlideProdImg[0];
                            //Link Prod NameTitle
                            getElementId('spnHPProdName' + intElement).innerHTML = arrSlideProdImg[1];
                            //Link Prod Name
                            getElementId('lnkHPProdName' + intElement).href = arrSlideProdImg[0];
                            
                            if (intElement + 1 > 5) {
                                break;
                            }
                        }
                        else {
                            getElementId('tdHPProd' + intElement).style.display = "none";
                        }
                        intElement += 1;
                        if (intElement > 5) {
                            intElement = 1;
                        }
                    }
                }
            }
            else {
                getElementId(_strUcId + 'divSlide').style.display = "none";
            }
        }
    }
}



/*
 Name            :       displayProducts
 Purpose         :       Displays the products for the item where the mouse is currently residing over on the page.
 Author          :       JohnD (Baudville) - 5/2009
 */
function displayProducts(item, id){


for (x=1;x<=5;x++) {
    getElementId('tdProd' + x).style.display="none";
}

getElementId('spnKudosTitle').style.display = 'none';
    if (getElementId(id).style.display == 'inline') {
var hidExtCode = getElementId(_strUcId + 'hidExtCode');    
        if (arrThemeSlideInfo.length > 0) {
            for (i = 0; i < arrThemeSlideInfo.length; i++) {
                var arrThm = new Array();
                arrThm = arrThemeSlideInfo[i].split('|');
                if (arrThm[5].indexOf(item) > -1) {
                
                     var arrThmInfo = new Array();
                    arrThmInfo = arrThemeSlideInfo[i].split('|');
                    if (arrThmInfo.length > 0) {
                        getElementId('spnTitle').innerHTML = arrThmInfo[0];
                        
                        if (arrThmInfo[1].length > 0) {
                            getElementId('spnTitle').innerHTML += ' | ' + arrThmInfo[1];
                        }
                        
                        
                        var strInfo = arrThmInfo[2];
                        if (strInfo.length == 0) {
                            strInfo = "SHOP ALL THMNUM<br /> PRODUCTS";
                        }
                        getElementId('lnkThemeLink').href = arrThmInfo[3];
                        getElementId('spnLinkText').innerHTML = strInfo.replace("THMNUM", arrThmInfo[4]);
                        
                    }
                    break;
                }
            }
            if (getElementId('divThemeInfo') != null) {
                getElementId('divThemeInfo').style.display = "none";
            }
        }
        
        var lngTD = 1;
        if (arrThemeProdData.length > 0) {
            for (i = 0; i < arrThemeProdData.length; i++) {
                    var arrThmInfo = new Array();
                    arrThmInfo = arrThemeProdData[i].split('|');
                if (arrThmInfo[8].indexOf(item) > -1) {
                
                
                
                
                    var arrThemeData = new Array();
                    arrThemeData = arrThemeProdData[i].split('|');
                    var blnContinue = false
                    if (arrThemeData.length > 0) {
                        if (arrThemeData[8].indexOf(item) > -1) {
                             blnContinue = true;
                        }
                    }
                    if (blnContinue) {
                   
                        var td = getElementId('tdProd' + lngTD);
                        if (td != null) {
                            td.style.display = "inline";
                            //Set up link
                            getElementId('lnkProd' + lngTD).href = getElementId(_strPgId + 'hidSiteDomain').value + arrThemeData[4] + '/theme-product-info/' + arrThemeData[5] + '/' + arrThemeData[6] + '/' + arrThemeData[0] + '/' + arrThemeData[8];
                            getElementId('lnkProd' + lngTD).title = arrThemeData[2];
                            //Image 
                            getElementId('imgProd' + lngTD).src = arrThemeData[9];
                            getElementId('imgProd' + lngTD).alt = arrThemeData[2];
                            getElementId('imgProd' + lngTD).style.display = "inline";
                            //getElementId('imgProd' + lngTD).style.border = "0";
                            // Product name
                            getElementId('lnkProdName' + lngTD).href = getElementId(_strPgId + 'hidSiteDomain').value + arrThemeData[4] + '/theme-product-info/' + arrThemeData[5] + '/' + arrThemeData[6] + '/' + arrThemeData[0] + '/' + arrThemeData[8];
                            getElementId('lnkProdName' + lngTD).title = arrThemeData[2];
                            getElementId('spnProdName' + lngTD).innerHTML = arrThemeData[2];
                            // Product Price
                            getElementId('tdProdPrice' + lngTD).innerHTML = arrThemeData[3];
                            
                        }
                        lngTD = lngTD + 1;
                    }
                    
                }
            }
            
            if (getElementId('divThemeProducts') != null) {
                getElementId('divThemeProducts').style.display = "inline";
            }
        }
        
    }
    
        var arrExtCode = new Array();
    arrExtCode = hidExtCode.value.split('|');
    for (i=0;i<arrExtCode.length;i++) {
        if (arrExtCode[i].length > 0) {
           
            getElementId('imgQuickview_' + arrExtCode[i]).style.display="none";
        }
    }
    getElementId('imgQuickview_' + item).style.display="inline"; 
    
}


/*
 Name            :       viewTheme
 Purpose         :       Displays the quick view dialog for themes
 Author          :       JohnD (Baudville) - 5/29/2009
 */
function viewTheme(strThemeSku, strExtCode, themeid_fk, themegroupid_fk){
    window.location = "/recognition-themes/ts/" + themegroupid_fk + "/" + themeid_fk;
    
    
    
}




/*
 Name            :       displayCardPins
 Purpose         :       Displays the card pins
 Author          :       JohnD (Baudville) - 5/2009
 */
function displayCardPins(strCardPinGroupId){
    var intNumSlides = getElementId(_strUcId + 'hidNumOfSlides').value;
    var hidThemeGroupIds = getElementId(_strUcId + 'hidThemeGroupIds');
    var arrThemeGroupIds = new Array();
    arrThemeGroupIds = hidThemeGroupIds.value.split('|');
    
    
    if (getElementId('divThemeInfo') != null) {
        getElementId('divThemeInfo').style.display = "none";
    }
    
    if (getElementId('divThemeProducts') != null) {
        getElementId('divThemeProducts').style.display = "none";
    }
    
    if (arrThemeGroupIds.length > 0) {
        for (i = 0; i < arrThemeGroupIds.length - 1; i++) {
            if (arrThemeGroupIds[i].length > 0) {
                if (arrThemeGroupIds[i] == strCardPinGroupId) {
                    getElementId("divCharPin_" + arrThemeGroupIds[i]).style.display = "inline";
                }
                else {
                
                    if (getElementId("divCharPin_" + arrThemeGroupIds[i]) != null) {
                        getElementId("divCharPin_" + arrThemeGroupIds[i]).style.display = "none";
                    }
                }
            }
        }
    }
    
}

/*
 Name        :       displaySlide
 Purpose     :       Displays the selected slide from the flash piece and the products that go with it.
 Author      :       JohnD (Baudville) - 5/19/2009
 */
function displaySlide(intSlideNum, strSlideType, blnJumpTo){
    //Local variables
    
    if (blnJumpTo != null) {
        _intSlideGoTo = intSlideNum;
        _blnSlideJumpTo = true;
    }
    var intNumOfSlides = getElementId(_strUcId + 'hidNumOfSlides').value;
    var strId = "";
    //Hide the elements
    for (i = 0; i <= intNumOfSlides - 1; i++) {
        if (i <= 9) {
            strId = _strProductSelectorId.replace("IDNUM", "0" + i);
            
            
            getElementId(strId).style.display = "none";
            
            strId = "";
            switch (strSlideType) {
                case "HP":
                    strId = _strProductInformationId.replace("IDNUM", "0" + (i));
                    break;
                case "THM":
                    //strId = _strProductInformationId.replace("IDNUM", "0" + (i-1));
                    break;
            }
            
            if (strId != "") {
                getElementId(strId).style.display = "none";
            }
        }
        else {
            strId = _strProductSelectorId.replace("IDNUM", (i));
            getElementId(strId).style.display = "none";
            strId = "";
            switch (strSlideType) {
                case "HP":
                    strId = _strProductInformationId.replace("IDNUM", "0" + (i));
                    break;
                case "THM":
                    //strId = _strProductInformationId.replace("IDNUM", "0" + (i-1));
                    break;
            }
            
            if (strId != "") {
                getElementId(strId).style.display = "none";
            }
        }
    }
    
    
    if (intSlideNum - 1 <= 9) {
        intSlideNum = "0" + (intSlideNum - 1);
    }
    else {
        intSlideNum = intSlideNum - 1;
    }
    //Display the products for the selected slide
    strId = _strProductSelectorId.replace("IDNUM", intSlideNum);
    
    getElementId(strId).style.display = "inline";
    
    strId = "";
    switch (strSlideType) {
        case "HP":
            strId = _strProductInformationId.replace("IDNUM", intSlideNum);
            break;
        case "THM":
            //Display the information for the selected slide
            //strId = _strProductInformationId.replace("IDNUM", "0" + (intSlideNum-1));
            break;
    }
    
    if (strId != "") {
        getElementId(strId).style.display = "block";
    }
}
