function windowOpen(path,params)

{

	window.open(path, "wndw", params);



}

function openErrorPage(szValue)
{
	var szSpace = ": ";
	var index = parseInt(szValue);
	addCookie("ErrorNum", szValue);
	var indexString = szValue+ szSpace;
	var szMsg = indexString + getErrorString(index);
	var urlString = "errorresponse.htm?Error ";
	var urlValue = urlString +  szMsg;
	windowOpen(urlValue,'scrollbars=yes, status=no, toolbar=no, width=1000, height=950,  left=25, top=10');
}


function addCookie(tag, value)

{

	var expireDate = new Date();

	var expireString = "";

	expireDate.setTime(expireDate.getTime() + (1000 * 60 * 60 * 24 * 365));

	expireString = "expires=" + expireDate.toGMTString();

	document.cookie = tag + "=" + escape(value) + ";" + expireString + ";";

}



function getCookie(tag)

{

	var value = null;

	var myCookie = document.cookie + ";";

	var findTag = tag + "=";

	var endPos;



	if (myCookie.length > 0)

	{//

	  	var beginPos = myCookie.indexOf(findTag);

	 	if (beginPos != -1)

	  	{

	     	beginPos += findTag.length;

	     	endPos = myCookie.indexOf(";", beginPos);

	     	if (endPos == -1)

				endPos = myCookie.length;

	     	value = unescape(myCookie.substring(beginPos, endPos));

	     }

	  }//



	return value;

}



function swapImage(doc, image)

{
	doc.src=image;

}

function catalogOpen(srch, params)
{

   	var  newPage = "../new_order.htm?" + srch;

   	location.href = newPage;

 }//***end function***



function setErrorNumber(errorNum)

{

	addCookie("ErrorNum", errorNum);

	var srch = "install_error_definition.htm";

	window.open(srch, "ScreenshotsExt", "scrollbars=yes, resize=yes, toolbar=no, width=700, height=275");



}



function selectPorterLicense(index)

{

	addCookie("PorterModel", index);

	location.href = "porter_v_2_type_select.htm";

}





function changeDownloadPage()

{

	var Index =  getCookie("Product");

	if(Index == 4)

		location.href = "porter_download.htm";

	else

		location.href = "download_cd_select.htm";

}



function  getInstallError(errorNum)

{

	var nVal;



	if(errorNum == 100)

		return 0;

	else if(errorNum == 200)

		return 1;

	else if(errorNum == 102)

		return 2;

	else if(errorNum == 121)

		return 3;

	else if(errorNum == 402)

		return 4;

	else if(errorNum == 647)

		return 6;

	else if(errorNum == 1207)

		return 7;

	else if(errorNum == 72 || errorNum == 418 )

		return 8;

	else if(errorNum == 72 )

		return 9;

	else if(errorNum == 669 || errorNum == 913 || errorNum == 914)

		return 10;

	else if(errorNum == 909 || errorNum == 809)

		return 11;

	else if(errorNum == 33 || errorNum == 43 || errorNum == 631 || errorNum == 632 || errorNum == 1177 || errorNum == 1178 || errorNum == 1179 || errorNum == 1118 || errorNum == 1163 || errorNum == 1283 || errorNum == 1403 || errorNum == 1570)

	 		return 12;

	else if(errorNum == 916 || errorNum == 1273 || errorNum == 1405)

		return 13;

	else if(errorNum == 38 )

		return 14;

	else if(errorNum == 2017  || errorNum == 122 || errorNum == 2016)

		return 15;

	else if(errorNum == 637  || errorNum == 639)

		return 16;

	else if(errorNum == 1491 )

		return 17;

	else if(errorNum == 1355 )

		return 18;

	else if(errorNum == 1357 || errorNum == 1358  || errorNum == 1413 || errorNum == 1414)

		return 19;

	else if(errorNum == 2322 )

		return 20;

	else if(errorNum == 963 || errorNum ==  940 || errorNum == 941)

		return 21;

	else if(errorNum == 1107 )

		return 22;

	else if(errorNum == 1191 || errorNum == 1171 || errorNum == 1172 || errorNum == 1173)

		return 23;

	else if(errorNum == 1189 )

		return 24;

	else if(errorNum == 1109 )

		return 25;

	else if(errorNum == 1164 )

		return 26;

	else if(errorNum == 1406 )

		return 27;

	else if(errorNum == 606)

		return 0;

	else

		return 28;

}



function getCustomError(errorNum)

{

	var nError = getInstallError(errorNum);



	var errorArray = new Array(

		"You have entered the wrong password and/or license ID number in the license activation dialog box.  Please check the data and try again",

		"You have entered the password and license ID number for a different aircraft. For example you are activating a Pilatus porter but you are accidentally using the license information for a Cessna 337.  Please check the data and try again",

		"The byte count for the internal archive of this installer is incomplete. The most likely cause is an incomplete file download.",

		"Invalid data received by our server. The most likely cause is security/firewall software corrupting the data. Try booting your computer in Safe Mode with Networking and see if this helps.",

		"Windows version is not XP or Vista and therefore, is not supported",

		"Invalid Customer name",

		"Invalid license ID entered",

		"Incomplete customer name data entered",

		"Incomplete email address entered",

		"License was not properly validated, or is corrupt. We reccommend running the installer again.",

		"Installation is not authorized on this computer",

		"License could not be read for validation",

		"Server could not be accessed to validate license",

		"Could not install critical driver file",

		"Could not start offline activation",

		"Could not launch data formatting.",

		"Error from background program",

		"Invalid password entered",

		"Windows will not allow formatting of critical data",

		"Could not access critical data for installation.",

		"Windows would not allow creation of installation log.",

		"Windows would not allow critical data to be set",

		"Demo period has expired",

		"Windows would not allow creation of a critical *.ini file",

		"Could not finalize installation data.",

		"Could not import manual activation data from online computer",

		"Could not validate information from server",

		"This error could occur due to a number of causes. Please contact support directly."

	);



	return errorArray[nError];



}



function errorValue(errorNum)

{

	var windowsError = "Problems in your software environment prevented local Windows operations from functioning. This could be due to a resource issue or a corruption in your operating system. Sometimes rebooting can solve this problem. This could also be due to a program running in the background, such as virus scanner, anti-spyware program, Windows \"theme manager\", firewall or network driver that is causing a resource issue. If the problem persists please contact FSD Tech Support for assistance";

	var NoSuchError = "No such error code could be located in the system";

	var IncorrectData = "Invalid data was received by the server. Please contact Technical Support for further assistance.";

	var InsufficientPrivilages = "There are insufficient user permissions to the registry.  Make sure that the program is run from a Windows login that has administrative permissions";

	var InstallError;



	if(errorNum > 3000)

		errorNum -= 3000;







	var errorCode = new Array(

	"The process was successful.",

	"WinSock could not be started. Make sure that the latest version of your web browser is installed properly, and with all the updates.",

	"WinSock could not find Server specified. Verify computer is connected to Internet, and Firewall/Proxy is setup properly.",

	"Invalid data received by our server. The most likely cause is security/firewall software corrupting the data. Try booting your computer in Safe Mode with Networking and see if this helps.",

	"Although you are connected to the Internet, connection with our server cannot be established. This could be an internal problem with our server, or with your Internet/browser security settings.",

	"Winsock could not send data to our server. Check your Internet security/firewall settings. Otherwise, rebooting the computer, or installing the latest version of Internet Explorer will often resolve this.",

	"Winsock could not read the return data from our server. Often rebooting the computer, or installing the latest version of Internet Explorer will resolve this.",

	"Our server log shows that the software has already been installed on another computer. Press \Report\" to notify our technical support staff for assistance.",

	"Contact with our server was established, but the data could not be interpreted through your Winsock. Check your firewall, Internet security or browser security settings.",

	"Windows reports that it cannot allocate enough memory to continue installation. Often rebooting the computer will resolve this problem.",

	"Winsock cannot resolve proxy server. Direct connection to the Internet without a proxy server is required to communicate with our server.",

	"WiniNet is not available on your computer...wininet.dll is a module that contains Internet-related functions used by applications and should not be disabled. This problem can often be caused by a computer virus.",

	"WiniNet is not available on your computer...wininet.dll is a module that contains Internet-related functions used by applications and should not be disabled. This problem can often be caused by a computer virus.",

	"A connection to the Internet could not be established. Check your firewall/Internet security settings and/or your browser security settings.",

	"Windows is reporting that you do not have sufficient administrative privilages to run this program.",

	"Cannot connect to Internet. Verify Internet connection.",

	"Windows is reporting a Winsock buffer overflow. Often rebooting the computer will resolve this problem. Otherwise, check your firewall/Internet settings and/or your browser settings.",

	"Windows reports an intermittent connection to the Internet. This is often caused by a connectivity problem though your ISP, or a problem with your modem/router. Often rebooting the computer will resolve this problem.",

	"Winsock reports an invalid login to your proxy server. Direct connection to the Internet without a proxy server is required to communicate with our server.",

	"Our server is non-responsive. This could be due to a problem on our server, or a connectivity problem though your ISP, or a problem with your modem/router. In such a case rebooting the computer may resolve this problem.",

	"Windows reports that it cannot read and/or create a necessary data file. Often rebooting the computer will resolve this problem.",

	"Corrupt installer. Check to make sure that Windows has not created a duplicate installer in the same directory with a number () appended to it.",

	"You have manually canceled the operation.",

	"While downloading a file, the \Download Dialog box\" could not be created.",

	"Windows reports that it cannot create a necessary data file. Check your computer monitoring/anti-virus of other security software running in the background. Otherwise, rebooting the computer will often resolve this problem.",

	"The item specified is invalid, or non-existent.",

	"Our server reports invalid data received. Check the data you entered and try again.",

	"Upload failed!",

	"Connection timeout with our server.",

	"Your Operating System does not support this program. Only Windows XP and Windows Vista are supported.",

	"The parameter specified is invalid or out of range.",

	"File could not be found on HTTP server."

	);



	if(errorNum <= 33)

		InstallError =  errorCode[errorNum];

	else if(errorNum > 33)

		return getCustomError(errorNum);

	else

		InstallError = NoSuchError;



	return InstallError;

}


function getErrorString(errorNum)

{

	var szResult;



	switch(errorNum)

	{

		case 0:

		szResult = "The error definition will be presented here.";

		break;



		case 1:

		szResult = "The process has succedded!";

		break;



		case 2:

		szResult = "Invalid data entered.  Please check your data and try again.";

		break;



		case 3:

		szResult = "Invalid data received by our server. Please check your data and try again. If problem persists press \"Report\" to notify our technical support staff for assistance.";

		break;



		case 4:

		szResult = "Windows reports a file access error. Often rebooting the computer will resolve this problem. You may also want to check your Windows security permissions. If problem persists press \"Report\" to notify our technical support staff for assistance.";

		break;



		case 5:

		szResult = "Windows write error. This is often caused by attempting to access a \"Read Only\" file, or by insufficient Windows security permissions.";

		break;



		case 6:

		szResult = "Windows reports it cannot close a data file. This is often caused by a resource issues, which can usually be solved by rebooting the computer. Otherwise this is an indication of a corruption of your Windows environment.";

		break;



		case 7:

		szResult = "The default number of license activations (up to 2 computers) has already been reached.  Please contact our technical support staff for assistance.";

		break;



		case 8:

		szResult = "Data file being accessed is empty.";

		break;



		case 9:

		szResult = "A data file could not be created. The most common reason is due to user’s security restrictions.";

		break;



		case 10:

		szResult = "Initialization failure. Archive TOC incomplete. This message means you only downloaded a file fragment.";

		break;



		case 11:

		szResult = "File creation error. This is most likely a Windows permission issue.";

		break;



		case 12:

		szResult = "Our server reports that an invalid password was used. This could also be a problem of data being sent out from your computer encrypted due to a firewall or proxy server.";

		break;



		case 13:

		szResult = "Our server reports invalid data received. Your file may be out of date, requiring replacement. You can get a new file from the Downloads page on our website.";

		break;



		case 14:

		szResult = "Internal data error. Please close this program and try again. This is often caused by a resource issues, which can usually be solved by rebooting the computer.";

		break;



		case 15:

		szResult = "A critical data file could not be found. This is often caused by attempting to access a \"Read Only\" file, or by insufficient Windows security permissions.";

		break;



		case 16:

		szResult = "Windows reports that it cannot allocate enough memory to continue installation. Often rebooting the computer will resolve this problem.";

		break;



		case 17:

		szResult = "Windows reports that the handle to a critical data file was not released after the file was closed or created.This is often caused by a resource issues, which can usually be solved by rebooting the computer.";

		break;



		case 18:

		szResult = "Windows reports an invalid handle was used to access a critical data file.This is often caused by a resource issues, which can usually be solved by rebooting the computer.";

		break;



		case 19:

		szResult = "Windows reports an incorrect address was used to access critical data. This is often caused by a resource issues, which can usually be solved by rebooting the computer.";

		break;



		case 20:

		szResult = "Windows reports a null value when attempting to access critical data. This is often caused by a resource issues, which can usually be solved by rebooting the computer.";

		break;



		case 21:

		szResult = "Obsolete installer. Please go to our Downloads page and login to you account to obtain a new installer.";

		break;



		case 22:

		szResult = "A duplicate computer id is being added to the license file.";

		break;



		case 23:

		szResult = "Network LAN error. Check your network connectivity and try again.";

		break;



		case 24:

		szResult = "Computer ID error";

		break;



		case 25:

		szResult = "Your license could not be accessed for validation. This is usually a problem with Windows permissions and/or permission access to your system registry. We recommend rebooting your computer in Safe Mode with Networking.";

		break;



		case 26:

		szResult = "License file is corrupt. Reinstallation is recommended";

		break;



		case 27:

		szResult = "License file is corrupt. Reinstallation is recommended";

		break;



		case 28:

		szResult = "Windows will not allow permission to unpack installation files  - Usually occurs due to insufficient Windows permissions. ";

		break;



		case 29:

		szResult = "Customer denied request to create temporary directory to unpack files - Usually occurs due to insufficient Windows permissions.";

		break;



		case 30:

		szResult = "License file is corrupt. Reinstallation is recommended";

		break;



		case 31:

		szResult = "Cannot access critical file - Usually occurs due to insufficient Windows permissions.";

		break;



		case 32:

		szResult = "License file is corrupt. Reinstallation is recommended";

		break;



		case 33:

		szResult = "License file is corrupt. Reinstallation is recommended";

		break;



		case 34:

		szResult = "License file is corrupt. Reinstallation is recommended";

		break;



		case 35:

		szResult = "License file is corrupt. Reinstallation is recommended";

		break;



		case 36:

		szResult = "License file is corrupt. Reinstallation is recommended";

		break;



		case 37:

		szResult = "License file is corrupt. Reinstallation is recommended";

		break;



		case 38:

		szResult = "Windows reports that data has been tampered with or has been corrupted. Reinstallation recommended.";

		break;



		case 39:

		szResult = "License file is corrupt. Reinstallation is recommended";

		break;



		case 40:

		szResult = "License file is corrupt. Reinstallation is recommended";

		break;



		case 41:

		szResult = "Windows reports that a file already exists and cannot be duplicated";

		break;



		case 42:

		szResult = "Windows reports that it can not open a regsitry key due to insufficient user permissions to the registry. Make sure that your Windows login has Administrator permissions.";

		break;



		case 43:

		szResult = "Windows reports that it can not access data from a regsitry key due to insufficient user permissions to the registry.  Make sure that your Windows login has Administrator permissions.";

		break;



		case 44:

		szResult = "Windows reports that there are insufficient user permissions to close the registry.  Make sure that your Windows login has Administrator permissions.";

		break;



		case 45:

		szResult = "Windows reports that there are insufficient user permissions to read the registry.  Make sure that your Windows login has Administrator permissions.";

		break;



		case 46:

		szResult = "Windows reports that there are insufficient user permissions to use the registry.  Make sure that your Windows login has Administrator permissions.";

		break;



		case 50:

		szResult = "Could not read Windows version, or an unsupported operating system was detected.";

		break;



		case 52:

		szResult = "Could not create data file for offline activation. This is typically a Windows permissions issue.";

		break;



		case 54:

		szResult = "Could not run program for offline activation. This is typically a Windows permissions issue.";

		break;



		case 55:

		szResult = "Could not create data file for offline activation. This is typically a Windows permissions issue.";

		break;



		case 56:

		szResult = "Could not write data to license for offline activation.";

		break;



		case 58:

		szResult = "Could not format data for offline activation.";

		break;



		case 59:

		szResult = "Winsock Error! Most likely due to access to the Internet being blocked by security software.";

		break;



		case 60:

		szResult = "Could not open license file to format data for offline activation";

		break;



		case 61:

		szResult = "Winsock Error! Most likely due to access to the Internet being blocked by security software.";

		break;



		case 62:

		szResult = "Could not format data for offline activation";

		break;



		case 63:

		szResult = "Winsock Error! Most likely due to access to the Internet being blocked by security software.";

		break;



		case 64:

		szResult = "Windows will not allow the installation program to run a critical setup file. This is usually a problem with Windows permissions or corruption of your operating system environment.";

		break;



		case 65:

		szResult = "Data from our server could not be parsed out correctly. Please check your data and try again. It is also possible that access to the Internet being blocked by security software.";

		break;



		case 66:

		szResult = "Cannot unpack software due to problems in your software environment. This is usually a problem with Windows permissions.";

		break;



		case 67:

		szResult = "Winsock error-Cannot resolve proxy server.";

		break;



		case 68:

		szResult = "System data could not be verified!";

		break;



		case 69:

		szResult = "The file you are using is out of date. Please go to the Downloads page on our website and download a new file.";

		break;



		case 70:

		szResult = "Your license could not be validated. This is usually a problem with Windows permissions and/or permission access to your system registry. We recommend rebooting your computer in Safe Mode with Networking.";

		break;



		case 71:

		szResult = "User does not have administrator privilages. Operation cancelled.";

		break;



		case 72:

		szResult = "Installer cannot unpack software due to license not being activated.";

		break;



		case 73:

		szResult = "Windows prevented installer from extracting files. This indicates a corrupt software environment, or low system resources. We recommend rebooting your computer in Safe Mode With Networking.";

		break;



		case 74:

		szResult = "The installer encountered a file that is not a valid Cabinet file for this project. Redownloading the software is recommended.";

		break;



		case 76:

		szResult = "Windows prevented creation of a context to extract CAB files. This indicates a corrupt software environment or a problem with Windows permissions.";

		break;



		case 77:

		szResult = "Windows could not clean buffer when extracting files from a cabinet file. This indicates a corrupt software environment or a problem with Windows permissions.";

		break;



		case 78:

		szResult = "Not all files from a cabinet archive could be extracted. This indicates a corrupt software environment or a problem with Windows permissions.";

		break;



		case 80:

		szResult = "Windows would not allow creation of installation log. This is a non-critical error, likely due to a Windows permission issue.";

		break;



		case 82:

		szResult = "Error recording installation data to our server. This is a non-critical error usually due to a problem in your Internet connection.";

		break;



		case 84:

		szResult = "Start menu shortcuts could not be created. This is usually a problem with Windows permissions";

		break;



		case 86:

		szResult = "Windows would not allow creation of installation log. This is a non-critical error, likely due to a Windows permission issue.";

		break;



		case 88:

		szResult = "Windows would not allow creation of installation log. This is a non-critical error, likely due to a Windows permission issue.";

		break;



		case 80:

		szResult = "Windows would not allow creation of installation log. This is a non-critical error, likely due to a Windows permission issue.";

		break;



		case 100:

		szResult =  "You have entered the wrong password and/or license ID number in the license activation dialog box.  Please check the data and try again.";

		break;



		case 200:

		szResult = "You have entered the password and license ID number for a different aircraft. For example you are activating a Pilatus porter but you are accidentally using the license information for a Cessna 337.  Please check the data and try again.";

		break;



		case 211:

		szResult = "Your license could not be accessed for validation. This is usually a problem with Windows permissions and/or permission access to your system registry. We recommend rebooting your computer in Safe Mode with Networking.";

		break;



		case 213:

		szResult = "Your license could not be validated.  We recommend rebooting your computer in Safe Mode with Networking and reinstalling.";

		break;



		case 809:

		szResult = "License could not be validated when attempting to extract files. Most likely you have a Windows permission error.";

		break;



		case 810:

		szResult = "License could not be validated when attempting to extract files. Most likely you have a Windows permission error.";

		break;



		case 811:

		szResult = "Could not open license file format data for offline activation";

		break;



		case 820:

		szResult = "Could not record data to license for offline activation.";

		break;



		case 821:

		szResult = "Could not record data to license for offline activation.";

		break;



		case 829:

		szResult = "Could not create offline activation data file";

		break;



		case 908:

		szResult = "License could not be validated when attempting to extract files. Most likely you have a Windows permission error.";

		break;



		case 913:

		szResult = "License could not be validated when attempting to extract files. Most likely you have a Windows permission error.";

		break;



		case 914:

		szResult = "License could not be validated when attempting to extract files. Most likely you have a Windows permission error.";

		break;



		case 2016:

		szResult = "Windows will not allow offline activation program to run";

		break;



		case 2017:

		szResult = "Windows would not allow installer to unpack offline activation file";

		break;



		case 273:

		szResult = "Non-critical error-Windows prevented installer from making backups of your Flight Simulator configuration files.";

		break;



		case 274:

		szResult = "Windows prevented installer access to the critical dll.xml Flight Simulator configuration file.";

		break;



		default:

		szResult = "Unknown error.";

		break;

	}



	return szResult;



}


function GenerateRandomCode(randomnumber)
{
	var ChaptaText = new Array("F1A8BB","572538","4A23F4", "AD18A7", "943651","22EBA","5EF1A7","9F6S03D",
							 "4C12AE5","997B4R", "55E00F","BE62E0","C3E2BD","C18396", "42D8BA","3FE2FF4",
							 "0CBE65D","E11E7E1","71A7C40","E7916C1","08D6475","30B400A","EBAD1B4","3A84AC2",
							 "AC2C22C","3D3AF5E","F840C14","DE81F3E","23B4AF2","29036BF","85E944A","3DAE854",
							 "9CF6112","023D9A1","4464BEF","EBBB8A6","6466A05","7E92641","86CF162","9C3BDF7");

	if(randomnumber > 40 || randomnumber < 0)
		return "INVALID NUMBER";
	else
		return ChaptaText[randomnumber];
}

function GetImage(randomnumber)
{
	var Img = new Array("1.jpg","2.jpg","3.jpg", "4.jpg", "5.jpg","6.jpg","7.jpg","8.jpg",
						"9.jpg","10.jpg","11.jpg", "12.jpg", "13.jpg","14.jpg","15.jpg","16.jpg",
						"17.jpg","18.jpg","19.jpg", "20.jpg", "21.jpg","22.jpg","23.jpg","24.jpg",
						"25.jpg","26.jpg","27.jpg", "28.jpg", "29.jpg","30.jpg","31.jpg","32.jpg",
						"33.jpg","34.jpg","35.jpg", "36.jpg", "37.jpg","38.jpg","39.jpg","40.jpg");


	if(randomnumber > 40 || randomnumber < 0)
		return "";
	else
		return Img[randomnumber];

}

function getRandImgNumber()
{
	return Math.floor(Math.random()*41);	
}



