
function goto(url) {
    location.href=url;
}

sfHover = function() {
	var sfEls = document.getElementById("primaryTopNav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}

if (window.attachEvent) window.attachEvent("onload", sfHover);
	//turn off primary when slide from primary to secondary NOT WORKING
	sfHoverOut = function() {
}

//secondary nav
function divSecondaryMenu() {
	this.ShowMenu = function ShowDiv(_id, _top, _left) {
		this.HideAll();
		this.ShowGuts(_id);
		document.getElementById(_id).style.display = 'inline';
	}

	this.ShowCart = function ShowCart(_id, _top, _right) {
		this.HideAll();
		this.ShowGuts(_id);
		document.getElementById(_id).style.display = 'inline';
	}

	this.HideAll = function HideSecondarySubNav() {
		var divs = document.getElementById("secondaryTopNav").getElementsByTagName("DIV");
		for (var i=0; i<divs.length; i++) {
			divs[i].style.display = 'none';
		}
	}

	this.ShowGuts = function ShowChildDivs(_id) {
		var divs = document.getElementById(_id).getElementsByTagName("DIV");
		for (var i=0; i<divs.length; i++) {
			divs[i].style.display = 'block';
		}
	}
}

divBrandNav = new divSecondaryMenu();
//end secondary

// Change Background Position on Search Div for rollover
function changePosition() {
document.getElementById('searchGO').style.backgroundPosition="0px -34px";
}
function changePositionBack() {
document.getElementById('searchGO').style.backgroundPosition="0px 0px";
}

// begin new jquery specific scripts
// this $(function() piece needs to surround any basic jquery scripts
// most scripts would go inside of this doc.ready piece anyway
// using this method allows us to use multiple script libraries
$(function() {
    
	$(document).ready(function(){ 
	    $(document).pngFix(); 
	    
	    $(".genericToggleArea").each(function() {
	    	$(this).css("width","590px");
	    	$(this).css("display","none");
	    });	
	    
	    //set scripts for accordian style toggles
	    $(".genericToggleBtn").each(function() {
			$(this).click(function()	{
				$(this).next().slideToggle('slow');
			});
		});
	    
	    $("#v_toggle").click(function()	{
			$("#vertical_slide").slideToggle('slow');
			return false;
		});
	    
	    $(".catToggleBtn").click(function()	{
	    	$(".catToggleArea").slideToggle('slow');
			return false;
		});
	    
	    $(".newsToggleArea").hide();
	    
	    $(".newsToggleBtn").click(function()	{
			$(".newsToggleArea").slideToggle('slow');
			return false;
		});
	    
	    $("#stateCSName").change( function() {
	    	var contactMethod = 1;
			if($('form radio:checked').attr('name', 'contactMethod')) {
				contactMethod = $('form input:radio:checked').val();
			}
			goto('/contactUs/index.jsp?f=CS&st='+$(this).attr('value')+ "&fn=" +$("#firstName").attr('value')+ "&mn=" +$("#middleName").attr('value')
					  							+ "&ln=" +$("#lastName").attr('value')+ "&e=" +$("#email").attr('value')+ "&ta=" +$("#phoneArea").attr('value')
					  							+ "&tp=" +$("#phonePrefix").attr('value')+ "&ts=" +$("#phoneSuffix").attr('value')+ "&addr=" +$("#address").attr('value')
					  							+ "&city=" +$("#city").attr('value')+ "&state=" +$("#stateId").attr('value')+ "&zip=" +$("#zip").attr('value')
					  							+ "&cnt=" +contactMethod+ "&dt=" +$("#datepicker").attr('value')+ "&inv=" +$("#invoiceNum").attr('value')+ "&sp=" +$("#salesPerson").attr('value'));
			//alert($(this).attr('value'));
		});
		$("#cityCSName").change( function() {
			var contactMethod = 1;
			if($('form radio:checked').attr('name', 'contactMethod')) {
				contactMethod = $('form input:radio:checked').val();
			}
			goto('/contactUs/index.jsp?f=CS&st='+$("#stateCSName").attr('value') + '&selCity='+$(this).attr('value')+ "&fn=" +$("#firstName").attr('value')+ "&mn=" +$("#middleName").attr('value')
					  							+ "&ln=" +$("#lastName").attr('value')+ "&e=" +$("#email").attr('value')+ "&ta=" +$("#phoneArea").attr('value')
					  							+ "&tp=" +$("#phonePrefix").attr('value')+ "&ts=" +$("#phoneSuffix").attr('value')+ "&addr=" +$("#address").attr('value')
					  							+ "&city=" +$("#city").attr('value')+ "&state=" +$("#stateId").attr('value')+ "&zip=" +$("#zip").attr('value')
					  							+ "&cnt=" +contactMethod+ "&dt=" +$("#datepicker").attr('value')+ "&inv=" +$("#invoiceNum").attr('value')+ "&sp=" +$("#salesPerson").attr('value'));
			//alert($(this).attr('value'));
		});
		$("#stateFinName").change( function() {
			var contactMethod = 1;
			if($('form radio:checked').attr('name', 'contactMethod')) {
				contactMethod = $('form input:radio:checked').val();
			}
			//var rating = -1;
			//if($('form radio:checked').attr('name', 'rating')) {
			//	rating = $('form input:radio:checked').val();
			//}
			goto('/contactUs/index.jsp?f=FinQuestions&st='+$(this).attr('value')+ "&fn=" +$("#firstName").attr('value')+ "&mn=" +$("#middleName").attr('value')
														  + "&ln=" +$("#lastName").attr('value')+ "&e=" +$("#email").attr('value')+ "&ta=" +$("#phoneArea").attr('value')
														  + "&tp=" +$("#phonePrefix").attr('value')+ "&ts=" +$("#phoneSuffix").attr('value')+ "&addr=" +$("#address").attr('value')
														  + "&city=" +$("#city").attr('value')+ "&state=" +$("#stateId").attr('value')+ "&zip=" +$("#zip").attr('value')
														  + "&cnt=" +contactMethod+ "&dt=" +$("#datepicker").attr('value'));
			//alert($(this).attr('value'));
		});
		$("#cityFinName").change( function() {
			var contactMethod = 1;
			if($('form radio:checked').attr('name', 'contactMethod')) {
				contactMethod = $('form input:radio:checked').val();
			}
			goto('/contactUs/index.jsp?f=FinQuestions&st='+$("#stateFinName").attr('value') + '&selCity='+$(this).attr('value')+ "&fn=" +$("#firstName").attr('value')+ "&mn=" +$("#middleName").attr('value')
														  + "&ln=" +$("#lastName").attr('value')+ "&e=" +$("#email").attr('value')+ "&ta=" +$("#phoneArea").attr('value')
														  + "&tp=" +$("#phonePrefix").attr('value')+ "&ts=" +$("#phoneSuffix").attr('value')+ "&addr=" +$("#address").attr('value')
														  + "&city=" +$("#city").attr('value')+ "&state=" +$("#stateId").attr('value')+ "&zip=" +$("#zip").attr('value')
														  + "&cnt=" +contactMethod+ "&dt=" +$("#datepicker").attr('value'));
			//alert($(this).attr('value'));
		});
		$("#stateWarName").change( function() {
			var contactMethod = 1;
			if($('form radio:checked').attr('name', 'contactMethod')) {
				contactMethod = $('form input:radio:checked').val();
			}
			goto('/contactUs/index.jsp?f=WarQuestions&st='+$(this).attr('value')+ "&fn=" +$("#firstName").attr('value')+ "&mn=" +$("#middleName").attr('value')
					  									  + "&ln=" +$("#lastName").attr('value')+ "&e=" +$("#email").attr('value')+ "&ta=" +$("#phoneArea").attr('value')
					  									  + "&tp=" +$("#phonePrefix").attr('value')+ "&ts=" +$("#phoneSuffix").attr('value')+ "&addr=" +$("#address").attr('value')
					  									  + "&city=" +$("#city").attr('value')+ "&state=" +$("#stateId").attr('value')+ "&zip=" +$("#zip").attr('value')
					  									  + "&cnt=" +contactMethod+ "&dt=" +$("#datepicker").attr('value')+ "&inv=" +$("#invoiceNum").attr('value')+ "&sp=" +$("#salesPerson").attr('value'));
			//alert($(this).attr('value'));
		});
		$("#cityWarName").change( function() {
			var contactMethod = 1;
			if($('form radio:checked').attr('name', 'contactMethod')) {
				contactMethod = $('form input:radio:checked').val();
			}
			goto('/contactUs/index.jsp?f=WarQuestions&st='+$("#stateWarName").attr('value') + '&selCity='+$(this).attr('value')+ "&fn=" +$("#firstName").attr('value')+ "&mn=" +$("#middleName").attr('value')
					  									  + "&ln=" +$("#lastName").attr('value')+ "&e=" +$("#email").attr('value')+ "&ta=" +$("#phoneArea").attr('value')
					  									  + "&tp=" +$("#phonePrefix").attr('value')+ "&ts=" +$("#phoneSuffix").attr('value')+ "&addr=" +$("#address").attr('value')
					  									  + "&city=" +$("#city").attr('value')+ "&state=" +$("#stateId").attr('value')+ "&zip=" +$("#zip").attr('value')
					  									  + "&cnt=" +contactMethod+ "&dt=" +$("#datepicker").attr('value')+ "&inv=" +$("#invoiceNum").attr('value')+ "&sp=" +$("#salesPerson").attr('value'));
			//alert($(this).attr('value'));
		});
		
		$(".sliderButton").each( function() {
			$(this).click(function() {
				$(".sliderButton").each( function() {
					$(this).removeClass('selectedSlider');
				});	
				$(this).addClass('selectedSlider');
								
				$(".slide").each(function (){
					$(this).hide();
				});
				$("."+this.id).show();
				
			});
			
		});
		//hide all slides onload except for first slide
		$(".slide").not("#slide1").each(function (){
			$(this).hide();
		});
		$("#slider1").addClass('selectedSlider');
		
		
		//image rotator script for multiple large product images
		
		$('.largeImageRotator').each( function(i, val) {
			var j= i+1;
			if(j < 10){j = "0"+j;}
			//alert("i = " + i);
			//alert("val = "+ val);
			$(this).click(function(){
				$('.imgPaginationActive').addClass("imgPagination");
				$('.imgPaginationActive').removeClass("imgPaginationActive");
				$(this).addClass("imgPaginationActive");
				$(this).removeClass("imgPagination");
				$("#largeImage").attr("src", this.id);
				//alert($("#largeImage").attr("src"));
			});
		});
		
		//alert($('#threeColumnContentCenterColumn').height());
		$('#threeColumnContentLeftColumn').css('padding-bottom', '30px');
		$('#threeColumnContentLeftColumn').css('margin-bottom', '-40px');
		leftColHeight = $('#threeColumnContentCenterColumn').height()+250;
		if(leftColHeight < 840){
			leftColHeight = 840;
		}	
		$('#threeColumnContentLeftColumn').css('height', leftColHeight);
		
	}); 
	
	//check for images that are missing	
	
	/*
	$(window).bind('load', function() {
		$('img').each(function() {
			if((typeof this.naturalWidth != "undefined" &&
				this.naturalWidth == 0 ) 
				|| this.readyState == 'uninitialized' ) {
				lastSlash = $(this).attr("src").lastIndexOf("/"); 
				prefix = $(this).attr("src").substr(0,lastSlash);
				$(this).attr("src", prefix+"/tn_noImage.jpg");
			}
		});
	})
	
	*/
	
});



