function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function printEventWorkList(file){

var printWin = window.open(file,"reportDefs","toolbar=yes,directories=yes,status=yes,menubar=yes,resizable=yes,scrollbars=yes,width=700,height=420,left=50,top=50"); 
if (navigator.appName == "Netscape")
  {
   if (navigator.appVersion.indexOf('3')>=0)
      printWin.focus();

   if (navigator.appVersion.indexOf('3')<0)
      printWin.opener = self;
   }   
printWin.focus();

}

function FWOnLoad() {   
    if (FwPrevHook) {
        FwPrevHook();     
    }
    FWLoadInit();
}
function printPR(file) {
  
var printWin = window.open(file,"reportDefs","toolbar=yes,directories=yes,status=yes,menubar=yes,resizable=yes,scrollbars=yes,width=700,height=420,left=50,top=50"); 
if (navigator.appName == "Netscape")
  {
   if (navigator.appVersion.indexOf('3')>=0)
      printWin.focus();

   if (navigator.appVersion.indexOf('3')<0)
      printWin.opener = self;
   }   
printWin.focus();
      
}  
function FWHookLoad() {
    var agent = navigator.userAgent;
    var hookPrev = true;
    if (agent.indexOf("MSIE") != -1 && agent.indexOf("Mac_") != -1) {
        hookPrev = false;
    }
    if (hookPrev) {
        FwPrevHook = window.onload;
    } else {
        FwPrevHook = false;
    }
    window.onload = FWOnLoad;
}


/**
* For Benchmark reports and all PDF files of other reports.
*/

function selectDivision(type){
  
  
  dIndex = document.frbmReport.division.selectedIndex;
  selected=document.frbmReport.division.options[dIndex].value;
  
  if( selected =="auto"  ){
   file="/pol/stellent/pdfxml/"+type+"-auto.pdf" ;
  }
  
  if( selected =="beauty"  ){
        file="/pol/stellent/pdfxml/"+type+"-beauty.pdf" ;
  }
  if( selected =="child"  ){
      file="/pol/stellent/pdfxml/"+type+"-child.pdf" ;
  }
  if( selected =="consumables"  ){
      file="/pol/stellent/pdfxml/"+type+"-consum.pdf" ;
  }
  if( selected =="consumables_b"  ){
      file="/pol/stellent/pdfxml/"+type+"-consum-B.pdf" ;
  }
  if( selected =="domestics"  ){
      file="/pol/stellent/pdfxml/"+type+"-dom.pdf" ;
  }
  if( selected =="elec"  ){
      file="/pol/stellent/pdfxml/"+type+"-electronics.pdf" ;
  }
  if( selected =="entertain"  ){
      file="/pol/stellent/pdfxml/"+type+"-entertainment.pdf" ;
  }
  if( selected =="garden"  ){
      file="/pol/stellent/pdfxml/"+type+"-garden.pdf" ;
  }
  if( selected =="gphia"  ){
      file="/pol/stellent/pdfxml/"+type+"-gphia.pdf" ;
  }
  if( selected =="hba"  ){
      file="/pol/stellent/pdfxml/"+type+"-health.pdf" ;
  }
  if( selected =="home_decor"  ){
   file="/pol/stellent/pdfxml/"+type+"-homedec.pdf" ;
  }
  if( selected =="home_impr"  ){
      file="/pol/stellent/pdfxml/"+type+"-homeimp.pdf" ;
  }
  if( selected =="hosiery"  ){
      file="/pol/stellent/pdfxml/"+type+"-inthose.pdf" ;
  }
  if( selected =="jewl_cosm"  ){
      file="/pol/stellent/pdfxml/"+type+"-jewacc.pdf" ;
  }
  if( selected =="men"  ){
      file="/pol/stellent/pdfxml/"+type+"-mens.pdf" ;
  }
  if( selected =="pharm"  ){
      file="/pol/stellent/pdfxml/"+type+"-pharm.pdf" ;
  }
  if( selected =="ready_to_wear"  ){
      file="/pol/stellent/pdfxml/"+type+"-rtw.pdf" ;
  }
  if( selected =="shoes"  ){
      file="/pol/stellent/pdfxml/"+type+"-shoes.pdf" ;
  } 
  if( selected =="sport"  ){
      file="/pol/stellent/pdfxml/"+type+"-sports.pdf" ;
  }
  if( selected =="stationery"  ){
   file="/pol/stellent/pdfxml/"+type+"-stationery.pdf" ;
  }
  if( selected =="toys"  ){
   file="/pol/stellent/pdfxml/"+type+"-toys.pdf" ;
  }
  if( selected =="house_wares"  ){
      file="/pol/stellent/pdfxml/"+type+"-housewares.pdf" ;
  }
  if( selected =="infant"  ){
      file="/pol/stellent/pdfxml/"+type+"-infant-toddler.pdf" ;
  }  
  if( selected =="ir_adv_schedule"  ){
   file="/pol/stellent/pdfxml/e_IR_Adv_Schedule.pdf" ;
  } 
  var pdfWin = window.open(file,"reportDefs","toolbar=no,directories=no,status=no,menubar=no,resizable=yes,scrollbars=yes,width=720,height=520,left=50,top=10");  
  pdfWin.focus();       

  
}

function getReports(){
  
  window.location = "/web-app/pol/reports/reportTemplate.jsp" ;   
} 

function displayReport(){
   
  dIndex = document.frmSandI.departmentId.selectedIndex;
  wIndex = document.frmSandI.endDate.selectedIndex;
  
  if( dIndex == 0 && wIndex == 0){
      //alert("You have to select department  and week .");
      
  }
  else   
  if( dIndex == 0 ){
   //alert("You have to select department .");
      
  }
  else
  if( wIndex == 0){
   //alert("You have to select week .");
      
  }   
  else
  if(dIndex > 0 && wIndex > 0){
   
   document.frmSandI.action="/web-app/pol/reports/sandi_view.jsp?display_view=viewBtn" ;
   document.frmSandI.submit();
  }
}

function displayOts(file){ 
  
  dIndex = document.frmReport.departmentId.selectedIndex;
  wIndex = document.frmReport.endDate.selectedIndex;  
  if( dIndex == 0 && wIndex == 0){
      //alert("You have to select department  and week .");
      
  }
  else 
  if( dIndex == 0 ){
   //alert("You have to select department .");
      
  }
  else
  if( wIndex == 0){
   //alert("You have to select week .");
      
  }   
  else
  if(dIndex > 0 && wIndex > 0){
   
   document.frmReport.action=file;
   document.frmReport.submit();
  }
}   

function displayFrc(file){ 
  //alert("Display frc:");
  dIndex = document.frmSandI.departmentId.selectedIndex;
  wIndex = document.frmSandI.endDate.selectedIndex;   
  if( dIndex == 0 && wIndex == 0){
      //alert("You have to select department  and week .");
      
  }  
  else 
  if( dIndex == 0 ){
   //alert("You have to select department .");
      
  }
  else
  if( wIndex == 0){
   //alert("You have to select week .");
      
  }   
  else
  if(dIndex > 0 && wIndex > 0){
   
   document.frmSandI.action=file;
   document.frmSandI.submit();
  }
}


function selectWeeks(reportName) {
  
  var Index;
  var txtDept;
  var txtURL;
  
  Index      = document.frmReport.departmentId.selectedIndex;
  txtDept   = document.frmReport.departmentId.options[Index].value;
  txtVendorId = document.frmReport.vendorId.value;
  txtCompanyId = document.frmReport.companyId.value;
  
  if (txtDept == "") {  
  }

  else {
   txtURL  = reportName+"&linkName=report&endDate=&departmentId=" + txtDept + "&vendorId=" + txtVendorId + "&companyId=" + txtCompanyId;     
   document.location.replace(txtURL);
       } 
   
  }
  
  function selectWeeksFrc(reportName) {  
      alert("sdfsdfsf"+reportName);
      var Index;
      var txtDept;
      var txtURL;
      alert("FRC change:"+reportName);
      Index      = document.frmSandI.departmentId.selectedIndex;
      txtDept   = document.frmSandI.departmentId.options[Index].value;
      txtVendorId = document.frmSandI.vendorId.value;
      txtCompanyId = document.frmSandI.companyId.value;
      
      if (txtDept == "") {  
      }
    
      else {
       txtURL  = reportName+"&linkName=report&endDate=&departmentId=" + txtDept + "&vendorId=" + txtVendorId + "&companyId=" + txtCompanyId;     
       alert("FRC change URL:"+txtURL);
       document.location.replace(txtURL);
           } 
       
  }
  
function printOts(file) {
  document.frmReport.submit();
  dIndex = document.frmReport.departmentId.selectedIndex;
  wIndex = document.frmReport.endDate.selectedIndex;
  dText = document.frmReport.departmentId.options[dIndex].value;    
  wText = document.frmReport.endDate.options[wIndex].value; 
  if( dIndex == 0 && wIndex == 0){
   //alert("You have to select department  and week .");
  }
  else  
  if( dIndex == 0 ){
   //alert("You have to select department .");
  }
  else
  if( wIndex == 0){
   //alert("You have to select week .");
  }   
  else
  if(dIndex > 0 && wIndex > 0){
  file = file+"&departmentId="+dText+"&endDate="+wText ;
  
   var printWin = window.open(file,"reportDefs","toolbar=yes,directories=yes,status=yes,menubar=yes,resizable=yes,scrollbars=yes,width=700,height=420,left=50,top=50"); 
            printWin.focus();
      }
}

function printSandi(file) {
  
  //document.frmSandI.submit();
  setTimeout("document.frmSandI.submit();", 2000);
  dIndex = document.frmSandI.departmentId.selectedIndex;
  wIndex = document.frmSandI.endDate.selectedIndex;
  dText = document.frmSandI.departmentId.options[dIndex].value;    
  wText = document.frmSandI.endDate.options[wIndex].value;  
  if( dIndex == 0 && wIndex == 0){
   
  }
  else 
  if( dIndex == 0 ){
   
  }
  else
  if( wIndex == 0){
   
  }   
  else
  if(dIndex > 0 && wIndex > 0){
  file = file+"&departmentId="+dText+"&endDate="+wText ;
  
   var printWin = window.open(file,"reportDefs","toolbar=yes,directories=yes,status=yes,menubar=yes,resizable=yes,scrollbars=yes,width=700,height=420,left=50,top=50"); 
            printWin.focus();
      }
}

function printFrd(file) {  

  document.frmSandI.submit();
  
  dIndex = document.frmSandI.departmentId.selectedIndex;
  
  dText = document.frmSandI.departmentId.options[dIndex].value;    
  
  if( dIndex == 0 && wIndex == 0){
   
  }
  else 
  if( dIndex == 0 ){
   
  }   
  if(dIndex > 0 ){
  file = file+"&departmentId="+dText ;  
   var printWin = window.open(file,"reportDefs","toolbar=yes,directories=yes,status=yes,menubar=yes,resizable=yes,scrollbars=yes,width=700,height=420,left=50,top=50"); 
   printWin.focus();
  }
}

function printAP(file) {
  
var printWin = window.open(file,"reportDefs","toolbar=yes,directories=yes,status=yes,menubar=yes,resizable=yes,scrollbars=yes,width=700,height=420,left=50,top=50"); 
if (navigator.appName == "Netscape")
  {
   if (navigator.appVersion.indexOf('3')>=0)
      printWin.focus();

   if (navigator.appVersion.indexOf('3')<0)
      printWin.opener = self;
   }   
printWin.focus();
      
}  
function popup(page,name,w,h,winstring)
{
  var win=window.open(page,name,winstring + ',width=' + w + ',height=' + h);

  if (navigator.appName == "Netscape")
  {
   if (navigator.appVersion.indexOf('3')>=0)
      win.focus();

   if (navigator.appVersion.indexOf('3')<0)
      win.opener = self;
   }
   win.focus();   
}

function viewReport()     
{ 
  
  var rptTitle=document.frmSandI.reportTitle.value;
  var bn="yes";   
  var view="YES" ;
    if (navigator.userAgent.indexOf("MSIE") > -1)
    {
      dIndex = document.frmSandI.departmentId.selectedIndex;   
      dText = document.frmSandI.departmentId.options[dIndex].value;    
      wIndex = document.frmSandI.endDate.selectedIndex;
      wText = document.frmSandI.endDate.options[wIndex].value;
     
          if( wText=="NO" ){
            bn="NO" ;
         }
         
      window.location = "/web-app/pol/reports/reportTemplate.jsp?departmentIdId=" + dText + "&endDate=" + wText + "&displayButton="+bn+"&reportTitle="+rptTitle+"&rptView="+view;
    } else {
        dIndex = document.navigation.document.frmSandI.departmentId.selectedIndex;
        dText = document.navigation.document.frmSandI.departmentId.options[dIndex].value;      
        wIndex = document.navigation.document.frmSandI.endDate.selectedIndex;
        wText = document.navigation.document.frmSandI.endDate.options[wIndex].value;
        if( dText=="NO" ){
                     bn="NO" ;
         }
        window.location = "/web-app/pol/reports/reportTemplate.jsp?departmentIdId=" + dText + "&endDate=" + wText + "&displayButton="+bn+"&reportTitle="+rptTitle+"&rptView="+view;
      }
    }
  
/*---end of report.jsp functions--*/

/**
  Script functions for AVP reports
*/
function selectDept(file)
{

 var Index;
 var txtDPC;
 var txtURL;
 Index      = document.frmReport.DPC.selectedIndex;
 txtDPC     = document.frmReport.DPC.options[Index].value;
  if (txtDPC == "" || txtDPC=="DEPTCLASS") { 
   }
  else
  {
  
  txtURL = file+"&DPC="+txtDPC ;
  
  document.location.replace(txtURL);
  }
}

function selectItem(file)
{
  var Index;
  var txtDPC;
  var txtITEM;
  var txtURL;
  Index      = document.frmReport.DPC.selectedIndex;
  txtDPC     = document.frmReport.DPC.options[Index].value;

  Index      = document.frmReport.ITEM.selectedIndex;
  txtITEM    = document.frmReport.ITEM.options[Index].value;

  if(txtDPC=="" || txtITEM=="" || txtDPC=="DEPTCLASS" || txtITEM=="ITEM"  )
  {
  }
  else
  {
  
  txtURL = file+"&DPC="+ txtDPC + "&ITEM="+txtITEM;
  
  document.location.replace(txtURL);
  } 
}


function avpReport(file)
{
  var Index;
  var txtDPC;
  var txtITEM;
  var txtWEEKS;
  var txtURL;

 Index      = document.frmReport.DPC.selectedIndex;
 txtDPC     = document.frmReport.DPC.options[Index].value;

 Index      = document.frmReport.ITEM.selectedIndex;
 txtITEM    = document.frmReport.ITEM.options[Index].value;

 Index      = document.frmReport.WEEKS.selectedIndex;
 txtWEEKS    = document.frmReport.WEEKS.options[Index].value;

  if(txtDPC=="" || txtITEM=="" || txtDPC=="DEPTCLASS" || txtITEM=="ITEM"  || txtWEEKS=="WEEKS"  )
  {
  }
  else
  {
  
  
  txtURL = file+"&DPC="+ txtDPC + "&ITEM="+txtITEM+"&WEEKS="+txtWEEKS+"&generate=report";
  
  document.location.replace(txtURL);
  } 
}





function printAvp(file)
{
  
  setTimeout("document.frmReport.submit();", 5000);  
  
  var Index;
  var txtDPC;
  var txtITEM;
  var txtWEEKS;
  var txtURL;
  
  
 Index      = document.frmReport.DPC.selectedIndex;
 txtDPC     = document.frmReport.DPC.options[Index].value;

 Index      = document.frmReport.ITEM.selectedIndex;
 txtITEM    = document.frmReport.ITEM.options[Index].value;

 Index      = document.frmReport.WEEKS.selectedIndex;
 txtWEEKS    = document.frmReport.WEEKS.options[Index].value;

  if(txtDPC=="" || txtITEM=="" || txtDPC=="DEPTCLASS" || txtITEM=="ITEM"  || txtWEEKS=="WEEKS"  )
  {
  }
  
  else
  {  
    txtURL = file+"&DPC="+ txtDPC + "&ITEM="+txtITEM+"&WEEKS="+txtWEEKS+"&generate=report";         
  
    var printWin = window.open(txtURL,"reportDefs","toolbar=yes,directories=yes,status=yes,menubar=yes,resizable=yes,scrollbars=yes,width=700,height=420,left=50,top=50"); 
    if (navigator.appName == "Netscape")
    {
      if (navigator.appVersion.indexOf('3')>=0)
          printWin.focus();   
    
        if (navigator.appVersion.indexOf('3')<0)
          printWin.opener = self;
      }       
  printWin.focus();  
  }
  
}
/** AVP report script functions end.*/

/**
IR Reports
*/

function popPdf(file){   
    //alert("gfdsg:"+file);
    var pdfWin = window.open(file,"reportDefsPdf","toolbar=yes,directories=no,status=no,menubar=no,resizable=yes,scrollbars=yes,width=720,height=520,left=50,top=10");  
      pdfWin.focus();
}

// Download Refresh
 function startReloadAvp(from) {    
       if( from == "avp") {       
       setTimeout("document.frmReport.submit();", 30000);      
       }
}

function startReload(from) {  
  if(from == "ots"){
      setTimeout("document.frmReport.submit();", 10000);      
  }
  if(from == "si" || from == "frc" || from == "frd" || from == "vrc"){
        setTimeout("document.frmSandI.submit();", 20000);      
    }
}


/**
ITEM REPORTS PRINT FUNCTIONS
*/

function printItem(file)
{
  var printWin = window.open(file,"vendreport","toolbar=yes,directories=yes,status=yes,menubar=yes,resizable=yes,scrollbars=yes,width=700,height=420,left=50,top=50"); 
  printWin.focus();   
  
}

/**
 *POM REPORTS PRINT FUNCTIONS
 */
function printPOM(file)
{
  var printWin = window.open(file,"pomreport","toolbar=yes,directories=yes,status=yes,menubar=yes,resizable=yes,scrollbars=yes,width=700,height=420,left=50,top=50"); 
  printWin.focus();   
}


/**
 *POM Disclaimer window
 */
function openPomDisclaimer()
{
  var disclaimerWin = window.open("/pol/stellent/pages/e_ePOM_Disclaimer.jsp","subWindow","HEIGHT=500,WIDTH=700,scrollbars=yes"); 
  disclaimerWin.focus();   
}

/*********************
* My account info page
**********************/
function myAccountInfo()
{
   var win = window.open("/pol/stellent/pages/e_AFP_Info.jsp","myAccount","toolbar=no,directories=no,status=no,menubar=no,resizable=no,scrollbars=yes,width=700,height=420,left=50,top=50");
   //win.title = "PartnersOnline.com - My Vendor Profile Instructions Page";
   win.focus();
}

