function behaviors(){
	
	Event.stopObserving($("SendToAFriend"),"click");
	MM_openBrWindow = function(){};
	//trigger ajax mailer
	Event.observe($("SendToAFriend"), "click",function (){ new Ajax.Updater($("ajax_overlay_div"),'mailer_form.php',{ evalScripts: true, method: 'post', parameters: ''})});
	
	
	//change product color based on query string
	var qs = window.location.search;
	if (qs.length > 0) {
		qs = qs.toQueryParams();
		if (qs.color){
			//swap the product image
			$("product_image_tag").src="images/sleeves/sm/"+qs.color+".jpg";
			//swap the lightbox 
			$("product_image_lightbox").href="images/sleeves/lg/"+qs.color+".jpg";

			//set the order form menus to the color
			$$("option.formy").each(function(e,i){
				if(e.getAttribute("rel")==qs.color){
					e.setAttribute("selected","selected");
					$("product_image_lightbox").title = e.getAttribute("rel").split("_").join(" ");
				}
			});	
		}		
	} else {
		
		//if no color, set the product color to the first menu item
		var c = new Array;
		$$("option.formy").each(function(e,i){
			if (e.value !="#"){
				if (e.readAttribute("rel")){
					v = e.value;
					c.push(e.readAttribute("rel"));
				} else {
					c.push(e.value);
				}
			}
		});
		c = $A(c);
		if($("product_image_tag")){
			$("product_image_tag").src="images/sleeves/sm/"+c.first()+".jpg";
		}
	}
	

	//change product image and lightbox when new product is selected from dropdown
	$$("select.formy").each(function(e,i){
		//change image and lightbox
		Event.observe(e,"change",function() {
			var c = new Array;
			//create an array of rel values for the menu
			e.select("option").each(function(o,n){
			var vv = o.value;
					if (o.readAttribute("rel")){
						c[vv] = o.readAttribute("rel");
					} else {
						c[vv]= o.value;
					}
			});
			var v = c[e.value];
			$("product_image_tag").src="images/sleeves/sm/"+v+".jpg";
			$('product_image_lightbox').title = v.split("_").join(" ") + " SLEEVE";
			$('product_image_lightbox').href="images/sleeves/lg/"+v+".jpg";
		});
	});
	
	
	//ajax form submission buttons
	$$("img.addtobasketimage").each(function(e,i){
		Event.observe(e,"click",function(el){
				var is_valid=true;
				//button needs to have "rel" property set to the value of parent form's id attribute
				if (!e.readAttribute("rel")){
					var f = $("six_inch");
					qq = "quantity_six_inch";
				} else{
					var f = $(e.readAttribute("rel"));
					var qq = "quantity_"+e.readAttribute("rel");
				}
				//all this just to isolate the value of the quantity field
				var qqq = $(qq).value;
				if (qqq < 1){
					is_valid=false;
				}
				//select the dropdown value via select.class=formy
				f.select("select.formy").each(function(p,n){
					if (p.getValue()=="#"){
						is_valid=false;
					}
				});
				if (is_valid){
					f.submit();
					new Ajax.Updater($('ajax_overlay_div'), 'shopping_bag_preview.php',{ evalScripts: true, method: 'post'});
				} else {
					alert("Please select a color and quantity for your order.");
				}
		});
	
		});
}



//this is used to validate the email forms
function validate_form(f){
	var has_error = false;
	
	//first, set the form to white
	f.select('.required').each(function(e,i){
		e.style.backgroundColor="#ffffff";
	});
	
	//set empty form fields to yellow
	f.select('.required').each(function(e,i){
		if (e.value.length < 1){
			has_error = true;
			e.style.backgroundColor="#ffffcc";
		}
	});
	
	//alert if empty forms
	if (has_error==true){
		alert("Please fill out the highlighted fields");
		return false;
	} else {
		//return true - submit handled in the form
		return true;
	}
}


//via ligthtbox.js
function getPageSize(){
        
     var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	
	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}

	return [pageWidth,pageHeight];
}


//stupid ie6 dropdown toggle
function show_dropdowns(){
	$$("select.formy").map(function(e){e.setStyle({display:"block"})});
}



