$(document).ready(function() {	
 
	//Show Banner
	$(".main_image .desc").show(); //Show Banner
	$(".main_image .block").animate({ opacity: 0.85 }, 1 ); //Set Opacity
 
	//Click and Hover events for thumbnail list
	$(".image_thumb ul li:first").addClass('active'); 
	$(".image_thumb ul li").click(function(){ 
		//Set Variables
		var imgAlt = $(this).find('img').attr("alt"); //Get Alt Tag of Image
		var imgTitle = $(this).find('a').attr("href"); //Get Main Image URL
		var imgLink = $(this).find('a').attr("rel"); //Get Main Image URL
		var imgDesc = $(this).find('.block').html(); 	//Get HTML of block
		var imgDescHeight = $(".main_image").find('.block').height();	//Calculate height of block	
		
		if ($(this).is(".active")) {  //If it's already active, then...
			return false; // Don't click through
		} else {
			//Animate the Teaser				
			$(".main_image .block").animate({ opacity: 0, marginBottom: -imgDescHeight }, 250 , function() {
				$(".main_image .block").html(imgDesc).animate({ opacity: 0.85,	marginBottom: "0" }, 250 );
				$(".main_image img").attr({ src: imgTitle , alt: imgAlt});
		
				$(".main_image a").attr({ href: imgLink});
			});
		}
		
		$(".image_thumb ul li").removeClass('active'); //Remove class of 'active' on all lists
		$(this).addClass('active');  //add class of 'active' on this list only
		return false;
		
	}) .hover(function(){
		$(this).addClass('hover');
		}, function() {
		$(this).removeClass('hover');
	});
			
	//Toggle Teaser
	$("a.collapse").click(function(){
		$(".main_image .block").slideToggle();
		$("a.collapse").toggleClass("show");
	});
	
t = setTimeout ( "rotater('secondBlock')", 8000 );
	
});//Close Function

function rotater(x) {
		clearTimeout(t);
		o = setTimeout ( "rotater2('thirdBlock')", 8000 );
		var myBlock = document.getElementById(x);
		var imgAlt = $(myBlock).find('img').attr("alt"); //Get Alt Tag of Image
		var imgTitle = $(myBlock).find('a').attr("href"); //Get Main Image URL
		var imgDesc = $(myBlock).find('.block').html(); 	//Get HTML of block
		var imgLink = $(myBlock).find('a').attr("rel"); //Get Main Image URL
		var imgDescHeight = $(".main_image").find('.block').height();	//Calculate height of block	
		
		if ($(myBlock).is(".active")) {  //If it's already active, then...
			return false; // Don't click through
		} else {
			//Animate the Teaser				
			$(".main_image .block").animate({ opacity: 0, marginBottom: -imgDescHeight }, 250 , function() {
				$(".main_image .block").html(imgDesc).animate({ opacity: 0.85,	marginBottom: "0" }, 250 );
				$(".main_image img").attr({ src: imgTitle , alt: imgAlt});
				$(".main_image a").attr({ href: imgLink});
			});
		}
		
		$(".image_thumb ul li").removeClass('active'); //Remove class of 'active' on all lists
		$(myBlock).addClass('active');  //add class of 'active' on this list only
		return false;
		
}
function rotater2(x) {
		clearTimeout(o);
		m = setTimeout ( "rotater3('firstBlock')", 8000 );
		var myBlock = document.getElementById(x);
		var imgAlt = $(myBlock).find('img').attr("alt"); //Get Alt Tag of Image
		var imgTitle = $(myBlock).find('a').attr("href"); //Get Main Image URL
		var imgDesc = $(myBlock).find('.block').html(); 	//Get HTML of block
		var imgLink = $(myBlock).find('a').attr("rel"); //Get Main Image URL
		var imgDescHeight = $(".main_image").find('.block').height();	//Calculate height of block	
		
		if ($(myBlock).is(".active")) {  //If it's already active, then...
			return false; // Don't click through
		} else {
			//Animate the Teaser				
			$(".main_image .block").animate({ opacity: 0, marginBottom: -imgDescHeight }, 250 , function() {
				$(".main_image .block").html(imgDesc).animate({ opacity: 0.85,	marginBottom: "0" }, 250 );
				$(".main_image img").attr({ src: imgTitle , alt: imgAlt});
				$(".main_image a").attr({ href: imgLink});
			});
		}
		
		$(".image_thumb ul li").removeClass('active'); //Remove class of 'active' on all lists
		$(myBlock).addClass('active');  //add class of 'active' on this list only
		return false;
		
}
function rotater3(x) {
		clearTimeout(m);
		t = setTimeout ( "rotater('secondBlock')", 8000 );
		var myBlock = document.getElementById(x);
		var imgAlt = $(myBlock).find('img').attr("alt"); //Get Alt Tag of Image
		var imgTitle = $(myBlock).find('a').attr("href"); //Get Main Image URL
		var imgDesc = $(myBlock).find('.block').html(); 	//Get HTML of block
		var imgLink = $(myBlock).find('a').attr("rel"); //Get Main Image URL
		var imgDescHeight = $(".main_image").find('.block').height();	//Calculate height of block	
		
		if ($(myBlock).is(".active")) {  //If it's already active, then...
			return false; // Don't click through
		} else {
			//Animate the Teaser				
			$(".main_image .block").animate({ opacity: 0, marginBottom: -imgDescHeight }, 250 , function() {
				$(".main_image .block").html(imgDesc).animate({ opacity: 0.85,	marginBottom: "0" }, 250 );
				$(".main_image img").attr({ src: imgTitle , alt: imgAlt});
				$(".main_image a").attr({ href: imgLink });
			});
		}
		
		$(".image_thumb ul li").removeClass('active'); //Remove class of 'active' on all lists
		$(myBlock).addClass('active');  //add class of 'active' on this list only
		return false;
		
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}

function stateChanged()
{
if (xmlhttp.readyState==4)
  {
  document.getElementById("manSelect").innerHTML=xmlhttp.responseText;
  }
}
function stateChangedmodel()
{
if (xmlhttp.readyState==4)
  {
  document.getElementById("modelSelect").innerHTML=xmlhttp.responseText;
  }
}
function stateChanged3()
{
if (xmlhttp.readyState==4)
  {
  document.getElementById("3Select").innerHTML=xmlhttp.responseText;
  }
}
var xmlhttp

function allowSubmit() {
	document.myform.button.disabled = false;
	document.myform.submit(); 
}

function getMan(str)
{
if (str.length==0)
  {
  document.getElementById("manSelect").innerHTML="";
  return;
  } else {
  document.getElementById("manSelect").innerHTML="<select id='manSelect2' name='manufacturer'><option value='' disabled='disabled'>Searching...</option></select>";
  document.getElementById("modelSelect").innerHTML="<select id='manSelect2' name='model'><option value='' disabled='disabled'>&nbsp;&nbsp;&nbsp;</option></select>";

  }
if (str == "Blackberry+Batteries" || str=="Aerial+Lift+Batteries" || str=="Airsoft+Gun+Batteries" || str=="Golf+Cart+Batteries" || str=="Industrial+Equipment+Batteries" || str=="Lantern+Batteries")
  {
  document.getElementById("modelSelect").innerHTML="";
  }
if (str =="Boat+%26+Marine+Batteries" || str=="Microphone" || str=="Military+Batteries" || str=="Optima+Batteries" || str=="Paintball+Batteries" || str=="Power+Utility+Batteries" || str=="Real+Time+Clock+Batteries" || str=="RV+Batteries" || str=="Solar+Batteries" || str=="Trolling+Motor+Batteries" || str=="Flashlights" || str=="Rechargeable+Batteries" || str=="Battery+Accessories" || str=="Battery+Chargers" || str=="Battery+Packs" || str=="Button+Cell+Batteries" || str=="Coin+Cell+Batteries" || str=="Alkaline+Batteries" || str=="Police+Fire" || str=="Airsoft+Gun+Chargers" || str=="Bike+%26+Helmet+Batteries" || str=="Camera+Digital+Film+Batteries" || str=="Forklift+Chargers" || str=="Hawker+Mono+Block+Batteries" || str=="Laptop+Computer+Accessories" || str=="Primary+Cells" || str=="R%2FC+Batteries" || str=="Specialty+Application+Batteries" || str=="TV+Remote+Control+Batteries")
  {
	  document.getElementById("modelSelect").innerHTML="";
	  document.getElementById("manSelect").innerHTML="";
	 document.myform.submit(); 
	 return;
  }
  
 /* Removed because Drop downs add show all link in the next field instead of a block under
// This section gets all of the Show All Links to show properly based on what the element is
if (str=="Aerial+Lift+Batteries") {
	document.getElementById("showall").innerHTML="<br><a href='/showall.asp?comm=Aerial+Lift+Batteries&refer=Aerial%2DLift%2DBatteries%2Findex%2Easp'>Show All Aerial Lift Batteries</a>";
}
if (str=="Airsoft+Gun+Batteries") {
	document.getElementById("showall").innerHTML="";
}
if (str=="Alarm+Batteries") {
	document.getElementById("showall").innerHTML="<br><a href='/showall.asp?comm=Alarm+Batteries&refer=Alarm%2DHome%2DSecurity%2DBatteries%2Findex%2Easp'>Show All Alarm &amp; Home Security Batteries</a>";
}
if (str=="ATV+Batteries") {
	document.getElementById("showall").innerHTML="<br><a href='/showall.asp?comm=ATV+Batteries&refer=ATV%2DAll%2DTerrain%2DVehicle%2DBatteries%2Findex%2Easp'>Show All ATV Batteries</a>";
}
if (str=="ATV+Batteries+Odyssey") {
	document.getElementById("showall").innerHTML="<br><a href='/showall.asp?comm=Odyssey+Batteries&refer=Odyssey%2DBatteries%2Findex%2Easp'>Show All Odyssey Batteries</a>";
}
if (str=="Automotive+Batteries") {
	document.getElementById("showall").innerHTML="<br><a href='/showallautomotive.asp?comm=Automotive+Batteries&refer=Automotive%2DCar%2DBatteries%2Findex%2Easp'>Show All Automotive Batteries</a>";
}
if (str=="Scanner+Batteries") {
	document.getElementById("showall").innerHTML="<br><a href='/showall.asp?comm=Scanner+Batteries&refer=Barcode%2DScanner%2DBatteries%2Findex%2Easp'>Show All Barcode Scanner Batteries</a>";
}
if (str=="Blackberry+Batteries") {
	document.getElementById("showall").innerHTML="";
}
if (str=="Boat+%26+Marine+Batteries") {
	document.getElementById("showall").innerHTML="<br><a href='/Boat-Marine-Batteries/showall.asp'>Show All Boat &amp; Marine Batteries</a>";
}
if (str=="Calculator+Batteries") {
	document.getElementById("showall").innerHTML="<br><a href='/showall4.asp?comm=Calculator+Batteries&refer=Calculator%2DBatteries%2Findex%2Easp'>Show All Calculator Batteries</a>";
}
if (str=="Camcorder+Batteries") {
	document.getElementById("showall").innerHTML="";
}
if (str=="Cellphone+Batteries") {
	document.getElementById("showall").innerHTML="";
}
if (str=="Cordless+Phone+Batteries") {
	document.getElementById("showall").innerHTML="";
}
if (str=="Cordless+Tool+Batteries") {
	document.getElementById("showall").innerHTML="<br><a href='/showall.asp?comm=Cordless+Tool+Batteries&refer=Cordless%2DPower%2DTool%2DBatteries%2Findex%2Easp'>Show All Cordless Power Tool Batteries</a>";
}
if (str=="Cordless+Tool+Battery+by+OE+Battery") {
	document.getElementById("showall").innerHTML="<br><a href='/showall.asp?comm=Cordless+Tool+Batteries&refer=Cordless%2DPower%2DTool%2DBatteries%2Findex%2Easp'>Show All Cordless Power Tool Batteries</a>";
}
if (str=="Dive+Computer+Batteries") {
	document.getElementById("showall").innerHTML="<br><a href='http://www.batterygiant.com/showall.asp?comm=Dive+Computer+Batteries&refer=Dive%2DComputer%2DBatteries%2Findex%2Easp'>Show All Dive Computer Batteries</a>";
}
if (str=="Dog+Collar+%26+Pet+Containment+Batteries") {
	document.getElementById("showall").innerHTML="<br><a href='http://www.batterygiant.com/showall2.asp?comm=Dog+Collar+%26+Pet+Containment+Batteries&refer=Dog%2DCollar%2DBatteries%2Findex%2Easp'>Show All Dog Collar &amp; Pet Containment Batteries</a>";
}
if (str=="Door+Lock+Batteries") {
	document.getElementById("showall").innerHTML="<br><a href='http://www.batterygiant.com/showall.asp?comm=Door+Lock+Batteries&refer=Door%2DLock%2DBatteries%2Findex%2Easp'>Show All Door Lock Batteries</a>";
}
if (str=="DVD+%26+CD+Player+Batteries") {
	document.getElementById("showall").innerHTML="<br><a href='http://www.batterygiant.com/showall.asp?comm=DVD+%26+CD+Player+Batteries&refer=DVD%2DCD%2DPlayer%2DBatteries%2Findex%2Easp'>Show All DVD &amp; CD Player Batteries</a>";
}
if (str=="Electric+Razor+Batteries") {
	document.getElementById("showall").innerHTML="<br><a href='http://www.batterygiant.com/showall2.asp?comm=Electric+Razor+Batteries&refer=Electric%2DRazor%2DBatteries%2Findex%2Easp'>Show All Electric Razor Batteries</a>";
}
if (str=="Emergency+Lighting+Batteries") {
	document.getElementById("showall").innerHTML="<br><a href='http://www.batterygiant.com/showall.asp?comm=Emergency+Lighting+Batteries&refer=Emergency%2DLighting%2DBatteries%2Findex%2Easp'>Show All Emergency Lighting &amp; Security Alarm Batteries</a>";
}
if (str=="Farm+Equipment+Batteries") {
	document.getElementById("showall").innerHTML="<br><a href='http://www.batterygiant.com/showallfarm.asp?comm=Farm+Equipment+Batteries&refer=Farm%2DEquipment%2DBatteries%2Findex%2Easp'>Show All Farm Equipment Batteries</a>";
}
if (str=="Flashlights") {
	document.getElementById("showall").innerHTML="";
}
if (str=="Flashlight+Stick+Batteries") {
	document.getElementById("showall").innerHTML="<br><a href='http://www.batterygiant.com/showall_prod6.asp?comm=Flashlight+Battery+Sticks&refer=Flashlight%2DBattery%2DSticks%2Findex%2Easp'>Show All Flashlight Battery Sticks</a>";
}
if (str=="Forklift+Batteries") {
	document.getElementById("showall").innerHTML="";
}
if (str=="Go+Kart+Batteries") {
	document.getElementById("showall").innerHTML="<br><a href=http://www.batterygiant.com/showall3.asp?comm=Go+Kart+Batteries&refer=Go%2DKart%2DBatteries%2Findex%2Easp'>Show All Go Kart Batteries</a>";
}
if (str=="Golf+Cart+Batteries") {
	document.getElementById("showall").innerHTML="";
}
if (str=="Hearing+Aid+Batteries") {
	document.getElementById("showall").innerHTML="<br><a href='http://www.batterygiant.com/showallHearing.asp?comm=Hearing+Aid+Batteries&refer=Hearing%2DAid%2DBatteries%2Findex%2Easp'>Show All Hearing Aid Batteries</a>";
}
if (str=="Industrial+Equipment+Batteries") {
	document.getElementById("showall").innerHTML="<br><a href='http://www.batterygiant.com/showall.asp?comm=Industrial+Equipment+Batteries&refer=Industrial%2DEquipment%2DBatteries%2Findex%2Easp'>Show All Industrial Equipment Batteries</a>";
}
if (str=="Lantern+Batteries") {
	document.getElementById("showall").innerHTML="";
}
if (str=="Laptop+Batteries") {
	document.getElementById("showall").innerHTML="";
}
if (str=="Lawn+%26+Garden+Batteries") {
	document.getElementById("showall").innerHTML="<br><a href='http://www.batterygiant.com/showallIndustrial.asp?comm=Lawn+%26+Garden+Batteries&refer=Lawn%2DGarden%2DBatteries%2Findex%2Easp'>Show All Lawn &amp; Garden Batteries</a>";
}
if (str=="Medical+Batteries") {
	document.getElementById("showall").innerHTML="";
}
if (str=="Microphone") {
	document.getElementById("showall").innerHTML="";
}
if (str=="Military+Batteries") {
	document.getElementById("showall").innerHTML="";
}
if (str=="Motor+Scooter+Batteries") {
	document.getElementById("showall").innerHTML="<br><a href='http://www.batterygiant.com/showall.asp?comm=Motor+Scooter+Batteries&refer=Motor%2DScooter%2DBatteries%2Findex%2Easp'>Show All Motor Scooter Batteries</a>";
}
if (str=="Motorcycle+Batteries") {
	document.getElementById("showall").innerHTML="<br><a href='http://www.batterygiant.com/showall.asp?comm=Motorcycle+Batteries&refer=Motorcycle%2DBatteries%2Findex%2Easp'>Show All Motorcycle Batteries</a>";
}
if (str=="Motorcycle+Odyssey+Batteries") {
	document.getElementById("showall").innerHTML="<br><a href='/showall.asp?comm=Odyssey+Batteries&refer=Odyssey%2DBatteries%2Findex%2Easp'>Show All Odyssey Batteries</a>";
}
if (str=="MP3+%26+iPod+Batteries") {
	document.getElementById("showall").innerHTML="";
}
if (str=="Odyssey+Batteries") {
	document.getElementById("showall").innerHTML="<br><a href='/showall.asp?comm=Odyssey+Batteries&refer=Odyssey%2DBatteries%2Findex%2Easp'>Show All Odyssey Batteries</a>";
}
if (str=="Optima+Batteries") {
	document.getElementById("showall").innerHTML="";
}
if (str=="Pager+Batteries") {
	document.getElementById("showall").innerHTML="<br><a href='http://www.batterygiant.com/showall.asp?comm=Pager+Batteries&refer=Pager%2DBatteries%2Findex%2Easp'>Show All Pager Batteries</a>";
}
if (str=="Paintball+Batteries") {
	document.getElementById("showall").innerHTML="";
}
if (str=="PWC+Odyssey+Batteries") {
	document.getElementById("showall").innerHTML="<br><a href='/showall.asp?comm=Odyssey+Batteries&refer=Odyssey%2DBatteries%2Findex%2Easp'>Show All Odyssey Batteries</a>";
}
if (str=="PWC+Standard+Batt") {
	document.getElementById("showall").innerHTML="<br><a href='http://www.batterygiant.com/showall.asp?comm=PWC+Standard+Batt&refer=Personal%2DWatercraft%2DJet%2DSki%2DBatteries%2Findex%2Easp'>Show All Personal Watercraft Batteries</a>";
}
if (str=="PDA+Batteries") {
	document.getElementById("showall").innerHTML="<br><a href='http://www.batterygiant.com/showall2.asp?comm=PDA+Batteries&refer=PDA%2DBatteries%2Findex%2Easp'>Show All PDA Batteries</a>";
}
if (str=="PLC+Batteries") {
	document.getElementById("showall").innerHTML="<br><a href='http://www.batterygiant.com/showall.asp?comm=PLC+Batteries&refer=PLC%2Findex%2Easp'>Show All PLC Batteries</a>";
}
if (str=="Power+Utility+Batteries") {
	document.getElementById("showall").innerHTML="";
}
if (str=="Power+Wheels+%26+Riding+Car+Batteries+%2D+Batteries") {
	document.getElementById("showall").innerHTML="<br><a href='/Power-Wheels-Batteries/'>Visit Power Wheels, Peg Perego &amp; Little Tikes Section for more options</a>";
}
if (str=="Real+Time+Clock+Batteries") {
	document.getElementById("showall").innerHTML="";
}
if (str=="Rechargeable+Batteries") {
	document.getElementById("showall").innerHTML="";
}
if (str=="RV+Batteries") {
	document.getElementById("showall").innerHTML="";
}
if (str=="XM+Radio+Batteries") {
	document.getElementById("showall").innerHTML="";
}
if (str=="Scrubber+Sweeper+Batteries") {
	document.getElementById("showall").innerHTML="<br><a href='http://www.batterygiant.com/showallScrubber.asp?comm=Scrubber+Sweeper+Batteries&refer=Scrubber%2DSweeper%2DBatteries%2Findex%2Easp'>Show All Scrubber / Sweeper Batteries</a>";
}
if (str=="SLI%2FSLA%2FMC%2FDC+Batteries") {
	document.getElementById("showall").innerHTML="";
}
if (str=="Snowmobile+Batteries") {
	document.getElementById("showall").innerHTML="<br><a href='http://www.batterygiant.com/showallSnowmobile.asp?comm=Snowmobile+Batteries&refer=Snowmobile%2DBatteries%2Findex%2Easp'>Show All Snowmobile Batteries</a>";
}
if (str=="Solar+Batteries") {
	document.getElementById("showall").innerHTML="";
}
if (str=="Trolling+Motor+Batteries") {
	document.getElementById("showall").innerHTML="";
}
if (str=="Truck+%26+Bus+Batteries") {
	document.getElementById("showall").innerHTML="<br><a href='http://www.batterygiant.com/showallSnowmobile.asp?comm=Truck+%26+Bus+Batteries&refer=Truck%2DBus%2DCoach%2DBatteries%2Findex%2Easp'>Show All Truck, Bus &amp; Coach Batteries</a>";
}
if (str=="Two+Way+Radio+%26+LMR+Batteries+%2D+Empire") {
	document.getElementById("showall").innerHTML="";
}
if (str=="UPS+Batteries") {
	document.getElementById("showall").innerHTML="<br><a href='http://www.batterygiant.com/showall.asp?comm=UPS+Batteries&refer=UPS%2DPower%2DSupply%2DBatteries%2Findex%2Easp'>Show All UPS Batteries</a>";
}
if (str=="Utility+Vehicle+Batteries") {
	document.getElementById("showall").innerHTML="<br><a href='http://www.batterygiant.com/showall.asp?comm=Utility+Vehicle+Batteries&refer=Utility%2DVehicle%2DBatteries%2Findex%2Easp'>Show All Utility Vehicle Batteries</a>";
}
if (str=="Video+Gaming+Batteries") {
	document.getElementById("showall").innerHTML="";
}
if (str=="Watch+Batteries") {
	document.getElementById("showall").innerHTML="<br><a href='http://www.batterygiant.com/showall4.asp?comm=Watch+Batteries&refer=Watch%2DBatteries%2Findex%2Easp'>Show All Watch Batteries</a>";
}
if (str=="Wheel+Chair+Batteries") {
	document.getElementById("showall").innerHTML="<br><a href='http://www.batterygiant.com/showall.asp?comm=Wheel+Chair+Batteries&refer=Wheelchair%2DBatteries%2Findex%2Easp'>Show All Wheel Chair Batteries</a>";
}
// End show all link generator
*/

xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support XMLHTTP!");
  return;
  } 
var url="getMan.asp";
url=url+"?j="+str;
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function getModel(str)
{
a = str.substring(0,7)
if (a == "showall"){
	document.getElementById("modelSelect").innerHTML="";
	document.myform.button.disabled = false;
} else {
	if (str.length==0)
	  {
	  document.getElementById("modelSelect").innerHTML="";
	  return;
	  } else {
	  document.getElementById("modelSelect").innerHTML="<select id='manSelect2' name='model'><option value='' disabled='disabled'>Searching...</option></select>";
	  }
	
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	  {
	  alert ("Your browser does not support XMLHTTP!");
	  return;
	  } 
	var url="getModel.asp";
	url=url+"?j="+document.getElementById("catSelect").value;
	url=url+"&m="+str;
	xmlhttp.onreadystatechange=stateChangedmodel;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}
}

