/*************************************************
** Javascript file for MossSpa.com
** Steven Ferrino, sferrino@realmcreative.com
**
**
**
*************************************************/



var timerMan;
var flyOut;
var lastMenu = new Object();
var servicesDiv = "servicesDiv";
var productsDiv = "productsDiv";
var aboutDiv = "aboutDiv";

var dd = "ce7145174d88bd6921148c04f5fc155c";

/*****************************************************************
** surprisingly this precaching still works after all these years
******************************************************************/
var philosophy_on = new Image();
var about_on = new Image();
var services_on = new Image();
var products_on = new Image();
var events_on = new Image(); 
var fitness_on = new Image();
var wellness_on = new Image();
var specials_on = new Image(); 
var gift_on = new Image();
var etiquette_on = new Image();
var location_on = new Image();
var contact_on = new Image();

philosophy_on.src = "/images/philosophy_on.gif";
about_on.src = "/images/about_on.gif";
services_on.src = "/images/services_on.gif";
products_on.src = "/images/products_on.gif";
events_on.src = "/images/events_on.gif";
fitness_on.src = "/images/fitness_on.gif";
wellness_on.src = "/images/wellness_on.gif";
specials_on.src = "/images/specials_on.gif";
gift_on.src = "/images/gift_on.gif";
etiquette_on.src = "/images/etiquette_on.gif";
location_on.src = "/images/location_on.gif";
contact_on.src = "/images/contact_on.gif";

var about_contact_on = new Image();
var about_employment_on = new Image();
var about_in_news_on = new Image();
var about_leed_on = new Image();
var about_philosophy_on = new Image();
var about_press_on = new Image();

var products_lines_on = new Image();
var products_store_on = new Image();

var services_art_lib_on = new Image();
var services_bodywork_on = new Image();
var services_facial_on = new Image();
var services_glossary_on = new Image();
var services_hair_on = new Image();
var services_nail_on = new Image();
var services_package_on = new Image();
var services_price_on = new Image();
var services_treatment_on = new Image();
function getActiveFontSize() {
	return document.getElementById("fontSize").value;
}

function init() {
	/* since older versions of IE don't support PNG
		 I had to use 2 different versions of the flyout menu
	*/ 
	if ((oldIE) || (IE6)) {
		aboutDiv = "aboutIEDiv";
		servicesDiv = "servicesIEDiv";
		productsDiv = "productsIEDiv";
	}
}


function decreaseFont() {
	var eleArray = new Array();
	eleArray = getElementsByStyleClass("LG");
	
	for (var t = 0; t < eleArray.length; t++) {
		var thisClass = eleArray[t].className.substr(0, parseInt(eleArray[t].className.length)-2);
		eleArray[t].className = thisClass + "SM";		
	}
	document.getElementById("fontSize").value = "SM";		
}

function increaseFont() {
	var eleArray = new Array();
	eleArray = getElementsByStyleClass("SM");
	
	for (var t = 0; t < eleArray.length; t++) {
		var thisClass = eleArray[t].className.substr(0, parseInt(eleArray[t].className.length)-2);
		eleArray[t].className = thisClass + "LG";		
	}
	document.getElementById("fontSize").value = "LG";	
}


function getElementsByStyleClass (className) {
  var all = document.all ? document.all:document.getElementsByTagName('*');
  var elements = new Array();
  for (var e = 0; e < all.length; e++) {
    if (all[e].className.indexOf(className) > -1) {
      elements[elements.length] = all[e];
		}
	}
  return elements;
}



/* For the Flyout Menus */
function highlight(oPlace, oSrc) {

	if (ui == dd) {
//		alert(oPlace.src + ":" + oSrc.src);
//		oPlace.src = oSrc.src;
//		alert(oPlace.src + ":" + oSrc.src);
	}

	if (isGood) {
		oPlace.src = oSrc.src;

		// lets turn them all off first to make sure no more than one is visible
		document.getElementById(aboutDiv).style.display = "none";

		document.getElementById(servicesDiv).style.display = "none";
		document.getElementById(productsDiv).style.display = "none";

		window.clearTimeout(timerMan);

		if (oPlace.id == "about") {
			if ((oldIE) || (IE6)) {
				allowDieNow("servicesIEDiv", "services_off.gif");
				allowDieNow("productsIEDiv", "products_off.gif");
				document.getElementById("aboutIEDiv").style.display = "block";
			} else {
				allowDieNow("servicesDiv", "services_off.gif");
				allowDieNow("productsDiv", "products_off.gif");
				document.getElementById("aboutDiv").style.display = "block";
			}				
		}

		if (oPlace.id == "services") {
			if ((oldIE) || (IE6)) {
				allowDieNow("aboutIEDiv", "about_off.gif");
				allowDieNow("productsIEDiv", "products_off.gif");
				document.getElementById("servicesIEDiv").style.display = "block";
			} else {
				allowDieNow("aboutDiv", "about_off.gif");
				allowDieNow("productsDiv", "products_off.gif");
				document.getElementById("servicesDiv").style.display = "block";
			}

		}
		if (oPlace.id == "products") {
			if ((oldIE) || (IE6)) {
				allowDieNow("aboutIEDiv", "about_off.gif");
				allowDieNow("servicesIEDiv", "services_off.gif");
				document.getElementById("productsIEDiv").style.display = "block";
			} else {
				allowDieNow("aboutDiv", "about_off.gif");
				allowDieNow("servicesDiv", "services_off.gif");
				document.getElementById("productsDiv").style.display = "block";
			}

		}			
	}
}

/* 
My own little concotion for testing forms and required fields
*/
function _testForm() {
	var myForm = document.getElementById('myForm');
	var oCount = myForm.length;

	/* 	I start Out true just in case an older version of a browser doesn't like anything
	 		it will still work itself out, we will just have the posibility that they didn't 
			fill out the whole form */
	var canSub = true;
	for (var i = 0; i < oCount; i++) {
		var customer_Ele = myForm[i];
		if ((customer_Ele.getAttribute('needed') == "true") && (customer_Ele.value == "") ) {
			try {
				alert(customer_Ele.getAttribute('msg'));
				customer_Ele.style.borderColor="red";
				customer_Ele.focus();

				// Of Cource IE couldn't plan nice with the other little reigndeer
				if (customer_Ele.addEventListener){
					customer_Ele.addEventListener('keypress', function() { customer_Ele.style.borderColor = "grey"; }, false); 
				} else if (customer_Ele.attachEvent){
					customer_Ele.attachEvent('onkeypress', function() { customer_Ele.style.borderColor="#ffffff"; } );
				}
				canSub = false;
				break;
			} catch(er) { }
		} else {

		}	
	}
	if (canSub) {		
		return true;
	} else {
		return false;
	}			
}

function newsLetter() {
	if (window.open) {
		 window.open ("http://visitor.constantcontact.com/d.jsp?m=1101639856545&p=oi", "mywindow","location=0,status=1,scrollbars=1,width=500,height=400");
	} else {
		
	}
}




// return the rolled over image to its normal state
function norm(oPlace, oImg) {

	window.clearTimeout(timerMan);

	oPlace.src = "/images/" + oImg;

	if (oPlace.id == "about") {
		document.getElementById(aboutDiv).style.display = "none";
	}

	if (oPlace.id == "services") {
		document.getElementById(servicesDiv).style.display = "none";
	}
	if (oPlace.id == "products") {
		document.getElementById(productsDiv).style.display = "none";
	}

}

function swapImage(oPlace, oImg) {
	oPlace.src = "http://www.mossspa.com/images/" + oImg;	
}

function keepAlive(oSel, oPlace) {
	window.clearTimeout(timerMan);
	oSel.style.display = "block";
	document.getElementById(oPlace).src = "/images/" + oPlace + "_on.gif" ;
}

function allowDie(oSel, oImg) {
	timerMan = window.setTimeout("allowDieNow('" + oSel + "','" + oImg + "');", 500);
}


function allowDieNow(oSel, oImg) {
	window.clearTimeout(timerMan);	
	document.getElementById(oSel).style.display = "none";
	flyOut = "";	
	oPlace = oImg.replace("_off.gif", "");
	document.getElementById(oPlace).src = "/images/" + oImg;		
}


