//function to validate by length
function validlength(item, len) {
   return (item.length >= len);
}
//function to validate an email address
function validemail(item) {
   if (!validlength(item, 5)) return false;
   if (item.indexOf ('@', 0) == -1) return false;
   return true;
}
// display an error alert
function error(elem, text) {
// abort if we already found an error
   if (errfound) return;
   window.alert(text);
   elem.select();
   elem.focus();
   errfound = true;
}
// main validation function
function validate_optin() {
   errfound = false;
			if (!validemail(document.optin.email.value))
    			error(document.optin.email,"Sorry, Invalid Email Address!");

   return !errfound; /* true if there are no errors */
}

function validate_contact() {
   errfound = false;
			if (!validlength(document.contactinfo.first_name.value,1))
    			error(document.contactinfo.first_name,"Sorry, Invalid First Name.\n\nThis information is required.");
			if (!validlength(document.contactinfo.last_name.value,1))
    			error(document.contactinfo.last_name,"Sorry, Invalid Last Name.\n\nThis information is required.");
			if (!validemail(document.contactinfo.email.value))
    			error(document.contactinfo.email,"Sorry, Invalid Email Address.\n\nYou might have mistyped your email.");

   return !errfound; /* true if there are no errors */

}

//Date
var time = new Date(), year;
year = time.getFullYear();

//erase imput box content
var effaced=0;
function efface (elem) {
	if (effaced == 1){
		elem.value='';
	}
	effaced=effaced+1;
}

//Footer
function print_footer () {
document.write ( 'Copyright &copy; ');
document.write (year);
document.write ( ' [Miller Giangrande CPAs and ADVISORs]. All rights reserved.');
}
//Navigation

//rollovers
if (document.images) {
	pic1 = new Image
	pic1.src = "http://www.mngcpa.com/assets/pics/btn_accounting_tax_a.gif"
	pic2 = new Image
	pic2.src = "http://www.mngcpa.com/assets/pics/btn_health_care_practice_a.gif"
	pic3 = new Image
	pic3.src = "http://www.mngcpa.com/assets/pics/btn_online_accountingt_a.gif"
	//pic4 = new Image
	//pic4.src = "http://www.mngcpa.com/assets/pics/btn_financial_services_a.gif"
	//pic5 = new Image
	//pic5.src = "http://www.mngcpa.com/assets/pics/btn_information_technologies_a.gif"
	pic6 = new Image
	pic6.src = "http://www.mngcpa.com/assets/pics/btn_information_technologies_a.gif"
} 

function turn_on (img,self) {
if (document.images) document.images[img].src='http://www.mngcpa.com/assets/pics/btn_' + img + '_a.gif'
}

function turn_off (img,self) {
if (active_btn != self) {
if (document.images) document.images[img].src='http://www.mngcpa.com/assets/pics/btn_' + img + '.gif'
}
}


function write_navig (active) {
active_btn = active;

document.write ( "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");

if (active_btn == "accounting_tax") {status="_a";} else {status="";}
document.write ( "<td align=\"center\"><a href=\"http://www.mngcpa.com/accounting_tax.html\" onMouseOver=\"turn_on('accounting_tax','accounting_tax'); turn_off ('" + active_btn + "','accounting_tax')\" onMouseOut=\"turn_off('accounting_tax','accounting_tax'); turn_on('" + active_btn + "','accounting_tax');\"><img name=\"accounting_tax\" src=\"http://www.mngcpa.com/assets/pics/btn_accounting_tax" + status + ".gif\" alt=\"Accounting & Tax\" width=\"92\" height=\"21\" border=\"0\"></a></td>");

if (active_btn == "business_consulting") {status="_a";} else {status="";}
document.write ( "<td align=\"center\"><a href=\"http://www.mngcpa.com/business_consulting.html\" onMouseOver=\"turn_on('business_consulting','business_consulting'); turn_off ('" + active_btn + "','business_consulting')\" onMouseOut=\"turn_off('business_consulting','business_consulting'); turn_on('" + active_btn + "','business_consulting');\"><img name=\"business_consulting\" src=\"http://www.mngcpa.com/assets/pics/btn_business_consulting" + status + ".gif\" alt=\"Business Consulting\" width=\"116\" height=\"21\" border=\"0\"></a></td>");

if (active_btn == "health_care_practice") {status="_a";} else {status="";}
document.write ( "<td align=\"center\"><a href=\"http://www.mngcpa.com/health_care_practice.html\" onMouseOver=\"turn_on('health_care_practice','health_care_practice'); turn_off ('" + active_btn + "','health_care_practice')\" onMouseOut=\"turn_off('health_care_practice','health_care_practice'); turn_on('" + active_btn + "','health_care_practice');\"><img name=\"health_care_practice\" src=\"http://www.mngcpa.com/assets/pics/btn_health_care_practice" + status + ".gif\" alt=\"Health Care Practice\" width=\"118\" height=\"21\" border=\"0\"></a></td>");

if (active_btn == "online_accountingt") {status="_a";} else {status="";}
document.write ( "<td align=\"center\"><a href=\"http://www.mngcpa.com/online_accounting.html\" onMouseOver=\"turn_on('online_accountingt','online_accountingt'); turn_off ('" + active_btn + "','online_accountingt')\" onMouseOut=\"turn_off('online_accountingt','online_accountingt'); turn_on('" + active_btn + "','online_accountingt');\"><img name=\"online_accountingt\" src=\"http://www.mngcpa.com/assets/pics/btn_online_accountingt" + status + ".gif\" alt=\"online accounting\" width=\"79\" height=\"21\" border=\"0\"></a></td>");

//if (active_btn == "financial_services") {status="_a";} else {status="";}
//document.write ( "<td align=\"center\"><a href=\"http://www.mngcpa.com/financial_services.html\" onMouseOver=\"turn_on('financial_services','financial_services'); turn_off ('" + active_btn + "','financial_services')\" onMouseOut=\"turn_off('financial_services','financial_services'); turn_on('" + active_btn + "','financial_services');\"><img name=\"financial_services\" src=\"http://www.mngcpa.com/assets/pics/btn_financial_services" + status + ".gif\" alt=\"Financial Services\" width=\"108\" height=\"21\" border=\"0\"></a></td>");

//if (active_btn == "information_technologies") {status="_a";} else {status="";}
//document.write ( "<td align=\"center\"><a href=\"http://www.mngcpa.com/information_technologies.html\" onMouseOver=\"turn_on('information_technologies','information_technologies'); turn_off ('" + active_btn + "','information_technologies')\" onMouseOut=\"turn_off('information_technologies','information_technologies'); turn_on('" + active_btn + "','information_technologies');\"><img name=\"information_technologies\" src=\"http://www.mngcpa.com/assets/pics/btn_information_technologies" + status + ".gif\" alt=\"Information Technologies\" width=\"126\" height=\"21\" border=\"0\"></a></td>");

document.write ( "</table>");
}

function write_subnavig (section) {
	var URL = unescape(location.href)
	var start = URL.lastIndexOf("/") + 1
	var end = URL.length
	var docName = URL.substring(start,end)

	if (section == "accounting_tax") {
		var docSection = new Array(
			"accounting_tax_audit.html",
			"accounting_tax_tax_consulting.html"
		);
		var nameSection = new Array(
			"Audit and Accounting",
			"Tax-oriented Consulting"
		);
	
	}

	if (section == "business_consulting") {
		var docSection = new Array(
			"business_consulting.html",
			"business_consulting_business_finance.html",
			"business_consulting_restructuring_turnaround.html",
			"business_consulting_transaction_due_diligence.html",
			"business_consulting_litigation_services.html"
		);
		var nameSection = new Array(
			"A Special Relationship",
			"Business Finance",
			"Restructuring and Turnaround",
			"Transaction Due Diligence",
			"Litigation Services"
		);
	
	}
	
		if (section == "about_us") {
		var docSection = new Array(
			"about_us_firm_history.html",
			"about_us_partners_bios.html"
		);
		var nameSection = new Array(
			"Firm History",
			"Meet the firm"
		);
		
	}

		if (section == "health_care_practice") {
		var docSection = new Array(
			"health_care_practice.html",
			"health_care_practice_service_profile.html#Practice_Management",
			"health_care_practice_service_profile.html#General_Accounting",
			"health_care_practice_service_profile.html#Financial_Analysis",
			"health_care_practice_service_profile.html#New_Business_Ventures",
			"health_care_practice_service_profile.html#Prepaid",
			"health_care_practice_service_profile.html#Data_Processing"
		);
		var nameSection = new Array(
			"Health Care Practice",
			"Practice Management",
			"General Accounting",
			"Financial Analysis",
			"New Business Ventures",
			"Prepaid/HMO Specific Services",
			"Data Processing"
		);
		
	}
	if (section && docSection) {
		for (var i=0; i<docSection.length; i++) {
			if (docName == docSection[i]) {
				color="D09298";
			} else {
				color="812235";
			}
			document.write ( '<a href="http://www.mngcpa.com/' + docSection[i] + '"><font color="' + color + '">' + nameSection[i] + '</font></a><br>');
		}
	}
}