//=============================================================================
// Stenocall JavaScript routines
// Note this file must be included in the HTML before any other JavaScript code
// that utilizes the function declarations, or variable declarations, contained
// in it.

//=============================================================================
// NEW functions (June 2006) related to rollover images in the NEW navigation
// bar (after adding the Two-Way button).
// Changed MM prefix to append an (approximate) version number string, so
// Dreamweaver will quit complaining when we update the library(ies) into the
// HTML files. This appears to be a result of our old version of Dreamweaver
// not supporting some of the code used to insert the newer version of these
// routines.
// Dreamweaver normally inserts all this stuff into the HTML, but I moved it
// here to eliminate a multitude of copies (it also is more efficient at page-
// loading time).

function MM_V3_swapImgRestore() { //v3.0
  var i,x,a=document.MM_V3_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_V3_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_V3_p) d.MM_V3_p=new Array();
    var i,j=d.MM_V3_p.length,a=MM_V3_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_V3_p[j]=new Image; d.MM_V3_p[j++].src=a[i];}}
}

function MM_V3_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_V3_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_V3_swapImage() { //v3.0
  var i,j=0,x,a=MM_V3_swapImage.arguments; document.MM_V3_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_V3_findObj(a[i]))!=null){document.MM_V3_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//=============================================================================
// Functions related to rollover images in the navigation bar.
// These were used in the older version of the nav bar -- guess they are
// obsolete now.

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		ContactButton_over = newImage("images/ContactButton-over.gif");
		homebutton_over = newImage("images/homebutton-over.gif");
		CallCenterButton_over = newImage("images/CallCenterButton-over.gif");
		PagerButton_over = newImage("images/PagerButton-over.gif");
		AnswerButton_over = newImage("images/AnswerButton-over.gif");
		CellButtton_over = newImage("images/CellButtton-over.gif");
		preloadFlag = true;
	}
}

//=============================================================================
// Variables related to type of page

// var CallCenterPage = false;

//=============================================================================
// Note: The various Email functions serve to hide our Email addresses from
// spam harvesters.  As far as possible, we don't want an "@" sign to appear
// in the HTML.
//=============================================================================
// Given the two main pieces of an Email address, build the entire address.

function build_email (name,domain){ 
return (name + "@" + domain)
}

//=============================================================================
// Insert the NON CALL CENTER Email address into the recipient field of the
// response form.

function set_email_in_form_ncc (string){
document.response_form.recipient.value = build_email("sales","stenocall.com");
}

//=============================================================================
// Insert the CALL CENTER Email address into the recipient field of the
// response form.

function set_email_in_form_cc (string){
document.response_form.recipient.value = build_email("salescc","stenocall.com");
}

//=============================================================================
// Display the (clickable) CALL CENTER sales Email address and when clicked,
// register a hit on the email-click-cc.html page for tracking.

function display_sales_email_cc() {
	var name1 = "salescc"
	var name2 = "@"
	var dom1 = "stenoca"
	var dom2 = "ll.com"
	var string = name1 + name2 + dom1 + dom2
	document.write("<a href=" + "mai" + "lto:" + string + " OnClick=\"mailtoframe.location.pathname='email-click-cc.html'\">" + string + "</a>")
}

//=============================================================================
// Display the (clickable) NON CALL CENTER sales Email address.

function display_sales_email_ncc() {
	var name1 = "sales"
	var name2 = "@"
	var dom1 = "stenoca"
	var dom2 = "ll.com"
	var string = name1 + name2 + dom1 + dom2
	document.write("<a href=" + "mai" + "lto:" + string + ">" + string + "</a>")
}

//=============================================================================
// Transitional function for GENERAL sales Email. Calls to this will be phased
// out and replaced with calls to display_sales_email_cc and
// display_sales_email_ncc.

function display_main_email() {
	display_sales_email_ncc()
}

//=============================================================================
// Display the (clickable) webmaster Email address.

function display_webmaster_email() {
	var name1 = "webmaster2"
	var name2 = "@"
	var dom1 = "stenoca"
	var dom2 = "ll.com"
	var string = name1 + name2 + dom1 + dom2
	document.write("<a href=" + "mai" + "lto:" + string + ">" + string + "</a>")
}

//=============================================================================
// Display the (clickable) employment Email address.

function display_employment_email() {
	var name1 = "hr"
	var name2 = "@"
	var dom1 = "stenoca"
	var dom2 = "ll.com"
	var string = name1 + name2 + dom1 + dom2
	document.write("<a href=" + "mai" + "lto:" + string + ">" + string + "</a>")
}

//=============================================================================
// Return the current date and time in an all-numeric string: yyyymmddhhmmss

function NumericDateTime() {
	var now = new Date()
	var year = now.getYear()
	var month = now.getMonth() + 1
	var day = now.getDate()
	var hour = now.getHours()
	var minute = now.getMinutes()
	var second = now.getSeconds()

	if (year < 1000) year += 1900
	if (month < 10) month = "0" + month
	if (day < 10) day = "0" + day
	if (hour < 10) hour = "0" + hour
	if (minute < 10) minute = "0" + minute
	if (second < 10) second = "0" + second

		// Force the whole thing to be a string

	return "" + year + month + day + hour + minute + second;
}

//=============================================================================
// Google Analytics prefix code - must call before other GA functions
// GAPageView and GACommerceTrack

function GAPrefix() {
	var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
	document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
}

//=============================================================================
// Google Analytics regular code to track a page view (same for every page).
// Call GAPrefix before calling this.

function GAPageView() {
	try {
		var pageTracker = _gat._getTracker("UA-7233152-1");
		pageTracker._trackPageview();
	} catch(err) {}
}

//=============================================================================
// Google Analytics code to track a simplified E-Commerce event. All you have
// to pass it is the order ID, description, and dollar amount.
// This doesn't track the page view, just the E-Commerce "transaction".
// Call GAPrefix before calling this.

function GACommerceTrack(OrderID,Description,Amount) {
	var pageTracker = _gat._getTracker("UA-7233152-1");

	pageTracker._addTrans(
		OrderID, // Order ID
		"", // Affiliation
		Amount, // Total
		"", // Tax
		"", // Shipping
		"", // City
		"", // State
		"" // Country
	);

	pageTracker._addItem(
		OrderID, // Order ID
		Description, // SKU
		Description + "-Name", // Product Name 
		"", // Category
		Amount, // Price
		"1" // Quantity
	);

	pageTracker._trackTrans();
}

