// JavaScript Document

// ---------------------------------------------------------------------- Clears searchform and changes text color
function checkEntry(o,dTxt){
	if (!o.defTxt){
		o.defTxt = dTxt;
		o.onblur = function (){
			trimField(this);
			with (this){
				if (value == '' || value == defTxt){
					value = defTxt;
					o.style.color = '#5a5e54';
				}
			}
		}
	}
	if (o.value == o.defTxt){
		o.value = '';
		o.style.color = '#000';
	}
}
function trimField (o){
	var v = o.value.replace(/^ +| +$/g,'');
	o.value = v;
}



// ---------------------------------------------------------------------- Category page product mouseover
window.addEvent('domready', function(){

	$$('.productCat').each(function(el, i){ //each browse through the $$ array
		//and here comes what you want el to do
		el.addEvent('mouseover', function(ongoingOver){
			$E('.image', el).setStyles( {
					'display': 'none'
			});
			$E('.description', el).setStyles( {
					'display': 'block'
			});
			$E('.ourPrice', el).setStyles( {
					'display': 'block'
			});
			$E('.order', el).setStyles( {
					'display': 'block'
			});
		});
		
		el.addEvent('mouseleave', function(ongoingOut){
			$E('.image', el).setStyles( {
					'display': 'block'
			});
			$E('.description', el).setStyles( {
					'display': 'none'
			});
			$E('.ourPrice', el).setStyles( {
					'display': 'none'
			});
			$E('.order', el).setStyles( {
					'display': 'none'
			});
		});
	
	});
	
  // random background image when not in a specific product category
  var arr = $$('div.visual', 'div.visualWide');
	if (arr){
	  var el = arr[0];
	  if(el && !el.getProperty('id')){
	    var r = Math.floor(Math.random() * 30) + 1;
	    if (r<10){ r = '0'+r; }
	    el.setStyle('background-image', 'url(../images/silt/visual_'+r+'.jpg)');
	  }
	}

});	