function inputTextBoxEvent(){
  if (!document.getElementsByTagName) return false;
  if (!document.getElementById) return false;
  var newsletter_input_box = document.getElementById("newsletter_input_box");
  if(!newsletter_input_box) return false;
	newsletter_input_box.onclick = function(){
		if(this.value == "Insert your e-mail here"){
			this.value = "";
		}else if(this.value == ""){
			this.value = "Insert your e-mail here";
		}
	}
	newsletter_input_box.onblur = function(){
		if(this.value == ""){
			this.value = "Insert your e-mail here";
		}
	}
}
function imageGallerySlidingEvent(){
  if (!document.getElementsByTagName) return false;
  if (!document.getElementById) return false;
  if(degradeByIDs(new Array("left_nav", "thumb1", "thumb2", "thumb3", "thumb4", "thumb5", "thumb6", "thumb7", "thumb8", "thumb9", "right_nav"))) return false;
  if(thumb_images.length > 9){
  	var left_nav = document.getElementById("left_nav");
  	left_nav.style.display = "inline";
  	left_nav.onclick = function(){
	//	var before = thumb_image_pointer;
  		if ((1<=thumb_image_pointer) && (thumb_image_pointer <= 9)) {
  			thumb_image_pointer = 0;
  		} else {
  			thumb_image_pointer -=9;
  		}
  		
  		if (thumb_image_pointer < 0) {
  			thumb_image_pointer = thumb_images.length - 9;
  		}
  		
  		
  		//	alert('before: ' + before + "\nafter: " + thumb_image_pointer + "\nLength: " + thumb_images.length);
			updateThumbnails(false);
			this.blur();
  		return false;
  	}
  	var right_nav = document.getElementById("right_nav");
  	right_nav.style.display = "inline";
  	right_nav.onclick = function(){
  		//thumb_image_pointer++;

  		thumb_image_pointer += 9;
		
  		//this case shows the last 9 images of the gallery when we get there
  		if (((thumb_images.length - thumb_image_pointer) < 9) && (thumb_image_pointer < thumb_images.length)) {
  			thumb_image_pointer = thumb_images.length - 9;
  		}
  		
  		//this case loops us back around to the beginning
  		if (thumb_images.length <= thumb_image_pointer) {
  			
  			thumb_image_pointer = 0;
  		}
  		
  		
  		updateThumbnails(false);
  		this.blur();
  		return false;
  	}
  }
  updateThumbnails(true);
}
function updateThumbnails(initialise){
  for(var i=1; i<=9; i++){
  	if(i <= thumb_images.length){
  		var thumbnail = document.getElementById("thumb"+i);
  		thumbnail.src = thumb_images[i-1+thumb_image_pointer];
  		if(initialise){
  			thumbnail.style.display = "inline";
  		}
  	}
  }
}
function imageGalleryEvent(){
  if (!document.getElementsByTagName) return false;
  if (!document.getElementById) return false;
  
  var gallery_nav = document.getElementById("gallery_nav");
  var bigImg = document.getElementById("bigImg");
  if(!gallery_nav) return false;
  if(!bigImg) return false;
  
  var navs = gallery_nav.getElementsByTagName("a");
  for(var i=0; i<navs.length; i++){
  	if(navs[i].className == "thumbs"){
  		// Image Onclick Events
  		navs[i].onclick = function(){
  			var bigImg = document.getElementById("bigImg");
  			var thumbImg = this.getElementsByTagName("img");
  			if(thumbImg[0]){
  				var src1 = thumbImg[0].src.replace("/thumbs/", "/");
  				var image_src = src1.replace("_up.jpg", ".jpg");
  				bigImg.src= src1.replace("_up.jpg", ".jpg");
  			}
  		}
			var thumbImg = navs[i].getElementsByTagName("img");
			if(thumbImg[0]){
				thumbImg[0].onmouseover = function(){
					this.src = this.src.replace(".jpg", "_up.jpg");
				}
				thumbImg[0].onmouseout = function(){
					this.src = this.src.replace("_up.jpg", ".jpg");
				}
			}
 		}
  }
}
function imageLoaded(preloadImage){}
function pricingEvent(){
  if (!document.getElementsByTagName) return false;
  if (!document.getElementById) return false;
	if(degradeByIDs(new Array("print_size", "price", "resetButton"))) return false;
	var print_size = document.getElementById("print_size");
	var resetButton = document.getElementById("resetButton");
	print_size.onchange = function(){
		var price = document.getElementById("price");
		var price_value = this.options[this.selectedIndex].className.substring(3);
		
		price.innerHTML = "";
		var meat = document.createTextNode(price_value);
		price.appendChild(meat);
	}
	resetButton.onclick = function(){
		var price = document.getElementById("price");
		var print_size = document.getElementById("print_size");
		var price_value = print_size.options[0].className.substring(3);
		
		price.innerHTML = "";
		var meat = document.createTextNode(price_value);
		price.appendChild(meat);
	}
}
function buttonsEvent(){
  if (!document.getElementsByTagName) return false;
  if (!document.getElementById) return false;
	if(degradeByIDs(new Array("emptycart", "continueshopping", "checkout", "burl"))) return false;
	
	var emptycart = document.getElementById("emptycart");
	var continueshopping = document.getElementById("continueshopping");
	var checkout = document.getElementById("checkout");
	
	emptycart.onclick = function(){
		var burl = document.getElementById("burl");
		window.location.href = burl.value + "empty-cart.html";
	}
	continueshopping.onclick = function(){
		var burl = document.getElementById("burl");
		window.location.href = burl.value + "gallery.html";
	}
	checkout.onclick = function(){
		var burl = document.getElementById("burl");
		window.location.href = burl.value + "shipping-address.html";
	}
}
function shopButtonsEvent(){
  if (!document.getElementsByTagName) return false;
  if (!document.getElementById) return false;
	if(degradeByIDs(new Array("pemptycart", "pcontinueshopping", "pcheckout", "pburl"))) return false;
	
	var pemptycart = document.getElementById("pemptycart");
	var pcontinueshopping = document.getElementById("pcontinueshopping");
	var pcheckout = document.getElementById("pcheckout");
	
	pemptycart.onclick = function(){
		var pburl = document.getElementById("pburl");
		window.location.href = pburl.value + "p-empty-cart.html";
	}
	pcontinueshopping.onclick = function(){
		var pburl = document.getElementById("pburl");
		window.location.href = pburl.value + "shop.html";
	}
	pcheckout.onclick = function(){
		var pburl = document.getElementById("pburl");
		window.location.href = pburl.value + "p-shipping-address.html";
	}
}
function slideShowEvent(){
  if (!document.getElementsByTagName) return false;
  if (!document.getElementById) return false;
	if(degradeByIDs(new Array("slideshow_link"))) return false;
	
	var slideshow_link = document.getElementById("slideshow_link");
	
	slideshow_link.onclick = function(){
	 	var width = 600;
		var height = 450; 
		window.open(this.href,'mywindow','width='+width+',height='+height+',resizable=yes,scrollbars=yes,left=0,top=0,screenX=0,screenY=0');
		return false;
	}
}
var slideshow_movement;
function slideShowControllersEvent(){
  if (!document.getElementsByTagName) return false;
  if (!document.getElementById) return false;
	if(degradeByIDs(new Array("slideshow_intervals","pause","restart","close_slideshow"))) return false;
	var slideshow_intervals = document.getElementById("slideshow_intervals");
	var pause = document.getElementById("pause");
	var restart = document.getElementById("restart");
	var close_slideshow = document.getElementById("close_slideshow");
	slideshow_intervals.onchange = function(){
		var slide_link = this.className + '&sec=' + this.options[this.selectedIndex].value;
		window.location.href = slide_link;
	}
	pause.onclick = function(){
		this.innerHTML = "";
		
		if(slideshow_movement == ""){
			var meat = document.createTextNode("Pause");
			this.appendChild(meat);
			runSlide();
			
		}else{
			clearTimeout(slideshow_movement);
			slideshow_movement = "";
			var meat = document.createTextNode("Resume");
			this.appendChild(meat);
		}
		return false;
	}
	restart.onclick = function(){
		window.location.href = this.className;
		return false;
	}
	close_slideshow.onclick = function(){
		window.close();
		return false;
	}
}
function paymentButtonsEvent(){
  if (!document.getElementsByTagName) return false;
  if (!document.getElementById) return false;
	if(degradeByIDs(new Array("editcart", "continueshopping", "paypal", "burl"))) return false;
	
	var editcart = document.getElementById("editcart");
	var continueshopping = document.getElementById("continueshopping");
	var paypal = document.getElementById("paypal");
	
	editcart.onclick = function(){
		var burl = document.getElementById("burl");
		window.location.href = burl.value + "cart.html";
	}
	continueshopping.onclick = function(){
		var burl = document.getElementById("burl");
		window.location.href = burl.value + "gallery.html";
	}
	paypal.onclick = function(){
		var burl = document.getElementById("burl");
		window.location.href = burl.value + "checkout.html";
	}
}
function shopPaymentButtonsEvent(){
  if (!document.getElementsByTagName) return false;
  if (!document.getElementById) return false;
	if(degradeByIDs(new Array("peditcart", "pcontinueshopping", "ppaypal", "pburl"))) return false;
	
	var peditcart = document.getElementById("peditcart");
	var pcontinueshopping = document.getElementById("pcontinueshopping");
	var ppaypal = document.getElementById("ppaypal");
	
	peditcart.onclick = function(){
		var pburl = document.getElementById("pburl");
		window.location.href = pburl.value + "shopcart.html";
	}
	pcontinueshopping.onclick = function(){
		var pburl = document.getElementById("pburl");
		window.location.href = pburl.value + "shop.html";
	}
	ppaypal.onclick = function(){
		var pburl = document.getElementById("pburl");
		window.location.href = pburl.value + "shopcheckout.html";
	}
}
addLoadEvent(slideShowControllersEvent);
addLoadEvent(slideShowEvent);
addLoadEvent(buttonsEvent);
addLoadEvent(shopButtonsEvent);
addLoadEvent(paymentButtonsEvent);
addLoadEvent(shopPaymentButtonsEvent);
addLoadEvent(pricingEvent);
addLoadEvent(imageGallerySlidingEvent);
addLoadEvent(imageGalleryEvent);
addLoadEvent(inputTextBoxEvent);
var menuids=["treemenu1"] //Enter id(s) of SuckerTree UL menus, separated by commas

function buildsubmenus_horizontal(){
for (var i=0; i<menuids.length; i++){
  var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul")
    for (var t=0; t<ultags.length; t++){
		if (ultags[t].parentNode.parentNode.id==menuids[i]){ //if this is a first level submenu
			ultags[t].style.top=ultags[t].parentNode.offsetHeight+"px" //dynamically position first level submenus to be height of main menu item
		}
    ultags[t].parentNode.onmouseover=function(){
    this.getElementsByTagName("ul")[0].style.visibility="visible"
    }
    ultags[t].parentNode.onmouseout=function(){
    this.getElementsByTagName("ul")[0].style.visibility="hidden"
    }
    }
  }
}

if (window.addEventListener)
window.addEventListener("load", buildsubmenus_horizontal, false)
else if (window.attachEvent)
window.attachEvent("onload", buildsubmenus_horizontal)
