// JScript source code
var NewWindow = '';

function isIE() {
	var browserName = navigator.appName;
	
	if (-1 == browserName.indexOf("Explorer", 0)) {
		return false;
	}
	return true;
}

function ShowSingleGraph(Title, TargetURL) {
/*
	if NewWindow.document is not defined chances are you are refreshing
	the Popup and it is not in scope, it can now be referenced with
	the window Object.
*/
	if (!NewWindow.document) {
		NewWindow = window;	
	}
	if (!NewWindow.document) {
		alert("NewWindow.document still undef");
		return;
	}
	var PopupDoc = NewWindow.document;
//	PopupDoc.open();	
	PopupDoc.writeln('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">');
	PopupDoc.writeln('<html>\n<head>');
	PopupDoc.writeln('<script type="text/javascript" src="MainGraphs.js"></script>');
	PopupDoc.writeln('<meta http-equiv="Refresh" content="60;URL=javascript:ShowSingleGraph(\'' + Title + '\', \'' + TargetURL +'\')"/>');
//	PopupDoc.writeln('<meta http-equiv="Refresh" content="10;URL=http://av.com"/>');
	PopupDoc.writeln('<meta http-equiv="Pragma" content="no-cache">');
	PopupDoc.writeln('<meta http-equiv="Expires" content="-1">');
	PopupDoc.writeln('<link rel="stylesheet" type="text/css" media="all" href="w.css">');
	PopupDoc.writeln('<title>' + Title + '</title>');
	PopupDoc.writeln('</head>');
	PopupDoc.writeln('<body>');
	PopupDoc.writeln('<table>\n<tr><td>');
	PopupDoc.writeln('<img src="' + TargetURL + '">');
	PopupDoc.writeln('</td></tr>');
	if (isIE()) {
		PopupDoc.writeln('<tr><td align="center"><a href="javascript:ShowSingleGraph(\'' + Title + '\', \'' + TargetURL +'\')">Refresh</a></td></tr>');
	}
	else {
		PopupDoc.writeln('<tr><td align="center"><b>Press F5 to Refresh</b></td></tr>');
	}
//	PopupDoc.writeln('<tr><td align="center"><a href="javascript:history.go(0)">Refresh2</a></td></tr>');
	PopupDoc.writeln('</table>');
	PopupDoc.writeln('</body>\n</html>');
	
	if (isIE()){
		//This causes the page to load as with out the document.close nothing is displayed
		NewWindow.history.go(0);
		
	}
	else {
		// this crashes IE
		PopupDoc.close();
	}
}

function PopitUp(Title, TargetURL, Width, Height) {
	// the "Handle need's to be assigned to a javascript varible to keep so browsers happy
	Height = Height + 60;
	Width = Width + 25;
	var windOptions = 'top=100, left=100, menubar=yes, resizable=yes, width=' + Width + ', height=' + Height;
	NewWindow = window.open('', 'Title', windOptions);
	
	ShowSingleGraph(Title, TargetURL);
	
	// return false so onclick doesn't actually take us to the link
	return false; 
}
