﻿function show(productID) {
    alert('show');
    document.getElementById(productID).style.display = 'block';
}

function hide(productID) {
    alert('hide');
    document.getElementById(productID).style.display = 'none';
}

function openDetail(path) {
    var rndStr = Math.floor(Math.random()*500000);
    window.open('detailImage.aspx?path='+path,'detail_'+rndStr,'left=20,top=20,width=500,height=500,toolbar=0,resizable=0');(path);
}

function showProduct() {
  document.getElementById('product_view').style.display = 'block';
  document.getElementById('order_view').style.display = 'none';
  document.getElementById('producttab').className = 'pink';
  document.getElementById('ordertab').className = 'grey';
}

function showOrderTable() {
  document.getElementById('product_view').style.display = 'none';
  document.getElementById('order_view').style.display = 'block';
  document.getElementById('producttab').className = 'grey';
  document.getElementById('ordertab').className = 'pink';
}

function checkStock(sender, stock) {
  var quantity = parseInt(sender.value);
  if (quantity > stock) {
    var message = document.getElementById('stock_text').value.replace('%NUMBER%', stock);
    alert(message);
    sender.value = stock;
  }
}
 function openDetails(productID, img)
 {
    details = window.open ("detailImages.aspx?productID=" + productID + "&image=" + img, "details","location=0, status=0, scrollbars=0, width=300, height=300");
 } 
 
function detailPopup(evt) {
  
   // Tooltip container
  _tooltipContainer = document.getElementById('detail_popup_area');

  // Check for an event, and get the mouse location
  var mouseLocationX = ( typeof(evt.pageX) == 'number' ) ? evt.pageX : ( evt.clientX + (document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft) ) ;
  var mouseLocationY = ( typeof(evt.pageY) == 'number' ) ? evt.pageY : ( evt.clientY + (document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop) );
		
  mouseLocationX -= position + 5;
  mouseLocationY -= 5;
  
  alert(menuLocationX);
		
  _tooltipContainer.innerHTML = renderTooltip(mouseLocationX, mouseLocationY, "");
	_tooltipContainer = null;
  
  setTimeout("detailClear()", 3000);
  return false;
  
}
 
function renderTooltip(locationX, locationY, text) {

  alert('');
  tooltip = "";
  tooltip += "<div onmouseout=\"detailClear();\" class=\"tooltip\" style=\"position: absolute; top: " + locationY + "px; left: " + locationX + "px;\">";
  tooltip += "  <div class=\"tooltip_middle\">";
  tooltip += "    hej";//<img src=\"" + text + "\" />";
  tooltip += "  </div>";
  tooltip += "  <div class=\"tooltip_bottom\"></div>";
  tooltip += "</div>";

  return tooltip;
  
}
 
function detailClear() {
   // Tooltip container
  _tooltipContainer = document.getElementById('detail_popup_area');
  _tooltipContainer.innerHTML = "";
  _tooltipContainer = null;
}
