$(document).ready(function(){

	/* CAPTCHA */

	$('input[name=captcha]').focus(function(){
		if(this.value=='(typ de code over)'){
			this.value='';
			this.style.color='#847a56';
		} else {
			this.style.color='#847a56';
		}
	});
	$('input[name=captcha]').blur(function(){
		if(this.value==''){
			this.value='(typ de code over)';
			this.style.color='#acab9e';
		} else if(this.value=='(typ de code over)'){
		this.style.color='#acab9e';
		} else {
			this.style.color='#847a56';
		}
	});
	
	/* MISC */

	$("a.popup").colorbox();
	$("a.popup_video").colorbox({iframe:true, innerWidth:633, innerHeight:505});
	
	$('div.order').hide();
	$('span.order').click(function() {
		$('div[id=order_'+ this.id +']').toggle(250);
	});
	
	/* THUMB */
	
	$('.popup span').css('opacity',0.0);
	$('.popup').hover(function() {
		$('span', this).animate({ opacity:0.8}, 100);
	}, function() {
		$('span', this).animate({ opacity:0.0}, 100);
	});
	
 $("#radio li").click(function(event){
	event.preventDefault();
	$('#radio > li').removeClass("active");
	var id = this.id;
	var newselect = id.replace('-li-', '-');
	$('#'+newselect).attr('checked', true);
	$(this).addClass("active");
	$(this).parent().addClass("active");
	return false;
 });
 
});

function numbersonly(myfield, e, dec){
	var key;
	var keychar;
	
	if(window.event){
		key = window.event.keyCode;
	} else if(e){
		key = e.which;
	} else {
		return true;
	}
	
	keychar = String.fromCharCode(key);
	
	if((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27)){ // control keys
		 return true;
	} else if((("0123456789").indexOf(keychar) > -1)){ // numbers
		 return true;
	} else if (dec && (keychar == ".")){ // decimal point jump
		 myfield.form.elements[dec].focus();
		 return false;
	} else {
		 return false;
	}
}
