﻿//pageType();

//Get the URL of current page and append ?type=print to it. Open the new page.
function printPage() {
	var append = document.URL;
	if(append!=''){
		var finalURL = append + "?type=print";
	window.open(finalURL);
	}
}

//Get the URL of the current page. If the URL ends in type=print, attach print-friendly styles.
function pageType() {    
  var str = document.URL;
  point = str.lastIndexOf("?");
  var suffix = (str.substring(point+1,str.length));
  if (suffix == "type=print") {
	document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"common/pfriendly.css\">");	
	var d = document.getElementById('innerbody');
	var w = document.getElementById('wrapper');
	var footer = document.getElementById('sub-footer');
    /*var d_main = document.getElementById('wrapper');*/
    var browser=navigator.appName;
    var b_version=navigator.appVersion;
    var version=parseFloat(b_version);
    if ((browser=="Microsoft Internet Explorer") && (version<=6)){
    height = document.getElementById('wrapper').offsetHeight;
    if(height > 1000){
        d_c = d.firstChild;
            while(d_c !=null)
            {
                d_c = d.firstChild;
                if(d_c.id != "sub-footer"){
                    if(d_c.nodeName == "UL" || d_c.nodeName == "LI" || d_c.nodeName == "HR" || d_c.nodeName == "IMG"){
                        w.insertBefore(d_c, d);
                    }
                    else
                    {
                        while(d_c.firstChild != null)
                        {
                            if(d_c.firstChild.nodeName == "UL" || d_c.nodeName == "LI" || d_c.nodeName == "HR" || d_c.nodeName == "IMG"){
                                w.insertBefore(d_c.firstChild, d);
                            }
                            else
                            {
                                while(d_c.firstChild.firstChild != null)
                                {
                                    if(d_c.firstChild.firstChild.nodeName == "UL" || d_c.nodeName == "LI" || d_c.nodeName == "HR" || d_c.nodeName == "IMG"){
                                        w.insertBefore(d_c.firstChild.firstChild, d);
                                    }
                                    else
                                    {
                                        d_c.insertBefore(d_c.firstChild.firstChild, d_c.firstChild);
                                    }
                                }
                            d.insertBefore(d_c.firstChild, d_c);
                            }
                        }
                    w.insertBefore(d_c, d);
                    }
                }
                else{
                w.insertBefore(d_c, d);
                d_c = null;   
                }
            }
    }
    }
	window.print();
    }
}

function popTAF(theURL,winName,features) { //v2.0
  window.open(theURL + "?REFERER=" + location.href,winName,features);
}
