﻿/*---------------------------------------------------------------------------------         
        Description			    :	 Products.js used in Producs.aspx                                     
        Create on			    :    05-04-2009
        Initial Code Created    :    Sathish.M
        Caution                 :    Change in any of the below functions will
                                     affect the products page.
---------------------------------------------------------------------------------*/
//Global variable

var gourl=location.href,mode,sertext,sm,exp='N',sr,er,spId;
var gurl=gourl.toQueryParams();

//On Popup
function funOnPopup(PopupId)
{
    try
    {   
        switch(PopupId)
        {            
            case 'dvPopup3rdCategories':
                switch($F('hdnMode'))
                {
                    case 'Def':
                    case 'fltr':
                        $(PopupId).style.display='block';  
                    break;                    
                }
            break;            
            case 'dvPopupFilterBy':
//                if($F('hdnMode')!='new')
                    $(PopupId).style.display='block';
            break;
        }     
    }
    catch(e)
    {
        //alert('@ funOnPopup');
    }
}
//Off Popups
function funOffPopups()
{
    try
    {
        $('dvPopup3rdCategories').style.display='none';
        $('dvPopupFilterBy').style.display='none';
        $('dvPopupFilterBy1').style.display='none';
        $('dvProductsSubTask').style.display='none';        
    }
    catch(e)
    {
        //alert('@ funOffPopups'); 
    }
}
//Calculate delivery date
function funAddDays(myDate,days) 
{
    try
    {
        return new Date(myDate + days*24*60*60*1000);
    }
    catch(e)
    {
        //alert('@ funAddDays')
    }
}
function funCalcTime() 
{
   Dte = new Date();
   try
   {    
        utc = Dte.getTime() + (Dte.getTimezoneOffset() * 60000);
        return utc;
   }
   catch(e)
   {
        //alert('@ funCalcTime');
   }
}
function funCalculateDelDate(HasOutOfStock,PrdVendorType,PrdDelDays,CourierLeadDays)
{   
    var Dte,Dt,Year,RtnDelDate='';
    var arrMnth=new Array(12);
    try
    {   
        Dte=funAddDays(funCalcTime(),parseInt(PrdDelDays)+parseInt(CourierLeadDays));
        Dt=Dte.getDate();           
        Year=Dte.getFullYear();             
        arrMnth[0]="Jan";arrMnth[1]="Feb";arrMnth[2]="Mar";arrMnth[3]="Apr";arrMnth[4]="May";arrMnth[5]="Jun";
        arrMnth[6]="Jul";arrMnth[7]="Aug";arrMnth[8]="Sep";arrMnth[9]="Oct";arrMnth[10]="Nov";arrMnth[11]="Dec"; 
        RtnDelDate='Delivered By '+Dt+'-'+arrMnth[Dte.getMonth()]+'-'+Year;
        if(HasOutOfStock>0 && PrdVendorType=='VA')
            RtnDelDate='OUT OF STOCK';
        else 
            RtnDelDate='Delivered By '+Dt+'-'+arrMnth[Dte.getMonth()]+'-'+Year;
            
        return RtnDelDate;
    }
    catch(e)
    {
        //alert('@ funCalculateDelDate');
    }
}
//On products mouser over
function funOnProductsMouseMove(PrdCode,PrdDesc,PrdLPic,HasOutOfStock,PrdVendorType,PrdDelDays,EsCourierLeadDays,PrdHasDis,PrdRate,PrdDisRate)
{   
    try
    {  
        $('imgPrdLPic').src='';
        $('imgPrdLPic').src='http://www.chennaibazaar.com/image/EsLoading.gif'; 
        $('imgPrdLPic').src=PrdLPic;
        $('imgPrdLPic').title=PrdCode+' - '+PrdDesc;
        $('hdnPrdCode').value=PrdCode;
        funSetProducts('novw',0,PrdCode,0)          
        if($F('hdnBusType')=='B2B' && $F('hdnUsrId')!='0')       
        {
            if(PrdHasDis=='0')
                $('spnPrdDtls').innerHTML=PrdCode+'|'+PrdRate+'|'+funCalculateDelDate(HasOutOfStock,PrdVendorType,PrdDelDays,EsCourierLeadDays);                
            else if(PrdHasDis=='1')
                $('spnPrdDtls').innerHTML=PrdCode+'|'+PrdDisRate+'|'+funCalculateDelDate(HasOutOfStock,PrdVendorType,PrdDelDays,EsCourierLeadDays);                
        }
        if($F('hdnBusType')=='B2C')       
        {
            if(PrdHasDis=='0')
                $('spnPrdDtls').innerHTML=PrdCode+'|'+PrdRate+'|'+funCalculateDelDate(HasOutOfStock,PrdVendorType,PrdDelDays,EsCourierLeadDays);                
            else if(PrdHasDis=='1')
                $('spnPrdDtls').innerHTML=PrdCode+'|'+PrdDisRate+'|'+funCalculateDelDate(HasOutOfStock,PrdVendorType,PrdDelDays,EsCourierLeadDays);                
        }        
    }
    catch(e)
    {
        //alert('@ funOnProductsMouseMove');
    }    
}
//Comparison view
function funComparisonView()
{
    try
    {
        if($F('hdnUsrId')!='0')
            window.location=$F('hdnAppPath')+'wish-list.html';
        else
            window.location=$F('hdnAppPath')+'UsrLogin.aspx';
    }
    catch(e)
    {
        //alert('@ funComparisonView');
    }
}
//Product gendral details
function funProductGenDtl(pcode,genId)
{
    var qStr='';
    try
    {   
        qStr='gendtl|PRDGENDTL|U3|'+$F('hdnSessionCurrency')+'|'+pcode+'|||'+genId+'||||0|0|0|0|0|0|';  
        funCallProductsHandlerSubTask(qStr);                        
    }
    catch(e)
    {
        //('@ funProductGenDtl');
    }
}
//Onload
function funProductsOnLoad()
{   
    var Cur;
    try
    {      
        switch($F('hdnMode'))
        {
            case 'bck':
            case '3Ctg':
            case 'novw':
            case 'wsh':
            case 'a2wsh':
            case 'rmwsh':
            case 'mailinfo':
            case 'fshnadv':
            case 'fltr':
            case 'newser':                
                funSetProducts($F('hdnMode'),0,'',0);
                break;
            case 'Def':
            case 'new':
            case 'ser':
            case 'smser':
            case 'fltser':            
                if($('dvPopupFilterBy')!=null)
                $('dvPopupFilterBy').innerHTML=$('dvFilterByData').innerHTML;
                        
                Cur=document.getElementsByName('Currency');
                for (var i = 0; i < Cur.length; i++) 
                {
                    if (Cur[i].value==$F('hdnSessionCurrency')) 
                    {	
                        Cur[i].checked=true;
                        break;
                    }
                }
                if($F('hdnBusType')=='B2B' && $F('hdnUsrId')!='0')       
                {
                    if($F('hdnPrdHasDiscount')=='0')
                        $('spnPrdDtls').innerHTML=$F('hdnPrdCode')+'|'+$F('hdnPrdCurrencyRate')+'|'+funCalculateDelDate($F('hdnHasOutOfStock'),$F('hdnPrdVendorType'),$F('hdnPrdDelDays'),$F('hdnEsCourierLeadDays'));                                                
                    else if($F('hdnPrdHasDiscount')=='1')
                        $('spnPrdDtls').innerHTML=$F('hdnPrdCode')+'|'+$F('hdnPrdCurrencyDisRate')+'|'+funCalculateDelDate($F('hdnHasOutOfStock'),$F('hdnPrdVendorType'),$F('hdnPrdDelDays'),$F('hdnEsCourierLeadDays'));                   
                }
                else if($F('hdnBusType')=='B2C')       
                {
                    if($F('hdnPrdHasDiscount')=='0')
                        $('spnPrdDtls').innerHTML=$F('hdnPrdCode')+'|'+$F('hdnPrdCurrencyRate')+'|'+funCalculateDelDate($F('hdnHasOutOfStock'),$F('hdnPrdVendorType'),$F('hdnPrdDelDays'),$F('hdnEsCourierLeadDays'));                                                
                    else if($F('hdnPrdHasDiscount')=='1')
                        $('spnPrdDtls').innerHTML=$F('hdnPrdCode')+'|'+$F('hdnPrdCurrencyDisRate')+'|'+funCalculateDelDate($F('hdnHasOutOfStock'),$F('hdnPrdVendorType'),$F('hdnPrdDelDays'),$F('hdnEsCourierLeadDays'));                   
                }    
            break;
        }  
    }
    catch(e)
    {
        //
    }
}
function funLogin()
{
    try
    {   
        window.location=$F('hdnAppPath')+'UsrLogin.aspx';
    }
    catch(e)
    {
        alert('No products found, select a different category from the top menu.');
    }
}

//Go back
function funProductsGoBack()
{
    try
    {   
        funSetProducts('bck',0,'',0);
    }
    catch(e)
    {
        alert('No products found, select a different category from the top menu.');
    }
}
//Set products page    
function funSetProducts(mode,ctgid,pcode,pid)
{
    /*  
    18 splits:
    
    qStr='ScriptMode|SpOprMode|SpSubOprMode|Currency|Product code|Of(For Fashion Advisor)|SearchText|GenId|SizeChart|';
    qStr=qStr + 'ExpShip|SaleNSpl|1stCtg|2ndCtg|3rdCtg|Product Id|StartRate|EndRate|DeliveryDate'; 
    */        
    var Cur,qStr='';
    arrPtId=new Array();
    try    
    {  
        Cur=document.getElementsByName('Currency');
        switch(mode)
        {             
            case 'bck':
                 qStr=mode+'|DEFAULT|U3|'+$F('hdnSessionCurrency')+'||||||||'+$F('hdn1stCtgId')+'|'+$F('hdn2ndCtgId')+'|'+$F('hdn3rdCtgId')+'|0|0|0|';                 
            break;            
            case '3Ctg':
                for (var i = 0; i < Cur.length; i++) 
                {
                    if (Cur[i].checked) 
                    {	
                        $('hdnSessionCurrency').value=Cur[i].value;
                        break;
                    }
                }
                $('hdn3rdCtgId').value=ctgid;                                         
                qStr=mode+'|DEFAULT|U3|'+$F('hdnSessionCurrency')+'||||||||'+$F('hdn1stCtgId')+'|'+$F('hdn2ndCtgId')+'|'+$F('hdn3rdCtgId')+'|0|0|0|';                       
            break;            
            case 'newser':
                $('dvResult').innerHTML='';
                $('dvResult').innerHTML='<center><img id="imgLoading" src="http://www.chennaibazaar.com/image/EsLoading.gif" alt="Loading..." title="Loading..." /></center>';  
                var varOf='',varLaWk='0';
                LaWk=document.getElementsByName('LAWk');                          
                for (var i = 0; i < LaWk.length; i++) 
                {
                    if (LaWk[i].checked) 
                    {	
                        varLaWk=LaWk[i].value;
                        break;
                    }
                }
                varOf=$F('ddlPrdType')!='-1'?$F('ddlPrdType'):'';
                qStr=mode+'|NEW|U3|'+$F('hdnSessionCurrency')+'|'+pcode+'|'+varOf+'||'+varLaWk+'||||0|0|0|'+pid+'|0|0|'; 
            break;
            case 'novw':   
                $('dvProductsSubTask').hide();
                qStr=mode+'|NOOFVIEWS|U3|'+$F('hdnSessionCurrency')+'|'+pcode+'|||||||0|0|0|'+pid+'|0|0|'; 
                funCallProductsHandlerSubTask(qStr)                
            break;
            case 'wsh': 
                $('dvCategories').disabled=true;
                document.title ='Your wish list';
                qStr=mode+'|WISHLIST|U3|'+$F('hdnSessionCurrency')+'||||||||0|0|0|0|0|0|'; 
            break;
            case 'a2wsh':
                if($F('hdnUsrId')!='0')
                {
                    if(confirm('Are you sure to add '+pcode+' in your comparison list?')==true)
                    { 
                        qStr=mode+'|ADD2WISHLIST|U3|'+$F('hdnSessionCurrency')+'|'+pcode+'|||||||0|0|0|'+pid+'|0|0|'; 
                        funCallProductsHandlerSubTask(qStr)                        
                    }
                }
                else
                    window.location=$F('hdnAppPath')+'UsrLogin.aspx?mode=wsh&pid='+pid;
            break;  
            case 'rmwsh': 
                qStr=mode+'|REMOVEFROMWISHLIST|U3|'+$F('hdnSessionCurrency')+'|'+pcode+'|||||||0|0|0|'+pid+'|0|0|'; 
            break; 
             case 'a2c':
                qStr=mode+'|ADD2CART|U3|'+$F('hdnSessionCurrency')+'|'+pcode+'|||||||0|0|0|'+pid+'|0|0|'; 
            break;     
            case 'mailinfo':
                qStr=mode+'|'+$F('hdn3rdCtgId')+'#'+$F('txtCusEmailId')+'|U3|'+$F('hdnSessionCurrency')+'||||||||0|0|0|0|0|0|'; 
            break;
            case 'fshnadv': //seo url work pending
                if(gurl.Ct=='C')                 
                    qStr=mode+'|FASHIONADVISOR-C|U3|'+$F('hdnSessionCurrency')+'||'+gurl.Of+'|||'+gurl.PrdSiz+'|||'+gurl.PtId+'|0|0|0|0|0|'; 
                else if (gurl.Ct=='R')  
                {             
                    arrPtId=gurl.PtId.split('|');
                    qStr=mode+'|FASHIONADVISOR-R|U3|'+$F('hdnSessionCurrency')+'||'+gurl.Of+'|||'+gurl.PrdSiz+'|||'+arrPtId[0]+'|0|0|0|0|0|'; 
                } 
            break;
            case 'fltr':  
                var SubOprMode='U3',GenId='',ExpShip='',SalNSpl='',Mnt='',Dy='',Yr='',DelDate='';
                for (var i = 0; i < Cur.length; i++) 
                {
                    if (Cur[i].checked) 
	                {	
		                $('hdnSessionCurrency').value=Cur[i].value;
		                break;
                    }
                }  
                if($('chViewAll')!=null && $('chViewAll').checked==true)
                {
                    SubOprMode='U2'
                    $('hdnViewType').value=SubOprMode;
                }
                else if($('chViewAll')!=null && $('chViewAll').checked==false)
                {
                    SubOprMode='U3'
                    $('hdnViewType').value=SubOprMode;
                }
                if($('ddlSize')!=null && $F('ddlSize')!='-1')
                        GenId=$F('ddlSize');
                if($('ddlFlavour')!=null && $F('ddlFlavour')!='-1')
                    if (GenId != '')
                        GenId=GenId+','+$F('ddlFlavour');
                    else
                        GenId=GenId+$F('ddlFlavour');
                if($('ddlColor')!=null && $F('ddlColor')!='-1')
                    if (GenId != '')
                        GenId=GenId+','+$F('ddlColor');
                    else
                         GenId=GenId+$F('ddlColor');
                if($('ddlCity')!=null && $F('ddlCity')!='-1')
                    if (GenId != '')
                        GenId=GenId+','+$F('ddlCity');  
                    else 
                        GenId=GenId+$F('ddlCity');  
                if($('chExpressShip')!=null && $('chExpressShip').checked==true)
                    ExpShip='Y';
                if($('chSalesNSpecials')!=null && $('chSalesNSpecials').checked==true)
                    SalNSpl='Y';                  
                if($('ddlMonth')!=null)       
                    Mnt=$F('ddlMonth')!='-1'?$F('ddlMonth'):'';
                if($('ddlDay')!=null)       
                    Dy=$F('ddlDay')!='-1'?$F('ddlDay'):'';
                if($('ddlYear')!=null)       
                    Yr=$F('ddlYear')!='-1'?$F('ddlYear'):'';
                if(Mnt!=''&&Dy!=''&&Yr!='')
                    DelDate=Mnt+'/'+Dy+'/'+Yr;              
                switch($F('hdnMode'))
                {   
                    case 'Def':
                        var StRt='',EnRt='';
                        StRt=$F('txtSrRate')==''?'0':$F('txtSrRate');
                        EnRt=$F('txtEnRate')==''?'0':$F('txtEnRate');
                        qStr=mode+'|FILTERBY|'+SubOprMode+'|'+$F('hdnSessionCurrency')+'||||'+GenId+'||'+ExpShip+'|'+SalNSpl+'|'+$F('hdn1stCtgId')+'|'+$F('hdn2ndCtgId')+'|'+$F('hdn3rdCtgId')+'|0|'+StRt+'|'+EnRt+'|'+DelDate;                         
                    break;
                    case 'wsh':
                        qStr=mode+'|WISHLIST|U3|'+$F('hdnSessionCurrency')+'||||||||0|0|0|0|0|0|'; 
                    break;
                    case 'ser':
                        sertext=gourl.split('/')[gourl.split('/').length-1].split('.')[0].replace('-',' ');
                        qStr=mode+'|SEARCH|U3|'+$F('hdnSessionCurrency')+'|||'+sertext+'|||||0|0|0|0|0|0|';                       
                    break;                    
                    case 'smser': 
                        arrSmSer=new Array();
                        if(gourl.indexOf('-above-')>0)
                        {
                            sm='A';
                            sr=0;
                            er=gourl.split('-above-')[1].split('-')[0];                                        
                        }
                        if(gourl.indexOf('-below-')>0)
                        {
                            sm='B';
                            sr=0
                            er=gourl.split('-below-')[1].split('-')[0];                                        
                        }
                        if(gourl.indexOf('-between-')>0)
                        {
                            sm='N';                    
                            sr=gourl.split('-between-')[1].split('-')[0];  
                            er=gourl.split('-between-')[1].split('-')[1];  
                        }
                        if(gourl.indexOf('/express-shipping/')>0)
                            exp='Y';                            
                           
                        spId=gourl.split('-c-')[1].split('.')[0];                      
                        qStr=mode+'|SMARTSEARCH|'+sm+'|'+$F('hdnSessionCurrency')+'||||||'+exp+'||0|'+spId+'|0|0|'+sr+'|'+er+'|';                 
                    break;
                    case 'fshnadv':
                        if(gurl.Ct=='C')                 
                            qStr=mode+'|FASHIONADVISOR-C|U3|'+$F('hdnSessionCurrency')+'||'+gurl.Of+'|||'+gurl.PrdSiz+'|||'+gurl.PtId+'|0|0|0|0|0|'; 
                        else if (gurl.Ct=='R')  
                        {             
                            arrPtId=gurl.PtId.split('|');
                            qStr=mode+'|FASHIONADVISOR-R|U3|'+$F('hdnSessionCurrency')+'||'+gurl.Of+'|||'+gurl.PrdSiz+'|||'+arrPtId[0]+'|0|0|0|0|0|'; 
                        } 
                    break;
                }                
                $('dvResult').innerHTML='<img id="imgLoading" src="http://www.chennaibazaar.com/image/EsLoading.gif" alt="Loading..." />';
            break;      
        }        
        if(mode!='novw' && mode!='a2wsh' && mode!='3Ctg')
        {                
            funOffPopups();
            funCallProductsHandler(qStr);
        }    
    }
    catch(e)
    {
        //alert('@ funSetProducts');
    }
}
//Mail information if category is missing its big products page
function funBigPrdPgeIssueMailInfo()
{   
    try
    {
        qStr='mailinfo|FASHIONADVISOR-R|U3|'+$F('hdnSessionCurrency')+'|||||||||0|0|0|0|0|'; 
        $('dvRedirIssue').hide();        
    }
    catch(e)
    {
        //alert('@ funBigPrdPgeIssueMailInfo');
    }
}
function funOutOfStockReq(pcode)
{
    try
    {
        $('spnReqPrdCode').innerHTML=pcode;
        revealElement('dvOutOfStockReqForm');       
    }
    catch(e)
    {
        //alert('@ funOutOfStockReq');
    }
}
//On products failure 
function funOnProductsFailure(originalRequest)
{
    try
    {
        alert(originalRequest.responseText);
    }
    catch(e)
    {
        //alert('@ funOnProductsFailure');            
    }
}
//On products success
function funOnProductsSuccess(originalRequest)
{   
    arrResponse=new Array();
    var orgRegText='',Cur,BPIssue='N';
    try
    {   
        arrResponse=originalRequest.responseText.split('|');
        if(arrResponse.length>0)
        {   
            $('dvResult').innerHTML='';
            switch(arrResponse[0])
            {   
                case 'N':
                    if($F('hdnMode')=='wsh' || $F('hdnMode')=='new' || $F('hdnMode')=='newser' || $F('hdnMode')=='ser' || $F('hdnMode')=='fshnadv')                    
                        $('dvResult').innerHTML='<br/><br/>Sorry...! No products found,<br/><br/>Kindly search in the categories for wide range of products.<br/><br/><br/><br/>';                                            
                     else 
                        $('dvResult').innerHTML='<br/><br/>Sorry...! No products found,<br/><br/>Kindly search in the categories for wide range of products.<br/><br/><br/><br/><a onclick="funProductsGoBack();">Back</a><br/><br/>';                    
                break;
                case 'Y':                    
                    $('dvResult').innerHTML=arrResponse[1];                    
                    if($('dvPopupFilterBy')!=null)
                        $('dvPopupFilterBy').innerHTML=$('dvFilterByData').innerHTML;
                    
                    Cur=document.getElementsByName('Currency');
                    for (var i = 0; i < Cur.length; i++) 
                    {
                        if (Cur[i].value==$F('hdnSessionCurrency')) 
                        {	
                            Cur[i].checked=true;
                            break;
                        }
                    }
                    if($F('hdnPrdHasDiscount')=='0')
                        $('spnPrdDtls').innerHTML=$F('hdnPrdCode')+'|'+$F('hdnPrdCurrencyRate')+'|'+funCalculateDelDate($F('hdnHasOutOfStock'),$F('hdnPrdVendorType'),$F('hdnPrdDelDays'),$F('hdnEsCourierLeadDays'));                                                
                    else if($F('hdnPrdHasDiscount')=='1')
                       $('spnPrdDtls').innerHTML=$F('hdnPrdCode')+'|'+$F('hdnPrdCurrencyDisRate')+'|'+funCalculateDelDate($F('hdnHasOutOfStock'),$F('hdnPrdVendorType'),$F('hdnPrdDelDays'),$F('hdnEsCourierLeadDays'));                       
                        
                    if($F('hdnViewType')=='U2')
                    {
                        $('chViewAll').checked=true;   
                        $('spnViewAll').innerHTML='Unselect the check box if you wish to view previous category items.'
                    }
                    else if($F('hdnViewType')=='U3')
                    {
                        $('chViewAll').checked=false;
                        $('spnViewAll').innerHTML='Select the check box if you wish to view all the items under '+$F('hdnSiteMap2')+'.';
                    }
                break;
                case 'a2c':
                    $('dvResult').innerHTML=arrResponse[1];
                    arrBP=$F('hdnGoPrdDltPge').toLowerCase().split('-');                    
                    if(arrBP.length>0)
                    {   
                        var ctg2desc,ctg3desc,pname;
                        ctg2desc=arrBP[6].replace(' ','-');ctg2desc=ctg2desc.replace(' ','-');ctg2desc=ctg2desc.replace(' ','-');ctg2desc=ctg2desc.replace(' ','-');ctg2desc=ctg2desc.replace(' ','-');ctg3desc=ctg2desc.replace(' ','-');
                        ctg3desc=arrBP[7].replace(' ','-');ctg3desc=ctg3desc.replace(' ','-');ctg3desc=ctg3desc.replace(' ','-');ctg3desc=ctg3desc.replace(' ','-');ctg3desc=ctg3desc.replace(' ','-');ctg3desc=ctg3desc.replace(' ','-');
                        pname=arrBP[5].replace(' ','-');pname=pname.replace(' ','-');pname=pname.replace(' ','-');pname=pname.replace(' ','-');pname=pname.replace(' ','-');pname=pname.replace(' ','-');pname=pname.replace(' ','-');

                        window.location=$F('hdnAppPath')+ctg2desc+'/'+ctg3desc+'/'+pname+'-p-'+arrBP[3]+'.html';
                    }
                    else                       
                        $('dvResult').innerHTML=$('dvRedirIssue').innerHTML;
                break;                  
                case 'rmwsh':
                    $('dvResult').innerHTML=arrResponse[1];
                    funSetProducts('wsh',0,'',0);
                break;
                case 'mailinfo':
                    window.location=$F('hdnAppPath')+'default.aspx';    
                break;
            }
         }
     }
     catch(e)
     {  
        //alert('@ funOnProductsSuccess');
     }
}
//Call products handler
function funCallProductsHandler(qStr)
{   
    try
    {   
        new Ajax.Request($F('hdnAppPath')+'GenetricHandler/Products.ashx?qStr='+qStr,
        {
            method   : 'get',
            onSuccess: funOnProductsSuccess,            
            onFailure: funOnProductsFailure
        });
    }
    catch(e)
    {
        //alert('@ funCallProductsHandler');       
    }
}
//On products success to perform sub task.
function funOnProductsSuccessSubTask(originalRequest)
{   
    arrResponse=new Array();
    var orgRegText='',Cur;
    try
    {   
        arrResponse=originalRequest.responseText.split('|');
        if(arrResponse.length>0)
        {   
            $('dvProductsSubTask').innerHTML=arrResponse[1];
            if(arrResponse[0]=='gendtl')
                revealElement('dvProductsSubTask');
        }   
     }
     catch(e)
     {
        //alert('@ funOnProductsSuccessSubTask');
     }
}
//Call products handler to perform sub task.
function funCallProductsHandlerSubTask(qStr)
{   
    try
    {    
        new Ajax.Request($F('hdnAppPath')+'GenetricHandler/Products.ashx?qStr='+qStr,
        {
            method   : 'get',
            onSuccess: funOnProductsSuccessSubTask,            
            onFailure: funOnProductsFailure
        });
    }
    catch(e)
    {
        //alert('@ funCallProductsHandlerSubTask');       
    }
}
