﻿//configure below variable for menu width, position on page
var menuwidth=110
var offsetleft=10
var offsettop=0

var ns4=document.layers?1:0
var ie4=document.all?1:0
var ns6=document.getElementById&&!document.all?1:0

function GetWindowsDimentions()
{     
    
    var viewportwidth;
    var viewportheight;

    // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
    if (typeof window.innerWidth != 'undefined')
     {
          viewportwidth = window.innerWidth,
          viewportheight = window.innerHeight
     }
    // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
     else if (typeof document.documentElement != 'undefined'
         && typeof document.documentElement.clientWidth !=
         'undefined' && document.documentElement.clientWidth != 0)
     {
           viewportwidth = document.documentElement.clientWidth,
           viewportheight = document.documentElement.clientHeight
     }
     // older versions of IE
     else
     {
           viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
           viewportheight = document.getElementsByTagName('body')[0].clientHeight
     }
     return new Array(viewportwidth, viewportheight);
}


function GetDetails(ElementName)
{
    if (ElementName != "") 
    {
	    var Element=document.getElementById(ElementName);
	    var Left=Element.offsetLeft;
	    var Top=Element.offsetTop;
	    var Width = Element.offsetWidth;
	    var Height = Element.offsetHeight;
	    while (Element.offsetParent != null)
	    {
		    Element = Element.offsetParent;
		    Left += Element.offsetLeft;
		    Top += Element.offsetTop;
	    }
	    return new Array(Left, Top, Width, Height);
    }
    else
	    return new Array(0,0,0,0);
}

function ShowPopup(x1,y1,x2,y2,imgParent,id,title,price)
{
    var top, left
    var objSrc = document.getElementById("AddToCart");
    var objProduct = document.getElementById("ctl00_ContentPlaceHolder1_lblProduct");
    var objQuantity = document.getElementById("ctl00_ContentPlaceHolder1_txtQty");
    var ElementDetails = GetDetails(imgParent);
    document.getElementById("ctl00_ContentPlaceHolder1_txtID").value = id;
    document.getElementById("ctl00_ContentPlaceHolder1_txtTitle").value = title;
    document.getElementById("ctl00_ContentPlaceHolder1_txtPrice").value = price;
    if (title.length > 30)
        top = (y1 - 90);
    else
        top = (y1 - 70);
    left = parseInt(((x1 + (x2-x1)/2)) - 120);
    //alert("left = " & left)
    //alert("top = " & top)
    x1 = left;
    objProduct.innerHTML = title;
    objQuantity.value = "";
    left = parseInt(ElementDetails[0]) + parseInt(left);
    top = parseInt(ElementDetails[1]) + parseInt(top);
    objSrc.style.left = left + "px";
    objSrc.style.top = top + "px";
    objSrc.style.visibility = 'visible';
}

function HidePopup()
{
    var objSrc = document.getElementById("AddToCart");
    objSrc.style.visibility = 'hidden';
}

function SetCartPosition()
{
    //var WindowsDetails = GetWindowsDimentions();
    //var objSrc = document.getElementById("ctl00_ContentPlaceHolder1_ShoppingCart");
    //left = parseInt(ElementDetails[0]) + parseInt(left);
    //objSrc.style.left = parseInt(WindowsDetails) - 300;
    //objSrc.style.top = 469;
}


