var escapetimes=0;
var escapetimer;
var saveurl='';

function framesync()
{
    var currentUrl = top.view.location.href;

    if (currentUrl != top.saveUrl && top.saveUrl != '')
	{
        top.edit.location.href = currentUrl + 'manage.html';
    }
    top.saveUrl = currentUrl;
    setTimeout('top.framesync()',100);
}

function framesync2()
{
	var newurl = top.edit.location.href;
	newurl = newurl.replace(/manage\.html$/gi,'');

	if ( top.view.location.href != newurl )
    	top.view.location.href = newurl;
}

function findframe(name)
{
    for (var i=0;i<parent.frames.length;i++) {
         if (parent.frames[i].name == name)
             return parent.frames[i];
    }
    return false;
}

function keypress1()
{
    if (window.event.keyCode == 27)
    {
	    clearTimeout(escapetimer);
    	escapetimes++;
    	if ( escapetimes >= 3 )
    	{
    	    clearkeypress();
    	    if ( findframe('edit') )
			{
				window.top.location.href='./';
			}
			else
			{
				window.top.location.href='admin';
			}
		}
		else
		{
			escapetimer = setTimeout('clearkeypress()',2500);
		}
	}
}

function clearkeypress()
{
	/*alert('cleared');*/
   	escapetimes=0;
}

function newWin(symbol)
{
	window.open(symbol,"",'width=200,height=200,left=100,screenX=100,top=50,screenY=50,scrollbars');
}

// main contact form
function submitForm() {
emailRegEx = /^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i;
	if(document.theForm.name.value.length < 1) {
		alert("Please enter your first name.");
		document.theForm.name.focus();
		return;
	} else if(document.theForm.lastname.value.length < 1) {
		alert("Please enter your last name.");
		document.theForm.lastname.focus();
		return;
	} else if(! emailRegEx.test(document.theForm.email.value)) {
		alert("Please enter a valid email address.");
		document.theForm.email.focus();
		return;
	} else if(document.theForm.phone1.value.length < 3) {
		alert("Please enter your area code.");
		document.theForm.phone1.focus();
		return;
	} else if(document.theForm.phone2.value.length < 3) {
		alert("Please enter your phone prefix.");
		document.theForm.phone2.focus();
		return;
	} else if(document.theForm.phone3.value.length < 4) {
		alert("Please enter your phone number.");
		document.theForm.phone3.focus();
		return;
	} else if(document.theForm.state.value.length < 1) {
		alert("Please select your state of residence.");
		document.theForm.state.focus();
		return;
	} else if(document.theForm.source.value.length < 1) {
		alert("Please indicate how you found us.");
		document.theForm.source.focus();
		return;
	}
	document.theForm.submit();
}

// dealer contact form
function dsubmitForm() {
emailRegEx = /^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i;
	if(document.theForm.fname.value.length < 1) {
		alert("Please enter your first name.");
		document.theForm.fname.focus();
		return;
	} else if(document.theForm.lname.value.length < 1) {
		alert("Please enter your last name.");
		document.theForm.lname.focus();
		return;
	} else if(! emailRegEx.test(document.theForm.email.value)) {
		alert("Please enter a valid email address.");
		document.theForm.email.focus();
		return;
	} else if(document.theForm.phone1.value.length < 3) {
		alert("Please enter your area code.");
		document.theForm.phone1.focus();
		return;
	} else if(document.theForm.phone2.value.length < 3) {
		alert("Please enter your phone prefix.");
		document.theForm.phone2.focus();
		return;
	} else if(document.theForm.phone3.value.length < 4) {
		alert("Please enter your phone number.");
		document.theForm.phone3.focus();
		return;
	} else if(document.theForm.state.value.length < 1) {
		alert("Please select your state of residence.");
		document.theForm.state.focus();
		return;
	} else if(document.theForm.source.value.length < 1) {
		alert("Please indicate how you found us.");
		document.theForm.source.focus();
		return;
	}
	document.theForm.submit();
}

// request catalog contact form
function rcsubmitForm() {
emailRegEx = /^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i;
	if(document.theForm.model.value.length < 1) {
		alert("Please select a model series.");
		document.theForm.model.focus();
		return;
	} else if(document.theForm.name.value.length < 1) {
		alert("Please enter your name.");
		document.theForm.name.focus();
		return;
	} else if(document.theForm.organization.value.length < 1) {
		alert("Please enter your organization.");
		document.theForm.organization.focus();
		return;
	} else if(! emailRegEx.test(document.theForm.email.value)) {
		alert("Please enter a valid email address.");
		document.theForm.email.focus();
		return;
	} else if(document.theForm.phone.value.length < 10) {
		alert("Please enter your phone.");
		document.theForm.phone.focus();
		return;
	} else if(document.theForm.catalog.checked && document.theForm.address.value.length < 1) {
		alert("Please enter your address.");
		document.theForm.address.focus();
		return;
	} else if(document.theForm.catalog.checked && document.theForm.city.value.length < 1) {
		alert("Please enter your city.");
		document.theForm.city.focus();
		return;
	} else if(document.theForm.catalog.checked && document.theForm.state.value.length < 1) {
		alert("Please select your state.");
		document.theForm.state.focus();
		return;
	} else if(document.theForm.catalog.checked && document.theForm.zip.value.length < 1) {
		alert("Please enter your zip.");
		document.theForm.zip.focus();
		return;
	}
	document.theForm.submit();
}

// request spec contact form
function rssubmitForm() {
emailRegEx = /^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i;
	if(document.theForm.model.value.length < 1) {
		alert("Please select a model series.");
		document.theForm.model.focus();
		return;
	} else if(document.theForm.name.value.length < 1) {
		alert("Please enter your name.");
		document.theForm.name.focus();
		return;
	} else if(document.theForm.organization.value.length < 1) {
		alert("Please enter your organization.");
		document.theForm.organization.focus();
		return;
	} else if(! emailRegEx.test(document.theForm.email.value)) {
		alert("Please enter a valid email address.");
		document.theForm.email.focus();
		return;
	} else if(document.theForm.phone.value.length < 10) {
		alert("Please enter your phone.");
		document.theForm.phone.focus();
		return;
	}
	document.theForm.submit();
}

// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 1500;
// Duration of crossfade (seconds)
var crossFadeDuration = 3;
// Specify the image files
var Pic = new Array();

// do not edit anything below this line
var t;
var j = 0;
var p = Pic.length;
var preLoad = new Array();
for (i = 0; i < p; i++) {
preLoad[i] = new Image();
preLoad[i].src = Pic[i];
}
function runSlideShow() {
if (document.all) {
document.images.SlideShow.style.filter="blendTrans(duration=2)";
document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)";
document.images.SlideShow.filters.blendTrans.Apply();
}
document.images.SlideShow.src = preLoad[j].src;
if (document.all) {
document.images.SlideShow.filters.blendTrans.Play();
}
j = j + 1;
if (j > (p - 1)) j = 0;
t = setTimeout('runSlideShow()', slideShowSpeed);
}
