/**************************************************************
** CATALOG ** BEGIN **
***************************************************************/
function show_big_picture(pic_id){
	$('#main_pic').css('background-image', 'url('+catalog_picture_list[pic_id][0]+')');
	$('#main_pic_download').attr('href', catalog_picture_list[pic_id][2]);
	$('#main_pic').attr('title', catalog_picture_list[pic_id][1]);
	active_picture_id = pic_id;
}
function show_next_picture(direction){
	var new_pic_id = active_picture_id+direction;
	if(new_pic_id < 0){
		return;
	}
	if(new_pic_id >= catalog_picture_list.length){
		return;
	}
	show_big_picture(new_pic_id);
}
/**************************************************************
** CATALOG ** END **
***************************************************************/


function openPopUp(sUrl, iWidth, iHeight) {
	window.open(sUrl, 'NewWindow', 'width='+iWidth+',height='+iHeight+',resizable=1'); 
	return false; 
}

function correct(caller){
	if($(caller).hasClass('error')){
		$(caller).removeClass('error');
	}
}

function wrong(caller){
	if(!$(caller).hasClass('error')){
		$(caller).addClass('error'); 
	}
}

function cannotBeEmpty(caller){
	if($(caller).val() == '') {
		wrong($(caller));
		return false;
	} else {
		correct($(caller));
		return true;
	}
}

function validePhone(caller){
	if($(caller).val() == '' || $(caller).val().match(/^\d{9}$/)){ //Spain - 9 numbers
		correct($(caller));
		return true;
	} else {
		wrong($(caller));
		return false;
	}
}

function valideEmail(caller){
	if(cannotBeEmpty($(caller))){
		if(!$(caller).val().match(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/)){
			wrong($(caller));
			return false;
		} else {
			return true;
		}
	} else {
		return false;
	}
}
