function windowOpen(path,params)
{
	window.open(path, "wndw", params);

}

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 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;
}



