// Checks to make sure that something has been entered
// in the search text box before it can be submitted to the search engine.
function checkrequired() {
if ((document.searchform.Terms.value=='')||(document.searchform.Terms.value=='Search zygo.com')) {
alert("Before starting the search,\nplease enter the words that you want to\nsearch for in the text box in the left column."); return false; }
else { return true; }
}

function startsearch() {
if ((document.searchform.Terms.value=='')||(document.searchform.Terms.value=='Search zygo.com')) {
alert("Before starting the search,\nplease enter the words that you want to\nsearch for in the text box in the left column."); }
else { document.searchform.submit(); }
}

function popup(mypage, myname, w, h, win_x, win_y, scroll, resize) {
	if (screen.width) {
	var win_x = (screen.width - w) / 2;
	var win_y = (screen.height - h) / 4;
	}
else { var win_x = "200"; var win_y = "100"; }
winprops = 'height='+h+',width='+w+',top='+win_y+',left='+win_x+',scrollbars='+scroll+',resizable='+resize;
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}


function laime(user,domain,link) {
var default_domain = "zygo.com";								// defines default domain for email addresses
// document.write('user='+user + ', domain=' + domain + '<br>')	// for troubleshooting
if (!domain) { domain = default_domain }						// inserts default domain if omitted
domain	= domain.replace( /[\s,]+/g, "." );						// convert space or , to .
user	= user.replace( /\s/g, "" );							// remove spaces in user name
if (!/\.\w{2,3}$/.test(domain)) { domain = domain + '.com' }	// appends .com if omitted
var fulladdr = user + "@" + domain;
if (!link) { link = fulladdr }									// if no link name specified, use address
document.write('<a href="mailto:' + fulladdr + '?bcc=webmaster@zygo.com">' + link + '</a>')
};

function laimetrap(user,domain,link) {
var default_domain = "zygo.com";								// defines default domain for email addresses
// document.write('user='+user + ', domain=' + domain + '<br>')	// for troubleshooting
if (!domain) { domain = default_domain }						// inserts default domain if omitted
domain	= domain.replace( /[\s,]+/g, "." );						// convert space or , to .
user	= user.replace( /\s/g, "" );							// remove spaces in user name
if (!/\.\w{2,3}$/.test(domain)) { domain = domain + '.com' }	// appends .com if omitted
var fulladdr = user + "@" + domain;
if (!link) { link = fulladdr }									// if no link name specified, use address
document.write(fulladdr)
};


function showStatus(msg) {
window.status=msg;
}

function popup(mypage, myname, w, h, scroll, win_x, win_y) {

if (!win_x) { win_x = (screen.width - w) / 2 };
if (!win_y) { win_y = (screen.height - h) / 4 };
// if (screen.width) {
// if (!win_x) { win_x = (screen.width - w) / 2 };
// if (!win_y) { win_y = (screen.height - h) / 4 };
// }
// else { var win_x = "200"; var win_y = "100"; }
winprops = 'height='+h+',width='+w+',top='+win_y+',left='+win_x+',scrollbars='+scroll+',resizable';
win = window.open(mypage, myname, winprops);
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}




function validate() {

if (document.hottip_form.ques_info != null) {			// see if comments box has content
var maxchar		= 500;
var sumval		= document.hottip_form.ques_info.value; sumval = strip(sumval);
var sumlength	= sumval.length;
var comment		= document.hottip_form.ques_info;
var diff		= sumlength - maxchar;

if (diff > 1) { var chars = " characters." } else { var chars = " character." }

if (sumlength > maxchar && comment != '') {
alert("The \"Question or Additional Info\" entry contains "+sumlength+" characters.\n\
The limit is "+maxchar+" characters.\nPlease shorten it by "+diff+chars); return false;}

}	// end spie summary checking

return true;

}	// end validate function




function strip( s ) {
	s = s.replace( /^\s+/, "" );   // remove leading whitespace
	s = s.replace( /\s+$/, "" );  // remove trailing whitespace
	return s;
}



function validate( aForm )
{

if	(aForm.elements.Dates2) {
	var value = aForm.elements.Dates2.value; value = strip( value );
	if ( value == '0' ) { alert( "You must enter a Second Choice for the Class Dates" ); return false; }
}

  var value = aForm.elements.Name.value;
  value = strip( value );
  if ( value == '' )
    {
    alert( "You must enter a Name" );
    return false;
    }
  value = aForm.elements.MailingAddress.value;
  value = strip( value );
  if ( value == '' )
    {
    alert( "You must enter a Mailing Address" );
    return false;
    }
  value = aForm.elements.PhoneNumber.value;
  value = strip( value );
  if ( value == '' )
    {
    alert( "You must enter a Phone Number" );
    return false;
    }
    
   value = aForm.elements.EMailAddress.value; value = strip( value );
   if ( value == '' )  { alert( "You must enter an EMail Address" ); return false; }


var postring = '';
if (aForm.elements.PONumber) { value = aForm.elements.PONumber.value; postring = ' or a PO Number'; } else { value = '' }
value = strip( value );
if ( value == '' )
{

    var value2 = aForm.elements.NameOnCard.value; value2 = strip( value2 );
    if ( value2 == '' ) { alert( "You must enter Credit Card Info" + postring ); return false; }

    value = aForm.elements.CardNumber.value; value = strip( value );
    if ( value == '' ) { alert( "You must enter a Credit Card Number" + postring ); return false; }

    value = aForm.elements.ExpirationDate.value; value = strip( value );
    if ( value == '' )  { alert( "You must enter an Expiration Date" ); return false; }

    value = aForm.elements.CardIssuer.value; value = strip( value );
    if ( value == '' )  { alert( "You must select a Credit Card Issuer\nfrom the drop-down menu" ); return false; }

}
else {
	value = aForm.elements.CardNumber.value; value = strip( value );
	if ( value != '' ) {
	alert( "You have entered both Credit Card Information\nand a PO Number. Please use one or the other." );
	return false;
	}
}

return true;

}

