if ( self.location.href.indexOf('item.php') != -1 && top.location.href.indexOf('/frame.php') == -1 && !GLOBAL.ADMIN ) {
	top.location.href = '/frame.php' + self.location.search;
}



$(function() {
	
	// Hightlight thumb
	if ( self.location.href.indexOf('/item.php') != -1 ) {
		(function highlight() {
			var thumbsFrame = top.frames['thumbs'];
			try {
				thumbsFrame.$('a.curThumb').removeClass();
				thumbsFrame.$("a[href*='itemId=" + GLOBAL.itemId + "']").addClass('curThumb');
			}
			catch( e ) {
				// Thumbs frame not loaded yet, try again later
				setTimeout(highlight, 200);
			}
		})();
	}
	
	
	$('#imageLayer a').click(function() {
		$('#btnItemIdNext').addClass('mOver');								   
	});
	
	
	// Show/hide infoLayer + blink 'Info...'
	var infoLayer = $('#infoLayer');	
	if (infoLayer.length != 0) {
		
		var caption = $('#caption');
		var str     = "<span id='btnInfo'>Info...</span>";
		if (caption.text().length == 0) {
			caption.html(str);
		}
		else {
			caption.append('&nbsp;|&nbsp;' + str);
		}
			
		// Blink 'Info...'
		var timerBlink, step = 1, fgColor = 15; // 0-15
		var btnInfo = $('#btnInfo');
		var defaultColor = btnInfo.css('color');
		(function blink() {
			var hex = fgColor.toString( 16 );
			if ( fgColor <= 3 || fgColor >= 15 ) {
				step *= -1;
			}
			fgColor += step;
			btnInfo.css('color', '#' + hex + hex + hex);
			timerBlink = setTimeout( blink, 60 );
		})();
		
		// Show/hide infoLayer
		$('#btnInfo').mouseover(function() {
			infoLayer.fadeTo('slow', 0.8).css('display', 'block');
			$('#btnInfo').stop().css('color', defaultColor);
			clearTimeout( timerBlink );
		}).mouseout(function() {
			infoLayer.fadeTo('fast', 0).css('display', 'none');
		});
	}
	
	
	
});



function keyUp() {
	var btnItemIdPrev = $('#btnItemIdPrev');
	if (btnItemIdPrev.length != 0) {
		btnItemIdPrev.addClass('mOver');
		top.frames['main'].location.href = btnItemIdPrev.attr('href');
	}
}



function keyDown() {
	var btnItemIdNext = $('#btnItemIdNext');
	if (btnItemIdNext.length != 0) {
		btnItemIdNext.addClass('mOver');
		top.frames['main'].location.href = btnItemIdNext.attr('href');
	}
}

