var photoBrowserWidth = 250;
var photoCounter = 0;
var photoCount = 0;
var photoFx;
var photoArray = [];

function photoInit()
{
	photoCounter = 0;
	var itemWidth= photoBrowserWidth;
	//if ( $('product_photos') == null ) return;
	var list = $$("#product_photos .product_photos_entry")
		
	photoFx = new Fx.Scroll('product_photos');
	photoCount = list.length;
	$('product_photos_content').setStyle('width',photoCount*itemWidth);
	
	var curr_loc = location.href;
	if( (curr_loc.lastIndexOf('#') > 0) && (curr_loc.lastIndexOf('pic=') > 0) ){
		anchor = curr_loc.substr(curr_loc.lastIndexOf('#')+1).replace(this.hashParam+'=','');
		photoShow( anchor.replace('pic=','') );
	}
	else{
		//photoShow( 0 );
	}
}

function photoPrev()
{
	photoCounter--;
	if ( photoCounter < 0 )
	{
		photoCounter = photoCount-1;
	}					
	photoShow(photoCounter);
}

function photoNext()
{
	photoCounter++;
	if ( photoCount == photoCounter )
	{
		photoCounter = 0;
	}
	photoShow(photoCounter);	
}

function photoShow( curCounter ){
	photoCounter = curCounter;
	objName = 'photo_box_'+photoCounter;
	obj = $(objName);
	imgObj = obj.getElementsByTagName("img")[0];
	if( imgObj && imgObj.title!='' ){
		imgObj.src = imgObj.title;
		imgObj.title = '';
	}
	
	photoFx.toElement('photo_box_'+photoCounter);		
	photoSetLink();
}

function photoZoom(){
	objName = 'photo_box_'+photoCounter;
	obj = $(objName);
	imgObj = obj.getElementsByTagName("a")[0];
	document.location.href = imgObj.href;
}

function photoSetLink(){
	var curr_loc = location.href;
	var found = false;
	base_loc = curr_loc.substr(0,curr_loc.indexOf('#'));
	document.location.href = base_loc+'#'+'pic='+photoCounter;
}

function photoSetTips(){
	var ProductTips = new Tips($$('.proTips'), {
		//fixed:true,
		offsets: {'x': -50, 'y': -200},
		initialize:function(){
			this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 250, wait: false}).set(0);
		},
		onShow: function(toolTip) {
			this.fx.start(1);
		},
		onHide: function(toolTip) {
			this.fx.start(0);
		}
	});
}

/*
Tips.implement({
	position: function(element){
		var pos = element.getPosition();
		this.toolTip.setStyles({
			'left': pos.x + this.options.offsets.x - $('thumb_holder').scrollLeft,
			'top': pos.y + this.options.offsets.y
		});
	}
});
*/

