

//popupTutorial.js
// Author: S. Bhattacharjee
// used by States and all other solve files to popup Tutorial pages. It also
// contains the counters.

var popUpWindow = null;
var windowCount = 0;
var windowName = "popUpWindow";
browser=navigator.appName;
browserVersion=parseInt (navigator.appVersion);

bWEB = true;  //used everywhere
if(window.location.toString().substring(0,4) == "file") {
    bWEB = false;
    URLPATH = '';
}

//// browser detect from quirksmode.org
//var BrowserDetect = {
//	init: function () {
//		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
//		this.version = this.searchVersion(navigator.userAgent)
//			|| this.searchVersion(navigator.appVersion)
//			|| "an unknown version";
//		this.OS = this.searchString(this.dataOS) || "an unknown OS";
//	},
//	searchString: function (data) {
//		for (var i=0;i<data.length;i++)	{
//			var dataString = data[i].string;
//			var dataProp = data[i].prop;
//			this.versionSearchString = data[i].versionSearch || data[i].identity;
//			if (dataString) {
//				if (dataString.indexOf(data[i].subString) != -1)
//					return data[i].identity;
//			}
//			else if (dataProp)
//				return data[i].identity;
//		}
//	},
//	searchVersion: function (dataString) {
//		var index = dataString.indexOf(this.versionSearchString);
//		if (index == -1) return;
//		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
//	},
//	dataBrowser: [
//		{ 	string: navigator.userAgent,
//			subString: "OmniWeb",
//			versionSearch: "OmniWeb/",
//			identity: "OmniWeb"
//		},
//		{
//			string: navigator.vendor,
//			subString: "Apple",
//			identity: "Safari"
//		},
//		{
//			prop: window.opera,
//			identity: "Opera"
//		},
//		{
//			string: navigator.vendor,
//			subString: "iCab",
//			identity: "iCab"
//		},
//		{
//			string: navigator.vendor,
//			subString: "KDE",
//			identity: "Konqueror"
//		},
//		{
//			string: navigator.userAgent,
//			subString: "Firefox",
//			identity: "Firefox"
//		},
//		{
//			string: navigator.vendor,
//			subString: "Camino",
//			identity: "Camino"
//		},
//		{		// for newer Netscapes (6+)
//			string: navigator.userAgent,
//			subString: "Netscape",
//			identity: "Netscape"
//		},
//		{
//			string: navigator.userAgent,
//			subString: "MSIE",
//			identity: "Explorer",
//			versionSearch: "MSIE"
//		},
//		{
//			string: navigator.userAgent,
//			subString: "Gecko",
//			identity: "Mozilla",
//			versionSearch: "rv"
//		},
//		{ 		// for older Netscapes (4-)
//			string: navigator.userAgent,
//			subString: "Mozilla",
//			identity: "Netscape",
//			versionSearch: "Mozilla"
//		}
//	],
//	dataOS : [
//		{
//			string: navigator.platform,
//			subString: "Win",
//			identity: "Windows"
//		},
//		{
//			string: navigator.platform,
//			subString: "Mac",
//			identity: "Mac"
//		},
//		{
//			string: navigator.platform,
//			subString: "Linux",
//			identity: "Linux"
//		}
//	]
//
//};
//BrowserDetect.init();



function switchImage(docID,imageFile,messageText)
{
    if ((browser.substring (0, 8) == "Netscape" && browserVersion >= 3)
        || (browser.substring (0, 9) == "Microsoft" && browserVersion >= 4))
        {
        document[docID].src = "testcentericons/"+imageFile+".jpg";
        window.status=messageText;
    }
}

// opens a float window named popUpWindow for Problems,Tutorial, etc.
function openPopUpWindow(winURL, winWidth, winHeight, winFeatures, winLeft, winTop){
    window.status="The orange colored Task Bar at the bottom provides permanent access to important TEST modules.";
    winFeatures="menubar=no, scrollbars=yes, resizable=yes";
    if(winHeight==600) winHeight=0.9*screen.availHeight;
    var defaultPixelLeft = 200
    var defaultPixelTop = 20
    windowName = "popUpWindow" + windowCount++ //unique name for each pop-up window
    closePopUpWindow()
    if (openPopUpWindow.arguments.length >= 4)
        winFeatures = "," + winFeatures
    else
        winFeatures = ""
    if (openPopUpWindow.arguments.length == 6)
        winFeatures += getLocation(winWidth, winHeight, winLeft, winTop)
    else
        winFeatures += getLocation(winWidth, winHeight, defaultPixelLeft, defaultPixelTop)
    popUpWindow = window.open(winURL, windowName, "width=" + winWidth
        + ",height=" + winHeight +  winFeatures)
    popUpWindow.moveTo(screen.availWidth-winWidth-5,0);
    //alert("executing openPopup in jscript"+winHeight);
    if(winHeight>1000){
        popUpWindow.moveTo(screen.availWidth-winWidth,0)
        popUpWindow.resizeTo(winWidth,screen.availHeight)
    }
}

function closePopUpWindow(){
    if (navigator.appName != "Microsoft Internet Explorer"
        || parseInt(navigator.appVersion) >=4)
        if(popUpWindow != null) if(!popUpWindow.closed) popUpWindow.close()
}



function getLocation(winWidth, winHeight, winLeft, winTop){
    return ""
}



function sizeParent(winWidth, winHeight){
    window.parent.resizeTo(winWidth,winHeight);
}



function writeYear() { //used by copyright
    var date=new Date();
    var yy=date.getFullYear();
    document.write(yy);
}

function handleCounter(){
//----comment out if page count to be turned off.
//document.write('<img src="http://thermo.sdsu.edu/cgi-bin/Count.cgi?sh=F&testpath=' + window.location + '">');

//_uacct = "UA-128479-1";
//urchinTracker();

}


function handleCounterShow(){
    // count without show;
    handleCounter();
//----count with show
//document.write('<br><tt>Since Nov. 1, 2003, this page has been visited  <img src="http://thermo.sdsu.edu/cgi-bin/Count.cgi?trgb=ffffff&dd=E&testpath=' + window.location + '"> times.</tt>');

}



 