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

	var css_browser_selector = function() {
		var 
			ua=navigator.userAgent.toLowerCase(),
			is=function(t){ return ua.indexOf(t) != -1; },
			h=document.getElementsByTagName('html')[0],
			b=(!(/opera|webtv/i.test(ua))&&/msie (\d)/.test(ua))?('ie ie'+RegExp.$1):is('gecko/')? 'gecko':is('opera/9')?'opera opera9':/opera (\d)/.test(ua)?'opera opera'+RegExp.$1:is('konqueror')?'konqueror':is('applewebkit/')?'webkit safari':is('mozilla/')?'gecko':'',
			os=(is('x11')||is('linux'))?' linux':is('mac')?' mac':is('win')?' win':'';
		var c=b+os+' js';
		h.className += h.className?' '+c:c;
	}();

  function resize_textarea(box, fixed) {
      lines =  box.value.split('\n')
      rows = 4
      thin_width = fixed ? 1 : 0.5
      thin_chars = "il!|'/,:;"
      lines.each(function(line){
        len = 0
        for(i=0;i<line.length; i++)
          len +=  ((thin_chars.indexOf(line[i]) > -1) ? thin_width : 1 )
        rows += 1+(len/box.cols)
      })
      box.rows = rows;
  }
  
	Event.observe(window,'load',function() {
		
		
		$$('div.fieldWithErrors').each( function(item) {
			item.up("tr").down("label").addClassName('labelFormError');
		} );
		
		
			
	});
		
	
  
  
  Event.addBehavior({
  
	// MOUSE OVER ON MAIN NAV  
	'.ch_nav_item a:mouseover' : function(e) {
		if(!this.up(".ch_nav_item").hasClassName("selected")) {
			this.up("div").next("span").setStyle( { backgroundImage: 'url(/images/nav_hover_right.png)' } );	
		}
  	}, 
  	'.ch_nav_item a:mouseout' : function(e) {  
  		if(!this.up(".ch_nav_item").hasClassName("selected")) {
	    	this.up("div").next("span").setStyle( { backgroundImage: 'url()' } ); 
		}
  	}, 
  	'#logo:click' : function() { 
  		window.location = "/";
  	},
  	
  	'#order_point_of_sale input:click' : function(e) {
  		$("order_pos").show();
  	}
  
	}); 
	
	
	