showLogin = function(){
	Effect.Appear('login_box',{ duration: 0.5 });
}
hideLogin = function(){
	Effect.Fade('login_box',{ duration: 0.5 });
}
showLargeImage = function(e){
	var element = $('imagebox');
	var over_element = $('product_image');
	if(!element.over){
		element.show();
		var myWidth = 0, myHeight = 0;
		if( typeof( window.innerWidth ) == 'number' ) {
			myWidth = window.innerWidth; myHeight = window.innerHeight;
		} else if( document.documentElement && ( document.documentElement.clientWidth ||document.documentElement.clientHeight ) ) {
			myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight;
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			myWidth = document.body.clientWidth; myHeight = document.body.clientHeight;
		}

		
		var browseWidth, browseHeight;
		if(document.layers||(document.getElementById&&!document.all)){ 
		   browseWidth=window.innerWidth;
		   browseHeight=window.innerHeight;
		}else if(document.all){
		   browseWidth=document.body.clientWidth;
		   browseHeight=document.body.clientHeight;
		}
		
		element.style.left = (Number(Position.cumulativeOffset(over_element)[0]) - 320)+"px";
		element.style.top = (Number(Position.cumulativeOffset(over_element)[1]) - 200)+"px";
		element.over = true;
		
		//element.style.left = (Number(myWidth) - 540)+"px";
		//element.style.top = (Event.pointerY(e)-200)+"px";
	}
}
hideLargeImage = function(){
	$('imagebox').hide();
	var element = $('imagebox');
	element.over = false;
}
showEmailColleague = function(){
	if(!$('email_to_colleague_form').isOpen){
		Effect.BlindDown('email_to_colleague_form');
		$('email_to_colleague_close').show();
		$('email_to_colleague_form').isOpen = true;
	}
	else{
		hideEmailColleague();
	}
}
hideEmailColleague = function(){
	if($('email_to_colleague_form').isOpen){
		Effect.BlindUp('email_to_colleague_form');
		$('email_to_colleague_close').hide();
		$('email_to_colleague_form').isOpen = false;
	}
}
Event.observe(window,'load', function(){
  if($('product_image')){
	Event.observe('product_image', "mouseover", showLargeImage, false);
	Event.observe('product_image', "mouseout", hideLargeImage, false);
  }
});

popUpWindow = function(href, width, height){
	window.open(href, '_blank', 'width=' + width + ',height=' +  height + ',scrollbars=auto');
	return false;
}

/**
 * Take the current shipping price and update the cart total dynamically 
 * @param {Object} shippingPrice - current shipping price selected from user
 */
calculateShipping = function(shippingPrice){
  //this is simply a helper function, if it has an error, capture it and do nothing 
	try{
		var shippingCost = parseFloat(shippingPrice);
    var totalItemCost = $('total_item_cost').innerHTML;
    totalItemCost = parseFloat(totalItemCost.substring(1,totalItemCost.length));
    var totalCost = (shippingCost + totalItemCost);
  
    $('total_shipping').innerHTML = '$' + shippingCost.toFixed(2);
    $('total_cost').innerHTML = '$' + totalCost.toFixed(2);
		
	}catch(e){}
	return false;
}