﻿

function openTerms()
{
	newwin = window.open("http://www.healthwavesaunas.com.au/terms.html","terms","width=405,height=400,scrollbars=yes");
}

function openPrivacy()
{
	newwin = window.open("http://www.healthwavesaunas.com.au/privacy.html","terms","width=405,height=400,scrollbars=yes");
}


// Flash test
var isDOM = (document.getElementById) ? true : false;
var isIE = (navigator.appName == "Microsoft Internet Explorer") ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
var isNetscape = (!isOpera && (navigator.appName.indexOf("Netscape") != -1 && navigator.userAgent.indexOf("4.") != -1)) ? true : false;
var isMac = (navigator.userAgent.indexOf("Mac") != -1) ? true : false;

var bUsedHTML = ((isDOM || isIE || isNetscape) && !isMac) ? true : false
var iLatestFlashVersion = 8;
var iMinimumFlashVersion = 6;
var iFlashVersion = -1;

// Variable must be global for VBScript to work correctly.
var thisFlashVersion;
function flash_getIEVersion() {

	var thisMaxVersion = false;
	for(var currentVersion=iMinimumFlashVersion; currentVersion<=iLatestFlashVersion; currentVersion++) {
		document.write('<SCR'+'IPT LANGUAGE="VBScript">\n');
		document.write('on error resume next\n');
		document.write('thisFlashVersion = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.'+currentVersion+'")))\n');
		document.write('</SCR'+'IPT>\n');

		if(thisFlashVersion) {
			thisMaxVersion = currentVersion;
		}
	}
	return thisMaxVersion;
}

function flash_setVersion() {
	if (navigator.plugins.length > 0) {
		// Plugin detect, no VBScript support
		navigator.plugins.refresh(false);
		numPlugins = navigator.plugins.length;
		for(var i=0; i<numPlugins; i++)	{
			plugDesc = navigator.plugins[i].description;
			iFlashVersion = (plugDesc.indexOf("Flash") != -1) ? parseInt(plugDesc.charAt(parseInt(plugDesc.indexOf("Flash"))+6)) : 0;
			if(iFlashVersion > 0) {
				return;
			}
		}
	} else if(!isMac && (isIE || isOpera)) {
		// No plugin detect, VBScript support
		iFlashVersion = flash_getIEVersion();
	} else {
		// No plugin detect, no VBScript support
		iFlashVersion = iLatestFlashVersion;
	}
}

// Set Flash Version
flash_setVersion();

function printFlash(flashSRC, imageSRC, width, height, map)
{
	var pntStr;
	if(iFlashVersion >= iMinimumFlashVersion)
	{
		pntStr = "<object width=" + width + " height=" + height + " VIEWASTEXT>";
		pntStr += "<param name='movie' value='" + flashSRC + "'>";
		pntStr += "<param name='quality' value='high'>";
		pntStr += "<embed src='" + flashSRC + "' quality='high' ";
		pntStr += "type='application/x-shockwave-flash' width=" + width + " height=" + height + ">";
		pntStr += "</embed></object>";
	}
	else
	{
		pntStr = "<img usemap='#" + map + "' src='" + imageSRC + "' width=" + width + " height=" + height + " alt='' border=0>";
	}
	document.write(pntStr);
}

/* start validation */
function validateForm(theForm)
{
 valid = true;
 message = "So we can deal with your enquiry:\n\n";
 if(theForm.elements["name"].value == "")
 {
  message += "  Please enter your name\n";
  valid = false;
 } 
 var supEmail = theForm.elements["email"].value;
 var emLen = supEmail.length;
 var posAt = supEmail.indexOf('@')
 var posDot = supEmail.lastIndexOf('.')
 if((emLen < 7) || (posAt < 1) || (posDot <= (posAt + 1)) || (posDot >= (emLen - 1)))
 {
  message += "  Please enter a valid email address\n";
  valid = false;
 }
 if(theForm.elements["heardabout"].value == "")
 {
  message += "  Please enter how you heard about Healthwave Saunas\n";
  valid = false;
 }

 if(valid)
 {
  return true;
 }
 else
 {
  alert(message);
  return false;
 }
}
/* end validation */

