/* POPUP WINDOW FUNCTION ***************************/
function windowOpen(url,params) {
	window.open(url,"somename",params);
}

/* DIV SHOW/HIDE FUNCTION ***************************/
function switchMenu(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != 'none' ) {
		closeHelp();
//		el.style.display = 'none';		
	} else {
		openHelp();
//		el.style.display = '';
	}
}

var helpW = 0;
var helpH = 0;
var speedW = 133;
var speedH = 100;

function openHelp(){
	if (helpW == 0 && helpH == 0)
	{
		document.getElementById("getHelpNow").style.width = "0px";
		document.getElementById("getHelpNow").style.height = "0px";
		document.getElementById("getHelpNow").style.display = "block";	
		document.getElementById("getHelpFrame").style.display = "none";
	}
	if (helpW < 400 && helpH < 300){
		helpW = helpW + speedW;
		helpH = helpH + speedH;
		document.getElementById("getHelpNow").style.width = helpW + "px";
		document.getElementById("getHelpNow").style.height = helpH + "px";
		setTimeout("openHelp()",1);
	}
	else{
		document.getElementById("getHelpFrame").style.display = "block";	
	}
}

function closeHelp(){
	if (document.getElementById("getHelpNow").style.width == "400px" && document.getElementById("getHelpNow").style.height == "300px")
	{
		helpW = 400;
		helpH = 300;
	}
	document.getElementById("getHelpFrame").style.display = "none";
	if (helpW > 0 && helpH > 0){
		helpW = helpW - speedW;
		helpH = helpH - speedH;
		document.getElementById("getHelpNow").style.width = helpW + "px";
		document.getElementById("getHelpNow").style.height = helpH + "px";
		setTimeout("closeHelp()",1);
	}
	else{
		document.getElementById("getHelpNow").style.display = "none";
	}
}

/* RANDOM STATEMENT IMAGE ***************************
var theImages = new Array()

theImages[0] = 'statement-1.jpg'
theImages[1] = 'statement-2.jpg'
theImages[2] = 'statement-3.jpg'
theImages[3] = 'statement-4.jpg'

var j = 0
var p = theImages.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
   preBuffer[i] = new Image()
   preBuffer[i].src = theImages[i]
}

var whichImage = Math.round(Math.random()*(p-1));

function showImage(){
	document.write('<img src="images/'+theImages[whichImage]+'" alt="">');
}

*/

/* FORM VALIDATION **********************************/
function checkEmail (strng) {
	var error="";
	if (strng == "") {
	   error = "Please enter your email address.\n";
	} else {
		var emailFilter=/^.+@.+\..{2,3}$/;
		if (!(emailFilter.test(strng))) { 
			error = "Please enter a valid email address.\n";
		} else {
	//test email for illegal characters
		   var illegalChars = "/[\(\)\<\>\,\;\:\\\"\[\]]/";
		   if (strng.match(illegalChars)) {
			  error = "The email address contains illegal characters.\n";
		   }
		}
	}
	return error;    
}

// non-empty textbox
function checkTextfield(strng,field) {
var error = "";
  if (strng.length == 0) {
	  if (field == 'name') {
	 error = "Please enter your name.\n";
	  } else if (field == 'phone') {
	 error = "Please enter your phone number.\n";
	  }
  }
return error;	  
}

function checkQuestion(strng) {
	var error = "";
	if(strng.length == 0) {
		error = "You didn't answer the easy question.";
	}
	strng = strng.toLowerCase();
	if(strng != 'wet'){
		error = "Your answer to the easy question is wrong. It's \"wet\"!";
	}
	return error;
}

function checkWholeForm(theForm) {
	var why = "";
		why += checkTextfield(theForm.name.value,'name');
		why += checkTextfield(theForm.phone.value,'phone');
		why += checkEmail(theForm.email.value);
	if (why != "") {
		alert(why);
		return false;
	} else {
		return true;
	}
}

/* FLASH INSERTION **********************************/
function makeFlash()
{
  	document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='354' height='279' title='Michael's House Facility Photos' class='flashbanner' VIEWASTEXT><param name='movie' value='facility/facility.swf' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><embed src='facility/facility.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='354' height='279' wmode='transparent' class='flashbanner'></embed></object>");
}

function loadAdPixel(){
  //	document.adPixel.src = "https://secure.ace-tag.advertising.com/action/type=282894319/bins=1/rich=0/mnum=1516/logs=0";
}