﻿function startMove(objDiv)
{
document.attachEvent("onmousemove",moveDiv);
document.attachEvent("onmouseup",endMove);
document.attachEvent("onselectstart",selectNo);
document["moveDiv"] = objDiv;
document["startX"] = event.x;
document["startY"] = event.y;
document["oldX"] = objDiv.getBoundingClientRect().left;
document["oldY"] = objDiv.getBoundingClientRect().top;
}
function moveDiv()
{
//try{
var obj = document["moveDiv"];
if(obj)
{
var l = document["oldX"];//obj.getBoundingClientRect().left;//obj.style.left// = 100//(event.x-document["startX"]);
var t = document["oldY"];//obj.getBoundingClientRect().top;//obj.style.top// = 100//(event.y-document["startY"]);
obj.style.position = "absolute";
obj.style.left = l + (event.x-document["startX"]);
obj.style.top = t + (event.y-document["startY"]);
}
//}catch(e){endMove();}
}
function endMove()
{
document.detachEvent("onmousemove",moveDiv);
document.detachEvent("onmouseup",endMove);
document.detachEvent("onselectstart",selectNo);
document["moveDiv"] = null;
document["startX"] = null;
document["startY"] = null;
}
function selectNo()
{ return false; }
function showManagePanel(panelID,hiddenText)
{
  var panel = document.all(panelID);
  var hidden = document.all(hiddenText);
  panel.style.display = "block";
  hidden.value = "block";
}

function hiddenManagePanel(panelID,hiddenText)
{
  var panel = document.all(panelID);
  var hidden = document.all(hiddenText);
  panel.style.display = "none";
  hidden.value = "none";
}




//show vote result div
function viewVoteResult(voteResult,bodyTop){  
    var bgObj=document.createElement('div');
    bgObj.setAttribute('id','result');
    bgObj.style.position='absolute';
    bgObj.style.top=20+bodyTop;
    bgObj.style.left='220';
    bgObj.style.width='550px';    
    bgObj.style.zIndex='1';
    bgObj.style.backgroundColor = '#FFFFFF';
    bgObj.style.borderStyle = 'solid';
    bgObj.style.borderWidth = '4px';
    bgObj.style.borderColor = '#0000FF';
    
    document.getElementById("divVoteResult").appendChild(bgObj);
    
    var html = ' '
              +'  <div style="padding:10px;background:#FFFFFF url(../../PictureResource/Static/popup_bg.jpg) repeat-x top left;padding-top:25px;border-bottom:1px solid #cccccc;margin-bottom:10px;">'
	          +'  <span style="font-size:16px;font-weight:bold;">投票ありがとうございます！</span>'       
	          +'  </div>'                
              +'  <div style="width:525px;">'
	          +'      <div class="ModuleTitle_Main" style="width:490px">'
    	      +'          <span>アンケート結果</span>'
	          +'      </div>'
              +'      <div style="width:100%;padding-left:10px;padding-top:10px;padding-bottom:20px;" id="divResult">'
              +'      </div>'
              +'  </div>'
              +'  <div align="center" style="margin-bottom:10px;">'
              +'      <input onclick="removeVoteResult();" type="button" value="閉じる" tabindex="1" />'
              +'  </div>';
              
    bgObj.innerHTML = html;
    document.getElementById("divResult").innerHTML = voteResult;
}

function removeVoteResult(){
    var bgObj = document.getElementById("result");
    bgObj.style.backgroundColor = '';
    bgObj.style.borderStyle = '';
    bgObj.style.borderWidth = '';
    bgObj.style.borderColor = '';
    bgObj.innerHTML = "";
}


function getWindowScrollTop() {
    var T;
	var w = window;
	with (w.document) 
	{
	    if (w.document.documentElement && documentElement.scrollTop) 
	    {
	        T = documentElement.scrollTop;
	    } 
	    else if (w.document.body) 
	    {
	        T = body.scrollTop;
	    }
	}
	
	return T;
}



//clear error
window.onerror = killErrors;

function killErrors(){
    return true;
}



//make IE,FF do the same thing
Object.prototype.attachEvent=function(method,func)
{
    if(!this[method])
        this[method]=func;
    else
        this[method]=this[method].attach(func);
}

Function.prototype.attach=function(func)
{
    var f=this;
    return function(){
        f();
        func();
    }
}