// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

// window.onload = function() {
// 	Form.Element.focus('user_email');
// }


document.observe("dom:loaded", function() {  
	// product display table cell hover style swaps
	if($$('td.results_product')) {
		$$('td.results_product').each(function(s){
			// send user on when they click anywhere in the cell
			s.observe('click', function(event){
				window.location = s.down(2).href;
			});
			// mouse over and off behaviors
			s.observe('mouseover', function(event){
				s.className = "results_product_hover";				
			});
			s.observe('mouseout', function(event){
				s.className = "results_product";
			});
		});
	}
});


function change_it(the_name) {
 if (document.images) {
  document.images[the_name].src= eval(the_name+"_new.src");
 }
}

function change_back(the_name) {
 if (document.images) {
	document.images[the_name].src= eval(the_name+"_init.src");
 }
}

function fadeWindow(el) {
	Effect.toggle(el, 'appear', {dur: 0.5})
}

function blindWindow(el) {
	Effect.toggle(el, 'blind', {dur: 0.2})
}

function checkuncheckit(boxid) {
 if ($(boxid).checked) 
	$(boxid).checked=false;	
 else 
	$(boxid).checked=true;
}

function searchByDeviceValidation(form_id) {
	var form = $('search_by_device_form')
	var check_boxes = form.getInputs('checkbox');
	var valid = false;
	check_boxes.each(function(d) {
		if(d.checked) {
			valid = true;
			return;
		}
	});
	if (valid == false) {
		alert("You must select at least one device")
		return false
	}
	return true;
}
