function GoToHome()
{
 window.open("http://www.pactsoft.com","PactSoft",'');
}
function FunctionUnAvailable()
{
    alert('Currently this functionality is not available.');
}
function CRMPopUp(strQueryString,iWidth,iHeight,CallBack,strWindowName,strCtrlID)
{
    CRMPopupPage("CSPopup.aspx?"+strQueryString,iWidth,iHeight,CallBack,strWindowName,strCtrlID)
}
function AddLoadAlertMsg(strMsg)
{
    var oldOnLoad=window.onload;
    if(typeof window.onload != 'function')
    {
        window.onload=function(){alert(strMsg);}
    }
    else
    {
        window.onload=function(){
                        if(oldOnLoad)
                            oldOnLoad();
                        alert(strMsg);
                      }
    }
}
function AddLoadMethod(LoadMethod)
{ 
    var oldOnLoad=window.onload;
    if(typeof window.onload != 'function')
    {
        window.onload=function(){LoadMethod();}
    }
    else
    {
        window.onload=function(){
                        if(oldOnLoad)
                            oldOnLoad();
                        LoadMethod();
                      }
    }
}
function CRMPopupPage(strURL,iWidth,iHeight,CallBack,strWindowName,strCtrlID)
{
    var left=0,top=0;
    var strParam;
    if(iWidth=='undefined')
        iWidth=screen.availWidth;
    if(iHeight=='undefined')
        iHeight=screen.availHeight;
    left=(screen.availWidth-iWidth)/2-2
    top=(screen.availHeight-iHeight)/2-17
    strParam='left='+left+',top='+top+',Height='+iHeight+',Width='+iWidth
    strParam+=',location=center,toolbar=no,menubar=no,scrollable=yes,resizable=no';

    var dt=new Date();
    if(strWindowName==undefined)
        strWindowName="CRMPopUp"+dt.getTime();    
    var objWindow=window.open(strURL,strWindowName,strParam);
    window.Child=objWindow
    objWindow.focus();
//debugger
    if(CallBack!='undefined' && CallBack!=undefined)
    {
         objWindow.CallBackMethod=CallBack;
    }
    else
    {
         objWindow.CallBackMethod=tempFunCall;
    }
    if(strCtrlID!='undefined' && strCtrlID!=undefined)
    {
         objWindow.ControlID=strCtrlID;
    }
}
function tempFunCall()
{
}
function HideContextMenu()
{
    CancelEvent();
}
function CancelEvent()
{
    event.cancelBubble=true;
    event.returnValue=false;
    return false;
}
function GoToLandingPage(strPage)
{
    //debugger;
    // window.history.back();
    if(window.name=="EDITPOPUP"||window.name=="EDITPOPUP1"||window.name=="EDITPOPUP2"||window.name=="EDITPOPUP3")
        window.close();
    else
    {
        window.parent.ShowLoadingImage(true);
        window.location.href = 'CSFeaturePage.aspx?Page='+strPage+'&Close=CloseClick'
    }
}

function ShowQuickLink(strPage)
{
    
    var iFrameFeature=document.getElementById("iFrameFeature")
    if(strPage=="NewEvent")
    {
        CRMPopUp("Page=NewEvent&QuickLink=QL",680,420,null,'NewEvent');
    }
    else if(strPage=="NewTask")
    {
        CRMPopUp("Page=NewTask&QuickLink=QL",680,300,null,'NewTask');
    }
    else
    {
//        ShowLoadingImage(true);
         CRMPopUp("Page="+ strPage+"&Window=window",780,600,null,strPage);
      //  iFrameFeature.src="CSFeaturePage.aspx?Page="+ strPage +'&iCntCalls='+new Date();
    }
}
function LookUpChange(obj)
{
    if(obj.selectedIndex>=0)
    {
        if(obj.options[obj.selectedIndex].attributes["Restricted"]!=null)
        {
            alert('Invalid Selection.');
            obj.selectedIndex=0;
        }
    }
}
function ValidateData(strData,strType)
{
    var strValidChars;
    if(strType=="INTEGER")
        strValidChars="0123456789-";
    else if(strType=="DECIMAL")
        strValidChars="0123456789-.";
    else
        return true;
    for(var i=strData.length-1;i>=0;i--)
    {
        if(strValidChars.indexOf(strData.charAt(i))==-1)
            return false;
    }
    return true;
}
function trimLeft(str)
{
    return str.replace(/^\s+/g,"");
}
function trimRight(str)
{
    return str.replace(/\s+$/g,"");
}
function trim(str)
{
    return str.replace(/^\s*|\s*$/g,"");
}
function trimEnd(str)
{
    try
    {
        return str.substring(0,str.length-1);
    }
    catch(Error)
    {
        return "";
    }
}
function trimEnd(str,tchar)
{
    while(str.length!=0)
    {
        if(str.charAt(str.length-1)!=tchar)
            break;
        str=str.substring(0,str.length-1);
    }
    return str;
}
function trimStart(str,tchar)
{
    while(str.length!=0)
    {
        if(str.charAt(0)!=tchar)
            break;
        str=str.substring(1,str.length);
    }
    return str;
}
function GetLocationImage(locationName)
{  
    if (locationName=="GUBBA GREEN COLD PVT LTD")
    return "agro";
    else if (locationName=="GNR COLD STORAGE PVT LTD")
    return "agro";
    else if (locationName=="GUBBA AGRO FRESH PVT LTD (MEDCHAL)" || locationName=="GUBBA AGRO FRESH PVT LTD (SHAMEERPET)")
    return "agro";
    else 
    return "agro";
}
function GetEmptyRow(Row,text)
{
var cel0=Row.insertCell(0);
cel0.colspan=4;
cel0.style.height='10px';
cel0.innerHTML=text
cel0.style.textAlign='center'   
return cel0;
}
function GetCell(Row,text,insertAt,textType,UnderLine)
{
 
var Cel0=Row.insertCell(insertAt);
if(textType=="html")
    Cel0.innerHTML=text;
else
   Cel0.innerText=text;
 if(UnderLine)
{
 Cel0.innerHTML="<p style='text-decoration: underline; font-size:12px;'>"+text+"</p>";
}   
return Cel0;
}
function GetTotal(ds,strColumn,Column)
{
var Tot=0;
 for(var i=0;i<ds.value.Tables[0].Rows.length;i++)
 {
 if(Column==0)
    Tot=Tot+parseInt(ds.value.Tables[0].Rows[i].Delivered);
 else  if(Column==1)
    Tot=parseInt(Tot+parseInt(ds.value.Tables[0].Rows[i].DeliveredKgs));
 }
 return Tot;
}

function ReturnBagsCondition(value)
{
 if(value==1)
 return "Good";
 else if(value==2)
 return "Not Good"; 
 return "null";
}
function ReturnLarva(value)
{
 if(value==1)
 return "Present";
 else if(value==2)
 return "Not Present";
 return "null";
}
function GetPrintLayout(ds,Image,PrintType)
{      var hLogin=document.getElementById(ucStockID+'_hLoginUser');
       var TotalBags=0;var TotalKgs=0;
       TotalBags=GetTotal(ds,"Delivered");
       TotalKgs=GetTotal(ds,"DeliveredKgs");
       var tblTemp=document.createElement('table'); 
       //tblTemp.style.borderCollapse='collapse'
       
        tblTemp.width='100%';
        tblTemp.border=1; tblTemp.cellpadding=0; tblTemp.cellspacing=1; tblTemp.className='RPTBgcolor';
        GetHeader(tblTemp,"INWARD MEMO",Image,ds);
        var MainRow;         
       var MainRow=tblTemp.insertRow(tblTemp.rows.length)   
       var cel0=GetEmptyRow(MainRow,""); 
       var MainRow=tblTemp.insertRow(tblTemp.rows.length)      
       var cel0=GetCell(MainRow,"<strong> S.No</strong>",0,"html",false);   
        cel0.style.textAlign='left' 
         
       var cel1=GetCell(MainRow,ds.value.Tables[0].Rows[0].VoucherNo,1,"text",false)  
        
        cel1.style.textAlign='left'  
        
        var cel2=GetCell(MainRow,"<strong> Date</strong>",2,"html",false);  
        cel2.style.textAlign='left' 
        var cel3=GetCell(MainRow,ds.value.Tables[0].Rows[0].dtDate.format("dd/MMM/yyyy"),3,"text",false);  
        cel3.style.textAlign='left' 
         
     
       var MainRow=tblTemp.insertRow(tblTemp.rows.length)      
       var cel0=GetCell(MainRow,"<strong> Company</strong>",0,"html",false);  
        cel0.style.textAlign='left' 
        if(ds.value.Tables[0].Rows[0].Company!=null)
            var cel1=GetCell(MainRow,ds.value.Tables[0].Rows[0].Company,1,"text",false)  
        else
           var cel1=GetCell(MainRow,ds.value.Tables[0].Rows[0].AccountName,1,"text",false)   
        cel1.style.textAlign='left' 
        cel1.colspan=3
      
       var MainRow=tblTemp.insertRow(tblTemp.rows.length)      
       var cel0=GetCell(MainRow,"<strong> TotalBags</strong>",0,"html",false);  
        cel0.style.textAlign='left' 
        if(PrintType==1)
            var cel1=GetCell(MainRow,ds.value.Tables[0].Rows[0].TotalBags,1,"text",false) 
        else 
            var cel1=GetCell(MainRow,TotalBags,1,"text",true)   
        cel1.style.textAlign='left' 
        
        
        var cel2=GetCell(MainRow,"<strong> Total Weight</strong>",2,"html",false);  
        cel2.style.textAlign='left' 
        var cel3=GetCell(MainRow,ds.value.Tables[0].Rows[0].TotalKgs + " kgs",3,"text",false);  
        cel3.style.textAlign='left' 
        
        var MainRow=tblTemp.insertRow(tblTemp.rows.length)      
        var cel=GetCell(MainRow,"",0,"text");  
        cel.colspan=2;
        var tbl=document.createElement('table')
        var tempRow=tbl.insertRow(tbl.rows.length);  tbl.width='100%';tbl.border=0;
        var cel0=GetCell(tempRow,"<strong>In Time</strong>",0,"html",false)
         cel0.style.textAlign='left'
        var cel1=GetCell(tempRow,ds.value.Tables[0].Rows[0].InTime,1,"text",false)
         cel1.style.textAlign='left'
        var cel2=GetCell(tempRow,"<strong>Out Time</strong>",2,"html",false)  
        cel2.style.textAlign='left' 
        var cel3=GetCell(tempRow,ds.value.Tables[0].Rows[0].OutTime,3,"text",false)
        cel3.style.textAlign='left'
        cel.appendChild(tbl);
        
        var cel21=GetCell(MainRow,"<strong> Vehicle No</strong>",1,"html",false);  
        cel21.style.textAlign='left'  
        var cel31=GetCell(MainRow,ds.value.Tables[0].Rows[0].VehicleNo,2,"text",false);  
        cel31.style.textAlign='left' 
        
        
        var MainRow=tblTemp.insertRow(tblTemp.rows.length)      
       var cel0=GetCell(MainRow,"<strong> Remarks</strong>",0,"html",false);  
        cel0.style.textAlign='left' 
        var cel1=GetCell(MainRow,ds.value.Tables[0].Rows[0].Remarks,1,"text",false)  
        cel1.style.textAlign='left' 
        cel1.colspan=3; 
          
         var MainRow=tblTemp.insertRow(tblTemp.rows.length)      
         var cel0=GetCell(MainRow,"<strong> Company DC.No</strong>",0,"html",false);   
        cel0.style.textAlign='left'  
       var cel1=GetCell(MainRow,ds.value.Tables[0].Rows[0].CompanyDCNo,1,"text",false) 
        cel1.style.textAlign='left'  
        var cel2=GetCell(MainRow,"<strong>Bags Condition</strong>",2,"html",false);  
        cel2.style.textAlign='left' 
        var cel3=GetCell(MainRow,ReturnBagsCondition(ds.value.Tables[0].Rows[0].BagsCondition),3,"text",false);  
        cel3.style.textAlign='left' 
         
         var MainRow=tblTemp.insertRow(tblTemp.rows.length)      
        var cel0=GetCell(MainRow,"<strong> Larva/Weevil</strong>",0,"html",false);   
        cel0.style.textAlign='left'  
        var cel1=GetCell(MainRow,ReturnLarva(ds.value.Tables[0].Rows[0].LarvaOrWeevil),1,"text",false)   
        cel1.style.textAlign='left'   
        var cel2=GetCell(MainRow,"<strong>Ded Larva/Weevil</strong>",2,"html",false);  
        cel2.style.textAlign='left' 
        var cel3=GetCell(MainRow,ReturnLarva(ds.value.Tables[0].Rows[0].DedLarva),3,"text",false);  
        cel3.style.textAlign='left' 
         
         
         var MainRow=tblTemp.insertRow(tblTemp.rows.length)       
        var cel=GetCell(MainRow,"",0,"text");  
        cel.colspan=3;
        var tbl=document.createElement('table')
        var tempRow=tbl.insertRow(tbl.rows.length);  tbl.width='100%';tbl.border=0;
        var cel0=GetCell(tempRow,"<strong>Grill In</strong>",0,"html",false)
         cel0.style.textAlign='left'
         if(ds.value.Tables[0].Rows[0].Grill=="1")
            var cel1=GetCell(tempRow,"Yes",1,"text",false)
        else
            var cel1=GetCell(tempRow,"No",1,"text",false)
         cel1.style.textAlign='left'
        var cel2=GetCell(tempRow,"Grill Out",2,"html",false)  
        cel2.style.textAlign='left' 
        if(ds.value.Tables[0].Rows[0].Grill=="2")
         var cel3=GetCell(tempRow,"Yes",3,"text",false)
        else
          var cel3=GetCell(tempRow,"No",3,"text",false)
        cel3.style.textAlign='left' 
        cel.appendChild(tbl);
      
        
         
        
        var MainRow=tblTemp.insertRow(tblTemp.rows.length)   
        var cel0=GetEmptyRow(MainRow,""); 

        var MainRow=tblTemp.insertRow(tblTemp.rows.length)   
        var cel0=GetEmptyRow(MainRow,"<strong>PALLET DETAILS</strong>");  
         
        var MainRow=tblTemp.insertRow(tblTemp.rows.length)   
        var cel0=GetEmptyRow(MainRow,"");  
        GetPrintGrid(cel0,ds);
        
        var MainRow=tblTemp.insertRow(tblTemp.rows.length)   
        var cel0=GetEmptyRow(MainRow,""); 

        var MainRow=tblTemp.insertRow(tblTemp.rows.length)      
        var cel0=GetCell(MainRow,"<strong> Signature of Representative/Driver</strong>",0,"html",false );  
        cel0.style.textAlign='left' 
        var cel1=GetCell(MainRow,"......................................",1,"text",true)  
        cel1.style.textAlign='left' 
        cel1.style.height='20px'

        var cel2=GetCell(MainRow,"<strong> Signature</strong>",2,"html",false);  
        cel2.style.textAlign='left' 
        var cel3=GetCell(MainRow,"......................................",3,"text",true);  
        cel3.style.textAlign='left' 
        
        
         var MainRow=tblTemp.insertRow(tblTemp.rows.length)      
        var cel0=GetCell(MainRow,"<strong> Name</strong>",0,"html",false);  
        cel0.style.textAlign='left' 
        var cel1=GetCell(MainRow,ds.value.Tables[0].Rows[0].RepName,1,"text",false)  
        cel1.style.textAlign='left' 
         cel1.style.height='20px'


        var cel2=GetCell(MainRow,"<strong> Supervisor</strong>",2,"html",false);  
        cel2.style.textAlign='left' 
        var cel3=GetCell(MainRow,ds.value.Tables[0].Rows[0].StrUserID,3,"text",false);  
        cel3.style.textAlign='left' 
        
        
var winPrint=window.open("","","height=800,width=750, location=center,toolbar=no,menubar=no,scrollbar=yes,resizable=yes");
var strStyle=".grheader{background-image:url(../images/gr-hdr.gif);background-repeat:repeat-x;color:#474646;text-align:center;height:20px;}";
strStyle+=".acoff1{background-color:#F8F8F8;}.acoff2{background-color:#FFFFFF;}";
strStyle+="body,td,th{font:normal 11px Arial; color:#474646}";
winPrint.document.write("<style>"+strStyle+"</style>");
winPrint.document.write(tblTemp.outerHTML)
winPrint.document.close(); 
 winPrint.print();
winPrint.close();

}
function GetPrintGrid(Cell,ds)
{  
var i;var iTotalBags=0;var iTotalKgs=0;
var tblGrid=document.createElement('table');
Cell.appendChild(tblGrid);tblGrid.width='100%';tblGrid.border=0
tblGrid.style.backgroundColor='#CFCFCF'
var row=tblGrid.insertRow(tblGrid.rows.length)
if((tblGrid.rows.length%2)==0)
row.className="acoff2";
else
row.className="acoff1";  
var Cell=GetCell(row,"<strong>Pallet/Bay</strong>",0,"html",false);
Cell.className='grheader';
var Cell=GetCell(row,"<strong>Bags</strong>",1,"html",false);
Cell.className='grheader';
var Cell=GetCell(row,"<strong>Kgs</strong>",2,"html",false);
Cell.className='grheader';
var Cell=GetCell(row,"<strong>Lot No</strong>",3,"html",false);
Cell.className='grheader';
var Cell=GetCell(row,"<strong>Chamber</strong>",4,"html",false);
Cell.className='grheader';
var Cell=GetCell(row,"<strong>Hybrid</strong>",5,"html",false);
Cell.className='grheader'; 
var Cell=GetCell(row,"<strong>Product</strong>",6,"html",false);
Cell.className='grheader'; 
for(i=0;i<ds.value.Tables[0].Rows.length;i++)
{
    var row=tblGrid.insertRow(tblGrid.rows.length)
    if((tblGrid.rows.length%2)==0)
    row.className="acoff2";
    else
    row.className="acoff1"; 
    var Cell=GetCell(row,ds.value.Tables[0].Rows[i].RackName,0,"html",false);
    Cell.className='grheader';
    var Cell=GetCell(row,ds.value.Tables[0].Rows[i].ibags,1,"html",false);
    Cell.className='grheader';
    var Cell=GetCell(row,ds.value.Tables[0].Rows[i].ikgs,2,"html",false);
    Cell.className='grheader';
    var Cell=GetCell(row,ds.value.Tables[0].Rows[i].lot,3,"html",false);
    Cell.className='grheader';
    var Cell=GetCell(row,ds.value.Tables[0].Rows[i].ChamberName,4,"html",false);
    Cell.className='grheader';
      var Cell=GetCell(row,ds.value.Tables[0].Rows[i].VarietyName,5,"html",false);
    Cell.className='grheader';
       var Cell=GetCell(row,ds.value.Tables[0].Rows[i].ProductName,6,"html",false);
    Cell.className='grheader';
    if(ds.value.Tables[0].Rows[i].ibags!=null)
        iTotalBags=parseInt(iTotalBags+parseInt(ds.value.Tables[0].Rows[i].ibags));
    if(ds.value.Tables[0].Rows[i].ikgs!=null)
    iTotalKgs=parseFloat(iTotalKgs+parseFloat(ds.value.Tables[0].Rows[i].ikgs));
}
 
    if (i < 19)
    {
    for (; i < 19; i++)
    { 
        var row=tblGrid.insertRow(tblGrid.rows.length) 
        row.style.backgroundColor="#FFFFFF"; 
        for(var j=0;j<7;j++)
        {  var Cell=GetCell(row,"",j,"html",false);
            Cell.className='grheader';
         
        } 
        
    }
   }
 var row=tblGrid.insertRow(tblGrid.rows.length)
 var Cell=GetCell(row,"<strong>Total</strong>",0,"html",false);
Cell.className='grheader';
var Cell=GetCell(row,"<strong>"+iTotalBags+"</strong>",1,"html",false);
Cell.className='grheader';
var Cell=GetCell(row,"<strong>"+iTotalKgs+"</strong>",2,"html",false);
Cell.className='grheader';
var Cell=GetCell(row,"",3,"html",false);
Cell.className='grheader';
var Cell=GetCell(row,"",4,"html",false);
Cell.className='grheader';
var Cell=GetCell(row,"",5,"html",false);
Cell.className='grheader';
var Cell=GetCell(row,"",6,"html",false);
Cell.className='grheader';
}

function GetHeader(tbl,Type,Image,ds)
{
var MainRow;
MainRow=tbl.insertRow(tbl.rows.length)  
        var celLeftMain=MainRow.insertCell(0);celLeftMain.style.width='350px';celLeftMain.colspan='2'
                    var tblLeft=document.createElement('table');
                    
                    tblLeft.width='100%'; tblLeft.height="100%";tblLeft.border=0;
                    var row=tblLeft.insertRow(tblLeft.rows.length)   
                    var cel0=GetCell(row,"All disputes subject to Hyderabad Jurisdiction only ",0,"text",false);
                    cel0.style.height="100";
		  cel0.style.textAlign='center'
                    cel0.style.verticalAlign='top'
                    var row=tblLeft.insertRow(tblLeft.rows.length)   
                    var cel0=GetCell(row,"<strong style='font:18px' >"+Type+"</strong>",0,"html",false); 
                    cel0.style.textAlign='center'
                    cel0.style.backgroundColor='GREEN';
                    cel0.style.color='White'; 
                    celLeftMain.appendChild(tblLeft);
                    
         var CelRightMain=MainRow.insertCell(1);       
         CelRightMain.colspan='2'
                    var tblRight=document.createElement('table');
                    tblRight.width='100%';  tblRight.border=0;
                    var row=tblRight.insertRow(tblRight.rows.length)  
                    var cel0=GetCell(row,"",0,"text",false);
                    cel0.colspan='2'
                     var tblTempRight=document.createElement('table');
                    var Row2=tblTempRight.insertRow(tblTempRight.rows.length)  
                    tblTempRight.border=0;tblTempRight.width='100%';
                    tblTempRight.cellspacing=0;tblTempRight.cellpadding=0;
                      var cel01=GetCell(Row2,"",0,"text",false);
                    var imgleft =document.createElement('IMG');
                    imgleft.alt="Image Error";
                    imgleft.src ="../Images/PrintLogos/gubba.bmp";//AppPath +   
                     imgleft.style.width = "220";
                     imgleft.style.height= "80";  
                     cel01.style.vAlign="bottom"; 
                    cel01.appendChild(imgleft);   
                    cel01.style.width="250"; cel01.style.height= "85";  
                    var cel011=GetCell(Row2,"<strong style='font:60px' >"+ds.value.Tables[0].Rows[0].AliasName+"</strong>",1,"html",false);
                      cel011.vAlign='bottom'
                    var Row2=tblTempRight.insertRow(tblTempRight.rows.length)  
                      var cel01=GetCell(Row2,"",0,"text",false); 
                      cel01.colspan='2'                        
                      cel01.innerHTML="&nbsp;&nbsp;&nbsp;<strong style='font:14px;color:green' >&nbsp;"+ds.value.Tables[0].Rows[0].LocationName.split('(')[0]+"</strong>";
                     cel0.appendChild(tblTempRight);
                  // cel0.innerHTML="<strong style='font:18px' >L1</strong>";
                    var row=tblRight.insertRow(tblRight.rows.length)  
                    var cel0=GetCell(row,"Office :",0,"text",false); 
                    cel0.style.textAlign='left'   
                    var celright1=GetCell(row,"3-6-305/43/1, Avantinagar, Basheerbagh,<br/> Hyderabad-500 029-17",1,"html",false);
                    celright1.style.textAlign='left'  
                    
                  
                    
                    var row=tblRight.insertRow(tblRight.rows.length)  
                    var cel0=GetCell(row,"Phone :",0,"text",false); 
                    cel0.style.textAlign='left' 
                    var celright1=GetCell(row,"66787626,66848626 Fax:040-66133626",1,"text",false);  
                    celright1.style.textAlign='left' 
                    
                    
                   var row=tblRight.insertRow(tblRight.rows.length)  
                    var cel0=GetCell(row,"Plant :",0,"text",false); 
                    cel0.style.textAlign='left' 
                    if(ds.value.Tables[0].Rows[0].Address!="")
                        var celright1=GetCell(row,ds.value.Tables[0].Rows[0].Address,1,false);
                    else
                        var celright1=GetCell(row,"Plant Address",1,false);
                     celright1.style.textAlign='left' 
                     
                    
                    var row=tblRight.insertRow(tblRight.rows.length)  
                    var cel0=GetCell(row,"Web :",0,"text",false); 
                    cel0.style.textAlign='left' 
                    var cel1=GetCell(row,"www.gubbagroup.com",1,"text",false);
                     cel1.style.textAlign='left'  
                    
                    var row=tblRight.insertRow(tblRight.rows.length)  
                    var cel0=GetCell(row,"Email :",0,"text",false); 
                    cel0.style.textAlign='left' 
                    var cel1=GetCell(row,"support@gubbagroup.com",1,"text",false);
                    cel1.style.textAlign='left' 
                     
            CelRightMain.appendChild(tblRight); 
}


function GetOutwardPrinting(ds,Image,GrillType)
{  
var hLogin=document.getElementById(ucStockID+'_hLoginUser');
    var TotalBags=0;var TotalKgs=0;
       TotalBags=GetTotal(ds,"Delivered",0);
       TotalKgs=GetTotal(ds,"DeliveredKgs",1);
       var tblTemp=document.createElement('table');
        tblTemp.width='100%';
        tblTemp.border=1; tblTemp.cellpadding=0; tblTemp.cellspacing=1; tblTemp.className='RPTBgcolor';
        GetHeader(tblTemp,"OUTWARD MEMO",Image,ds);
        var MainRow;    
       var MainRow=tblTemp.insertRow(tblTemp.rows.length)   
       var cel0=GetEmptyRow(MainRow,""); 
       var MainRow=tblTemp.insertRow(tblTemp.rows.length)      
       var cel0=GetCell(MainRow,"<strong> S.No</strong>",0,"html",false);   
        cel0.style.textAlign='left'  
        var cel1=GetCell(MainRow,ds.value.Tables[0].Rows[0].OutwardVoucher,1,"text",false)  
        cel1.style.textAlign='left' 
          
        var cel2=GetCell(MainRow,"<strong> Date</strong>",2,"html",false);  
        cel2.style.textAlign='left' 
        var cel3=GetCell(MainRow,ds.value.Tables[0].Rows[0].dtDate.format("dd/MMM/yyyy"),3,"text",false);  
        cel3.style.textAlign='left' 
         
     
       var MainRow=tblTemp.insertRow(tblTemp.rows.length)      
       var cel0=GetCell(MainRow,"<strong> Company</strong>",0,"html",false);  
        cel0.style.textAlign='left' 
        var cel1=GetCell(MainRow,ds.value.Tables[0].Rows[0].Company,1,"text",false)  
        cel1.style.textAlign='left' 
        cel1.colspan=3
        
       
        
        
      
       var MainRow=tblTemp.insertRow(tblTemp.rows.length)      
       var cel0=GetCell(MainRow,"<strong> TotalBags</strong>",0,"html",false);  
        cel0.style.textAlign='left' 
        var cel1=GetCell(MainRow,TotalBags,1,"text",false)   
        cel1.style.textAlign='left' 
        
        
        var cel2=GetCell(MainRow,"<strong> Total Weight</strong>",2,"html",false);  
        cel2.style.textAlign='left' 
        var cel3=GetCell(MainRow,TotalKgs + " kgs ",3,"text",false);  
        cel3.style.textAlign='left' 
        
        var MainRow=tblTemp.insertRow(tblTemp.rows.length)      
        var cel0=GetCell(MainRow,"<strong> InTime</strong>",0,"html",false);  
        cel0.style.textAlign='left' 
        var cel1=GetCell(MainRow,ds.value.Tables[0].Rows[0].InTime,1,"text",false)   
        cel1.style.textAlign='left' 
        
        
        var cel2=GetCell(MainRow,"<strong> OutTime</strong>",2,"html",false);  
        cel2.style.textAlign='left' 
        var cel3=GetCell(MainRow,ds.value.Tables[0].Rows[0].OutTime,3,"text",false);  
        cel3.style.textAlign='left' 
        
        
        var MainRow=tblTemp.insertRow(tblTemp.rows.length)      
       var cel0=GetCell(MainRow,"<strong> Vehicle</strong>",0,"html",false);  
        cel0.style.textAlign='left' 
        var cel1=GetCell(MainRow,ds.value.Tables[0].Rows[0].VehicleNo,1,"text",false)  
        cel1.style.textAlign='left' 
         
         
        var cel=GetCell(MainRow,"",2,"text");  
        cel.colspan=2;
        var tbl=document.createElement('table')
        var tempRow=tbl.insertRow(tbl.rows.length);  tbl.width='100%';tbl.border=0;
        var cel0=GetCell(tempRow,"<strong>Grill In</strong>",0,"html",false)
         cel0.style.textAlign='left'
         if(ds.value.Tables[0].Rows[0].ReservationSeqo>0)
            var cel1=GetCell(tempRow,"YES",1,"text",false)
        else
            var cel1=GetCell(tempRow,"NO",1,"text",false)
            
         cel1.style.textAlign='left'
        var cel2=GetCell(tempRow,"Grill Out",2,"html",false)  
        cel2.style.textAlign='left' 
        if(ds.value.Tables[0].Rows[0].ReservationSeqo==-1)
         var cel3=GetCell(tempRow,"YES",3,"text",false)
        else
          var cel3=GetCell(tempRow,"NO",3,"text",false)
        cel3.style.textAlign='left' 
        cel.appendChild(tbl);
        
        var MainRow=tblTemp.insertRow(tblTemp.rows.length)      
        var cel0=GetCell(MainRow,"<strong> Remarks</strong>",0,"html",false);  
        cel0.style.textAlign='left' 
        var cel1=GetCell(MainRow,ds.value.Tables[0].Rows[0].Remarks,1,"text",false)   
        cel1.style.textAlign='left' 
        cel1.colspan=3
        var MainRow=tblTemp.insertRow(tblTemp.rows.length)   
        var cel0=GetEmptyRow(MainRow,""); 

        var MainRow=tblTemp.insertRow(tblTemp.rows.length)   
        var cel0=GetEmptyRow(MainRow,"<strong>PALLET DETAILS</strong>");  
         
        var MainRow=tblTemp.insertRow(tblTemp.rows.length)   
        var cel0=GetEmptyRow(MainRow,"");  
        GetGridOutward(cel0,ds,TotalBags,TotalKgs);
        
        var MainRow=tblTemp.insertRow(tblTemp.rows.length)   
        var cel0=GetEmptyRow(MainRow,""); 

        var MainRow=tblTemp.insertRow(tblTemp.rows.length)      
        var cel0=GetCell(MainRow,"<strong> Signature of Representative/Driver</strong>",0,"html",false );  
        cel0.style.textAlign='left' 
        var cel1=GetCell(MainRow,"......................................",1,"text",false)  
        cel1.style.textAlign='left' 
        cel1.style.height='20px'

        var cel2=GetCell(MainRow,"<strong> Signature</strong>",2,"html",false);  
        cel2.style.textAlign='left' 
        var cel3=GetCell(MainRow,"......................................",3,"text",false);  
        cel3.style.textAlign='left' 
        
        
         var MainRow=tblTemp.insertRow(tblTemp.rows.length)      
        var cel0=GetCell(MainRow,"<strong> Name</strong>",0,"html",false);  
        cel0.style.textAlign='left' 
        var cel1=GetCell(MainRow,ds.value.Tables[0].Rows[0].RepName,1,"text",false)  
        cel1.style.textAlign='left' 
         cel1.style.height='20px'

 
        var cel2=GetCell(MainRow,"<strong> Supervisor</strong>",2,"html",false);  
        cel2.style.textAlign='left' 
        var cel3=GetCell(MainRow,ds.value.Tables[0].Rows[0].StrUserID,3,"text",false);  
        cel3.style.textAlign='left' 
        
        
var winPrint=window.open("","","height=800,width=750, location=center,toolbar=no,menubar=no,scrollbar=yes,resizable=yes");
var strStyle=".grheader{background-image:url(../images/gr-hdr.gif);background-repeat:repeat-x;color:#474646;text-align:center;height:20px;}";
strStyle+=".acoff1{background-color:#F8F8F8;}.acoff2{background-color:#FFFFFF;}";
strStyle+="body,td,th{font:normal 11px Arial; color:#474646}";
winPrint.document.write("<style>"+strStyle+"</style>");
winPrint.document.write(tblTemp.outerHTML)
winPrint.document.close();
 winPrint.print();
winPrint.close();

}

function GetGridOutward(Cell,ds,iTotalBags,iTotalKgs)
{  
var i; 
var tblGrid=document.createElement('table');
Cell.appendChild(tblGrid);tblGrid.width='100%';tblGrid.border=0
tblGrid.style.backgroundColor='#CFCFCF'
var row=tblGrid.insertRow(tblGrid.rows.length)
if((tblGrid.rows.length%2)==0)
row.className="acoff2";
else
row.className="acoff1";  
var Cell=GetCell(row,"<strong>Incoming Memo</strong>",0,"html",false);
Cell.className='grheader'; 
var Cell=GetCell(row,"<strong>Pallet/Bay</strong>",1,"html",false);
Cell.className='grheader';
var Cell=GetCell(row,"<strong>Bags</strong>",2,"html",false);
Cell.className='grheader';
var Cell=GetCell(row,"<strong>Kgs</strong>",3,"html",false);
Cell.className='grheader';
var Cell=GetCell(row,"<strong>Lot No</strong>",4,"html",false);
Cell.className='grheader';
var Cell=GetCell(row,"<strong>Chamber</strong>",5,"html",false);
Cell.className='grheader';
var Cell=GetCell(row,"<strong>Product</strong>",6,"html",false);
Cell.className='grheader';
for(i=0;i<ds.value.Tables[0].Rows.length;i++)
{
    var row=tblGrid.insertRow(tblGrid.rows.length)
    if((tblGrid.rows.length%2)==0)
    row.className="acoff2";
    else
    row.className="acoff1"; 
    var Cell=GetCell(row,ds.value.Tables[0].Rows[i].Inwardvoucher,0,"html",false);
    Cell.className='grheader';
     var Cell=GetCell(row,ds.value.Tables[0].Rows[i].RackName,1,"html",false);
    Cell.className='grheader';
    var Cell=GetCell(row,ds.value.Tables[0].Rows[i].Delivered,2,"html",false);
    Cell.className='grheader';
    var Cell=GetCell(row,ds.value.Tables[0].Rows[i].DeliveredKgs,3,"html",false);
    Cell.className='grheader';
    var Cell=GetCell(row,ds.value.Tables[0].Rows[i].Lot,4,"html",false);
    Cell.className='grheader';
    var Cell=GetCell(row,ds.value.Tables[0].Rows[i].ChamberName,5,"html",false);
    Cell.className='grheader';
    var Cell=GetCell(row,ds.value.Tables[0].Rows[i].ProductName,6,"html",false);
    Cell.className='grheader'; 
}
 
    if (i < 19)
    {
    for (; i < 19; i++)
    { 
        var row=tblGrid.insertRow(tblGrid.rows.length) 
        row.style.backgroundColor="#FFFFFF"; 
        for(var j=0;j<7;j++)
        {  var Cell=GetCell(row,"",j,"html",false);
            Cell.className='grheader';
         
        } 
        
    }
   }
 var row=tblGrid.insertRow(tblGrid.rows.length)
  var Cell=GetCell(row,"",0,"html",false);
Cell.className='grheader';
 var Cell=GetCell(row,"<strong>Total</strong>",1,"html",false);
Cell.className='grheader';
var Cell=GetCell(row,"<strong>"+iTotalBags+"</strong>",2,"html",false);
Cell.className='grheader';
var Cell=GetCell(row,"<strong>"+iTotalKgs+"</strong>",3,"html",false);
Cell.className='grheader';
for(var j=4;j<7;j++)
{
var Cell=GetCell(row,"",j,"html",false);
Cell.className='grheader';
} 
}


