// JScript File

// getElementById Special to handle quirky browsers
// most will use getElementById()
function getElementById_s(id){
    var obj = null;
    
    if(document.getElementById){
    /* Prefer the widely supported W3C DOM method, ifavailable:-*/

        //alert("yap1");
        obj = document.getElementById(id);
    
    }else if(document.all){

        /* Branch to use document.all on document.all only browsers. Requires that IDs are unique to the page
        and do not coincide with NAME attributes on otherelements:- */
        
        //alert("yap2");
        obj = document.all[id];
    
    }
    
    /* If no appropriate element retrieval mechanism exists on this browser this function always returns null:-*/
    //alert("returned obj is " + obj);
    return obj;
}


//*******************************************************************************
// Function:     printPopupContent
// Author:       michael.chu@cgi.com
// Project:      iMove Build - 0.3
// Date:         Sep 21 2006
//
// Description:  This function generates a new popup which resembles the friendly 
//               version of the page. It uses the id of the HTML element that is
//               named specifically "contentPrint". It can only be used once
//               on each page, otherwise it should return the first element with
//               this name and might cause unexpected behaviour.
//               Example of usage includes the following:
//               <div id="contentPrint" name="contentPrint">...</div>
//               <td id="contentPrint" name="contentPrint">...</td>
//               <p id="contentPrint" name="contentPrint">...</p>
//               etc.
// Parameters:	 
// Returns:	     
// Calls:        
// Called By:    PrintAndHelp.acsx
//
// Revision History:
//
//   Name        Date        Description
//  ------       ------      ------------------------------------------------
//
//*******************************************************************************
function printPopupContent(contentId) {

    var errorMessage = "Oops - there's been an error delivering your Printer Friendly page. We're sorry for the inconvenience. Please contact webmaster@i-move.ca and let us know you've had a problem.";

    if ((contentId == null) || (contentId == ""))
        contentId = "contentPrint";

    // get the content element
    //var content = document.getElementById(contentId);
    var content = getElementById_s(contentId);
    
    // check if content exist
    if (content == null)
    {
        alert (errorMessage);
        return;
    }



    // get its content
    var html = content.innerHTML;

    var help1TestInt;
    var help2TestInt;
    var print1TestInt;
    var print2TestInt;            

    //check to see if this help icon is in the html, if so, hide it
    help1TestInt = html.indexOf('atis-flash-i-help.gif');   
    if (help1TestInt != -1){        
        html = html.replace(/atis-flash-i-help.gif/, "blankPixel.gif");
    }
    
    //check to see if this help icon is in the html, if so, hide it
    help1TestInt = html.indexOf('atis-i-help2.gif');   
    if (help1TestInt != -1){        
        html = html.replace(/atis-i-help2.gif/, "blankPixel.gif");
    }

    //check to see if this help icon is in the html, if so, hide it
    help1TestInt = html.indexOf('atis-flash-i-print.gif');   
    if (help1TestInt != -1){        
        html = html.replace(/atis-flash-i-print.gif/, "blankPixel.gif");        
    }

    //check to see if this help icon is in the html, if so, hide it
    help1TestInt = html.indexOf('atis-i-print2.gif');   
    if (help1TestInt != -1){        
        html = html.replace(/atis-i-print2.gif/, "blankPixel.gif");
    }

    
    //alert(html);
    
    // get the document's title
    var title = document.title;
    var arrayCss = document.styleSheets;   
    
    // if there is content inside the tag, open a new popup page
    // otherwise alert user about the error.
    if (html != "") {
        printWindow = window.open("","_blank","location=no,menubar=yes,resizable=yes,scrollbars=yes,status=yes,titlebar=yes,toolbar=yes");
        printWindow.document.open();
        printWindow.document.writeln("<HTML>\n<HEAD>\n");

    for (i=0;i<arrayCss.length;i++)
        {
            printWindow.document.writeln("<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"" + arrayCss[i].href + "\">\n");
        }

    // manually add stylesheet for header
    //printWindow.document.writeln("<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"/ATIS/App_Themes/ATIS/popup-cam.css\">\n");

        printWindow.document.writeln("</HEAD>\n<BODY style=\"background-image:none;\">\n");

        headerHtml = "<!-- Popup Header -->";
        headerHtml += "<div id=\"iMovePopupHeader\">";
        headerHtml += "<div id=\"iMovePopupHeaderTitle\">";
        headerHtml += "<img id=\"iMoveHeaderImage\" src=\"/ATIS/App_Themes/ATIS/images/atis-popup-generic.jpg\" alt=\"iMove\" />"
        headerHtml += "</div>";
        headerHtml += "</div>";
        headerHtml += "<!-- End Popup Header -->";
        
       //var yoyo = "<!-- Start Body Content --><IMG height=15 alt='Body Header' src='/ATIS/App_Themes/ATIS/images/atis-MHeader.gif' width=612><DIV class=bdCenterContent><DIV class=contentPadding><DIV class=tools id=toolsLinks><A id=printLink href='javascript:printPopupContent();'><IMG id=printIcon alt=print hspace=5 src='/ATIS/App_Themes/ATIS/images/atis-i-print2.gif' border=0></A> <A id=_ctl0_ContentPlaceHolder1_PrintAndHelp1_helpLink onclick='this.href = 'javascript:myVoid()';helpFilePopupContent('/SiteTools/Help');' href='../../UserControls/Public/#'><IMG id=helpIcon alt=help src='/ATIS/App_Themes/ATIS/images/atis-i-help2.gif' border=0></A> </DIV><H1><SPAN id=_ctl0_ContentPlaceHolder1_HtmlPlaceholderControl1><P>Highways</P></SPAN></H1><SPAN id=_ctl0_ContentPlaceHolder1_HtmlPlaceholderControl2><P align=justify>Ullamcorper auciisl massa mollis.</P></SPAN><SPAN id=_ctl0_ContentPlaceHolder1_SingleImagePlaceholderControl1></SPAN></DIV>&nbsp;</DIV><IMG height=12 alt='Body Footer' src='/ATIS/App_Themes/ATIS/images/atis-MFooter.gif' width=612>";
        //printWindow.document.writeln("<table width=100% border=0><tr><td align='left'>");
        
        printWindow.document.writeln(headerHtml);
        
        //alert("html is:'" + html + "'");
        
        //printWindow.document.writeln(yoyo);
        printWindow.document.writeln(html);
        //printWindow.document.writeln(htmlBB);
        
        //printWindow.document.writeln("</td></tr></table>");
        
        //michaels print code        
        //printWindow.document.writeln(html);
        printWindow.document.writeln("</body>");
        printWindow.document.writeln("</html>");
        printWindow.document.close();
        printWindow.document.title = title + " (Printer Friendly)";
        printWindow.focus();
    } 
    
    content = null;

}

//*******************************************************************************
// Function:     printPopupContent
// Author:       michael.chu@cgi.com
// Project:      iMove Build - 0.3
// Date:         Sep 21 2006
//
// Description:  This function generates a new popup which resembles the friendly 
//               version of the page. It uses the id of the HTML element that is
//               named specifically "contentPrint". It can only be used once
//               on each page, otherwise it should return the first element with
//               this name and might cause unexpected behaviour.
//               Example of usage includes the following:
//               <div id="contentPrint" name="contentPrint">...</div>
//               <td id="contentPrint" name="contentPrint">...</td>
//               <p id="contentPrint" name="contentPrint">...</p>
//               etc.
// Parameters:	 
// Returns:	     
// Calls:        
// Called By:    PrintAndHelp.acsx
//
// Revision History:
//
//   Name        Date        Description
//  ------       ------      ------------------------------------------------
//
//*******************************************************************************
function helpFilePopupContent(helpFile) {
    //window.open(helpFile,'_blank','width=650,height=670,scrollbars=1');
    
    //Brian NOTE:  changed width above from 650 to 655 to avoid horizontal scrollbar
    window.open(helpFile,'_blank','width=655,height=670,scrollbars=1');
}
//*******************************************************************************
// Function:     myVoid
// Author:       michael.chu@cgi.com
// Project:      iMove Build - 0.3
// Date:         Sep 21 2006
//
// Description:  This function simply does nothing so that the navigation link
//               that open a new window will not have anything return to it.
//               It is used in conjunction with the above function as follows:
//               <a href="#" onclick="this.href = 'javascript:myVoid()';helpFilePopupContent('navigationUrl');">link</a>
// Parameters:	 
// Returns:	     
// Calls:        
// Called By:    
//
// Revision History:
//
//   Name        Date        Description
//  ------       ------      ------------------------------------------------
//
//*******************************************************************************
function myVoid() { }
