﻿// Copyright(c)2008 GODNTECH All rights reserved.
// Title : CodiDiary Viewer Javascript Library
// Version : 1.0
// Date : 2008-06-23
// Client : Stylet
// Developer : Jae-Kyun, Park (NOSPAM_______duex5190@nate.com)

// History : 1.0 - Functions are Implemented.

var CodiItemViewer = {
    _canvassize: 500,
    _innerno: 0,

    imgView: function (panelobj, imgsrc) {
        var imgobj = document.createElement("IMG");
        imgobj.src = imgsrc;

        var divobj = document.createElement("DIV");
        var s = divobj.style;
        s.position = "absolute";
        s.top = "0px";
        s.left = "0px";
        s.zIndex = 5;
        //divobj.appendChild(imgobj);

        jQuery(panelobj).append(imgobj); //transmon
    },

    additem: function (panelobj, top, left, width, height, zindex, itemtype, itemno, itemUrl) {
        this._innerno++;
        this.trace("additem[" + this._innerno + "] : top(" + top + "),left(" + left + "),width(" + width + "),height(" + height + "),zindex(" + zindex + "),itemtype(" + itemtype + "),itemno(" + itemno + "),itemUrl('" + itemUrl + "')");
        if (itemtype != 2) return;

        var t = top;
        var l = left;
        var w = width;
        var h = height;
        var margin = 7;
        var widthover = false;
        var heightover = false;

        if (w <= 0 || h <= 0) return;

        /*
        if(t<0)
        {
        h = h - t;
        t = margin;
        }
        
        if(l<0)
        {
        w = w - (l*-1);
        l = margin;
        }
        
        if(t+h>=this._canvassize)
        {
        heightover = true;
        h = this._canvassize-margin-t;
        }
        
        if(l+w>=this._canvassize)
        {
        widthover = true;
        w = this._canvassize-margin-l;
        }
        */

        var aobj = document.createElement("A");
        aobj.setAttribute("_ajaxurl", "/stylet/codidiary/module/ItemToolTip.aspx?itemno=" + itemno);

        if (itemtype == 2) {
            aobj.className = "clsCodiItem";
            aobj.title = "상세보기";
        }
        var s = aobj.style;
        s.position = "absolute";
        s.top = (t - 2) + "px";
        s.left = (l - 2) + "px";
        s.width = (w + 2) + "px";
        s.height = (h + 2) + "px";
        s.zIndex = zindex + 10;

        var msg = "additem[" + this._innerno + "] \ntop : " + (t - 2) + "px";
        msg += "\nleft : " + (l - 2) + "px";
        msg += "\nwidth : " + (w + 2) + "px";
        msg += "\nheight : " + (h + 2) + "px";
        msg += "\nzindex : " + zindex + 10;
        this.trace(msg);

        //s.border = "1px solid #000000";   
        //s.backgroundColor = "white";
        //s.opacity = "0.5";//filter:alpha(opacity:80);
        //s.filter = "alpha(opacity:50)";    

        //FILTER: alpha(opacity=0);	WIDTH: 100%;	HEIGHT: 100%;	BACKGROUND-COLOR: #ffffff;	opacity: 0
        var divobj = document.createElement("DIV");
        divobj.style.filter = "alpha(opacity=0)";
        divobj.style.width = "100%";
        divobj.style.height = "100%";
        divobj.style.backgroundColor = "#ffffff";
        divobj.style.opacity = "0";
        divobj.className = "codiitem_each";

        //flashing 효과
        //divobj.style.backgroundColor = "#666666";        

        aobj.appendChild(divobj);
        aobj.setAttribute("_client_itemno", itemno);

        if (itemtype == 2) {

            aobj.onmouseover = function () {
                //alert(this.getAttribute("_client_itemno"));
                var divobj = this.childNodes[0];
                this.style.border = "2px outset #ffffff";
                this.style.cursor = "hand";
                this.style.filter = "Glow(color=#ffffff,strength=10)";
                divobj.style.filter = "alpha(opacity=20)";
                divobj.style.opacity = "0.2";
                jQuery(divobj).fadeTo("slow", 0.01);
            };

            aobj.onmouseout = function () {
                this.style.border = "0px solid #000000";
                this.style.cursor = "default";
                this.style.filter = ""; //"Glow(color=#ffffff,strength=10)";

            };


            aobj.onclick = function () {
                //Common.popupLayerMousePosition(event,340,160,"/stylet/Common/layerpop/RecommendPoll.aspx?pollno=" + pollno + "&choiceno=" + choiceno,'');    
                //Common.popupLayerMousePosition(event,520,310,"/stylet/Common/layerpop/GetItemInfo.aspx?itemno=" + itemno + "&type=1");    
                //Common.popupLayerMousePosition(event,420,185,"/stylet/CodiDiary/popItemInfo.aspx?itemno=" + itemno);
                //Linker.ItemDetailOne(this.getAttribute("_client_itemno"));
                //
                //jQuery.get("ItemToolTip.aspx", {itemno:this.getAttribute("_client_itemno")}, function (response){
                //alert(response);
                //tip(response, 370, "white"); 
                //});
                //alert("OK");
                //링크관련 ItemPage 로 변경[2011.11.28 허휘영]
                location.href='/stylet/stylepicksv6/ItemDetail.aspx?itemno='+itemno;
                //location.href = "javascript:window.open('" + itemUrl + "');void(0);";
            };

        }


        jQuery(panelobj).append(aobj);
        //$('h4').cluetip({attribute: 'id', hoverClass: 'highlight'});
        //jQuery(aobj).cluetip({activation:'click',attribute:'_ajaxurl'});

        panelobj.onmouseout = function () {
            //
        };

    },

    trace: function (msg) {
        return;
        alert(msg);
    },

    toString: function () {
        return "CodiItemViewer";
    }
}


jQuery(document).ready(function() {
    /*
    jQuery('.clsCodiItem').cluetip({
          attribute:'_ajaxurl', 
          activation:'click',
          cluetipClass: 'jtip', 
          arrows: true, 
          dropShadow: true,
          dropShadowSteps: 5, 
          hoverIntent: false,
          sticky: true,
          mouseOutClose: true,          
          closePosition: 'title',
          closeText: '<img src="/stylet/codidiary/module/images/cross.png" alt="" />',
          width:380 
        });
        
        */
});    
