﻿function ShowWordDescription(dictionaryRefId) {
  PageMethods.GetWordDescription(dictionaryRefId, OnWordDescriptionSucceeded, OnFailed);
}

function HideWordDescription() {
  document.getElementById('wordDescriptionPopUpContainer').style.display = 'none';
  document.getElementById('popUpBackGround').style.display = 'none';
  document.getElementById('wordDescription').innerHTML = '';
}

function OnWordDescriptionSucceeded(result, userContext, methodName) {
  document.getElementById('wordDescriptionPopUpContainer').style.display = 'block';
  document.getElementById('popUpBackGround').style.display = 'block';

  var word = "";
  wordArray = result.Word.split(";");
  for (i = 0; i < wordArray.length; i++) {
    word += wordArray[i];
    if (i < wordArray.length - 1)
      word += ", ";
  }

  document.getElementById('word').innerHTML = word;
  document.getElementById('wordDescription').innerHTML = result.Description;
}

//        
//        function ShowProductImages(productId) 
//        {
//            PageMethods.GetProductImages(productId, OnProductImagesSucceeded, OnFailed); 
//        }

//        function HideProductImages()
//        {
//            document.getElementById('productImagePopUpContainer').style.display = 'none';
//            document.getElementById('popUpBackGround').style.display = 'none';
//        }
//        
//        function OnProductImagesSucceeded(result, userContext, methodName) 
//        {
//            document.getElementById('popUpBackGround').style.display = 'block';
//            document.getElementById('productImagePopUpContainer').style.display = 'block';
//            var navigation = '';
//            
//            for ( var i=0, len=result.length; i<len; ++i )
//            {
//                var onclick = "ChangeProductImage('"+result[i]+"')";
//                navigation += '<a style="cursor:pointer;cursor:hand;" onClick="'+onclick+'">['+(i+1)+']</a>';
//                
//                if (i == 0)
//                {
//                    document.getElementById("productImage").src = '/CreateImageTumbnail.aspx?file='+result[i]+'&height=600&maxWidth=600';
//                }
//            }
//            
//            document.getElementById("navigation").innerHTML = navigation;
//        }
//        
//        function ShowImageLarge(imageUrl)
//        {
//            document.getElementById('popUpBackGround').style.display = 'block';
//            document.getElementById('productImagePopUpContainer').style.display = 'block';
//            document.getElementById("productImage").src = '/CreateImageTumbnail.aspx?file='+imageUrl+'&height=600&maxWidth=600';
//        }
//        
//        function ChangeProductImage(imageUrl)
//        {
//            document.getElementById("productImage").src = '/CreateImageTumbnail.aspx?file='+imageUrl+'&height=700&maxWidth=700';
//            //document.getElementById("productImage").href = 'JavaScript:HideProductImages();';
//        }

function OnFailed(error, userContext, methodName) {
  alert(error.get_exceptionType());
  alert(error.get_message());
}
