﻿/*
var xmlHttp;
function createXMLHttpRequest() {
    if (window.ActiveXObject) {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    } 
    else if (window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();
    }
}

function send_Request(url) {
    createXMLHttpRequest();
    xmlHttp.onreadystatechange = callback_Request;
    xmlHttp.open("GET", url, true);
    xmlHttp.send(null);
}

function callback_Request() {
    if(xmlHttp.readyState == 4) {
        if(xmlHttp.status == 200) {
            var pos = getAbsolutePos(obj_position);
            obj_display.style.left = pos.left - 100 + "px";
            obj_display.style.top = pos.top + pos.height - 10 + "px";
            obj_display.style.display = "";
            document.getElementById("results_div").innerHTML = xmlHttp.responseText;
        }
    }
}
*/
var obj_display;
var obj_position;
var old_id;
function viewExplain(item_id, pos_id)
{
    obj_display = getObject("display_div");
    if( old_id == item_id ) {
        if( obj_display.style.display == "none" ) {
            //obj_display.style.display = "";
            ItemService.GetItem(item_id, OnComplete, OnError);
        } else {
            hiddenDiv();
        }
    } else {
        old_id = item_id;
        obj_position = getObject(pos_id);
        //var url = "/App/itemshop/explain_popup.aspx?id="+item_id
        //send_Request(url);
        //Item.DetailViewService.GetExplain(item_id, OnComplete, OnError);
        ItemService.GetItem(item_id, OnComplete, OnError);
    }
}

function OnComplete(result)
{
  var pos = getAbsolutePos(obj_position);
  obj_display.style.left = pos.left - 100 + "px";
  obj_display.style.top = pos.top + pos.height - 10 + "px";
  obj_display.style.display = "";
  document.getElementById("results_div").innerHTML = result;
}

function OnError(error)
{
  alert("Error: " + error.get_message());
}

function hiddenDiv()
{
    getObject("display_div").style.display = "none";
}

function create_div()
{
    var html  = "<div id='display_div' style='position:absolute;display:none;z-index:10000;'>";
        html += "<table border='0' cellpadding='0' cellspacing='0' id='con_exp_box'>";
        html += "    <tr>";
        html += "        <td class='bg_exp_tit f_w06'><img src='"+getImgUrl()+"/images/itemmall/icon_exp.gif' style='vertical-align:middle;'/> Features & Effects</td>";
        html += "        <td class='f_w06' style='background-color:#2c2a27;'><span style='cursor:pointer;' onclick='hiddenDiv();' title='close'>X</span>&nbsp;&nbsp;</td>";
        html += "	</tr>";
        html += "	<tr>";
        html += "	    <td width='100%' colspan='2'>";
        html += "		    <div class='con_exp_box2' id='results_div'></div>";
        html += "		</td>";
        html += "	</tr>";
        html += "</table>";
        html += "</div>";
    
    document.write(html);
}
