// JavaScript Document
function getFileName() { //Function Purpose: change class of menu items based on file name to highlight current menu choice

//this gets the full url
var url = document.location.href;
//this removes the anchor at the end, if there is one
url = url.substring(0, (url.indexOf("#") == -1) ? url.length : url.indexOf("#"));
//this removes the query after the file name, if there is one
url = url.substring(0, (url.indexOf("?") == -1) ? url.length : url.indexOf("?"));
//this removes everything before the last slash in the path
url = url.substring(url.lastIndexOf("/") + 1, url.length);
//test url and apply styles accordingly
	  switch (url){
		case "program_moveIn.html":
		$("marketing").className = "current"; // the '$' is being used instead of document.getElementById thanks to scriptaculous
		$("marketingSub").style.display = "";
		  break;
		case "program_birthday.html":
		$("marketing").className = "current";
		$("marketingSub").style.display = "";
		  break;
		case "program_jansplan.html":
		$("marketing").className = "current";
		$("marketingSub").style.display = "";
		  break;
		case "program_recall.html":
		$("marketing").className = "current";
		$("marketingSub").style.display = "";
		  break;
		case "industry_supermarkets.html":
		$("marketing").className = "current";
		$("marketingSub").style.display = "";
		$("supermarket").className = "current";
		  break;
		case "program_custom.html":
		$("marketing").className = "current";
		$("marketingSub").style.display = "";
		  break;
		case "reasons.html":
		$("marketing").className = "current";
		$("marketingSub").style.display = "";
		$("reasons").className = "current";
		  break;
		case "25-tips.html":
		$("marketing").className = "current";
		$("marketingSub").style.display = "";
		$("tips").className = "current";
		  break;
		case "testimonials.htm":
		$("marketing").className = "current";
		$("marketingSub").style.display = "";
		$("testimonials").className = "current";
		  break;
		case "postcard-gallery.html":
		$("marketing").className = "current";
		$("marketingSub").style.display = "";
		$("samples").className = "current";
		  break;
		case "index.htm": 
		  $("home").className = "current";
		  break;
		case "about-us.htm": 
		  $("about").className = "current";
		  break;
		case "transition-books.htm": 
		  $("books").className = "current";
		  break;
		case "marketing.htm": 
		  $("marketing").className = "current";
		  break;
		case "consulting.htm": 
		  $("consulting").className = "current";
		  break;
		case "email_newsletter.html": 
		  $("newsletter").className = "current";
		  break;
		case "contact-us.php": 
		  $("contact").className = "current";
		  break;
		case "faq.htm": 
		  $("faq").className = "current";
		  break;
		case "web-design.htm": 
		  $("web-design").className = "current";
		  break;
		case "transition-speaking.htm": 
		  $("speaking").className = "current";
		  break;
		case "contact-thanks.htm": 
		  $("contact").className = "current";
		  break;
		case "contact-error.php": 
		  $("contact").className = "current";
		  break;
		case "email_newsletter_archives.html": 
		  $("newsletter").className = "current";
		  break;
		case "program_moveIn.html": 
		  $("marketing").className = "current";
		  break;
		case "program_jansplan.html": 
		  $("marketing").className = "current";
		  break;
		case "program_birthday.html": 
		  $("marketing").className = "current";
		  break;
		case "other_industries.html": 
		  $("marketing").className = "current";
		  break;
		case "industry_supermarkets.html": 
		  $("marketing").className = "current";
		  break;
		case "industry_optical.html": 
		  $("marketing").className = "current";
		  break;
		case "industry_restaurants.html": 
		  $("marketing").className = "current";
		  break;
		case "industry_artgalleries.html": 
		  $("marketing").className = "current";
		  break;
		default : ;
		}
}

function changeColor(obj,x){ //Function Purpose: Turn on and off highlight class on mouseOver and mouseOut
	if (x == "on" && obj.className != "current") { // if the object is alread current do nothing
		obj.className = "on";
	} else if (obj.className != "current") { // if the object is alread current do nothing
		obj.className = "off";
	}
}

function writeText(cat){
	  switch (cat){
		case "moveIn":
		$("marketingSubText").innerHTML="Attract new movers to your store";
		  break;
		case "birthday":
		$("marketingSubText").innerHTML="Send a birthday greeting and offer to your customers";
		  break;
		case "saturation":
		$("marketingSubText").innerHTML="Send notice of a special event or offer to every household in your area";
		  break;
		case "recall":
		$("marketingSubText").innerHTML="Remind clients/patients to make their next appointment";
		  break;
		case "custom":
		$("marketingSubText").innerHTML="We can design artwork and a mailing program just for you!";
		  break;
		default :
				$("marketingSubText").innerHTML="&nbsp;";
		}
}

function over(cat){
	  switch (cat){
		case "moveIn":
		$("icon-moveIn").src="images/icons-marketing-red_02.jpg";
		  break;
		case "birthday":
		$("icon-birthday").src="images/icons-marketing-red_03.jpg";
		  break;
		case "saturation":
		$("icon-saturation").src="images/icons-marketing-red_04.jpg";
		  break;
		case "recall":
		$("icon-recall").src="images/icons-marketing-red_05.jpg";
		  break;
		case "custom":
		$("icon-custom").src="images/icons-marketing-red_06.jpg";
		  break;
		default :
		}
}
function out(cat){
	  switch (cat){
		case "moveIn":
		$("icon-moveIn").src="images/icons-marketing_02.jpg";
		  break;
		case "birthday":
		$("icon-birthday").src="images/icons-marketing_03.jpg";
		  break;
		case "saturation":
		$("icon-saturation").src="images/icons-marketing_04.jpg";
		  break;
		case "recall":
		$("icon-recall").src="images/icons-marketing_05.jpg";
		  break;
		case "custom":
		$("icon-custom").src="images/icons-marketing_06.jpg";
		  break;
		default :
		}
}

function preloader() 

{
     // counter
     var i = 0;
     // create object
     imageObj = new Image();
     // set image list
     images = new Array();
     images[0]="images/icons-marketing-red_02.jpg"
     images[1]="images/icons-marketing-red_03.jpg"
     images[2]="images/icons-marketing-red_04.jpg"
     images[3]="images/icons-marketing-red_05.jpg"
     images[4]="images/icons-marketing-red_06.jpg"
     // start preloading
     for(i=0; i<=4; i++) 
     {
          imageObj.src=images[i];
     }
} 