var pdfFile = '';
var src_prefix = 'documents/priceSheets/';
var thisPage = '';

function loadSalesPricingPDF(make, region)
{
	//pdfFile = 'priceSheets/' + make + '-' + region + '.pdf'
	pdfFile = 'download.php?make=' + make + '&region=' + region;
	thisPage = "pricing";
	$('pdfViewer').src = pdfFile;
}

function validate_login()
{
	valid = true;
	$('formError').style.display = 'none';
	
	if ($('j_username').value == "")
	{
		$('formError').style.display = 'block';
		valid = false;
	}
	
	return valid;
}

function CheckIsIE()
{
	if (navigator.appName.toUpperCase() == 'MICROSOFT INTERNET EXPLORER') { return true; }
	else { return false; }
}

function printPDF()
{
	if (CheckIsIE() == true)
	{
		document.pdfViewer.focus();
		document.pdfViewer.print();
	}   
	else
	{
		 window.frames['pdfViewer'].focus();
		 window.frames['pdfViewer'].print();
	}
}

function downloadPDF(filename)
{
	if(filename != '' && thisPage != "pricing")
	{
		if (CheckIsIE() == true)
		{
			document.pdfViewer.location.href = "download.php?f=" + filename;
		}   
		else
		{
			 window.frames['pdfViewer'].location.href = "download.php?f=" + filename;
		}
	}
	else if(filename != '' && thisPage == "pricing")
	{
		filename += '&is_download=true';
		$('pdfViewer').src = filename;
	}
}

function enlargePDF(filename)
{
	if(filename != '')
	{
		if(thisPage != 'pricing')
		{
			URL = 'documents/' + filename;
		}
		else
		{
			URL = filename;
		}
		day = new Date();

		id = day.getTime();

		eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=1,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=800,height=600,left = 320,top = 150');");
	}
}

function submitForgotPassword()
{
	if(validate_login())
	{
		$('loginForm').action = "https://secure.zag.com/login.html";
		$('emailPassword').value = "yes";
		$('loginForm').submit();
	
		$('loginForm').action = "https://secure.zag.com/j_acegi_security_check";
		$('emailPassword').value = "no";
		return true;
	}
	
	return false;
}

var d = document;
function over(imgName, img_src) {
	d[imgName].src=img_src;
}

function out(imgName, img_src) {
	d[imgName].src=img_src;
}