//This function checks if the "showAlert" value is set to true on the incoming Qstring
function displayAlert()
{
	ShowAccountStartupMessage();
}

function ShowAccountStartupMessage()
{
	var query = location.search.substring(1);    			 
	// Get query string
	var pairs = query.split(",");
	// Break at comma
	for(var i = 0; i < pairs.length; i++)
	{
		var pos = pairs[i].indexOf('=');
		// Look for "name=value"
		if (pos == -1) continue;
		// If not found, skip
		var argname = pairs[i].substring(0,pos);
		// Extract the name
		var value = pairs[i].substring(pos+1);

		if (argname=='showAlert' && value=='true')
		alert("We notice this is your first login to your new account!\r\r" +
		"There are several configurable options that can be set for your Account.\r\r" +
		"All or any of these options can be accessed via the \"My Account Menu\" \r" +
		"displayed on this page.");
	}
}

function PresentEULA()
{
	
}

function NavToClientLogonPage()
{
	switch (ClientId)
	{
		case 1: //Cengage
			top.location.href = "home.aspx";
			break;
		case 2: //QLD
			top.location.href = "/qld.login";
			break;
		default:
			top.location.href = "home.aspx";
			break;
	}
}

function confirmDeleteCustomer()
{
	return confirm("If you delete this customer all estimates associated with this customer will also be deleted. Are you sure you wish to delete this customer?");
}

function confirmDeleteEstimate()
{
	return confirm("Are you sure you wish to delete this estimate?");
}

function confirmDeleteSpecialItem()
{
	return confirm("Are you sure you wish to delete this part? Note: If any estimates reference this part, it cannot be deleted.");
}

function confirmDeleteCustomOp()
{
	return confirm("Are you sure you wish to delete this custom operation? Note: If any estimates reference this custom operation, it cannot be deleted.");
}

function confirmDeleteEstimateLineItem()
{
	return confirm("Are you sure you wish to delete this line from the estimate?");
}

function confirmDeleteEstimateLineItemCB(checkBox)
{
	checkBox.checked = !checkBox.checked;
	if (checkBox.checked)
	{
		var result = confirm("Remove this line from the estimate?");
		if (result)
		{
			checkBox.checked = !checkBox.checked;
		}
		
		return result;
	}
	else
	{
		checkBox.checked = !checkBox.checked;
		return true;
	}
}

function MainOnUnloadHandler(LogoutURL)
{
//	location.href = LogoutURL; //temporarily commented out for Invomax demo
	/*
	if (!confirm("Are you sure you wish to logout?"))
	{
		location.href = 'ProWeb.aspx';
	}
	else
	{
		location.href = LogoutURL;
	}
	*/
}

function BreakFrames()
{
	if (window != top) top.location.href = location.href;
}

function CloseOpener()
{
	if (window.opener)
	{
		window.opener.close();
	}
}
	
function MM_reloadPage(init)
{  //reloads the window if Nav4 resized
	if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
		document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
	else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
		
function PrintTroubleCode(code, engine)
{
	var URL = "CVPrintPage.aspx?code=" + escape(code) + "&engine=" + escape(engine);
	OpenPopWin(URL, 400, 400);
}

function OpenPopWin(URL, Height, Width)
{
	window.open(URL, null, "height=" + Height + ",width=" + Width + ",status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes");
}

function GetFileNameFromPath(FilePath)
{
	return FilePath.substring(FilePath.lastIndexOf("\\") + 1);
}

function noContentKeyAction(rootUrl) {
	$("#noContentKeyMessage").fadeIn(1000);
	setTimeout("$('#noContentKeyMessage').fadeOut(1000);", 3000);
	setTimeout("location.href = '" + rootUrl + "Logout.aspx?type=REDIR'", 4000);
}

function hidePrintFeature() {
	$('#printLnk').css('visibility', 'hidden');
	$('#printImg').css('visibility', 'hidden');
	$('#lblPrintPipe').css('visibility', 'hidden');
}
