function setRollOver(id,photoUrl){
	document.getElementById(id).src = photoUrl;	
}

function setRollOut(id,photoUrl){
	document.getElementById(id).src = photoUrl;	
}

function showBox(id,boxLeft,boxTop,boxZindex){
	if(document.getElementById(id).style.display != "block"){
		document.getElementById(id).style.display = "block";
		document.getElementById(id).style.left = boxLeft + "px";
		document.getElementById(id).style.top = boxTop + "px";
		document.getElementById(id).style.zIndex = boxZindex;
	}else{
		document.getElementById(id).style.display = "none";
	}
}

var isDrag = false;
var dragBox;
var dragboxX_start;
var dragBoxX_now;
var dragBoxY_start;
var dragBoxY_now;
var mouseX_start;
var mouseX_now;
var mouseY_start;
var mouseY_now;
var distanceX;
var distanceY;
var myTimer;

document.onmousemove = function(evt){
	if(isDrag == true){
		if(document.all){
			mouseX_now = parseInt(event.screenX);
			mouseY_now = parseInt(event.screenY);
		}else{
			mouseX_now = parseInt(evt.pageX);
			mouseY_now = parseInt(evt.pageY);
		}
		dragBoxX_now = mouseX_now - distanceX;
		dragBoxY_now = mouseY_now - distanceY;
	}
}

function startDrag(id){
	isDrag = true;
	dragBox = document.getElementById(id);
	setTimeout("setPoint()",0);
}

document.onmousedown = function(evt){
	if(isDrag == true){
		if(document.all){
			mouseX_start = parseInt(event.screenX);
			mouseY_start = parseInt(event.screenY);
		}else{
			mouseX_start = parseInt(evt.pageX);
			mouseY_start = parseInt(evt.pageY);
		}
		dragBoxX_start = parseInt(dragBox.style.left);
		dragBoxY_start = parseInt(dragBox.style.top);
		distanceX = mouseX_start - dragBoxX_start;
		distanceY = mouseY_start - dragBoxY_start;
	}
}

function setPoint(){
	clearTimeout(myTimer);
	if(dragBoxX_now != null){
		dragBox.style.left = dragBoxX_now +"px";
		dragBox.style.top = dragBoxY_now +"px";
	}
	myTimer = setTimeout("setPoint()",0);
}

function stopDrag(){
	isDrag = false;
	dragBox = null;	
	dragboxX_start = null;
	dragBoxX_now = null;
	dragBoxY_start = null
	dragBoxY_now =null;
	mouseX_start = null;
	mouseX_now = null
	mouseY_start = null;
	mouseY_now = null;
	distanceX = null;
	distanceY = null;
	clearTimeout(myTimer);
}

function showPopUpText(){
	clearTimeout(myTimer);
	popUpText.style.display = "block";
	popUpText.style.left = mouseX_now + 10 + "px";

	popUpText.style.top = mouseY_now + 10 + "px";
	popUpText.style.zIndex = 4;
}

var popUpText;
var isPopUpText = false ;
function setPopUpText(id){
	if(isPopUpText == false){
 		isPopUpText = true;
		popUpText = document.getElementById(id);
	myTimer = setTimeout("showPopUpText()",33);
	}
}

function hidePopUpText(){
	popUpText.style.display = "none";
	isPopUpText = false;
}

var reDrawTimer;
function reDraw(){ 
	clearInterval(reDrawTimer);
	document.body.style.backgroundColor = "#FFFFFF";
	var old = document.body.style.backgroundColor;
	document.body.style.backgroundColor = "transparent";
	document.body.style.backgroundColor = old;
	reDrawTimer = setInterval("reDraw()",0);
}

function changeSelectDistrict(){
	var selectedCategory = document.search_from_area.select_category_area[document.search_from_area.select_category_area.selectedIndex].value;
	if(selectedCategory == "Buy1" ){
		for(i=0;i<34;i++){
			document.search_from_area[3][i+1].text = document.search_from_area[3][i+1].value + "（" + document.search_from_area.Region_num[i].value +"件）";
		}
	}else if(selectedCategory == "Buy2" ){
		for(i=0;i<34;i++){
			document.search_from_area[3][i+1].text = document.search_from_area[3][i+1].value + "（" + document.search_from_area.Region_num_buyLand[i].value +"件）";
		}
	}else if(selectedCategory == "Rent" ){
		for(i=0;i<34;i++){
			document.search_from_area[3][i+1].text = document.search_from_area[3][i+1].value + "（" + document.search_from_area.Region_num_rent[i].value +"件）";
		}
	}
}

function changeSelectLine(){
	var selectedCategory = document.search_from_line.select_category_line[document.search_from_line.select_category_line.selectedIndex].value;
	if(selectedCategory == "Buy1" ){
		for(i=0;i<34;i++){
			document.search_from_line[3][i].text = document.search_from_line[3][i].value + "（" + document.search_from_line.Region_num_buy_line[i].value +"件）";
		}
	}else if(selectedCategory == "Buy2" ){
		for(i=0;i<34;i++){
			document.search_from_line[3][i].text = document.search_from_line[3][i].value + "（" + document.search_from_line.Region_num_buyLand_line[i].value +"件）";
		}
	}else if(selectedCategory == "Rent" ){
		for(i=0;i<34;i++){
			document.search_from_line[3][i].text = document.search_from_line[3][i].value + "（" + document.search_from_line.Region_num_rent_line[i].value +"件）";
		}
	}
}
