﻿/*
    Name        :   displayThemeProducts
    Purpose     :   Displays the product for the current moused over card
    Author      :   JohnD (Baudville) - 6/26/2009
    Params      :
*/
function displayThemeProducts(strExtCode, strThemeSku, themeid_fk, themegroupid_fk){

    //Clear products
    for (x=1;x<=5;x++) {
        getElementId('tdProd' + x).style.display="none";
        getElementId('imgProd' + x).style.display="none";
    }
    
    getElementId('spnTitle').innerHTML = "";
    getElementId('lnkThemeLink').href="";
    getElementId('spnLinkText').innerHTML = "";
    
    var strExtCode = getElementId(strExtCode).value;
    //Display products
    var lngTD = 1;
    for (i=0;i<arrThemeProdData.length;i++) {
        var arrTPD = new Array();
        arrTPD = arrThemeProdData[i].split('|');
     
        if (arrTPD[8] == strExtCode) {
            if (lngTD <= 5) {
                            getElementId('lnkProd' + lngTD).href = getElementId(_strCPId + 'hidSiteDomain').value + arrTPD[4] + '/theme-product-info/' + arrTPD[5] + '/' + arrTPD[6] + '/' + arrTPD[0] + '/' + arrTPD[8];
                            getElementId('tdProd' + lngTD).style.display = "inline";
                            getElementId('lnkProd' + lngTD).title = arrTPD[2];
                            //Image 
                            getElementId('imgProd' + lngTD).src = arrTPD[9];
                            getElementId('imgProd' + lngTD).alt = arrTPD[2];
                            getElementId('imgProd' + lngTD).style.display = "inline";
                            //getElementId('imgProd' + lngTD).style.border = "0";
                            // Product name
                            getElementId('lnkProdName' + lngTD).href = getElementId(_strCPId + 'hidSiteDomain').value + arrTPD[4] + '/theme-product-info/' + arrTPD[5] + '/' + arrTPD[6] + '/' + arrTPD[0] + '/' + arrTPD[8];
                            getElementId('lnkProdName' + lngTD).title = arrTPD[2];
                            getElementId('spnProdName' + lngTD).innerHTML = arrTPD[2];
                            // Product Price
                            getElementId('tdProdPrice' + lngTD).innerHTML = arrTPD[3];
            }
            
            lngTD += 1;
        
        }
    }
    
    //Display slide information
    for (i=0;i<arrThemeSlideInfo.length;i++) {
        var arrTSI = new Array();
        arrTSI = arrThemeSlideInfo[i].split('|');
        
        if (arrTSI[5] == strExtCode) {
            getElementId('spnSection').innerHTML = '"' + arrTSI[0] + '"';
            getElementId('spnTitle').innerHTML = arrTSI[0] + ' | ' + arrTSI[1];
                       var strInfo = arrTSI[2];
                        if (strInfo.length == 0) {
                            strInfo = "SHOP ALL THMNUM<br /> PRODUCTS";
                        }
                        getElementId('lnkThemeLink').href = arrTSI[3];
                        getElementId('spnLinkText').innerHTML = strInfo.replace("THMNUM", arrTSI[4]);
        }
        
        

    }
    
    var intThemeGroupId = getElementId(_strCPId + 'hidThemeGroupId').value;
    var strThemeCopy = "";
    var intUserMsgId = 18;
    if (intThemeGroupId == null) {
        strThemeCopy = _arrUserMsg[18];
    } else {
        switch (parseInt(intThemeGroupId)) {
            case 1: //Attitude
                intUserMsgId = 24;
                break;
            case 2: //Excellence
                intUserMsgId = 23;
                break;
            case 3: //Dedication
                intUserMsgId = 22;
                break;
            case 4: //Motivational
                intUserMsgId = 21;
                break;
            case 6: //Thank you
                intUserMsgId = 20;
                break;
            case 7: //Teamwork;
                intUserMsgId = 19;
                break;
            case 12: //Main
                intUserMsgId = 18;
                break;
        }
        strThemeCopy = _arrUserMsg[intUserMsgId];
        getElementId('spnThemeGroups').innerHTML = strThemeCopy;
    }
    
    

}
/*
    Name        :   clearImages
    Purpose     :   Clears the contents of the controls imgSlots
    Author      :   JohnD (Baudville) - 6/26/2009
    Params      :
*/
function clearImages() {
    for (y=1;y<=4;y++) {
        getElementId(_strCPId + 'imgSlot' + y).style.display="none";
    }
}

/*
    Name        :   jumpToThmTg
    Purpose     :   Brings the user to the selected themegroup
    Author      :   JohnD (Baudville) - 6/26/2009
    Params      :
*/
function jumpToThmTg(ddl) {
    //Get the url
    var strUrl = getElementId(_strCPId + 'hidSiteDomain').value;
    //Get the dropdown element
    ddl = getElementId(ddl);
    //Check to see where the user wants to go.
    if (ddl.options[ddl.selectedIndex].value.indexOf("View") == -1) {
        //View all themes in the selected theme group
        var lngTgId = ddl.options[ddl.selectedIndex].value;
        strUrl += 'recognition-themes/trt/' + lngTgId;
    } else {
        //View all themes
        strUrl += 'recognition-themes/showthm/all';
    }
    //Goto the selected item from the drop down
    window.location = strUrl;
    
    return false
}

/*
 Name            :       quickViewTheme
 Purpose         :       Displays the quick view dialog for themes
 Author          :       JohnD (Baudville) - 5/29/2009
 */
function quickThemeView(strExtCode, strThemeSku, themeid_fk, themegroupid_fk, strValueType)
{
	if (strValueType == "element")
	{
    strExtCode = getElementId(strExtCode).value;
    strThemeSku = getElementId(strThemeSku).value;
    themeid_fk = getElementId(themeid_fk).value;
    themegroupid_fk = getElementId(themegroupid_fk).value;
   }
    openRadWindow('/qv/' + strThemeSku + '/' + escape(strExtCode + "þ" + themeid_fk + "þ" + themegroupid_fk) + '/thm', 650, 800, 1, 0, 1, 1, '0');
}


/*
    Name        :   bringUpSldies
    Purpose     :   Pulls back the slides
    Author      :   JohnD (Baudville) - 6/26/2009
    Params      :
*/
function bringUpSlides (lngSlot1, lngSlot4) {
    var lngSlot = 1;
    

    //Clear products
    for (x=1;x<=5;x++) {
        getElementId('tdProd' + x).style.display="none";
        getElementId('imgProd' + x).style.display="none";
    }
    
    for (i=0;i < arrThemeCards.length; i++) {
        var arrTC = new Array();
        arrTC = arrThemeCards[i].split('|');
        
        if (arrTC.length > 0) {
            if (parseInt(arrTC[2]) >= parseInt(lngSlot1) && parseInt(arrTC[2]) <= parseInt(lngSlot4)) {
                for (x=lngSlot1;x<=lngSlot4;x++) {
                    if (parseInt(x) == arrTC[2]) {
                        getElementId(_strCPId + 'imgSlot' + lngSlot).src = arrTC[0];
                        getElementId(_strCPId + 'imgSlot' + lngSlot).style.display = "inline";
                        getElementId(_strCPId + 'imgSlot' + lngSlot).alt = arrTC[7];
                        getElementId(_strCPId + 'hidCharCode' + lngSlot).value = arrTC[4];
                        getElementId(_strCPId + 'hidCSKU' + lngSlot).value = arrTC[6];
                        getElementId(_strCPId + 'hidTgId' + lngSlot).value = arrTC[1];
                        getElementId(_strCPId + 'hidThmId' + lngSlot).value = arrTC[5];
                        lngSlot +=1;
                    }
                }
            }
        }
    }
}


/*
    Name        :   nextCards
    Purpose     :   Handles the click event for the scroll right button
    Author      :   JohnD (Baudville) - 6/26/2009
    Params      :   
*/
function nextCards() {


var hidCurrPage = getElementId(_strCPId + 'hidCurrPage');
var hidSlot1 = getElementId(_strCPId + 'hidSlot1');
var hidSlot4 = getElementId(_strCPId + 'hidSlot4');
var hidNumOfSlides = getElementId(_strCPId + 'hidNumOfSlides');
var hidTotalPages = getElementId(_strCPId + 'hidTotalPages');
var imgLeftArrow = getElementId(_strCPId + 'imgLeftArrow');
var imgLeftDisabled = getElementId(_strCPId + 'imgLeftDisabled');
var imgRightArrow = getElementId(_strCPId + 'imgRightArrow');
var imgRightDisabled = getElementId(_strCPId + 'imgRightDisabled');


   //Get the current page and set it to the next page available
   var lngCurrPage = hidCurrPage.value;
   var lngSlot1 = hidSlot1.value;
   var lngSlot4 = hidSlot4.value;
   
   clearImages();
   imgLeftArrow.style.display="inline";
   imgLeftDisabled.style.display="none";
   
   //Move to the page
   if ((parseInt(lngCurrPage) + 1) > parseInt(hidTotalPages.value)) {
        //At the end of the available pages, turn off the next button
        lngCurrPage = parseInt(hidTotalPages.value);
        imgRightArrow.style.display="none";
        imgRightDisabled.style.display="inline";
   } else {
        lngCurrPage = parseInt(lngCurrPage) + 1;
   }
   //If at the end of the available pages, then turn off the next button
   if (parseInt(lngCurrPage) == parseInt(hidTotalPages.value)) {
      
       imgRightArrow.style.display="none";
       imgRightDisabled.style.display="inline";
   }
   hidCurrPage.value = lngCurrPage;
    
   //Okay get the next set of slides to be displayed
   lngSlot1 = parseInt(lngSlot1) + 4;
   lngSlot4 = parseInt(lngSlot4) + 4;
   
   bringUpSlides (lngSlot1,lngSlot4)
   hidSlot1.value = lngSlot1;
   hidSlot4.value = lngSlot4;
   
   
    displayThemeProducts('ctl00_ContentPlaceHolder1_hidCharCode1','ctl00_ContentPlaceHolder1_hidCSKU1','ctl00_ContentPlaceHolder1_hidThmId1','ctl00_ContentPlaceHolder1_hidTgId1');
}

/*
    Name        :   previousCards
    Purpose     :   Handles the click event for the scroll left button
    Author      :   JohnD (Baudville) - 6/26/2009
    Params      :   
*/
function previousCards() {

var hidCurrPage = getElementId(_strCPId + 'hidCurrPage');
var hidSlot1 = getElementId(_strCPId + 'hidSlot1');
var hidSlot4 = getElementId(_strCPId + 'hidSlot4');
var hidNumOfSlides = getElementId(_strCPId + 'hidNumOfSlides');
var hidTotalPages = getElementId(_strCPId + 'hidTotalPages');
var imgLeftArrow = getElementId(_strCPId + 'imgLeftArrow');
var imgRightArrow = getElementId(_strCPId + 'imgRightArrow');
var imgLeftArrow = getElementId(_strCPId + 'imgLeftArrow');
var imgLeftDisabled = getElementId(_strCPId + 'imgLeftDisabled');
var imgRightArrow = getElementId(_strCPId + 'imgRightArrow');
var imgRightDisabled = getElementId(_strCPId + 'imgRightDisabled');

   
   //Get the current page and set it to the next page available
   var lngCurrPage = hidCurrPage.value;
   var lngSlot1 = hidSlot1.value;
   var lngSlot4 = hidSlot4.value;

    clearImages();   
   imgRightDisabled.style.display="none";
   imgRightArrow.style.display="inline";
   //Move to the page
   if ((lngCurrPage - 1) < 1) {
        //At the end of the available pages, turn off the next button
        lngCurrPage = 1;
        imgLeftArrow.style.display="none";
        imgLeftDisabled.style.display="inline";
   } else {
        lngCurrPage = parseInt(lngCurrPage) - 1;
   }
   //If at the end of the available pages, then turn off the next button
   if (parseInt(lngCurrPage) == 1) {
      
       imgLeftArrow.style.display="none";
       imgLeftDisabled.style.display="inline";
   }
   hidCurrPage.value = lngCurrPage;
    
   //Okay get the next set of slides to be displayed
   lngSlot1 = parseInt(lngSlot1) - 4;
   lngSlot4 = parseInt(lngSlot4) - 4;
   
   if (lngSlot1 < 1) {
    lngSlot1 = 1;
    lngSlot4 = 4;
   }
   
   bringUpSlides (lngSlot1,lngSlot4)
   hidSlot1.value = lngSlot1;
   hidSlot4.value = lngSlot4;
   
    displayThemeProducts('ctl00_ContentPlaceHolder1_hidCharCode1','ctl00_ContentPlaceHolder1_hidCSKU1','ctl00_ContentPlaceHolder1_hidThmId1','ctl00_ContentPlaceHolder1_hidTgId1');

}
