﻿/*---------------------------------------------------------------------------------         
        Description			    :	 product-details.js
        Create on			    :    29-03-2009
        Initial Code Created    :    Sathish.M
        Caution                 :    Change in any of the below functions will
                                     affect the product-details.aspx
---------------------------------------------------------------------------------*/

//Query string built by 6 splits:    
//vQStr='ScriptMode|SpOprMode|Currency|Product code|Product Id|Product general Id1|Product genral Id2'
        
//Query string built by 14 splits:    
//vQStr='ScriptMode|SpOprMode|Currency|Product code|Product con code|Product city detail|Product color detail|'
//vQStr+='Product flavour detail|Product size detail|Product Stitich(Y/N)|Measurement flag|Unique field|Quantity|Cart id'


var vQStr ='';
//Product details onload
function funPrdDtlsOnLoad()
{     
    var vCur, vPrdTabDtl; 
    try{
        //Session currency  
        vCur=document.getElementsByName('Currency');
        for (var i = 0; i < vCur.length; i++)
        {   
            if (vCur[i].value==$F('hdnSessionCurrency'))
            {	
                vCur[i].checked=true;
                break;
            }
        } 
        //Supplementry
        $('cbBLOptn').checked=false;
             
        //Product tab details
        vPrdTabDtl = new Spry.Widget.TabbedPanels('dvPrdTabDtl');  
    }
    catch(e)
    {
        //alert('@ funPrdDtlsOnLoad');
    }
}
 
//Product details unstitched option
function funPrdDtlsStUnSt(pStitchOpt)
{   
    var vStyle='';
    switch(pStitchOpt)
    {
        case 'Stitched':
            $('rbCustMsrC').checked=true;
            break;
        case 'Unstitched':
            vMsrOpt=document.getElementsByName('MsrOpt');
            for (var i = 0; i < vMsrOpt.length; i++)
            {
                vMsrOpt[i].checked=false;
            }    
            break;
    }
}

//Product details supplementry process 
function funPrdDtlsBLOptn()
{
    var vBL;
    try
    {   
        if($('cbBLOptn').checked==true)
             $('tblBLOptn').style.display='block';
        else if($('cbBLOptn').checked==false)
        {
            $('rbBL').checked=false;             
            $('tblBLOptn').style.display='none';
            $('tblBLMsrOptn').style.display='none';
            vBL=document.getElementsByName('BL');
            for (var i = 0; i < vBL.length; i++) 
            {
                vBL[i].checked=false;
            }            
        }
        funPrdDtlsUpdateDeliveryDate();
    }
    catch(e)
    {
        alert('@ funPrdDtlsBLOptn');
    }
}
function funPrdDtlsBLMsrOptn()
{
    try
    {   
        $('tblBLMsrOptn').style.display='block';
        funPrdDtlsUpdateDeliveryDate();
    }
    catch(e)
    {
       alert('@ funPrdDtlsBLMsrOptn');
    }
}

//Product details approximate delivery date calculations
function funPrdDtlsUpdateDeliveryDate()
{   
    var vSASupl=document.getElementsByName('SASupl');
    var vSASuplChked=false;
    try
    {   
        for(var i = 0; i < vSASupl.length; i++)
        {   
            if(vSASupl[i].checked)
               vSASuplChked=true;
        }
        if($('cbBLOptn')!=null)
        {
            if((vSASuplChked==true)||($('cbBLOptn').checked==true)) 
            {
                var vBLType=document.getElementsByName('BL');
                var vBLTypeVal='';
                for(var i = 0; i < vBLType.length; i++)
                {   
                    if(vBLType[i].checked)
                       vBLTypeVal=vBLType[i].value;
                }
                if(vBLTypeVal!='BLO06')
                    funPrdDtlGetAppDelDate(parseInt($F('hdnEsCustLeadDays'))+parseInt($F('hdnEsCourLeadDays')))
                else if(vBLTypeVal=='BLO06')
                    funPrdDtlGetAppDelDate(parseInt($F('hdnEsCustLeadDays'))+parseInt($F('hdnEsCourLeadDays'))+3)
            }
            else
                funPrdDtlGetAppDelDate(parseInt($F('hdnEsCourLeadDays')))
        }
        else
        {
            if((vSASuplChked==true))
                funPrdDtlGetAppDelDate(parseInt($F('hdnEsCustLeadDays'))+parseInt($F('hdnEsCourLeadDays')))
            else
                funPrdDtlGetAppDelDate(parseInt($F('hdnEsCourLeadDays')))
        }
        $('spnAppDelInfo').style.display='block';
    }
    catch(e)
    {
        alert('@ funPrdDtlsUpdateDeliveryDate');
    }
}
function funPrdDtlGetAppDelDate(pDays)
{   
    var vDte,vDt,vYear;
    var arrMonth=new Array(12);
    try
    {
        arrMonth[0]="Jan";arrMonth[1]="Feb";arrMonth[2]="Mar";arrMonth[3]="Apr";arrMonth[4]="May";arrMonth[5]="Jun";
        arrMonth[6]="Jul";arrMonth[7]="Aug";arrMonth[8]="Sep";arrMonth[9]="Oct";arrMonth[10]="Nov";arrMonth[11]="Dec";
        vDte=funPrdDtlAddDays(funPrdDtlCalcTime(),parseInt($('hdnPrdDelDays').value)+pDays)
        vDt = vDte.getDate();            
        vYear = vDte.getFullYear();             
        $('spnAppDelDte').innerHTML='Approx. Delivery Date: '+ vDt+ ' ' + arrMonth[vDte.getMonth()] + ' ' + vYear;   
    }
    catch(e)
    {
        alert('@ funPrdDtlGetAppDelDate');
    }
}
function funPrdDtlAddDays(pMyDate,pDays) 
{   
    try
    {
        return new Date(pMyDate + pDays*24*60*60*1000);   
    }
    catch(e)
    {
        alert('@ funPrdDtlAddDays');
    }    
}
function funPrdDtlCalcTime() 
{
    try
    {
        vDt = new Date();
        return vDt.getTime() + (vDt.getTimezoneOffset() * 60000);        
    }
    catch(e)
    {
        alert('@ funPrdDtlCalcTime');
    }
}

function funPrdDtlsChangeViewCloser(pSrc)
{   
    try
    {
        $('imgUandLLarge').src='http://www.chennaibazaar.com/image/EsLoading.gif';
        $('imgUandLLarge').src=pSrc;
    }
    catch(e)
    {
        alert('@ funPrdDtlsChangeViewCloser');
    }
}
//Product details add to wish list
function funPrdDtlsWishList(pUsrId,pPrdId)
{   
    try
    {
        if(pUsrId!='0')
        {   
            vQStr='Add2Wish||'+$F('hdnSessionCurrency')+'||'+pPrdId+'|0|0';
            funPrdDtlsCallHandler('MainTask',vQStr); 
        }
        else
            window.location=$F('hdnAppPath')+'UsrLogin.aspx?mode=wsh&pid='+pPrdId;
            
    }
    catch(e)
    {
        alert('@ funWishList');
    }  
}
//Product details change currency
function funPrdDtlsChangeCurrency(pCur)
{
   try
   {   
       vQStr='Currency|DEFAULT|'+pCur+'|'+$F('hdnPrdCode')+'|0|0|0';  
       funPrdDtlsCallHandler('MainTask',vQStr); 
   }
   catch(e)
   {
       alert('@ funPrdDtlsChangeCurrency');
   }
}

//Product details navigation move next or back
function funPrdDtlsNaviNxtBck(pNaviMode)
{   
//    debugger;
    var vScrMode='';
    try
    {
       if(pNaviMode=='NAVINEXT')
        vScrMode='NaviNext'
       else if(pNaviMode=='NAVIBACK')
        vScrMode='NaviBack' 
       vQStr=vScrMode+'|'+pNaviMode+'|'+$F('hdnSessionCurrency')+'|'+$F('hdnPrdCode')+'|0|0|0';
       funPrdDtlsCallHandler('MainTask',vQStr);  
    }
    catch(e)
    {
        alert('@ funPrdDtlsNaviNxtBck');
    }
}

//Product details check general details is out of stock.
function funPrdDtlsChkGenDtlOs(pHasCity,pHasColor,pHasFlav,pHasSize)
{   
    var arrGenId1=new Array();
    var arrGenId2=new Array();
    try
    {            
        if(pHasCity==1 && pHasFlav==1)
        {
            arrGenId1=$F('ddlCity').split('^');
            vQStr='PrdGenDtlOs|PRDGENDTLOS|'+$F('hdnSessionCurrency')+'|'+$F('hdnPrdCode')+'|0|'+arrGenId1[0]+'|0';            
            funPrdDtlsCallHandler('SubTask1',vQStr);             
        }
        if(pHasSize==1 && pHasColor==1)
        {        
            arrGenId1=$F('ddlSize').split('^');
            vQStr='PrdGenDtlOs|PRDGENDTLOS|'+$F('hdnSessionCurrency')+'|'+$F('hdnPrdCode')+'|0|'+arrGenId1[0]+'|0'; 
            funPrdDtlsCallHandler('SubTask1',vQStr);             
        }
        if(pHasSize==1 && pHasColor==0)
        {   
            arrGenId1=$F('ddlSize').split('^');
            vQStr='PrdGenDtlQty|PRDGENDTLQTY|'+$F('hdnSessionCurrency')+'|'+$F('hdnPrdCode')+'|0|'+arrGenId1[0]+'|0'; 
            funPrdDtlsCallHandler('SubTask2',vQStr);         
        }
        if(pHasSize==0 && pHasColor==1)
        {
            arrGenId2=$F('ddlColor').split('^');
            vQStr='PrdGenDtlQty|PRDGENDTLQTY|'+$F('hdnSessionCurrency')+'|'+$F('hdnPrdCode')+'|0|0|0'+arrGenId2[0]; 
            funPrdDtlsCallHandler('SubTask2',vQStr);          
        }
        if(pHasSize==1 && pHasColor==1)
        {
            arrGenId1=$F('ddlSize').split('^');
            arrGenId2=$F('ddlColor').split('^');
            vQStr='PrdGenDtlQty|PRDGENDTLQTY|'+$F('hdnSessionCurrency')+'|'+$F('hdnPrdCode')+'|0|'+arrGenId1[0]+'|'+arrGenId2[0]; 
            funPrdDtlsCallHandler('SubTask2',vQStr);             
        }
    }
    catch(e)
    {
        alert('@ funPrdDtlsChkGenDtlOs');
    }
}
//Product details out of stock request
function funPrdDtlsOutOfStockReq()
{   
    var vErrMsg='',vPrdCode='';
    try
    {   
        if($('hdnPageName')!=null && $F('hdnPageName')=='Products') 
            vPrdCode=$('spnReqPrdCode').innerHTML;
        else if($('hdnPageName')==null) 
            vPrdCode=$('spnPrdCode').innerHTML;
        if($F('txtPRName')=='')
            vErrMsg='\nName';            
        if($F('txtPREmailId')==''||emailCheck($F('txtPREmailId'))==false)        
            vErrMsg=vErrMsg + '\nEmail Id Missing/Invalid'; 
        if($F('txtPRCountry')=='')
            vErrMsg=vErrMsg + '\nCountry';                  
        if(vErrMsg!='')
        {
            alert('Please submit the below required details.\r\n-------------------------------------------------\r'+vErrMsg);             
            return false;
        }
        else
        {  
            vQStr='PrdOsReq||'+$F('hdnSessionCurrency')+'|'+$F('hdnPrdCode')+'|'+$F('txtCmts')+'^'+$F('txtPRName')+'^'+$F('txtPREmailId')+'^'+$F('txtPRPhone')+'^'+$F('txtPRCountry'); 
            $('dvOutOfStockReqForm').hide();
            funPrdDtlsCallHandler('MainTask',vQStr); 
        }   
    }
    catch(e)
    {
        alert('@ funPrdOutOfStockReq');
    }
}

//Product details add to cart
function funPrdDtlsAdd2Cart(pPrdNature)
{ 
    var vCityDtl='',vColorDtl='',vFlavDtl='',vSizeDtl='',vStitchYN='Y',vErrMsg='';
    try
    {  
        if($('opUnStitched')!=null && $('opUnStitched').checked==true)
            vStitchYN='N';
        if($('ddlQty')!=null && $F('ddlQty')!='-1')
        {              
            switch(pPrdNature)
            {   
                case 'saree':
                    var vSupl=document.getElementsByName('SASupl'); 
                    var vSuplBL=document.getElementsByName('BL');        
                    var vSuplPrdCodes='',vBLAMsrmnt='*A=N',vBLBMsrmnt='*B=N',vBLCMsrmnt='*C=N',vMsrmnt='';
                    //Other than blouse suplementry.
                    for(var i = 0; i < vSupl.length; i++)
                    {   
                        if(vSupl[i].checked)
                          vSuplPrdCodes+=vSupl[i].value+'^';
                    }
                    //Only blouse suplementry.  
                    for(var i = 0; i < vSuplBL.length; i++)
                    {   
                        if(vSuplBL[i].checked)
                           vSuplPrdCodes+=vSuplBL[i].value;
                    }
                    if(funPrdDtlChkSaree()==true)
                    {   
                        if($('rbBLMsrA')!=null)
                        {
                            if($('rbBLMsrA').checked==true)
                                vBLAMsrmnt='*A=Y';
                            if($('rbBLMsrB').checked==true)
                            {
                                vBLBMsrmnt='*B=Y';
                                vSuplPrdCodes+='^SLIN04';
                            }
                            if($('rbBLMsrC').checked==true)
                                vBLCMsrmnt='*C=Y';
                        }   
                        vMsrmnt=vBLAMsrmnt+vBLBMsrmnt+vBLCMsrmnt;      
                        vQStr='Add2Cart|ADD2CART|'+$F('hdnSessionCurrency')+'|'+$F('hdnPrdCode')+'|'+vSuplPrdCodes+'|||||'+vStitchYN+'|'+vMsrmnt+'|'+$F('ddlQty')+'|'+pPrdNature;
                        funPrdDtlsCallHandler('MainTask',vQStr);       
                    }
                    break;
                case 'salwar':
                case 'lehenga':
                case 'tunic':
                case 'sherwani':
                case 'suit':                
                    var vSupl=document.getElementsByName('SASupl'); 
                    var vSuplPrdCodes='',vMsrmnt='';
                    if(vSupl.length>0)
                    {   
                        //Suplementry
                        for(var i = 0; i < vSupl.length; i++)
                        {
                           if(vSupl[i].checked==true)
                               vSuplPrdCodes+=vSupl[i].value+'^';
                        }
                    }
                    if($('rbStdMsr').checked==true)
                        vMsrmnt='S'; 
                    if(pPrdNature=='sherwani' || pPrdNature=='suit')
                    {
                        if($('rbCustMsr').checked==true) 
                        vMsrmnt='C';
                    }
                    else if(pPrdNature!='sherwani' || pPrdNature!='suit')
                    {   
                        if($('rbCustMsrA').checked==true)
                            vMsrmnt='CA';
                        if($('rbCustMsrB').checked==true)
                        {
                            vMsrmnt='CB';
                            vSuplPrdCodes+='SLIN04';
                        }
                        if($('rbCustMsrC').checked==true)
                            vMsrmnt='CC';   
                    }    
                    vQStr='Add2Cart|ADD2CART|'+$F('hdnSessionCurrency')+'|'+$F('hdnPrdCode')+'|'+vSuplPrdCodes+'|||||'+vStitchYN+'|'+vMsrmnt+'|'+$F('ddlQty')+'|'+pPrdNature;                   
                    funPrdDtlsCallHandler('MainTask',vQStr); 
                    break;
                case 'general':
                    if($('ddlCity')!=null && $F('ddlCity')!='-1')
                        vCityDtl=$F('ddlCity');
                    if($('ddlCity')!=null && $F('ddlCity')=='-1')
                        vErrMsg='\nSelect City';    
                    if($('ddlColor')!=null && $F('ddlColor')!='-1')
                        vColorDtl=$F('ddlColor');
                    if($('ddlColor')!=null && $F('ddlColor')=='-1')
                         vErrMsg+= '\nSelect Color'; 
                    if($('ddlFlavour')!=null && $F('ddlFlavour')!='-1')
                        vFlavDtl=$F('ddlFlavour');
                    if($('ddlFlavour')!=null && $F('ddlFlavour')=='-1')
                        vErrMsg+= '\nSelect Flavour'; 
                    if($('ddlSize')!=null && $F('ddlSize')!='-1')    
                        vSizeDtl=$F('ddlSize');
                    if($('ddlSize')!=null && $F('ddlSize')=='-1')    
                        vErrMsg+= '\nSelect Size';
                    if(vErrMsg!='')
                    {
                        alert('Please submit the below required details.\r\n-------------------------------------------------\r'+vErrMsg);             
                        return false;
                    }  
                    else
                    {   
                        vQStr='Add2Cart|ADD2CART|'+$F('hdnSessionCurrency')+'|'+$F('hdnPrdCode')+'||'+vCityDtl+'|'+vColorDtl+'|'+vFlavDtl+'|'+vSizeDtl+'|N||'+$F('ddlQty')+'|'+pPrdNature;
                        funPrdDtlsCallHandler('MainTask',vQStr); 
                        return true;
                    }
                    break;
            }
        }
        else if($('ddlQty')==null || $F('ddlQty')=='-1')
        {       
                if($('ddlCity')!=null && $F('ddlCity')!='-1')
                    vCityDtl=$F('ddlCity');
                if($('ddlCity')!=null && $F('ddlCity')=='-1')
                    vErrMsg='\nSelect City';    
                if($('ddlColor')!=null && $F('ddlColor')!='-1')
                    vColorDtl=$F('ddlColor');
                if($('ddlColor')!=null && $F('ddlColor')=='-1')
                     vErrMsg+= '\nSelect Color'; 
                if($('ddlFlavour')!=null && $('ddlFlavour')!='-1')
                    vFlavDtl=$F('ddlFlavour');
                if($('ddlFlavour')!=null && $F('ddlFlavour')=='-1')
                    vErrMsg+= '\nSelect Flavour'; 
                if($('ddlSize')!=null && $('ddlSize')!='-1')    
                    vSizeDtl=$F('ddlSize');
                if($('ddlSize')!=null && $F('ddlSize')=='-1')  
                    vErrMsg+= '\nSelect Size';
                if(vErrMsg!='')
                {
                    alert('Please submit the below required details.\r\n-------------------------------------------------\r'+vErrMsg);             
                    return false;
                }   
        }
       
    }
    catch(e)
    {
        alert('@ funPrdDtlsAdd2Cart');    
    }
}
function funPrdDtlChkSaree()
{
    var vErrMsg='';
    try
    {   
        if($('cbBLOptn')!=null && $('cbBLOptn').checked==true)
        {   
            var vSuplBL=document.getElementsByName('BL');
            var vBLOptnSelected=false;
            for (var i = 0; i < vSuplBL.length; i++) 
            {
                if (vSuplBL[i].checked) 
	            {	
		            vBLOptnSelected= true;
		            break;
	            }
            }           
            if (!vBLOptnSelected) 
                vErrMsg='\nBlouse stitiching option';    
            if(vErrMsg!='')
            {
                alert('Please submit the below required details.\r\n-------------------------------------------------\r'+vErrMsg);             
                return false;            
            }    
            else
             return true; 
        }        
        else
            return true;    
    }
    catch(e)
    {   
        //revealElement('dvSuppIssue');
    }
}

//--------------------------------CALL HANDLER----------------------------------------//
//Product details on failure 
function funPrdDtlsOnFailure(pResponse)
{
    try
    {
        alert(pResponse.responseText);
    }
    catch(e)
    {
        alert('@ funPrdDtlsOnFailure');            
    }
}

//Product details on success     
function funPrdDtlsOnSuccessMainTask(pResponse)
{   
//    debugger;
    arrResponse=new Array();
    try
    {   
        arrResponse=pResponse.responseText.split('|');
        if(arrResponse.length>0)
        {   
            switch(arrResponse[1])
            {
                 case 'Currency':
                    window.location=location.href;
                    break;
                 case 'Add2Wish':
                    window.location=$F('hdnAppPath')+'wish-list.html';
                    break;
                 case 'Add2Cart':
                    switch(arrResponse[2])
                    {                           
                        case 'saree':
                            if(arrResponse[3]!=0)
                                //Redirection occures automatically to ViewCart.aspx if no supplementry
                                //product was selected else will move to MsrMntPg.aspx 
                                 
                                //window.location=$F('hdnAppPath')+'MsrMntPg.aspx?'+arrResponse[4];
                                window.location=$F('hdnAppPath')+'measurements.aspx?'+arrResponse[4];
                            else if(arrResponse[3]==0)
                                window.location=$F('hdnAppPath')+'UsrLogin.aspx?mode=samsrmnt&url=' + arrResponse[5];
                        break;
                        case 'salwar': 
                        case 'lehenga':
                        case 'tunic':                            
                            switch(arrResponse[3])
                            {
                                case 'Y':
                                    if(arrResponse[4]!=0)
                                    //Redirection occures automatically to ViewCart.aspx if no supplementry
                                    //product was selected else will move to MsrMntPg.aspx  
                                    
                                        //window.location=$F('hdnAppPath')+'MsrMntPg.aspx?'+arrResponse[5];
                                        window.location=$F('hdnAppPath')+'measurements.aspx?'+arrResponse[5];
                                    else if(arrResponse[4]==0)
                                        window.location=$F('hdnAppPath')+'UsrLogin.aspx?mode=othrmsrmnt&url=' + arrResponse[6];
                                break;
                                case 'N':
                                if(arrResponse[4]!=0)
                                    window.location=$F('hdnAppPath')+'ViewCart.aspx';
                                else if(arrResponse[4]==0)
                                    window.location=$F('hdnAppPath')+'UsrLogin.aspx?mode=nomsrmnt'; 
                                break;
                            }
                        break;
                        case 'sherwani':
                        case 'suit':
                            switch(arrResponse[3])
                            {
                                case 'Y':
                                    if(arrResponse[4]!=0)
                                    //Redirection occures automatically to ViewCart.aspx if no supplementry
                                    //product was selected else will move to MsrMntPg.aspx  
                                    
                                        //window.location=$F('hdnAppPath')+'MsrMntPg.aspx?'+arrResponse[5];
                                        window.location=$F('hdnAppPath')+'measurements.aspx?'+arrResponse[5];
                                    else if(arrResponse[4]==0)
                                        window.location=$F('hdnAppPath')+'UsrLogin.aspx?mode=othrmsrmnt&url=' + arrResponse[6];
                                break;
                                case 'N':
                                if(arrResponse[4]!=0)
                                    window.location=$F('hdnAppPath')+'ViewCart.aspx';
                                else if(arrResponse[4]==0)
                                    window.location=$F('hdnAppPath')+'UsrLogin.aspx?mode=nomsrmnt'; 
                                break;
                            }
                        break;
                        case 'general':
                            if(arrResponse[3]!=0)
                               window.location=$F('hdnAppPath')+'ViewCart.aspx';
                            else if(arrResponse[3]==0)
                               window.location=$F('hdnAppPath')+'UsrLogin.aspx?mode=nomsrmnt';   
                        break;
                    }
                    break;
                 case 'PrdOsReq':                    
                    window.location=$F('hdnAppPath')+'latest-arrivals.html';
                    break;
                 case 'NaviNext':
                 case 'NaviBack':
                    if(arrResponse[0].split('^')[1]!=null)
                    {                        
                        arr=new Array();                   
                        arr=location.href.split('/');
                        window.location= location.href.replace(arr[arr.length-1],arrResponse[0].split('^')[1])+'.html';
                    }
                    else if(arrResponse[0].split('^')[1]==null)
                    {
                        if(arrResponse[1]=='NaviNext')
                            alert('Last product in this category');
                        else if(arrResponse[1]=='NaviBack')
                            alert('First product in this category');
                    }   
                    break;
            }
        }        
    }
    catch(e)
    {
         alert('@ funPrdDtlsOnSuccess');          
    }
}
function funPrdDtlsOnSuccessSubTask1(pResponse)
{   
    arrResponse=new Array();
    try
    {   
        arrResponse=pResponse.responseText.split('|');
        $('dvProductDetailsSubTask1').innerHTML=arrResponse[0];
    }
    catch(e)
    {
       alert('@ funPrdDtlsOnSuccessSubTask1');
    }
}
function funPrdDtlsOnSuccessSubTask2(pResponse)
{   
    arrResponse=new Array();
    try
    {   
        arrResponse=pResponse.responseText.split('|');
        $('dvProductDetailsSubTask2').innerHTML=arrResponse[0];
        if($F('hdnPrdVenType')!='VA')
        {
            if($F('hdnStkQty')<=0 || $F('hdnStkQty')>=6)
            {
                 $('spnApprxDelDate').innerHTML=$F('hdnPrdApprxDelDteOrg');
                 if($('spnPrdName')!=null)
                    $('spnPrdName').style.display='none';
            }    
            else if($F('hdnStkQty')>0 || $F('hdnStkQty')<=5)
            {
                 $('spnApprxDelDate').innerHTML=$F('hdnPrdApprxDelDteNew');
                 $('spnPrdName').style.display='block';
            }
        }        
    }
    catch(e)
    {
       alert('@ funPrdDtlsOnSuccessSubTask2');
    }
}

//Product details call handlers
function funPrdDtlsCallHandler(pMode,pQStr)
{   
    try
    {    
        switch(pMode)
        {
            case 'MainTask':
                new Ajax.Request($F('hdnAppPath')+'GenetricHandler/product-details.ashx?qStr='+pQStr,
                {
                    method   : 'get',
                    onSuccess: funPrdDtlsOnSuccessMainTask,            
                    onFailure: funPrdDtlsOnFailure
                });       
                break;
            case 'SubTask1':
                new Ajax.Request($F('hdnAppPath')+'GenetricHandler/product-details.ashx?qStr='+pQStr,
                {
                    method   : 'get',
                    onSuccess: funPrdDtlsOnSuccessSubTask1,            
                    onFailure: funPrdDtlsOnFailure
                });       
                break;
            case 'SubTask2':
                new Ajax.Request($F('hdnAppPath')+'GenetricHandler/product-details.ashx?qStr='+pQStr,
                {
                    method   : 'get',
                    onSuccess: funPrdDtlsOnSuccessSubTask2,            
                    onFailure: funPrdDtlsOnFailure
                });       
                break;
        }        
    }
    catch(e)
    {
        alert('@ funPrdDtlsCallHandler');       
    }
}

/*------------------------------------------------------------------------------------*/
function funShowBLHelpImgs(pBLCode,pEvent)
{
//    debugger;
    try
    {
        var dom = (document.getElementById) ? true : false;
        var ns5 = (!document.all && dom || window.opera) ? true: false;
        var standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
		var mouseX = (ns5)? pEvent.pageX: window.event.clientX + standardbody.scrollLeft;
		var mouseY = (ns5)? pEvent.pageY: window.event.clientY + standardbody.scrollTop;        
        switch(pBLCode)
        {
            case 'BLO05':
                $('dvBLTitle').innerHTML='<b>Patterned Blouse</b>';
                $('pBLText').innerHTML='Saree Blouse with a touch of detailing and style. Interesting necklines and sleeves that are uniquely styled along'
                    +' with a hint of trimmings and embellishments. Blouse pattern as shown in the photo option is available.<br />Know more about PB(Patterned Blouse)<a href=\'/Faq.aspx?mode=QnA&ArtId=330\' title="Click here to know more about PB"><strong style="color:Red;">Click here</strong></a>';
                $('imgBLHelp1').src='/image/Measurements-V2/es-msr-help-bl-pb1.jpg';
                $('imgBLHelp2').src='/image/Measurements-V2/es-msr-help-bl-pb2.jpg';
                $('imgBLHelp3').src='/image/Measurements-V2/es-msr-help-bl-pb3.jpg';
                $('imgBLHelp4').src='/image/Measurements-V2/es-msr-help-bl-pb4.jpg';
            break;
            case 'BLO01':
                $('dvBLTitle').innerHTML='<b>Regular Blouse</b>';
                $('pBLText').innerHTML='Simple and timeless!! Conventional Saree Blouse featuring simple and clean cuts, plain sleeves and basic necklines such as round, '
                    +'square, sweetheart, etc. Blouse pattern as shown in the photo option is not available.<br />Know more about RB(Regular Blouse)<a href=\'/Faq.aspx?mode=QnA&ArtId=329\' title="Click here to know more about RB"><strong style="color:Red;">Click here</strong></a>';
                $('imgBLHelp1').src='/image/Measurements-V2/es-msr-help-bl-rb1.jpg';
                $('imgBLHelp2').src='/image/Measurements-V2/es-msr-help-bl-rb2.jpg';
                $('imgBLHelp3').src='/image/Measurements-V2/es-msr-help-bl-rb3.jpg';
                $('imgBLHelp4').src='/image/Measurements-V2/es-msr-help-bl-rb4.jpg';
            break;
            case 'BLO06':
                $('dvBLTitle').innerHTML='<b>Trendy Designer Blouse</b>';
                $('pBLText').innerHTML='Trendsetting and fashionable Designer Saree Blouse that’s in vogue. Featuring stylish cuts, Trendy Designer Blouse is'
                    +' exclusively designed and custom tailored for you, as per your requirements, by our Designers. On selection of this option, '
                    +'our designers would send you a choice of blouse patterns from which you can select your preferred style. Also, Trendy Designer Blouse '
                    +'can be custom-made in any large size including plus size at no extra cost.<br />Know more about TDB(Trendy Designer Blouse) <a href=\'/Faq.aspx?mode=QnA&ArtId=316\' title="Click here to know more about TDB"><strong style="color:Red;">Click here</strong></a>';
                $('imgBLHelp1').src='/image/Measurements-V2/es-msr-help-bl-tdb1.jpg';
                $('imgBLHelp2').src='/image/Measurements-V2/es-msr-help-bl-tdb2.jpg';
                $('imgBLHelp3').src='/image/Measurements-V2/es-msr-help-bl-tdb3.jpg';
                $('imgBLHelp4').src='/image/Measurements-V2/es-msr-help-bl-tdb4.jpg';
            break;           
        }
        var d=$('dvBLHelpImgs');
        d.style.position="absolute";
        d.style.display='block'; 
        d.style.visibility ='visible';
        d.style.top=mouseY-250+'px';
        d.style.left=mouseX-220+'px';       
        d.style.zIndex='2000';               
    }
    catch(e)
    {
        alert('@ funShowBLHelpImgs');
    }
}

function funValueforMoney()
{
    try
    {
        $('dvValueforMoney').style.display='block'; 
        $('dvValueforMoney').style.visibility ='visible';
        $('dvValueforMoney').style.top=0+'px';
        $('dvValueforMoney').style.left=-500+'px';
        $('dvValueforMoney').style.position="absolute";
        $('dvValueforMoney').style.zIndex='2000';
        $('dvValueforMoney').innerHTML='<div class="close" onclick="$(\'dvValueforMoney\').hide()"></div>'
                        +'<ul>'
                        +'<li><span>Value For Money</span></li>'
                        +'<li rel="nofollow">Our shipping rates are the lowest. It remains the same for products of all prices. Shipping rates for USA and UK are $10 per item.</li>'
                        +'<li rel="nofollow">Our product rates are genuinely competitive and we offer price drop guarantee as well.</li>'
                        +'<li rel="nofollow">Our blouse-stitching cost tends to be more as the blouses conform to the highest standard of quality '
                        +'and finishing, ensure a perfect fit and are made by skilled and experienced tailors and dressmakers. This increases the cost of making every blouse.</li>'
                        +'<li rel="nofollow">Every product is customized by an experienced fashion designer.</li>'
                      +'</ul>'
                      +'<div class="clear"></div>';
    }
    catch(e)
    {
        alert('@ funValueforMoney');
    }
}