function slideshow() {
	$('.slideshow').cycle();
}

function checkEnter(e, whereto) {
	var Key;

	if (window.event)        // IE
	{
		Key = window.event.keyCode;
	}
	else if (e.which) // Netscape/Firefox/Opera
	{
		Key = e.which
	}

	//alert('hi');
	if (Key == 13) {
		var obj = document.getElementById('mapsearch');
		//obj.click();
		//alert('here1');

		if (e && e.stopPropagation) //if stopPropagation method supported
			e.stopPropagation()
		else
			event.cancelBubble = true

		window.location = whereto;
		//alert('here2');
		e.returnValue = false;
		e.cancelBubble = true;
		setTimeout("//alert('hi')", 5000);
		for (i = 0; i < 10000; i++) {
			i * 10 / 56;
		}

		return false;
	}
	return true;
}

// add the searchbox where needed
function searchbox() {
	$("#searchbox").html("<input type='text' id='searchinput' onKeyPress='return checkEnter(event, \"WhereToBuy.aspx?type=service&zip=\" + document.getElementById(\"searchinput\").value);' onclick=\"if(this.value == 'Zip Code'){this.value = '';}\" onblur=\"if(this.value == ''){this.value = 'Zip Code';}\" style='width:100px' value='Zip Code' /><input type='button' id='mapsearch' style='color:black;' value='Search' onclick='if(document.getElementById(\"searchinput\").value != \"\" && document.getElementById(\"searchinput\").value != \"Zip Code\"){window.location = \"WhereToBuy.aspx?type=service&zip=\" + document.getElementById(\"searchinput\").value;}' />");
	$("#searchzipbox").html("<input type='text' id='searchinput' onKeyPress='return checkEnter(event, \"WhereToBuy.aspx?type=all&zip=\" + document.getElementById(\"searchinput\").value);' onclick=\"if(this.value == 'Zip Code'){this.value = '';}\" onblur=\"if(this.value == ''){this.value = 'Zip Code';}\" style='width:100px' value='Zip Code' /><input type='button' id='mapsearch' style='color:black;' value='Search' onclick='if(document.getElementById(\"searchinput\").value != \"\" && document.getElementById(\"searchinput\").value != \"Zip Code\"){window.location = \"WhereToBuy.aspx?type=all&zip=\" + document.getElementById(\"searchinput\").value;}' />");
	$("#searchcf325box").html("<input type='text' id='searchinput' onKeyPress='return checkEnter(event, \"WhereToBuy.aspx?type=cf325&zip=\" + document.getElementById(\"searchinput\").value);' onclick=\"if(this.value == 'Zip Code'){this.value = '';}\" onblur=\"if(this.value == ''){this.value = 'Zip Code';}\" style='width:100px' value='Zip Code' /><input type='button' id='mapsearch' style='color:black;' value='Search' onclick='if(document.getElementById(\"searchinput\").value != \"\" && document.getElementById(\"searchinput\").value != \"Zip Code\"){window.location = \"WhereToBuy.aspx?type=cf325&zip=\" + document.getElementById(\"searchinput\").value;}' />");
	$("#searchcs150box").html("<input type='text' id='searchinput' onKeyPress='return checkEnter(event, \"WhereToBuy.aspx?type=cs150&zip=\" + document.getElementById(\"searchinput\").value);' onclick=\"if(this.value == 'Zip Code'){this.value = '';}\" onblur=\"if(this.value == ''){this.value = 'Zip Code';}\" style='width:100px' value='Zip Code' /><input type='button' id='mapsearch' style='color:black;' value='Search' onclick='if(document.getElementById(\"searchinput\").value != \"\" && document.getElementById(\"searchinput\").value != \"Zip Code\"){window.location = \"WhereToBuy.aspx?type=cs150&zip=\" + document.getElementById(\"searchinput\").value;}' />");
	$("#searchpf150sppbox").html("<input type='text' id='searchinput' onKeyPress='return checkEnter(event, \"WhereToBuy.aspx?type=pf150s-pp&zip=\" + document.getElementById(\"searchinput\").value);' onclick=\"if(this.value == 'Zip Code'){this.value = '';}\" onblur=\"if(this.value == ''){this.value = 'Zip Code';}\" style='width:100px' value='Zip Code' /><input type='button' id='mapsearch' style='color:black;' value='Search' onclick='if(document.getElementById(\"searchinput\").value != \"\" && document.getElementById(\"searchinput\").value != \"Zip Code\"){window.location = \"WhereToBuy.aspx?type=pf150s-pp&zip=\" + document.getElementById(\"searchinput\").value;}' />");
	$("#searchpf350box").html("<input type='text' id='searchinput' onKeyPress='return checkEnter(event, \"WhereToBuy.aspx?type=pf350&zip=\" + document.getElementById(\"searchinput\").value);' onclick=\"if(this.value == 'Zip Code'){this.value = '';}\" onblur=\"if(this.value == ''){this.value = 'Zip Code';}\" style='width:100px' value='Zip Code' /><input type='button' id='mapsearch' style='color:black;' value='Search' onclick='if(document.getElementById(\"searchinput\").value != \"\" && document.getElementById(\"searchinput\").value != \"Zip Code\"){window.location = \"WhereToBuy.aspx?type=pf350&zip=\" + document.getElementById(\"searchinput\").value;}' />");
	$("#searcheventsbox").html("<input type='text' id='searchinput' onKeyPress='return checkEnter(event, \"WhereToBuy.aspx?type=events&zip=\" + document.getElementById(\"searchinput\").value);' onclick=\"if(this.value == 'Zip Code'){this.value = '';}\" onblur=\"if(this.value == ''){this.value = 'Zip Code';}\" style='width:100px' value='Zip Code' /><input type='button' id='mapsearch' style='color:black;' value='Search' onclick='if(document.getElementById(\"searchinput\").value != \"\" && document.getElementById(\"searchinput\").value != \"Zip Code\"){window.location = \"WhereToBuy.aspx?type=events&zip=\" + document.getElementById(\"searchinput\").value;}' />");
}

function tabs() {
	// Tabs
	$('#tabs').tabs();
	// rounded corners
	$('.rcorner').rcorner();
}


$(document).ready(function() {
	tabs();
	searchbox();
	slideshow();
	
	// blog comment form, take out the url field
	$(".ekcommentdata:last").css("display", "none");

	// lightbox
	$("a.lightbox").fancybox({  
		'imageScale': true,
		'overlayOpacity': .7
	}); 
	
	// reformat menu due to ektron
	$("#horiznav > div > ul > li > ul").addClass("nav-one").addClass("nav").attr("id", "nav-one");

	var parental = $(".nav-one").parent().parent().parent().parent();
	$(".nav-one").appendTo(parental);
	$(".nav-one li:last").addClass("last-child");

	// remove initial container
	$("#horiznav > div").remove();

	// menu
	$(".nav-one li").hover( 
		function() {$("ul", this).addClass("sfhover") }, 
		function() {$("ul", this).removeClass("sfhover")} 
	);  

});
