// (C) 2000 www.CodeLifter.com
// http://www.codelifter.com
// Free for all users, but leave in this  header
// NS4-6,IE4-6
// Fade effect only in IE; degrades gracefully

// =======================================
// set the following variables
// =======================================

// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 5000

// Duration of crossfade (seconds)
var crossFadeDuration = 3

// Specify the image files
var Pic = new Array() // don't touch this
// to add more images, just continue
// the pattern, adding to the array below

Pic[0] = './images/windshield.jpg'
Pic[1] = './images/showerglass.jpg'
Pic[2] = './images/heavyglass.jpg'
Pic[3] = './images/homewindow.jpg'

// =======================================
// do not edit anything below this line
// =======================================

var t
var j = 0
var p = Pic.length
var i

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)
}





function init()
{
	runSlideShow(); 
	updateClock();
	setInterval('updateClock()', 1000 );
}


function validate_form ( )
{
    valid = true;

    if (document.pword_form.newPass.value == "" )
    {
        alert ( "Please fill in the 'New Password' field." );
        valid = false;
	document.pword_form.newPass.focus();
    }
    else if (document.pword_form.conPass.value == "" )
    {
        alert ( "Please fill in the 'Confirm Password' field." );
        valid = false;
	document.pword_form.conPass.focus();
    }
    else if (document.pword_form.conPass.value != document.pword_form.newPass.value)
    {
        alert ( "Passwords do not match. Please try again." );
        valid = false;
	document.pword_form.newPass.focus();
    }

    return valid;
}

function enableFields()
{
	var item = document.quote_form.sType.value;
	if(document.quote_form.sType.value == "Auto Glass Replacement")
	{
		document.quote_form.vMake.disabled = false;
		document.quote_form.vModel.disabled = false;
		document.quote_form.vYear.disabled = false;
		document.quote_form.vDoors.disabled = false;
	}
	else if(document.quote_form.sType.value == "Auto Glass Repair")
	{
		document.quote_form.vMake.disabled = false;
		document.quote_form.vModel.disabled = false;
		document.quote_form.vYear.disabled = false;
		document.quote_form.vDoors.disabled = false;
	}
	else
	{
		document.quote_form.vMake.disabled = true;
		document.quote_form.vModel.disabled = true;
		document.quote_form.vYear.disabled = true;
		document.quote_form.vDoors.disabled = true;
	}
}

function changeType()
{
	if(document.quote_form.sLocation.value == "815 51st Street - Saskatoon")
	{
		document.quote_form.sType.options[2].enabled;
		document.quote_form.sType.options[3].enabled;
		document.quote_form.sType.options[4].enabled;
		document.quote_form.sType.options[5].enabled;
	}
	else if(document.quote_form.sLocation.value == "Onsite Service - Saskatoon")
	{
		document.quote_form.sType.options[2].enabled;
		document.quote_form.sType.options[3].enabled;
		document.quote_form.sType.options[4].enabled;
		document.quote_form.sType.options[5].enabled;
	}
	else
	{
		//document.getElementById("sType").options[2] = null;
		//document.getElementById("sType").options[3] = null;
		//document.getElementById("sType").options[4] = null;
		//document.getElementById("sType").options[5] = null;
	}
}

function removeOptions(servicebox)
{
	servicebox.options[2].disabled;
	servicebox.options[3].disabled;
	servicebox.options[4].disabled;
	servicebox.options[5].disabled;
}

function addOptions(servicebox)
{
	servicebox.options[2].enabled;
	servicebox.options[3].enabled;
	servicebox.options[4].enabled;
	servicebox.options[5].enabled;
}


function validate_quote_form ( )
{
    valid = true;

    if (document.quote_form.cFName.value == "" )
    {
        alert ( "Please fill in the 'First Name' field." );
        valid = false;
	document.quote_form.cFName.focus();
    }
    else if (document.quote_form.cLName.value == "" )
    {
        alert ( "Please fill in the 'Last Name' field." );
        valid = false;
	document.quote_form.cLName.focus();
    }
    else if (document.quote_form.cPhone.value == "" )
    {
        alert ( "Please fill in the 'Phone Number' field." );
        valid = false;
	document.quote_form.cPhone.focus();
    }

    return valid;
}

function updateClock ( )
{
  var currentTime = new Date ( );

  var currentHours = currentTime.getHours ( );
  var currentMinutes = currentTime.getMinutes ( );
  var currentSeconds = currentTime.getSeconds ( );

  // Pad the minutes and seconds with leading zeros, if required
  currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
  currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;

  // Choose either "AM" or "PM" as appropriate
  var timeOfDay = ( currentHours < 12 ) ? "AM" : "PM";

  // Convert the hours component to 12-hour format if needed
  currentHours = ( currentHours > 12 ) ? currentHours - 12 : currentHours;

  // Convert an hours component of "0" to "12"
  currentHours = ( currentHours == 0 ) ? 12 : currentHours;

  // Compose the string for display
  var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds + " " + timeOfDay;

  // Update the time display
  document.getElementById("clock").firstChild.nodeValue = currentTimeString;
}