// JavaScript Document
function alternateRowColors() {
	var className = 'pipetables';
	var classNameTwo = 'specialstable';
	var rowcolor = '#eeeeee';
	var rows, arow;
	var tables = document.getElementsByTagName("table");
	var rowCount = 1;
	for(var i=1;i<tables.length;i++) {
		//dump(tables.item(i).className + " " + tables.item(i).nodeName + "\n");
		if(tables.item(i).className == className) {
			atable = tables.item(i);
			rows = atable.getElementsByTagName("tr");
			for(var j=0;j<rows.length;j++) {
				arow = rows.item(j);
				if(arow.nodeName == "TR") {
					if(rowCount % 2) {
						arow.style.backgroundColor = rowcolor;
					} else {
						// default case
					}
					rowCount++;
				}
			}
			rowCount = 0;
		}
		
		if(tables.item(i).className == classNameTwo) {
			atable = tables.item(i);
			rows = atable.getElementsByTagName("tr");
			for(var j=1;j<rows.length;j++) {
				arow = rows.item(j);
				if(arow.nodeName == "TR") {
					if(rowCount % 2) {
						arow.style.backgroundColor = rowcolor;
					} else {
						// default case
					}
					rowCount++;
				}
			}
			rowCount = 0;
		}
	}
}

/**************************************************
PopUp DocViewer
- opens document inside a popup browser window
(granted appropriate software/plugin is installed)

(c) 2003 Glenn G. Vergara     http://www21.brinkster.com/gver/

MS Office documents open inside IE (.doc, .xls, .ppt)
Acrobat documents open inside IE, Netscape4 and Netscape6 (.pdf)
Shockwave files open inside IE and Netscape6 (.swf)
*************************************************/

function openDoc(filename,target,windowTitle){
        
        //to ensure no global variable conflict with other script
        var strWinHandle = target + "objDocWin"; 
        
        //just focus to the corresponding window if it is already open
        if (window[strWinHandle] && !window[strWinHandle].closed){
                window[strWinHandle].focus();
                return false;
        }
        
        //open blank page
        window[strWinHandle] = window.open('',target,'menubar=1,location=0,toolbar=0,resizable=1,status=0');
                
                //change window name (target); later, target will be used as frame name
                window[strWinHandle].name = strWinHandle; 
        
        //create frameset with only 1 frame     
        var strHTML = '<html>\r\n<head>\r\n';
        //window title defaults to filename if not specified
        var winTitle = (windowTitle) ? windowTitle:filename.substring(filename.lastIndexOf("/")+1);
        strHTML += '<title>'+winTitle+'</title>\r\n';
        strHTML += '</head>\r\n';
        strHTML += '<frameset onload="window.focus()" rows="92,*" border="0" frameborder="0" framespacing="0">\r\n';
        strHTML += '<frame name="topFrame" src="frame_top.html" scrolling="NO" noresize>\r\n';
		strHTML += '<frame name="'+target+'" src="about :blank" onload="window.focus()">\r\n'; //set target as frame name
        strHTML += '</frameset>\r\n';
        strHTML += '</html>';
        window[strWinHandle].document.write(strHTML);
        window[strWinHandle].document.close();
		onload = frames[1].focus();
        
        //put a little delay; Netscape6 causes a null document object when called directly
        setTimeout('loadDoc("'+strWinHandle+'","'+target+'","'+filename+'")',0);
        
        return false; //this cancels href of the calling link
}

function loadDoc(strWinHandle,target,filename){
        //Flash the 'Loading...' message
        var strHTML = '<html><body>';
        strHTML += '<table width="100%" height="100%">';
        strHTML += '<tr><td align="center" valign="middle">';
        strHTML += '<font face="Arial" color="red">Loading...Please wait.</font><br><br>';
        //provide link to close window (for browsers with no appropriate plugin for the needed software)
        strHTML += '<font face="Arial" size="1" color="gray">If you do not have the needed software/plugin to launch the document inside the browser, please <a href="java script:window.close()">close</a> this window.</font>';
        strHTML += '</td></tr></table>';
        strHTML += '</body></html>';
        var winDocFrame = window[strWinHandle].frames[target];
        winDocFrame.document.write(strHTML); //winDocFrame.document is null in Netscape6 if called directly
        winDocFrame.document.close();
        
        //preload the document
        var doc = new Image();
        doc.onerror = function(){
                //check window if still open, the user might have closed it
                if (window[strWinHandle] && !window[strWinHandle].closed){
                        winDocFrame.location.replace(filename); //finally, set frameset's location to the document filename
                }
        }
        doc.src = filename; //onerror handler fires since image src is not actually an image
		
		/***********
		Sample calls: 
		(backward compatible since if javascript is disabled, the document will still be opened in a new window)
		(each link must have different target, target must not have spaces and other special characters except underscore)
		
		for anchor links:
		<a href="docs/file.pdf" target="_pdf" onlick="return openDoc(this.href,this.target,this.alt)" alt="This is document 1">doc 1</a>
		<a href="docs/file2.pdf" target="_pdf2" onlick="return openDoc(this.href,this.target,this.alt)" alt="This is document 2">doc 2</a>
		
		for buttons:
		<input type="button" value="Open doc 1" onclick="openDoc('docs/file.pdf','_pdf','Acrobat File 1')">
		<input type="button" value="Open doc2" onclick="openDoc('docs/file2.pdf','_pdf2','Acrobat File 2')">
		
		for onload popups:
		
		<body onload="openDoc('docs/file.swf','_swf','My ShockWave File')">
		***********/
}