// JavaScript Function Library
VENDOR = ''

// Check DOM support
if 	(document.getElementById)	DOMS = 3	// Supports Web Standard
else if	(document.all)		 	DOMS = 2	// Supports MS document.all
else if	(document.layers)	 	DOMS = 0	// Supports NS layers
else				 	DOMS = 0;	// No DOM gateway support

// Return DOM object pointer for appropriate DOM interface
function getObj(s) {
  switch(DOMS) { 
    case 1: return(document[s]);
    case 2: return(document.all[s]);
    case 3: return(document.getElementById(s));
  }
}

// Reset input field color when changed
function fldReset() { this.style.backgroundColor=''; this.style.borderColor='#bbbbbb'; }

// display error message, color error field, set 
function setErm(f,m) {
  alert(m);
  f.onchange = fldReset;
  f.style.backgroundColor="#ff9"; 
  f.style.borderColor="#f00"; 
  f.focus(); 
  return false;
}

// Check mailto form field(s) for required input, When a field is found with missing input,
// alert user, set field pink, and set focus to it.
function chkMailform(s) {
   if (s.Name.value=='')		return setErm(s['Name'],		'You must enter your name to continue.')
   if (s.Telephone.value=='')		return setErm(s['Telephone'],		'You must enter your daytime phone number to continue.')
   if (s.EveTelephone.value=='')	return setErm(s['EveTelephone'],	'You must enter your evening phone number to continue.')
   if (s['MM_EMAILTO[]'][1].value=='')	return setErm(s['MM_EMAILTO[]'][1],	'You must enter your email address to continue.')
   if (s.Email.value=='')		return setErm(s['Email'],		'You must verify your email address to continue.')
   return true;
}

function imgRot(s,pt,tm) {
  document.images[s].src = "images/"+s+"/"+pt+".jpg";
  ++pt;
  if (pt>6) { pt = 1 };
  setTimeout('imgRot("' + s + '",' + pt + ',' + tm + ')',tm);
}

function distCheck(s) {
  var sz = s['MM_EMAILTO[]'].length;
  if (sz==undefined) {
    if (s['MM_EMAILTO[]'].checked==true) {
      open_Broadcast();
      return true;
    }
  }
  else for (var i=0; i<sz; i++) if (s['MM_EMAILTO[]'][i].checked==true) { open_Broadcast(); return true; }
  alert("You must select at least 1 email recipent to continue.");
  return false;
}

function verifyDelete(s)	{ return(confirm("Are you sure you want to delete " + s + "?")); }

function editAdverts(advid)		{ window.open('admin_adverts_edit.php?advid='+advid,'advedit','height=600,width=800,scrollbars,resizable'); return false; }
function editAdd(advid,addid)		{ window.open('admin_adverts_add.php?advid='+advid+'&addid='+addid,'addedit','height=750,width=1000,scrollbars,resizable'); return false; }
function editCoupon(advid,couponid)	{ window.open('admin_adverts_coupon.php?advid='+advid+'&couponid='+couponid,'couponedit','height=500,width=500,scrollbars,resizable'); return false; }
function editAddCond(addid,adcid)	{ window.open('admin_adverts_addcond.php?addid='+addid+'&adcid='+adcid,'acedit','height=500,width=500,scrollbars,resizable'); return false; }
function editColor(cid)		{ window.open('admin_colors_edit.php?cid='+cid,'color','height=200,width=300,scrollbars,resizable'); return false; }
function editEtype(etid)		{ window.open('admin_etypes_edit.php?etid='+etid,'etype','height=200,width=300,scrollbars,resizable'); return false; }
function editEvent(eventid)		{ window.open('admin_events_edit.php?eventid='+eventid,'event','height=500,width=500,scrollbars,resizable'); return false; }
function editLength(lid)		{ window.open('admin_lengths_edit.php?lid='+lid,'length','height=200,width=360,scrollbars,resizable'); return false; }
function editNeckline(nlid)		{ window.open('admin_necklines_edit.php?nlid='+nlid,'length','height=200,width=360,scrollbars,resizable'); return false; }
function editState(stateid)		{ window.open('admin_states_edit.php?stateid='+stateid,'length','height=200,width=360,scrollbars,resizable'); return false; }
function editMsg(eventid)               { window.open('event_msgboard_edit.php?eventid='+eventid,'msgedit','height=500,width=500,scrollbars,resizable');  return false; }
function eventAdd()			{ window.open('event_add.php','eventadd','height=500,width=500,scrollbars,resizable'); return false; }
function eventSearch()		{ window.open('event_search.php','sarevent','height=400,width=400,scrollbars,resizable'); return false; }
function eventSearchClear()		{ window.open('event_search.php?EV_FUNC=clear','sarevent','height=400,width=400,scrollbars,resizable'); return false; }
function eventSearchDate()		{ window.open('event_search_date.php','sardate','height=380,width=280,resizable,scrollbars'); return false; }
function dressAdd()			{ window.open('dress_add.php','dressadd','height=750,width=1000,scrollbars,resizable'); return false; }
function editDress(eventid,dressid)	{ window.open('admin_dress_edit.php?eventid='+eventid+'&dressid='+dressid,'dressedit','height=750,width=1000,scrollbars,resizable'); return false; }
function editNews(newsid)		{ window.open('admin_news_edit.php?newsid='+newsid,'advedit','height=500,width=500,scrollbars,resizable'); return false; }
function eventStatePick(etid)		{ window.open('event_state_pick.php?etid='+etid,'statepick','height=200,width=300,scrollbars,resizable'); return false; }

function allClients() {
  var sz = document.distrib['MM_EMAILTO[]'].length;
  for (var i=0; i<sz; i++) document.distrib['MM_EMAILTO[]'][i].checked=true;
}

function editContact(contactid) {
  window.open('admin_contacts_edit.php?contactid='+contactid,'contact','height=550,width=650,scrollbars');
  return false;
}

function open_Broadcast() {
  window.open('','broadcast','height=500,width=500,scrollbars');
  return false;
}

function chkContact(s) {
   if (s.firstname.value=='')		return setErm(s['firstname'],	'You must enter your first name to continue.');
   if (s.lastname.value=='')		return setErm(s['lastname'],	'You must enter your last name to continue.');
   if ((s.contacthow.value=='Phone')&&(s.dayphone.value=='')&&(s.evephone.value=='')) return setErm(s['dayphone'],	'You must enter a phone number to continue.');
   //if (s.street.value=='')		return setErm(s['street'],	'You must enter your street address to continue.');
   //if (s.city.value=='')		return setErm(s['city'],	'You must enter your city to continue.');
   //if (s.zipcode.value=='')		return setErm(s['zipcode'],	'You must enter your Zip Code to continue.');
   //if (s.dayphone.value=='')		return setErm(s['dayphone'],	'You must enter your daytime phone number to continue.');
// if (s.evephone.value=='')		return setErm(s['evephone'],	'You must enter your evening phone number to continue.');
   if (s.email.value=='')		return setErm(s['email'],	'You must enter your email address to continue.');
   if ((s.email.value.indexOf('@')==-1) || (s.email.value.indexOf('.')==-1)) return setErm(s['email'],'Your E-mail address appears to be invalid. Plaese check!');
   return true;
}

