function getObj(name) {
	if (document.getElementById) {
		return document.getElementById(name);
	} else if (document.all) {
		return document.all[name];
	} else {
	return document.layers[name];
	}
}

function closeAll(number) {
	var div;
	for (var i=1; i<=number; i++) {
		div=getObj('d' + i);
		div.style.display = "none";
	}
	
	//var divCollection = document.getElementsByTagName("div");
  //for (var i=0; i<divCollection.length; i++) {
  //    if(divCollection[i].getAttribute("className") == "info") {
  //        divCollection[i].style.display = "none";
  //	   } 
  //}
 
}

function toggle(that,prodImg,num_to_close) {
  //var img = getObj('detail'); //we must be nice for standards-compliant browsers to play with us
	//img.src = '/savasa/images/products/'+prodImg;
	closeAll(num_to_close);
	if (that.style.display == "none") {
		that.style.display = "inline";
	} else {
		that.style.display = "none";
	}
}

function toggle2(that) {
	if (that.style.display == "none") {
		that.style.display = "inline";
	} else {
		that.style.display = "none";
	}
}

function show_file_upload(file) {
	var div = getObj(file)	
	if (div.style.display == "none") {
		div.style.display = "inline";
	} else {
		div.style.display = "none";
	}
}

function popIt(index) {
  window.open('index.cfm?zx=popup&img=' + index + '', 'script', 'height=550,width=550,scrollbars=0,resizable=0,menubar=0,left=0,top=0');
}

function popIt2(index) {
  window.open(index, 'script', 'height=500,width=515,scrollbars=0,resizable=0,menubar=0,left=0,top=0');
}

function popIt3(index) {
  window.open(index, 'script', 'height=650,width=515,scrollbars=0,resizable=0,menubar=0,left=0,top=0');
}

function popIt4(index) {
  window.open(index, 'script2', 'height=250,width=375,scrollbars=0,resizable=0,menubar=0,left=0,top=0');
}


function popProduct(index, width, height) {
  var height2 = parseInt(height);
	height2 = height2 + 60;
  window.open('index.cfm?zx=popup&img=' + index + '', 'script', 'height=' + height2 + ',width=' + width + ',scrollbars=0,resizable=0,left=0,top=0');
}

//configure the two variables below to match yoursite's own info
var bookmarkurl="http://www.savasayoga.com"
var bookmarktitle="SavasaYoga.com"

function addbookmark() {
	if (navigator.appName=="Netscape") {
		alert('To bookmark this site, click '+'Bookmarks | Add bookmark '+'or press Ctrl+D.');
	}
	if (document.all) {
		window.external.AddFavorite(location.href,document.title);
	}
}

/*
The following were copied from the login.js file in the same directory
*/

//document.write('<style> .menu{position: absolute;}</style>');
var timeOn = null
numMenus = 4;
document.onmouseover = hideAllMenus;
document.onclick = hideAllMenus;
window.onerror = null;

//FOR MENU DROP DOWN MENU
// MENU MOUSE OVER 
function menuOver(itemName) {
 clearTimeout(timeOn)
 menuActive = 1
}// MENU MOUSE OUT 
function menuOut(itemName) {
 if(document.layers) {
 	menuActive = 0 
 	timeOn = setTimeout("hideAllMenus()", 1)
  }
}

function getStyleObject(objectId) {
    // cross-browser function to get an object's style object given its id
    if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
	return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
	return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
	return document.layers[objectId];
    } else {
	return false;
    }
} // getStyleObject

function changeObjectVisibility(objectId, newVisibility) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
	styleObject.visibility = newVisibility;
	return true;
    } else {
	//we couldn't find the object, so we can't change its visibility
	return false;
    }
} // changeObjectVisibility

function showMenu(menuNumber, eventObj, labelID) {
    hideAllMenus();
	if(document.layers) {
	img = getImage("img" + menuNumber);
 	x = getImagePageLeft(img);
 	y = getImagePageTop(img);
 	menuTop = y + 10; // LAYER TOP POSITION
	eval('document.layers["menu'+menuNumber+'"].top="'+menuTop+'"');
 	eval('document.layers["menu'+menuNumber+'"].left="'+x+'"');
	}
	eventObj.cancelBubble = true;
    var menuId = 'menu' + menuNumber;
    if(changeObjectVisibility(menuId, 'visible')) {
	return true;
    } else {
	return false;
    }
}

function hideAllMenus() {
    for(counter = 1; counter <= numMenus; counter++) {
	changeObjectVisibility('menu' + counter, 'hidden');
    }
}


function isEmailAddr(email)
{
  var result = false;
  var theStr = new String(email);
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}

function validRequired(formField,fieldLabel)
{
	var result = true;
	
	if (formField.value == "")
	{
		alert('Please enter a value for the "' + fieldLabel +'" field.');
		formField.focus();
		result = false;
	}
	
	return result;
}

function allDigits(str)
{
	return inValidCharSet(str,"0123456789");
}

function inValidCharSet(str,charset)
{
	var result = true;

	// Note: doesn't use regular expressions to avoid early Mac browser bugs	
	for (var i=0;i<str.length;i++)
		if (charset.indexOf(str.substr(i,1))<0)
		{
			result = false;
			break;
		}
	
	return result;
}

function validEmail(formField,fieldLabel,required)
{
	var result = true;
	
	if (required && !validRequired(formField,fieldLabel))
		result = false;

	if (result && ((formField.value.length < 3) || !isEmailAddr(formField.value)) )
	{
		alert("Please enter a complete email address in the form: yourname@yourdomain.com");
		formField.focus();
		result = false;
	}
   
  return result;

}


function validateForm(theForm)
{
	// Customize these calls for your form

	// Start ------->
	if (!validRequired(theForm.name,"Name",true))
		return false;

	if (!validEmail(theForm.email,"Email Address",true))
		return false;

	// <--------- End
	
	return true;
}

function validateForm2(theForm)
{
	// Customize these calls for your form

	// Start ------->
	if (!validRequired(theForm.name,"Your Name",true))
		return false;
		
	if (!validRequired(theForm.friend_name,"Friend's Name",true))
		return false;

	if (!validEmail(theForm.email,"Email Address",true))
		return false;
		
	if (!validEmail(theForm.friend_email,"Friend's Email Address",true))
		return false;

	// <--------- End
	
	return true;
}