﻿//-----------------------------------------------------------------------------
// Author : Sudipta Das
//-----------------------------------------------------------------------------
function Large(obj)
{
    var imgbox=document.getElementById("imgbox");
    imgbox.style.visibility='visible';
    var img = document.createElement("img");    
    img.src=obj.src;
    //img.style.width='150px';
    //img.style.height='150px';
    //img.style.width=parseInt(obj.width)*2 + 'px';
    //img.style.height=parseInt(obj.height)*2 + 'px';
    
    if(img.addEventListener){
        img.addEventListener('mouseout',Out,false);
    } else {
        img.attachEvent('onmouseout',Out);
    }             
    imgbox.innerHTML='';    
    imgbox.appendChild(img);    
    imgbox.style.left=getElementLeft(obj) +'px';
    imgbox.style.top=getElementTop(obj) + 'px';
    //imgbox.style.width=parseInt(obj.width)*3 + 'px';
    //imgbox.style.height=parseInt(obj.height)*3 + 'px';              
}  

function Out()
{
    document.getElementById("imgbox").style.visibility='hidden';
}

function Move(obj,e)
{
    var mouseY=e.clientY;
    alert(e.x)
    var mouseX=e.clientX; 
    var scrollTop=document.documentElement.scrollTop; 
    var scrollLeft=document.documentElement.scrollLeft;
    var y=scrollTop+mouseY+20;
    var x=scrollLeft+mouseX+20; 
    document.getElementById("imgbox").style.left=x + "px";
    document.getElementById("imgbox").style.top=y + "px";
}

function getElementLeft(elm) 
{
    var x = 0;

    //set x to elm’s offsetLeft
    x = elm.offsetLeft;

    //set elm to its offsetParent
    elm = elm.offsetParent;

    //use while loop to check if elm is null
    // if not then add current elm’s offsetLeft to x
    //offsetTop to y and set elm to its offsetParent

    while(elm != null)
     {

        x = parseInt(x) + parseInt(elm.offsetLeft);
        elm = elm.offsetParent;
     }
     
     return x;
}

function getElementTop(elm) 
{
    var y = 0;

    //set x to elm’s offsetLeft
    y = elm.offsetTop;

    //set elm to its offsetParent
    elm = elm.offsetParent;

    //use while loop to check if elm is null
    // if not then add current elm’s offsetLeft to x
    //offsetTop to y and set elm to its offsetParent

    while(elm != null)
     {

        y = parseInt(y) + parseInt(elm.offsetTop);
        elm = elm.offsetParent;
     }
     
     return y;
}

// calculate the ASCII code of the given character
function CalcKeyCode(aChar) {
  var character = aChar.substring(0,1);
  var code = aChar.charCodeAt(0);
  return code;
}

function checkNumber(val) {
  var strPass = val.value;
  var strLength = strPass.length;
  var lchar = val.value.charAt((strLength) - 1);
  var cCode = CalcKeyCode(lchar);

  /* Check if the keyed in character is a number
     do you want alphabetic UPPERCASE only ?
     or lower case only just check their respective
     codes and replace the 48 and 57 */

  if (cCode < 48 || cCode > 57 ) {
    var myNumber = val.value.substring(0, (strLength) - 1);
    val.value = myNumber;
  }
  return false;
}

function minimumAmount(val) {
  var strPass = val.value;
  var intLength = parseInt(strPass.length);

  /* check if the value passed is empty */

  if (intLength < 1 ) {    
    val.value = 1;
  }
  return false;
}

function addProdCount(s) {
    var objLink = document.getElementById("hypURL" + s);
    var objCount = document.getElementById("txtAddCartCount" + s);    
    objLink.href = objLink.href + "&count=" + objCount.value;    
}

function ShowMessage(Message){
    alert(Message);
}