// JavaScript Document



// index & search
function showZoom(event, anchor, image, smallImageName){
	$('mini-zoom-link').href= anchor.href;

    document.miniZoom = new Image();
    document.miniZoom.onload = miniZoomOnLoad;
    document.miniZoom.src = smallImageName.replace('_152.jpg', '_300.jpg');
    
    cumOffset = Position.cumulativeOffset($(image));
    //$('log').innerHTML = image + '<br />'+ 	cumOffset[0] + ',' + cumOffset[1];;
	$('mini-zoom-image').src = smallImageName;

	$('mini-zoom-wrapper').style.position = 'absolute';
	$('mini-zoom-wrapper').style.top = (cumOffset[1] -40 )+ 'px';
	$('mini-zoom-wrapper').style.left = (cumOffset[0] - 70) + 'px';
	
	$('mini-zoom-wrapper').onmouseout = hideMiniZoom;
	
//	$('mini-zoom-image').style.display = 'block';
	Effect.Appear('mini-zoom-wrapper', {duration: 0.2});
	//$('mini-zoom-wrapper').style.display = 'block';
	
}

function miniZoomOnLoad(e) {
	$('mini-zoom-image').src = document.miniZoom.src;
	
}

function hideMiniZoom(event) {
	Effect.Fade('mini-zoom-wrapper', {duration: 0.2});
	//$('mini-zoom-wrapper').style.display = 'none';
}
function hideZoom(target){
	target.className='zoom-inactive';
  }
  
  
  
// product page
function toggleDetailCopy(){
	$('product-copy-details').toggle();
  }

function showSizeChart(){
	document.getElementById(tagetID).className='zoom-active';
  }
  
function toggleSizeChart(){
	target = document.getElementById('product-size-chart');
	if (target.className=='active'){
	   target.className='inactive';
	}else{
	   target.className='active';
	}
  }
  
function toggleGiftBoxDetails(){
	target = document.getElementById('gift-box-details');
	if (target.className=='active'){
	   target.className='inactive';
	}else{
	   target.className='active';
	}
  }
function onLoad() {
	if($('system-message-negative') != null) {
		new Effect.Highlight('system-message-negative', {duration: 3, startcolor:'#c0001a'})
	}
	
	if($('system-message-positive') != null) {
		new Effect.Highlight('system-message-positive', {duration: 3, startcolor:'#008200'})
	}
	
	if($('added-item') != null) {
		new Effect.Highlight('added-item', {duration: 3, startcolor:'#D7EBD7'})
	}
}

document.holder = new Array(13);
document.holderPosition = 0;
function processKeystroke(e)
{
	if(e.keyCode == 13) {
		str = "";
		for(i = 0; i < 13; i++) {
			
			str+=String.fromCharCode(document.holder[ (i+document.holderPosition) % 13]);
			if(str.match(/^(\w{5}).(\w{7})/)) {
				window.location = 'http://'+window.location.hostname+'/style.php/style/'+str;	
			}
		}
	} else {
		document.holder[document.holderPosition%13] = e.keyCode;	
		document.holderPosition++
	}
}
