function validateForm(formObj) {
	// Validates form to make sure all elements exist
	var checked = false;
	for(i=0; i<formObj.elements.length; i++)
	{
		if(formObj.elements[i].type == "text" || formObj.elements[i].type == "textarea")
		{
			if(formObj.elements[i].value.length < 1){ return false; }
			if(formObj.elements[i].value==formObj.elements[i].alt){  return false; }
		}else if(formObj.elements[i].type == "select")
		{
			if(formObj.elements[i].options[formObj.elements[i].selectedIndex].text.length < 1)
			{
				return false;
			}
		}
	}
	return true;
}
function enlarge(ele,wid,hei) {
	// Enlarges a window showing garment/design
	var url = ele.getProperty("href");
	var w = window.getWidth();
	var h = window.getHeight();
	var l = (w / 2) - (wid/2);
	var t = (h / 2) - (hei/2) + 100;
	window.open(url, 'enlarge', 'width='+wid+',height='+hei+',resize=true,left='+l+',top='+t);
}
function ReadCookie(cookieName) {
	// Reads a cookie
 	var theCookie=""+document.cookie;
 	var ind=theCookie.indexOf(cookieName);
 	if (ind==-1 || cookieName=="") return null; 
 	var ind1=theCookie.indexOf(';',ind);
 	if (ind1==-1) ind1=theCookie.length; 
 	return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}


function validateEmail(addr,man,db) {
if (addr == '' && man) {
   if (db) alert('email address is mandatory');
   return false;
}
if (addr == '') return true;
var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
for (i=0; i<invalidChars.length; i++) {
   if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
      if (db) alert('email address contains invalid characters');
      return false;
   }
}
for (i=0; i<addr.length; i++) {
   if (addr.charCodeAt(i)>127) {
      if (db) alert("email address contains non ascii characters.");
      return false;
   }
}

var atPos = addr.indexOf('@',0);
if (atPos == -1) {
   if (db) alert('email address must contain an @');
   return false;
}
if (atPos == 0) {
   if (db) alert('email address must not start with @');
   return false;
}
if (addr.indexOf('@', atPos + 1) > - 1) {
   if (db) alert('email address must contain only one @');
   return false;
}
if (addr.indexOf('.', atPos) == -1) {
   if (db) alert('email address must contain a period in the domain name');
   return false;
}
if (addr.indexOf('@.',0) != -1) {
   if (db) alert('period must not immediately follow @ in email address');
   return false;
}
if (addr.indexOf('.@',0) != -1){
   if (db) alert('period must not immediately precede @ in email address');
   return false;
}
if (addr.indexOf('..',0) != -1) {
   if (db) alert('two periods must not be adjacent in email address');
   return false;
}
var suffix = addr.substring(addr.lastIndexOf('.')+1);
if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {
   if (db) alert('invalid primary domain in email address');
   return false;
}
return true;
}