﻿// JavaScript Document

/*
This script create functions for banner rotation, total of 4 banners, real-time clock, and tab navigation on the whole application.
*/

// Banner functions by Nam
function loadbanner() 
{
    index1 = 0;
    listofimages = new Array(4);
    listofimages[0] = new Image(217,337)
    listofimages[0].src = "images/box.jpg"
    listofimages[1] = new Image(206,555)
    listofimages[1].src = "images/box.jpg"
    listofimages[2] = new Image(217,358)
    listofimages[2].src = "images/box.jpg"
    listofimages[3] = new Image(206,357)
    listofimages[3].src = "images/box.jpg"

	//listofimages[x] = new Image(xx,yy)
	//listofimages[x].src = "URL/location"
	
    thetimer = setTimeout("changeimage()", 5000); //approx 5 seconds
}

function changeimage()
{
    index1 = index1 + 1
    if (index1 == "4") 
    {  //total # of image 
        index1 = 0 
    }
    imagesource = listofimages[index1].src
    window.document.banner1.src = imagesource

    thetimer = setTimeout("changeimage()", 5000); //approx 5 seconds
}

function changebanner() 
{
    if (index1 == 0) 
    {
		//link for first banner listofimages[0]
        newlocation = "http://www.backyardmarketinggroup.com/file-storage/" 
    }
    else if (index1 == 1) 
    {
		//link for second banner listofimages[1]
        newlocation = "http://www.backyardmarketinggroup.com/file-storage/" 
    }
    else if (index1 == 2) 
    {
		//link for banner listofimages[2]
        newlocation = "http://www.backyardmarketinggroup.com/file-storage/" 
    }
    else if (index1 == 3) 
    {
		//link for banner listofimages[3]
        newlocation = "http://www.backyardmarketinggroup.com/file-storage/" 
    }
    location = newlocation 
}

// Clock function by Le
function startclock()
{
var thetime=new Date();

var nhours=thetime.getHours();
var nmins=thetime.getMinutes();
var nsecn=thetime.getSeconds();
var nday=thetime.getDay();
var nmonth=thetime.getMonth();
var ntoday=thetime.getDate();
var nyear=thetime.getYear();
var AorP=" ";

if (nhours>=12)
    AorP="PM";
else
    AorP="AM";

if (nhours>=13)
    nhours-=12;

if (nhours==0)
   nhours=12;

if (nsecn<10)
 nsecn="0"+nsecn;

if (nmins<10)
 nmins="0"+nmins;

if (nday==0)
  nday="Sunday";
if (nday==1)
  nday="Monday";
if (nday==2)
  nday="Tuesday";
if (nday==3)
  nday="Wednesday";
if (nday==4)
  nday="Thursday";
if (nday==5)
  nday="Friday";
if (nday==6)
  nday="Saturday";

nmonth+=1;

if (nyear<=99)
  nyear= "19"+nyear;

if ((nyear>99) && (nyear<2000))
 nyear+=1900;

document.getElementById("datetime").innerHTML=nday+", "+nmonth+"/"+ntoday+"/"+nyear + "     " +nhours+":"+nmins+":"+nsecn+""+AorP+"&nbsp;";

setTimeout('startclock()',1000);
}

//Set Focus to First Available Form Control, skipping hidden and disabled elements.
function setToFirstControl()
{
  var bFound = false;  

  //for each form
  for (f=0; f < document.forms.length; f++) 
  { 
    //for each element in each form
    for(i=0; i < document.forms[f].length; i++) 
    { 
      //if it's not a hidden element
      if (document.forms[f][i].type != "hidden") 
      { 
        //and it's not disabled
        if (document.forms[f][i].disabled != true) 
        {
          try {
             //set the focus to it
             document.forms[f][i].focus();
             var bFound = true;
          }
          catch(er) {
          }
        }
      }
      //if found in this element, stop looking
      if (bFound == true)
        break;
    }
    //if found in this form, stop looking
    if (bFound == true)
      break;
  }
}

//The function below copy mailing address to billing address if address is the same in Auditor table
	function copyAddress()
	{
		if(document.auditor.auditor_sameaddress.checked)
		{
			document.auditor.auditor_billingaddress.value=document.auditor.auditor_address.value;
			document.auditor.auditor_billingaddress2.value=document.auditor.auditor_address2.value;
			document.auditor.auditor_billingcity.value=document.auditor.auditor_city.value;
			document.auditor.auditor_billingstate.value=document.auditor.auditor_state.value;
			document.auditor.auditor_billingzip.value=document.auditor.auditor_zip.value;
		}else{
			document.auditor.auditor_billingaddress.value="";
			document.auditor.auditor_billingaddress2.value="";
			document.auditor.auditor_billingcity.value="";
			document.auditor.auditor_billingstate.value="";
			document.auditor.auditor_billingzip.value="";
		}
	}

// Open feedback in new customized window
function openFeedback()
{
window.open("http://auditor.signalauditing.com/feedback.asp","_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=yes, width=640, height=400");
}

// Open auditor manual in new customized window
function openAuditorManual()
{
window.open("http://auditor.signalauditing.com/manualAuditor.asp","_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=yes, width=990, height=700");
}

// Open user manual in new customized window
function openUserManual()
{
window.open("http://auditor.signalauditing.com/manualUser.asp","_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=yes, width=990, height=700");
}

// Open conceptual schema in new customized window
function openConceptual()
{
window.open("http://auditor.signalauditing.com/images/conceptualModel2.jpg","_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=yes, width=900, height=700");
}

// Open auditing schema in new customized window
function openAuditing()
{
window.open("http://auditor.signalauditing.com/images/schemaAuditing.jpg","_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=yes, width=1100, height=700");
}

// Open calendar schema in new customized window
function openCalendar()
{
window.open("http://auditor.signalauditing.com/images/schemaCalendar.jpg","_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=yes, width=900, height=700");
}

function openNavigation()
{
window.open("http://auditor.signalauditing.com/images/navigation2.jpg","_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=yes, width=1000, height=780");
}
