document.onmousedown = rtclicknocopy

window.defaultStatus ="Mylston Solutions...offers web, intranet and database solutions for your specific industry and company needs" 

var mymessage = "PLEASE RESPECT INTELLECTUAL PROPERTY. The contents of this site, including the scripts, written materials, graphics and audio files, are COPYRIGHT PROTECTED. Please do not copy and post its contents, in part or in whole, on ANY commercial, non-profit, or personal website and other similar media. Thank you.";

if (document.images) {
	navprojects 		= new Image
	navcollaboration	= new Image
	navwebcard   		= new Image
	navinquiry    		= new Image
	navsupport			= new Image
	navhome				= new Image

	navprojectsdim 		= new Image
	navcollaborationdim	= new Image
	navwebcarddim  		= new Image
	navinquirydim  		= new Image
	navsupportdim 		= new Image
	navhomedim 			= new Image

	navprojects.src  		= "nav_projects100.gif"
	navcollaboration.src	= "nav_collaboration100.gif"
	navwebcard.src    		= "nav_webcard100.gif"
	navinquiry.src    		= "nav_inquiry100.gif"
	navsupport.src 			= "nav_support100.gif"
	navhome.src 			= "nav_home100.gif"

	navprojectsdim.src  	= "nav_projects100dim.gif"
	navcollaborationdim.src	= "nav_collaboration100dim.gif"
	navwebcarddim.src    	= "nav_webcard100dim.gif"
	navinquirydim.src    	= "nav_inquiry100dim.gif"
	navsupportdim.src 		= "nav_support100dim.gif"
	navhomedim.src	 		= "nav_home100dim.gif"
}

function rtclicknocopy(keyp){
  if (navigator.appName == "Netscape" && keyp.which == 3) {
    alert(mymessage);
    return false;
  }

  if (navigator.appVersion.indexOf("MSIE") != -1 && event.button == 2) {
    alert(mymessage);
    return false;
  }
}

// pop-up window for site map
function updateParentWin(newURL) {
	window.opener.open(newURL,'_parent');
}

function statusMsg(type) {
  switch (type) 
    {
    /* shopper options */
	case "Company" :
         window.status="Manage company information, including testimonials, promos, news and calendar..." 
  	     break
	case "Products" :
         window.status="Manage sections, facilities, e-condolences, e-prayers and e-cards..." 
  	     break
	case "Parks" :
         window.status="Manage parks and lots..." 
  	     break
	case "Obituaries" :
         window.status="Manage obituaries and interments..." 
  	     break
	case "Agents" :
         window.status="Manage agents, announcements/broadcasts and price inquiries..." 
	     break
	case "Sales" :
         window.status="Manage sales, owners, payments and payment due alerts..." 
	     break
	case "Ads" :
         window.status="Manage ads for currently-owned lots..." 
	     break
	case "Users" :
         window.status="Activate accounts and manage site users and e-privileges..." 
	     break
	case "Site" :
         window.status="Go back to the Holy Gardens Memorial Park site..." 
	     break
	case "Products Menu" :
         window.status="Go on a garden tour, examine the lot types and facilities, inquire about prices and even order the lot online!" 
  	     break
	case "Bereaved Menu" :
         window.status="For the bereaved friends and family, extend your condolences, read the obituaries and know the interment details..." 
  	     break
	case "Owners Menu" :
         window.status="For the lot owners, track payments and outstanding balances, monitor lot usage and learn about your online privileges..." 
  	     break
	case "Agents Menu" :
         window.status="For authorized agents, download prices, list price inquiries and clients, read announcements and send messages..." 
  	     break
	case "Investors Menu" :
         window.status="For authorized investors, have access to confidential financial reports and send messages to the company..." 
  	     break
	case "Marketplace Menu" :
         window.status="For lot owners, advertise lots for sale while those interested to buy, post buy ads..." 
  	     break
	case "Profile Menu" :
         window.status="All the relevant information on the company..." 
  	     break
    default:
         window.status="Kindly click to avail of more information"
    }
	return true
}

/*-------------------------------------------------------------------*/              
//function to validate numeric entry
function validNum(item,label,max,min,sint) {

   if (isNaN(item.value)) 
      {errorAlert(item,"INVALID: "+label+" Must Be Numeric"); }

   if (item.value > max) 
      {errorAlert(item,"INVALID: "+label+" Exceeds Maximum Allowable Value"); }
 
   if (item.value < min) 
      {errorAlert(item,"INVALID: "+label+" Is Below Minimum Allowable Value"); }

   if (sint=="yes") {
      // convert to integer
      item.value=Math.round(item.value); 
   }
} 

//function to validate credit card entry
function validCard(item,label,max,min) {
   msgError = " Is Not A Valid Card Number";

   if (isNaN(item.value)) 
      {errorAlert(item,"INVALID: "+label+msgError); }

   if (item.value > max) 
      {errorAlert(item,"INVALID: "+label+msgError); }
 
   if (item.value < min) 
      {errorAlert(item,"INVALID: "+label+msgError); }
} 


//function to validate date using select data entry
function validDate2(month,day,year,msg) {
   var invalid = 'n'; 

   if (((month==4 || month==6 || month==9 || month==11) && day>30)) 
      {invalid = 'y';}
   else
      {if (day>31) invalid='y';}
   
   if ((month==2 && (year/4)==0 && day>29) || (month==2 && (year/4)!=0 && day>28)) 
      invalid = 'y'; 
   
   if (invalid=='y')
      errorAlert2("INVALID: "+msg);
}


//function to validate blank entry
function validBlank(item) {
   return (item.length > 0);
}

//function to compare values
function validPassword(pass1,pass2) {
   return (pass1 == pass2);
}

//function to validate an email address
function validEmail(item) {
   var wAt=item.indexOf ('@')
   // if without @ or at start
   if (wAt== -1 || wAt== 0) return false;
   return true;
}

//function to validate radio buttons
function validRadio(item) {
   var wChk = -1
   for (i=0; i<item.length;i++) {
		if (item[i].checked) {
			wChk = i
	    }
   }
   if (wChk==-1) return false;
   return true;
}

//function to determine checked radio button
function chkRadio(item) {
   var wChk = -1
   for (i=0; i<item.length;i++) {
		if (item[i].checked) {
			wChk = i
	    }
   }
   return wChk;
}

//function to un-check radio buttons
function unchkRadio(item) {
   for (i=0; i<item.length;i++) {
		if (item[i].checked) {
			item[i].checked=false
	    }
   }
}

// display an error alert and return to erroneous data
function errorAlert(elem, text) {
   // abort if we already found an error, one error handling at a time
   if (errFound) return;
   window.alert(text);
   elem.select();
   elem.focus();

   errFound = true;
}

// display an error alert for radio buttons
function errorAlert2(text) {
   // abort if we already found an error, one error handling at a time
   if (errFound) return;
   window.alert(text);

   errFound = true;
}

//global variable for error flag
var errFound = false;

// main validation function

function validInqForm() {
	errFound = false;
	// blank
	if (!validBlank(document.inqForm.co_name.value))
		errorAlert(document.inqForm.co_name,"INVALID: Company Name Must Be Specified");
	if (!validBlank(document.inqForm.firstname.value))
		errorAlert(document.inqForm.firstname,"INVALID: First Name Must Be Specified");
	if (!validBlank(document.inqForm.lastname.value))
		errorAlert(document.inqForm.lastname,"INVALID: Last Name Must Be Specified");

	if (!validBlank(document.inqForm.phones.value) &&
	   !validBlank(document.inqForm.fax.value) &&
	   !validBlank(document.inqForm.email.value) &&
	   !validBlank(document.inqForm.cell.value)
	)
		errorAlert(document.inqForm.phones,"Please specify at least one phone no./FAX no./e-mail address/cell phone no.");

	if (document.inqForm.email.value!='') {
		if (!validEmail(document.inqForm.email.value)) 
			errorAlert(document.inqForm.email,"Sorry, invalid E-Mail Address");
	}

	return !errFound; /* true if there are no errors */
}

function validSupportForm() {
	errFound = false;
	// blank
	if (!validBlank(document.supportForm.co_name.value))
		errorAlert(document.supportForm.co_name,"INVALID: Company Name Must Be Specified");
	if (!validBlank(document.supportForm.co_conperson.value))
		errorAlert(document.supportForm.co_conperson,"INVALID: Contact Person Must Be Specified");
	if (!validBlank(document.supportForm.prob_details.value))
		errorAlert(document.supportForm.prob_details,"INVALID: Details Must Be Specified");

	return !errFound; /* true if there are no errors */
}

