var slash = "/"
var selectedSize
var ImagePath
var ImageHeight
var ImageWidth
var arrImage
var arrImageDimensions
var selectedAPNum
var strAPNumToBeReplaced
var strProducttype
var arrPODAttributes
var bApplyShadow
var customerZoneID
var ISOCurrency
var DLEPODConfigID = 0;
var DLEcanFrame;

$(document).ready(function() {

    //get the ZoneID and currency details.
    GetZoneAndCurrency();

    formatMainImage();
    
    //To Handle the combination of POD and Non-POD Items
    DLEPODConfigID = $('.moreSizesDD_Row_selected').find('#moreSizesDD_selected_PODConfigID').text();
    if (DLEPODConfigID != "")
    {
        var varDLEAPNUMOnLoad = $('.moreSizesDD_Row_selected').find('#moreSizesDD_selected_APNum').text();
        DLEcanFrame = $('.moreSizesDD_Row_selected').find('#moreSizesDD_selected_ItemFrame').text();
        setDLEPODParameters(DLEPODConfigID,varDLEAPNUMOnLoad,DLEcanFrame,false,$('.moreSizesDD_Row_selected').find('#ItemDisplayedTypeText').text());
    }


    $('#MainImage').live('click', function(e) {
        //we are using the same function as used by Zoom link. when Zoom link is not there, the event does not fire.
        eval($('#ZoomLink').attr('href'));
    });

    $('.moreSizesDD_Row').live('click', function(e) {

        var bFramingEnabled, PODSizeID, PODSubstrateID, PODTechnologyID, PODConfigID, canvasStretch, currentRow, previousSelectedRow, APNum
        var zoneProductID

        currentRow = $(this);

        APNum = currentRow.find('#moreSizesDD_selected_APNum').text();
        bApplyShadow = currentRow.find('#moreSizesDD_selected_ApplyShadow').text();
        bFramingEnabled = currentRow.find('#moreSizesDD_selected_ItemFrame').text();
        PODConfigID = currentRow.find('#moreSizesDD_selected_PODConfigID').text();
        arrPODAttributes = currentRow.find('#moreSizesDD_selected_PODConfigAttributes').text().split("@");
        zoneProductID = currentRow.find('#moreSizesDD_selected_zoneProductID').text();
        
        DLEPODConfigID = PODConfigID;
        
        
        	/*DLE Code Start*/
                setDLEPODParameters(PODConfigID,APNum,bFramingEnabled,true,currentRow.find('#ItemDisplayedTypeText').text());
                /*DLE Code End*/

        // We have the PODAttributes string as PODSizeID=<PODSizeID>@PODSubstrateID=<PODSubstrateID>@PODTechnologyID=<PODTechnologyID>
        PODSizeID = arrPODAttributes[0]
        PODSubstrateID = (arrPODAttributes[1].split("="))[1]
        PODTechnologyID = arrPODAttributes[2]
        canvasStretch = currentRow.find('#moreSizesDD_selected_canCanvasStretch').text();

        previousSelectedRow = $('.moreSizesDD_Row_selected');

        applySelectedRowStyle(currentRow, previousSelectedRow);

        DisplayMainAndZoomImage(currentRow);
        //Apply drop shadows or not.
        ApplyShadowToMainImage(canvasStretch, bApplyShadow, customerZoneID);

        PopulateSelectedSizeAttributes(currentRow);
        //Display Framing Options.
        showFramingOptions(bFramingEnabled, APNum, PODConfigID, currentRow);

        //Display Other Service Options.
        DisplayOtherServiceOptions(APNum, PODConfigID, zoneProductID);

    })

    $('#AddToCart').live('click', function(e) {

        var CartLink = $('#hdAddToCart').html();
        var selectedPODConfigID = $('.moreSizesDD_Row_selected').find('#moreSizesDD_selected_PODConfigID').text();
        var strZoneProductID = $('.moreSizesDD_Row_selected').find('#moreSizesDD_selected_zoneProductID').text();
        CartLink = CartLink.replace(/&amp;/g, "&");

        if ($.trim(selectedPODConfigID) == "") {
            linkForm(CartLink);
        }
        else {
            if ($.trim(selectedPODConfigID) == "") {
                selectedPODConfigID = 0;
            }

            var selectedSpecID = "sp--" + strZoneProductID.substr(strZoneProductID.length - 1, strZoneProductID.length)
            var selectedProductID = "pdta--" + strZoneProductID.substr(0, strZoneProductID.length - 1);
            var strPODConfigID = "PODConfigID=" + selectedPODConfigID;
            var strProductIDToBeReplaced = GetParameterToBeReplaced(CartLink, "pdta--", '/');
            var strSpecIDToBeReplaced = GetParameterToBeReplaced(CartLink, "sp--", '/');
            var strPODConfigIDToBeReplaced = GetParameterToBeReplaced(CartLink, "podconfigid=", '&');
            var ReplacedCartHTML = replaceString(replaceString(replaceString(CartLink, strPODConfigIDToBeReplaced, strPODConfigID), strProductIDToBeReplaced, selectedProductID), strSpecIDToBeReplaced, selectedSpecID);
            linkForm(ReplacedCartHTML);
        }
    })

    $('.moreSizesDD_Row_selected').live('click', function(e) {

        var moreCustomOptions = $("#moreCustom1");

        if (moreCustomOptions.attr('class') != "") {
            moreCustomOptions.attr('style', "");
        }
    })

    $('#linkToEmailFriend').live('click', function(e) {
        var selectedPODConfigID, selectedRow, selectedZoneProductID, selectedProductID, ReplacedPODConfigIDLink, selectedSpecID;
        var strProductIDToBeReplaced, strSpecIDToBeReplaced, strPODConfigIDToBeReplaced;

        var EmailPopUpLink = $('#hdmailaFriendURL').text();
        selectedRow = $('.moreSizesDD_Row_selected');
        selectedPODConfigID = selectedRow.find('#moreSizesDD_selected_PODConfigID').text()

        if (selectedPODConfigID != "") {
            strProductIDToBeReplaced = GetParameterToBeReplaced(EmailPopUpLink, "pd--", '/');
            strSpecIDToBeReplaced = GetParameterToBeReplaced(EmailPopUpLink, "sp--", '/');
            strPODConfigIDToBeReplaced = GetParameterToBeReplaced(EmailPopUpLink, "PODConfigID=", '&');

            selectedZoneProductID = selectedRow.find('#moreSizesDD_selected_zoneProductID').text()
            selectedSpecID = "sp--" + selectedZoneProductID.substr(selectedZoneProductID.length - 1, selectedZoneProductID.length)
            selectedProductID = "pd--" + selectedZoneProductID.substr(0, selectedZoneProductID.length - 1);
            selectedPODConfigID = "PODConfigID=" + selectedPODConfigID;

            ReplacedPODConfigIDLink = replaceString(replaceString(replaceString(EmailPopUpLink, strPODConfigIDToBeReplaced, selectedPODConfigID), strProductIDToBeReplaced, selectedProductID), strSpecIDToBeReplaced, selectedSpecID);
        }
        else {
            ReplacedPODConfigIDLink = EmailPopUpLink;
        }
        eval(ReplacedPODConfigIDLink);
    })
	
	//Rolling Stone
	var $includedText = $('#AdditionalText');
	includedText = $includedText.text().toLowerCase();
	//if product content contains 'rolling stone' and 'subscription' then add a link to popup the details
	if (includedText.indexOf('rolling stone') > 1 && includedText.indexOf('subscription') > 1 ){
		var rsClickEvent = "RollingStoneDetailsWindow('12','$6.48')";
		rollingStoneOfferLink = '<div><a href="#" onclick="'+rsClickEvent+'">Offer and rebate details</a></div>';
		$includedText.append(rollingStoneOfferLink);
	}

    function DisplayMainAndZoomImage(currentRow) {
        //get the imagepath, width and height
        ImagePath = currentRow.find('#moreSizesDD_selected_ImageFileAttr').html()

        arrImage = currentRow.find('#moreSizesDD_selected_ImageFileAttr').html().split("@");

        arrImageDimensions = arrImage[1].split("_");

        ImageWidth = arrImageDimensions[0];
        ImageHeight = arrImageDimensions[1];

        $('#MainImage').attr('height', ImageHeight);
        $('#MainImage').attr('width', ImageWidth);
        $('#MainImage').attr('src', arrImage[0].replace(/&amp;/g, "&"));
        $('#ZoomLink').attr('href', arrImage[2]);

        formatMainImage();
    }


    function applySelectedRowStyle(currentRow, previousSelectedRow) {
        //swap the selected row indicator and style.
        currentRow.find('.moreSizesDD_arrow #imgIndicator').attr('src', 'http://artfiles.art.com/images/pub/productPage/right_arrow.gif');
        previousSelectedRow.find('.moreSizesDD_arrow #imgIndicator').attr('src', 'http://artfiles.art.com/images/misc/blank.gif');

        previousSelectedRow.addClass('moreSizesDD_Row').removeClass('moreSizesDD_Row_selected');
        currentRow.addClass('moreSizesDD_Row_selected').removeClass('moreSizesDD_Row');

        $('.moreSizesDD_selected_Cell').addClass('moreSizesDD_Cell').removeClass('moreSizesDD_selected_Cell');
        currentRow.find('.moreSizesDD_Cell').addClass('moreSizesDD_selected_Cell').removeClass('moreSizesDD_Cell');

        //swap the price with selected row price.       
        $('.moreSizesDD_selected_Price').addClass('moreSizesDD_price').removeClass('moreSizesDD_selected_Price');
        currentRow.find('.moreSizesDD_price').addClass('moreSizesDD_selected_Price').removeClass('moreSizesDD_price');
    }

    function PopulateSelectedSizeAttributes(currentRow) {
        //set the price as per selected size.
        //$('.finalPrice').text($.trim($(this).find('.moreSizesDD_selected_Price').text()));
        $('#shipInfoLine').html($('#shipInfoLine').html().replace($('#shipInfoLine').html(), currentRow.find('#moreSizesDD_selected_TimeToShipLink').html()));

        $('#ProductSize_dBox1_SizeText').html($('#ProductSize_dBox1_SizeText').html().replace($('#ProductSize_dBox1_SizeText').html(), currentRow.find('#moreSizesDD_selected_productSize').html()));
        $('#ProductSize_dBox2_SizeText').html($('#ProductSize_dBox2_SizeText').html().replace($('#ProductSize_dBox2_SizeText').html(), currentRow.find('#moreSizesDD_selected_productSize').html()));

        //Swap the Included text with the selected value.
        $('#AdditionalText').html($('#AdditionalText').html().replace($('#AdditionalText').html(), currentRow.find('#moreSizesDD_selected_IncludedText').html()));
        //$('#AdditionalText').text(currentRow.find('#moreSizesDD_selected_IncludedText').text());

        //Swap the Interior Dimensions text.
        $('#InteriorDimension').text(currentRow.find('#moreSizesDD_selected_cropDimensions').text());

        //Swap the Product Type.
        $('#ProductType').text(currentRow.find('#ItemDisplayedTypeText').text());

        //Swap the item#.
        $('#ZoneProductID').text(currentRow.find('#moreSizesDD_selected_zoneProductID').text());

        //Swap the price.
        DisplayPrice(currentRow.find('#moreSizesDD_selected_DisplayPriceString').html());
    }

    function DisplayPrice(sPriceDetails) {
        var aPriceDetails, PriceTitle, PriceValue
        aPriceDetails = sPriceDetails.split("@");
        PriceTitle = aPriceDetails[0];
        PriceValue = aPriceDetails[1];
        $('#PriceTitles').html(PriceTitle);
        $('#PriceTitlesValue').html(PriceValue);
    }

    function GetZoneAndCurrency() {
        var LocDetails;
        LocDetails = ($('#hdLocalizationDetails').text().split("@"));
        customerZoneID = LocDetails[0];
        ISOCurrency = LocDetails[1];
    }

    function DisplayOtherServiceOptions(APNum, PODConfigID, ZoneProductID) {
        var output;
        $.ajax({
            type: "POST",
            url: "/asp/include/ValueAddedServicesHelper.asp",
            dataType: "application/x-www-form-urlencoded",
            data: "PODAPNum=" + APNum + "&PODItemConfigAPNum = " + PODConfigID + "&ZoneID=" + customerZoneID + "&ISOCurrencyCode=" + ISOCurrency + "&isAjax=Y",
            async: false,
            success: function(msg) { output = msg; }
        })
        if ($.trim(output) != "") {
            FetchServiceOptionValues(output)
            ReplacePODConfigZoneProductIDInServiceURL(PODConfigID, ZoneProductID)
        }
    }

    function FetchServiceOptionValues(output) {
        var serviceOptions, canCanvasTransfer, canMount, canLaminate, aServiceOptions
        serviceOptions = output;

        //Service options are in the following format.
        //canvastransfer@canmount@canLaminate.
        aServiceOptions = serviceOptions.split("@");
        canCanvasTransfer = aServiceOptions[0];
        canMount = aServiceOptions[1];
        canLaminate = aServiceOptions[2];

        //Hide or display based on the availability of the flags.
        showHideServiceOptions(canCanvasTransfer, canMount, canLaminate)
    }

    function showHideServiceOptions(canCanvasTransfer, canMount, canLaminate) {
        if (canCanvasTransfer > 0 || canMount > 0 || canLaminate > 0) {
            $("#moreCustom").removeClass('hiddenClass').addClass('displayClass');
            $("#CustomOptionsDD_Container").removeClass('hiddenClass').addClass('displayClass');
            $("#AdditionalServices").removeClass('hiddenClass').addClass('displayClass');
        }
        else {
            $("#moreCustom").removeClass('displayClass').addClass('hiddenClass');
            $("#CustomOptionsDD_Container").removeClass('displayClass').addClass('hiddenClass');
            $("#AdditionalServices").removeClass('displayClass').addClass('hiddenClass');
        }

        if (canCanvasTransfer == 0) {
            $("#CanvasTransferLink").hide();
            $("#divImgCanvasTransfer").removeClass('displayClass').addClass('hiddenClass');
        }
        else {
            $("#CanvasTransferLink").show();
            $("#divImgCanvasTransfer").removeClass('hiddenClass').addClass('displayClass');
        }

        if (canMount == 0) {
            $("#MountingLink").hide();
            $("#divImgMounting").removeClass('displayClass').addClass('hiddenClass');
        }
        else {
            $("#MountingLink").show();
            $("#divImgMounting").removeClass('hiddenClass').addClass('displayClass');
        }

        if (canLaminate == 0) {
            $("#LaminatingLink").hide();
            $("#divImgLaminating").removeClass('displayClass').addClass('hiddenClass');
        }
        else {
            $("#LaminatingLink").show();
            $("#divImgLaminating").removeClass('hiddenClass').addClass('displayClass');
        }
    }

    function ReplacePODConfigZoneProductIDInServiceURL(PODConfigID, ZoneProductID) {
        var strToBeReplacedPODConfigID;
        var selectedPODConfigID;
        var selectedProductID
        var strToBeReplacedProductID;
        var strToBeReplacedSpecID;
        var selectedSpecID;

        selectedPODConfigID = "PODConfigID=" + PODConfigID
        strToBeReplacedPODConfigID = GetParameterToBeReplaced($('#MountingLink').attr('href'), "PODConfigID=", '&');

        selectedProductID = "pd--" + ZoneProductID.substr(0, ZoneProductID.length - 1);
        strToBeReplacedProductID = GetParameterToBeReplaced($('#MountingLink').attr('href'), "pd--", '/');

        selectedSpecID = "sp--" + ZoneProductID.substr(ZoneProductID.length - 1, ZoneProductID.length).toLowerCase();
        strToBeReplacedSpecID = GetParameterToBeReplaced($('#MountingLink').attr('href'), "sp--", '/');

        $('#CanvasTransferLink').attr('href', replaceString($('#CanvasTransferLink').attr('href'), strToBeReplacedPODConfigID, selectedPODConfigID));
        $('#MountingLink').attr('href', replaceString($('#MountingLink').attr('href'), strToBeReplacedPODConfigID, selectedPODConfigID));
        $('#LaminatingLink').attr('href', replaceString($('#LaminatingLink').attr('href'), strToBeReplacedPODConfigID, selectedPODConfigID));

        $('#CanvasTransferLink').attr('href', replaceString($('#CanvasTransferLink').attr('href'), strToBeReplacedProductID, selectedProductID));
        $('#MountingLink').attr('href', replaceString($('#MountingLink').attr('href'), strToBeReplacedProductID, selectedProductID));
        $('#LaminatingLink').attr('href', replaceString($('#LaminatingLink').attr('href'), strToBeReplacedProductID, selectedProductID));

        $('#CanvasTransferLink').attr('href', replaceString($('#CanvasTransferLink').attr('href'), strToBeReplacedSpecID, selectedSpecID));
        $('#MountingLink').attr('href', replaceString($('#MountingLink').attr('href'), strToBeReplacedSpecID, selectedSpecID));
        $('#LaminatingLink').attr('href', replaceString($('#LaminatingLink').attr('href'), strToBeReplacedSpecID, selectedSpecID));

    }

    function replaceString(str, strToBeReplaced, newStr) {
        var reg, result

        if (str != null) {
            reg = new RegExp(strToBeReplaced, "gi");
            result = str.replace(reg, newStr);
        }
        return result;
    }


    function ApplyShadowToMainImage(canvasStretch, applyShadow, customerZoneID) {
        if (canvasStretch.toLowerCase() == "true") {
            if (customerZoneID == 3) {
                $("#wrap1").removeClass('wrap1').addClass('canvaswrap1');
                $("#wrap2").removeClass('wrap2').addClass('canvaswrap2');
                $("#wrap3").removeClass('wrap3').addClass('canvaswrap3');
            }
            else {
                $("#wrap1").removeClass('wrap1').addClass('canvaswhitewrap1');
                $("#wrap2").removeClass('wrap2').addClass('canvaswhitewrap2');
                $("#wrap3").removeClass('wrap3').addClass('canvaswhitewrap3');
            }
            $("#mainImageBorder").removeClass('mainImageBorder');
        }
        else if (applyShadow == 0) {
            if (customerZoneID == 3) {
                $("#wrap1").removeClass('wrap1').removeClass('canvaswrap1');
                $("#wrap2").removeClass('wrap2').removeClass('canvaswrap2');
                $("#wrap3").removeClass('wrap3').removeClass('canvaswrap3');
            }
            else {
                $("#wrap1").removeClass('wrap1').removeClass('canvaswhitewrap1');
                $("#wrap2").removeClass('wrap2').removeClass('canvaswhitewrap2');
                $("#wrap3").removeClass('wrap3').removeClass('canvaswhitewrap3');
            }
            $("#mainImageBorder").removeClass('mainImageBorder');
        }
        else {
            if (customerZoneID == 3) {
                $("#wrap1").removeClass('canvaswrap1').addClass('wrap1');
                $("#wrap2").removeClass('canvaswrap2').addClass('wrap2');
                $("#wrap3").removeClass('canvaswrap3').addClass('wrap3');
            }
            else {
                $("#wrap1").removeClass('canvaswhitewrap1').addClass('wrap1');
                $("#wrap2").removeClass('canvaswhitewrap2').addClass('wrap2');
                $("#wrap3").removeClass('canvaswhitewrap3').addClass('wrap3');
            }
            $("#mainImageBorder").addClass('mainImageBorder');
        }
    }

    function showFramingOptions(showFraming, APNum, PODConfigID, currentRow) {
        var bShowFrame, strAPNumToBeReplaced, selectedAPNum, strPODConfigIDtoBeReplaced, selectedPODconfigID

        var FrameItButton = $('.cf_FrameContainer');
        //var customFrameLink = $('#customFrameLink');
        var GenericCustomFraming = $('#GenericCustomFraming');

        bShowFrame = false

        if (showFraming.toLowerCase() == "true") // && PODSubstrateID != 4985629)
        {
            bShowFrame = true;
        }

        if (bShowFrame) {
            FrameItButton.removeClass('hiddenClass').addClass('displayClass');
            //customFrameLink.removeClass('hiddenClass').addClass('displayClass');
            GenericCustomFraming.removeClass('hiddenClass').addClass('displayClass');

            strAPNumToBeReplaced = GetParameterToBeReplaced(GenericCustomFraming.html(), "APNum=", '&');
            //alert("To be replaced : " +  strAPNumToBeReplaced);
            selectedAPNum = 'apnum=' + APNum;
            //alert("Current APNum " + selectedAPNum);
            strPODConfigIDtoBeReplaced = GetParameterToBeReplaced(GenericCustomFraming.html(), "PODConfigID=", '&amp;');
            selectedPODconfigID = "PODConfigID=" + PODConfigID;
            //alert("selectedPODconfigID " + selectedPODconfigID);

            //FrameItButton.html(replaceString(FrameItButton.html(),strPODConfigIDtoBeReplaced,selectedPODconfigID))
            //customFrameLink.html(replaceString(customFrameLink.html(),strPODConfigIDtoBeReplaced,selectedPODconfigID));
            GenericCustomFraming.html(replaceString(GenericCustomFraming.html(), strPODConfigIDtoBeReplaced, selectedPODconfigID));
            //FrameItButton.html(replaceString(FrameItButton.html(),strAPNumToBeReplaced,selectedAPNum))
            //customFrameLink.html(replaceString(customFrameLink.html(),strAPNumToBeReplaced,selectedAPNum));
            //GenericCustomFraming.html(replaceString(GenericCustomFraming.html(),strAPNumToBeReplaced,selectedAPNum));
             $('#dleIcon').show();
             $('#DLELinkBanner').show();
        }
        else {
             $('#dleIcon').hide();
             $('#DLELinkBanner').hide();
             
            FrameItButton.removeClass('displayClass').addClass('hiddenClass');
            //customFrameLink.removeClass('displayClass').addClass('hiddenClass');
            GenericCustomFraming.removeClass('displayClass').addClass('hiddenClass');
        }
    }

    function GetParameterToBeReplaced(strHTML, str, delimiter) {
        var HTML, loc1, loc2, sub1
        if (strHTML != null) {
            HTML = strHTML.toLowerCase();
            loc1 = HTML.indexOf(str.toLowerCase());
            loc2 = HTML.indexOf(delimiter, loc1);
            sub1 = HTML.substring(loc1, loc2);
        }
        return sub1
    }

    /*
    function GetAPNumToBeReplaced(strHTML)
    {
    //var theNewURL = '';
    var HTML = strHTML.toLowerCase();
    var loc1 = HTML.indexOf('apnum=');
    var loc2 = HTML.indexOf('&',loc1);
    var sub1 = HTML.substring(loc1,loc2);
    return sub1
    }
  
  function GetPODConfigIDToBeReplaced(strHTML,delimiter)
    {
    //var theNewURL = '';
    var HTML = strHTML.toLowerCase();
    var loc1 = HTML.indexOf('podconfigid=');
    var loc2 = HTML.indexOf(delimiter,loc1);
    var sub1 = HTML.substring(loc1,loc2);
    return sub1
    }
    */

    function formatMainImage() {
        var mainImageContainer = $("#MainImageContainer");
        mainImageContainer.css('margin-left', 0);
        var iw = $("#MainImage").attr('width');
        var cw = $("#MainImageContainer").width();
        var mw = (cw - iw) / 2 + 5;

        mainImageContainer.css('margin-left', mw);
        mainImageContainer.css('width', '');
    }

    $('#divAddtoGallery').live('click', function(e) {

        var PODConfigID, APNum, Title, ProductID, SpecID, selectedRow, ZoneProductID;
        selectedRow = $('.moreSizesDD_Row_selected');
        Title = $('#hdFormattedTitle').text();

        if (selectedRow.html() == null) {
            PODConfigID = $('#hdItemPODConfigID').text();
            APNum = $('#hdItemAPNum').text();
            ZoneProductID = $('#ZoneProductID').text();
        }
        else {
            PODConfigID = selectedRow.find('#moreSizesDD_selected_PODConfigID').text();
            APNum = selectedRow.find('#moreSizesDD_selected_APNum').text();
            ZoneProductID = selectedRow.find('#moreSizesDD_selected_zoneProductID').text();
        }
        ProductID = ZoneProductID.substr(0, ZoneProductID.length - 1);
        SpecID = ZoneProductID.substr(ZoneProductID.length - 1, ZoneProductID.length)
        doGalleryPopUP(this, 'DetailsSubBlock', Title, ProductID, SpecID, APNum, PODConfigID)
    });

    $('#divAddtoWishList').live('click', function(e) {
        var PODConfigID, APNum, Title, ProductID, SpecID, selectedRow, ZoneProductID;
        selectedRow = $('.moreSizesDD_Row_selected');
        Title = $('#hdFormattedTitle').text();

        if (selectedRow.html() == null) {
            PODConfigID = $('#hdItemPODConfigID').text();
            APNum = $('#hdItemAPNum').text();
            ZoneProductID = $('#ZoneProductID').text();
        }
        else {
            PODConfigID = selectedRow.find('#moreSizesDD_selected_PODConfigID').text();
            APNum = selectedRow.find('#moreSizesDD_selected_APNum').text();
            ZoneProductID = selectedRow.find('#moreSizesDD_selected_zoneProductID').text();
        }
        ProductID = ZoneProductID.substr(0, ZoneProductID.length - 1);
        SpecID = ZoneProductID.substr(ZoneProductID.length - 1, ZoneProductID.length)
        doWLPopUP(this, 'DetailsSubBlock', Title, ProductID, SpecID, APNum, PODConfigID)
    });
    //Quick Save related.
    var $popupContainer = $('#inPageFS');
    var gCloseText = 'close';
    $popupContainer.dialog({ modal: true, autoOpen: false, width: '900' });
    $popupContainer.dialog('option', 'height', '725');
    $popupContainer.dialog('option', 'title', gCloseText);
    $popupContainer.dialog('option', 'position', ['center', 'top']);
    $popupContainer.dialog('open');
    $('.ui-widget').css('margin-top', '10px');
    $('.ui-dialog-content').css("min-height", "0");
    $('.ui-widget').css('height', '725px');
    $('.ui-dialog-titlebar').live('click', function() {
        $('#inPageFS').dialog('close');
    });
    //End of Quick Save related.
});

  
  
  function setDLEPODParameters(PODConfigID,DLEApnum,FramingFlag,IsPODSelectionChanged,ItemType)
{
    
    var varDLEPopUpParametsId;
        var finalString;
         varMultiDLEString  = $().find('.MultiplePODDLE').text();
        varDLEPopUpParametsId = $().find('.DLEPopUpParametsId').text()
        
        
        var stringtoFind = "currentItemType="+ItemType+",";
         var intIndexPOD = 0;
          var intIndexPODto = 0;
         
        intIndexPOD = varMultiDLEString.indexOf(stringtoFind);
        
         intIndexPODto = varMultiDLEString.indexOf("currentItemType=",(intIndexPOD+stringtoFind.length));
         if (intIndexPODto == -1)
         {
            finalString = varMultiDLEString.substring((intIndexPOD+stringtoFind.length),varMultiDLEString.length);
         }
         else
         {
            finalString = varMultiDLEString.substring((intIndexPOD+stringtoFind.length),intIndexPODto);
         }
        
         if (finalString.indexOf("PODConfigId="+PODConfigID+",") > 0)
         {
            var stringDefaultDLEImage;
            var stringReplaceDefaultDLEImage;
            
            if (PODConfigID>0)
            {
                stringDefaultDLEImage = ",isDefaultImage=False,PODConfigId="+PODConfigID+",";
                stringReplaceDefaultDLEImage = ",isDefaultImage=True,PODConfigId="+PODConfigID+",";
            }
            else
            {
                                         
                finalString = finalString.replace( "isDefaultImage=True", "isDefaultImage=False");
                 
                var apnumindex = finalString.indexOf("ImageAPNUM="+DLEApnum+",")
                var apnumindexto = finalString.indexOf(",isDefaultImage=",apnumindex);
                stringDefaultDLEImage = finalString.substring(apnumindex,apnumindexto)+",isDefaultImage=False";
                stringReplaceDefaultDLEImage = finalString.substring(apnumindex,apnumindexto)+",isDefaultImage=True";  
                  
            }
                     
            finalString = finalString.replace( stringDefaultDLEImage, stringReplaceDefaultDLEImage);
                     
            var varpopdlefunctionString;
             
            var intDLEStrIndex  =0;
            var intDLEStrNewIndex  =0;
            
             intDLEStrIndex = varDLEPopUpParametsId.indexOf(",");
             var varDLECID =  varDLEPopUpParametsId.substring(0,intDLEStrIndex);  
             
             
             intDLEStrNewIndex = varDLEPopUpParametsId.indexOf(",",intDLEStrIndex+1);         
             var varDLEImageDir =  varDLEPopUpParametsId.substring(intDLEStrIndex+1,intDLEStrNewIndex);
             
             intDLEStrIndex = intDLEStrNewIndex+1;
             
             intDLEStrNewIndex = varDLEPopUpParametsId.indexOf(",",intDLEStrIndex+1); 
             //var varDLEAPNum =  varDLEPopUpParametsId.substring(intDLEStrIndex,intDLEStrNewIndex);
             
             var varDLEAPNum=DLEApnum;
             intDLEStrIndex = intDLEStrNewIndex+1;
             
             intDLEStrNewIndex = varDLEPopUpParametsId.indexOf(",",intDLEStrIndex+1); 
             var varDLETrackingPath =  varDLEPopUpParametsId.substring(intDLEStrIndex,intDLEStrNewIndex);
             
             intDLEStrIndex = intDLEStrNewIndex+1;
             intDLEStrNewIndex = varDLEPopUpParametsId.indexOf(",",intDLEStrIndex+1); 
             var varDLEImageId =  varDLEPopUpParametsId.substring(intDLEStrIndex,intDLEStrNewIndex);

            intDLEStrIndex = intDLEStrNewIndex+1;
             intDLEStrNewIndex = varDLEPopUpParametsId.indexOf(",",intDLEStrIndex+1); 
             var varDFLEDomainURL =  varDLEPopUpParametsId.substring(intDLEStrIndex,intDLEStrNewIndex);

             intDLEStrIndex = intDLEStrNewIndex+1;
             intDLEStrNewIndex = varDLEPopUpParametsId.indexOf(",",intDLEStrIndex+1); 
             var varDLECountryCode =  varDLEPopUpParametsId.substring(intDLEStrIndex,intDLEStrNewIndex);
             
             intDLEStrIndex = intDLEStrNewIndex+1;
             intDLEStrNewIndex = varDLEPopUpParametsId.indexOf(",",intDLEStrIndex+1); 
             var varDLEFramingServicePath =  varDLEPopUpParametsId.substring(intDLEStrIndex,intDLEStrNewIndex);
             
             intDLEStrIndex = intDLEStrNewIndex+1;
             intDLEStrNewIndex = varDLEPopUpParametsId.indexOf(",",intDLEStrIndex+1); 
             var varCustomerZoneid =  varDLEPopUpParametsId.substring(intDLEStrIndex,intDLEStrNewIndex);
             
              intDLEStrIndex = intDLEStrNewIndex+1;
             intDLEStrNewIndex = varDLEPopUpParametsId.indexOf(",",intDLEStrIndex+1); 
             var varLanguageId =  varDLEPopUpParametsId.substring(intDLEStrIndex,intDLEStrNewIndex);
             
              intDLEStrIndex = intDLEStrNewIndex+1;
             intDLEStrNewIndex = varDLEPopUpParametsId.indexOf(",",intDLEStrIndex+1); 
             var varCurrencyId =  varDLEPopUpParametsId.substring(intDLEStrIndex,intDLEStrNewIndex);
             
              intDLEStrIndex = intDLEStrNewIndex+1;
             intDLEStrNewIndex = varDLEPopUpParametsId.indexOf(",",intDLEStrIndex+1); 
             var varCurrencyCode =  varDLEPopUpParametsId.substring(intDLEStrIndex,intDLEStrNewIndex);
             
             intDLEStrIndex = intDLEStrNewIndex+1;
             intDLEStrNewIndex = varDLEPopUpParametsId.indexOf(",",intDLEStrIndex+1); 
             var varUnitofMeasure =  varDLEPopUpParametsId.substring(intDLEStrIndex,intDLEStrNewIndex);
             
             intDLEStrIndex = intDLEStrNewIndex+1;
             intDLEStrNewIndex = varDLEPopUpParametsId.indexOf(",",intDLEStrIndex+1); 
             var varDLEFrameDetailString =  varDLEPopUpParametsId.substring(intDLEStrIndex,intDLEStrNewIndex);
             
             
             
             intDLEStrIndex = intDLEStrNewIndex+1;
             intDLEStrNewIndex = varDLEPopUpParametsId.indexOf(",",intDLEStrIndex+1); 
             var varDLECurrencyDisplaySymbol =  varDLEPopUpParametsId.substring(intDLEStrIndex,intDLEStrNewIndex);

             intDLEStrIndex = intDLEStrNewIndex+1;
             intDLEStrNewIndex = varDLEPopUpParametsId.indexOf(",",intDLEStrIndex+1); 
             var varDLEEmailID =  varDLEPopUpParametsId.substring(intDLEStrIndex,intDLEStrNewIndex);
             if (intDLEStrNewIndex <=0)
             {
             varDLEEmailID = "";
             }
             
             intDLEStrIndex = intDLEStrNewIndex+1;
             var varDLEFrameItemID =  varDLEPopUpParametsId.substring(intDLEStrIndex,varDLEPopUpParametsId.length);
             if (intDLEStrNewIndex <=0)
             {
             varDLEFrameItemID = "";
             }
             
              if (FramingFlag == 'True') 
              {
                $('#dleIcon').show();
                $('#DLELinkBanner').show();
              }
              else
              {
                $('#dleIcon').hide();
                $('#DLELinkBanner').hide();
              }
             
             
             if (IsPODSelectionChanged == true)
             {
                $('#DLELink').unbind('click');
                $('#DLELink1').unbind('click');
                $('#DLELinkBanner').unbind('click');
             }
              
               
             $('#DLELink').bind('click',function(){
                      javascript:popDLE(finalString,varDLECID,varDLEImageDir,varDLEAPNum,varDLETrackingPath,varDLEImageId,varDFLEDomainURL,varDLECountryCode,varDLEFramingServicePath,varCustomerZoneid,varLanguageId,varCurrencyId,varCurrencyCode,varUnitofMeasure,varDLEFrameDetailString,varDLECurrencyDisplaySymbol,varDLEEmailID,varDLEFrameItemID);
                       });
                       
             $('#DLELink1').bind('click',function(){
                      javascript:popDLE(finalString,varDLECID,varDLEImageDir,varDLEAPNum,varDLETrackingPath,varDLEImageId,varDFLEDomainURL,varDLECountryCode,varDLEFramingServicePath,varCustomerZoneid,varLanguageId,varCurrencyId,varCurrencyCode,varUnitofMeasure,varDLEFrameDetailString,varDLECurrencyDisplaySymbol,varDLEEmailID,varDLEFrameItemID);
                       });
                       
            $('#DLELinkBanner').bind('click',function(){
                      javascript:popDLE(finalString,varDLECID,varDLEImageDir,varDLEAPNum,varDLETrackingPath,varDLEImageId,varDFLEDomainURL,varDLECountryCode,varDLEFramingServicePath,varCustomerZoneid,varLanguageId,varCurrencyId,varCurrencyCode,varUnitofMeasure,varDLEFrameDetailString,varDLECurrencyDisplaySymbol,varDLEEmailID,varDLEFrameItemID);
                       });
          
         }
         else
         {
            $('#dleIcon').hide();
             $('#DLELinkBanner').hide();
         }
         
                   
}
//Rolling Stone
function RollingStoneDetailsWindow(numIssues,value) 
{
	if (numIssues == '')
		numIssues = '12';
	if (value == '')
		value = '$6.48';
	StonesWindow=window.open('','RollingStoneOffer','height=400,width=450,resizable=yes,top=100,left=100');
	var tmp = StonesWindow.document;
	tmp.write('<html><head><title>Art.com</title>');
	tmp.write('</head><body><p style=\"font-family:Verdana;font-size:12px;\"><b>Your Rolling Stone Authentic cover reprint comes with a '+numIssues+'-issue subscription to Rolling Stone. That\'s a '+value+' value already covered in your purchase price!</b></p>');
	tmp.write('<p style=\"font-family:Verdana;font-size:12px;\">For new subscribers (only) this means '+numIssues+' issues to see why Rolling Stone Magazine has been the official Rock and Roll chronicler for over 4 decades.</p>');
    tmp.write('<p style=\"font-family:Verdana;font-size:12px;\">If at anytime within thirty days of this purchase you want to cancel Rolling Stone and get a rebate for this year\'s subscription allocation, you must print, fill out, and mail in this form with a copy of your Rolling Stone Authentic receipt to: Rolling Stone Refund, PO Box 8243, Red Oak, IA 51591. The subscription allocation on this purchase is '+value+'. Fill out the below if you do NOT want your subscription:</p>');
    tmp.write('Name_________________________________<br>');
    tmp.write('Address_______________________________<br>');
    tmp.write('City, State, ZIP___________________________<br>');
    tmp.write('<p style=\"font-family:Verdana;font-size:12px;\">Limit one per household. Offer will be valid for new Rolling Stone subscribers residing in the US only.</p>');
	tmp.write('</body></html>');
	tmp.close();
}