/* pickpop.js */
/* need tigra_hints.js */
/* admz_myHint  */

var admzHINTS_CFG = {
'wise'       : true,	// don't go off screen, don't overlap the object in the document
'margin'     : 10,	// minimum allowed distance between the hint and the window edge (negative values accepted)
'gap'        : 20,	// minimum allowed distance between the hint and the origin (negative values accepted)
//'align'      : 'bctc',	// align of the hint and the origin (by first letters origin's top|middle|bottom left|center|right to hint's top|middle|bottom left|center|right)
'align'      : 'tcbc',	// align of the hint and the origin (by first letters origin's top|middle|bottom left|center|right to hint's top|middle|bottom left|center|right)

'css'        : 'hintsClass', // a style class name for all hints, applied to DIV element (see style section in the header of the document)
'show_delay' : 200,	// a delay between initiating event (mouseover for example) and hint appearing
'hide_delay' : 0,	// a delay between closing event (mouseout for example) and hint disappearing
'follow'     : false,	// hint follows the mouse as it moves
'z-index'    : 100,	// a z-index for all hint layers
'IEfix'      : false,	// fix IE problem with windowed controls visible through hints (activate if select boxes are visible through the hints)
'IEtrans'    : [null, null],	// [show transition, hide transition] - nice transition effects, only work in IE5+
//'IEtrans'    : ['blendTrans(DURATION=.3)', 'blendTrans(DURATION=.3)'],
'opacity'    : 100	// opacity of the hint in %%
};

var admzMess = [];
//admzMess[0] = ' '; //dummy
//var admz_myHint = new THints( admzMess, admzHINTS_CFG );


var paidLids = new Array();

function in_array( needle, haystack, argStrict )
{
        var found = false, key, strict = !!argStrict;

        for (key in haystack) {
                if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) {
                        found = true;
                        break;
                }
        }
        return found;
}

function adsWrite( event, sid, lid )
{
        if ( event != null ) {
                var hint_id = 'h' + admz_myHint.n_id + '_' + '0'; //hintの中のid:一番最後の数字は 配列の添え字

                document.getElementById(hint_id).innerHTML =
			"<div class='pad'>" + 
                        document.getElementById('admz_h'+lid).innerHTML +
			"<div style='text-align:center;margin-top:5px;'>サムネイルをクリック</div></div>";

                admz_myHint.show( 0 );
	}
}

function adsClicked0( sid, lid, bpaid, strCbNext )
{
	admz_myHint.hide();

	var hint_id = 'h' + admz_myHint.n_id + '_' + '0'; //hintの中のid:一番最後の数字は 配列の添え字

	var title = tolist[sid]['ttl'];
	var imgurl = '/img/dat/' + sid + '.jpg';

	document.getElementById(hint_id).innerHTML =
			"<div class='pad'>" + 

			"<p>"+ title +"</p>" + 
			"<p><img src='" + imgurl +"' alt='"+ title +"' width='320'></p>" + 

			//document.getElementById('admz_h'+lid).innerHTML +
			"<div style='text-align:center;margin-top:5px;'>" + 
			"<input type='button' onclick='"+strCbNext+"("+sid+","+lid+","+bpaid+")'  value='計測する' />" +
			"<input type='button' onclick='admz_myHint.hide()' value='閉じる' />" +
			"</div></div>";

	admz_myHint.show( 0 );
}

function adsClicked( sid, lid, bpaid )
{
	if ( bpaid ) {
		goSpot( sid );
		return;
	}

	admz_myHint.hide();

	if ( !ptFocus( sid )) { return; }

/*
	var wrap = document.getElementById('admz_h'+lid);
	var imgs = $A(wrap.getElementsByTagName('img'));

	if ( 1 ) { 
		if ( imgs.length ) {
			document.getElementById('maptarget').innerHTML = "<img src='"+imgs[0].src+"' />";
		} else {
			document.getElementById('maptarget').innerHTML = "ホームページがありません";
		}
	} else {
		if ( bpaid ) {
			if ( imgs.length ) {
				document.getElementById('maptarget').innerHTML = "<img src='"+imgs[0].src+"' />";
			} else {
				document.getElementById('maptarget').innerHTML = "ホームページがありません";
			}
		} else {
			document.getElementById('maptarget').innerHTML = "";
		}
	}
*/
//	var resultset = { id:sid };
//	cbAdClick( resultset, bpaid )

	admz_myHint.show( 1 );
}


function adsFocus( event, idx, lid )
{
	if ( admz_myHint.o_lastHintID != 1 ) {
        	adsWrite( event, idx, lid );
	}
}

function adsDefocus()
{
	if ( admz_myHint.o_lastHintID != 1 ) { //== 0 はNG
		admz_myHint.hide();
	}
}

//for drag window

var mvo = { "obj": null, "offsetX": 0, "offsetY": 0};

function onMouseDown(e)
{
        mvo.obj = document.getElementById("h0_1"); //2nd window ■

        if ( document.all ) {
                mvo.offsetX = event.offsetX + 2;
                mvo.offsetY = event.offsetY + 2;
        } else if ( mvo.obj.getElementsByTagName ) {
                mvo.offsetX = e.pageX - parseInt( mvo.obj.style.left );
                mvo.offsetY = e.pageY - parseInt( mvo.obj.style.top );
        }
        return false;
}

function local_f_hintPosition (e_element, e_hint, a_params )
{
        var n_hintLeft;
        var n_hintTop;

        if ( document.all ) {
                n_hintLeft  = n_mouseX - mvo.offsetX;
                n_hintTop  = n_mouseY - mvo.offsetY;
        } else if ( mvo.obj.getElementsByTagName ) {
                if ( n_mouseX > 0 ) { n_hintLeft = n_mouseX - mvo.offsetX; }
                if ( n_mouseY > 0 ) { n_hintTop = n_mouseY - mvo.offsetY; }
        }

        e_hint.style.left = n_hintLeft + 'px';
        e_hint.style.top = n_hintTop + 'px';

        // synchronize iframe if exists
        var e_iframe = getElement( e_hint.id + '_if' );
        if ( e_iframe ) {
                e_iframe.style.left = n_hintLeft + 'px';
                e_iframe.style.top = n_hintTop + 'px';
                //e_iframe.style.width = n_hintWidth + 'px';
                //e_iframe.style.height = n_hintHeight + 'px';
        }
}

function onMouseMove(e)
{
        if (!e && window.event)
                e = window.event;
        if (!e)
                return true;

        if ( !mvo.obj ) {
                return true;
        }

        n_mouseX = e.pageX ? e.pageX : e.clientX + f_scrollLeft();
        n_mouseY = e.pageY ? e.pageY + 2 : e.clientY + f_scrollTop();

        var o_hint = A_HINTS[0];
        if (o_hint.o_lastHintID)
                local_f_hintPosition(o_hint.a_elements[o_hint.o_lastHintID], o_hint.a_hints[o_hint.o_lastHintID], o_hint.a_cfg);
	return false;
}

function onMouseUp(e)
{
        mvo.obj = null;
}

//document.getElementById("mapbar").onmousedown = onMouseDown;
//document.onmousemove = onMouseMove;
//document.onmouseup = onMouseUp;


