// TTFfuncs.js
// PVA 20040130

//var myWin=0;
var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
// Handle all the the FSCommand messages in a Flash movie
function TFF_DoFSCommand(command, args) {
  var TFFObj = InternetExplorer ? TFF : document.TFF;
//var WindowWidth;
		if (command == "messagebox") {
			alert(args);
			//errorwindow=window.open("","","width=250,height=200");
			//errorwindow.document.write('<title>Javascript Error...</title>');
			//errorwindow.document.write('<center>'+args+'<BR><b>(Error 102 TGIF)</b><Br><form>');
			//errorwindow.document.write('<input type="button" value="Yes" onClick="window.close()">');
			//errorwindow.document.write('<input type="button" value="No" onClick="window.close()">');
			//errorwindow.document.write('</form></center>');
			//errorwindow.document.close();
			//errorwindow.document.bgColor="white";
			//return true;
		}
		// PVA20031205: added function confirm
		if (command == "confirm") {
			var bResult = confirm(args);
			//alert(bResult);
			window.document.TFF.SetVariable("_BrowserResult.value", bResult);
		}		
		if (command == "setW"){
			WindowWidth = args;
			//alert ("WW" + WindowWidth + " args:" + args);
		}
		
//		if (command == "resize") {
//			//alert ("WW" + WindowWidth + " args:" + args);
//			//var intLeft = (screen.width-WindowWidth)/2;
//			var intLeft = (screen.availWidth-WindowWidth)/2;
//			var intHeight = args;
//			if (screen.width=="800"){		
//				var intTop = 0;
//			}else{		
//				//var intTop = (screen.height-575)/2-50;
//				var intTop = (screen.availheight-575)/2-50;
//
//			}
//			var intTop=(screen.height-intHeight)/2;
//			self.resizeTo(WindowWidth ,args);
//			self.moveTo(intLeft ,intTop );
//		}

		if (command == "redirect") {		
			//alert ("redirect to: " + args);
			newWin = window.open(args, "Result", "status=yes,menubar=yes,scrollbars=yes,resizable=yes, width=400, height=400");
			newWin.focus();
			////Window.open(args, "_top", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=600, height=300" );
			////self.resizeTo(WindowWidth ,args);
			//self.close();
		}
		
		// PVA20031217:
		if (command == "newWindow") {		
			//alert ("newWindow to: " + args);
			newWin = window.open(args, "Result", "status=yes,menubar=yes,scrollbars=yes,resizable=yes, width=400, height=400");
			newWin.focus();
		}

		
		if (command == "SetCursor") {
			 document.body.style.cursor = args;
			top.window.status="command: " + command+ " , arg: " +args;
		}

		if (command == "GetCookieValue"){
			var strCookieName = args
			var strResult;
			var search = strCookieName+"=";
			if (document.cookie.length>0) {
				// if there are any cookies
				offset = document.cookie.indexOf(search);
				if (offset != -1) {
					// if cookie exists
					offset += search.length;
					// set index of beginning of value
					end = document.cookie.indexOf(";", offset);
					// set index of end of cookie value
					if (end == -1) {
						end = document.cookie.length;
					}
					strResult = unescape(document.cookie.substring(offset, end));
				}
			}
			window.document.TFF.SetVariable(strCookieName, strResult);
			//alert ("GetCookieValue "+strCookieName+ " value="+strResult);
		}

	//alert("command: " + command+ " , arg: " +args);
}
// Hook for Internet Explorer 
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && 
	  navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<SCRIPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('Sub TFF_FSCommand(ByVal command, ByVal args)\n');
	document.write('  call TFF_DoFSCommand(command, args)\n');
	document.write('end sub\n');
	document.write('</SCRIPT\> \n');
}
//
function statusBar(myText) {
	window.status = myText;
}
//
function JS_Preview(strURL, strTarget){
	//myWin = window.open("targetPreview.asp?URL="+strURL+"&target="+ strTarget);
	//alert (strURL + " - " + strTarget);
	myWin = window.open("targetPreview.asp?URL="+strURL, strTarget);
	myWin.focus();
}
// PVA20040130
function JS_ChangeBackground(strImageURL){
	document.body.background = strImageURL;
	//alert("JS_ChangeBackground: "+strImageURL);
	//alert("JS_ChangeBackground called");
}
