var strip_pos = new Array(0, 0, 0, 0);
var strip_limit = new Array(0, 30-7, 12-7, 20-7);

// submit search on Enter
function submitonEnter(){
	var keycode;
	if (window.event)
		keycode = window.event.keyCode;
	else if (e)
		keycode = e.which;
	if(keycode == "13") {
		document.forms[0].submit();
	}
}

function empty() {
	this.value='';
}

// display or hide gallery left/right arrows
function check_first_last() {
	for (i = 1; i<=3; i++) {
		if (strip_pos[i] == 0) {
			$('#gal-arrow-l'+i).attr('style', 'display:none');
		} else {
			$('#gal-arrow-l'+i).attr('style', 'display:block');
		}
	}
	for (i = 1; i<=3; i++) {
		if (strip_pos[i] == strip_limit[i]+1) {
			$('#gal-arrow-r'+i).attr('style', 'display:none');
		} else {
			$('#gal-arrow-r'+i).attr('style', 'display:block');
		}
	}
}

// menu highlight scroll
$(document).ready(function(){
	function effects(num) {
		$("#trigger"+num).mouseover(function(){
			$("#effect"+num).animate({ 
				width: "470px"
			}, 300 );
		});
		$("#trigger"+num).mouseout(function(){
			$("#effect"+num).animate({ 
				width: "0px"
			}, 300 );
		});
	}

	for (i = 1; i<=6; i++) {
		effects(i);
	}

	check_first_last();
});

// gallery scroll
function removeSubstring(myStr, mySubstr) {
  myStr = myStr.substring(0, myStr.length-2);
  return myStr;
}

function scroll(dir, row) {
	if (dir == -1 && strip_pos[row] > 0) {
		strip_pos[row] += dir;
	}
	if (dir == 1  && strip_pos[row] <= strip_limit[row]) {
		strip_pos[row] += dir;
	}

	$("#debug").html(strip_pos[1]+'; '+strip_pos[2]+'; '+strip_pos[3]+" ["+(-140*strip_pos[row])+'px]');

	$("#gal-strip"+row).animate({
		left: (-140*strip_pos[row])+'px'
	}, 300 );

	check_first_last();
}
