function Over(evt) {
	try{
		if(event.srcElement.className == "rollover") {
			var obj = event.srcElement;
			var srcPath = obj.src;
			var overImg = obj.over;
			var outImg = obj.out;
			var newSrcPath = srcPath.replace(outImg, overImg);
			event.srcElement.src = newSrcPath;
		}
	}catch(e){
		if(evt.target.className == "rollover") {
			var obj = evt.target;
			var srcPath = obj.src;
			var newSrcPath = srcPath.replace(".jpg", "_02.jpg");
			evt.target.src = newSrcPath;
		}
	}
}

function Out(evt) {
	try{
		if(event.srcElement.className == "rollover") {
			var obj = event.srcElement;
			var srcPath = obj.src;
			var overImg = obj.over;
			var outImg = obj.out;
			var newSrcPath = srcPath.replace(overImg, outImg);
			event.srcElement.src = newSrcPath;
		}
	}catch(e){
		if(evt.target.className == "rollover") {
			var obj = evt.target;
			var srcPath = obj.src;
			var newSrcPath = srcPath.replace("_02.jpg", ".jpg");
			evt.target.src = newSrcPath;
		}
	}
}

var __mouse_x	= null;
var __mouse_y	= null;
function Move(evt){
	try{
		__mouse_x	= document.body.scrollLeft + event.clientX;
		__mouse_y	= document.body.scrollTop + event.clientY;
	}catch(e){
		__mouse_x	= evt.pageX;
		__mouse_y	= evt.pageY;
	}
}

function init() {
	try{
		document.body.attachEvent("onmouseover", Over);
		document.body.attachEvent("onmouseout", Out);
		document.body.attachEvent("onmousemove", Move);
	}catch(e){
		document.onmouseover	= Over;
		document.onmouseout	= Out;
		document.onmousemove	= Move;
	}
}

function imageOver(){
	var e = event.srcElement;
	var name = e.name;
	var over = e.over;
	var out = e.out;
	var obj = eval("document.all."+name);
	for(var i=0; i<obj.length; i++){
		obj[i].src = obj[i].src.replace(obj[i].over, obj[i].out);
	}
	e.src = e.src.replace(e.out, e.over);
}

var script_number	= 0;
function scriptInsert(){
	var reObj	= null;
	var nav	= navigator.appName;
	if(nav.indexOf("Netscape") != -1){
		reObj	= scriptInsertNS();
	}else{
		reObj	= scriptInsertIE();
	}
	return reObj;
}

function scriptInsertIE(){
	var obj		= document.getElementById("script_layer");
	var oRow	= obj.insertRow();
	var cCell	= oRow.insertCell();
	var reObj	= "";

	cCell.innerHTML	= "&nbsp;<script id='script_"+script_number+"'></script>";
	reObj		= document.getElementById("script_"+script_number);
	
	script_number	= script_number + 1;
	return reObj;
}

function scriptInsertNS(){
	var obj		= document.getElementById("script_layer");
	obj.innerHTML	= "&nbsp;<script id='script_"+script_number+"'></script>";
	reObj		= document.getElementById("script_"+script_number);
	
	script_number	= script_number + 1;
	return reObj;
}

function schRegion(sido, gugun, selectId, selectIndex){
	var addr = "";
	var obj = scriptInsert();
	if(selectId.indexOf("gugun") >= 0){
		addr = sido;
	}else
	if(selectId.indexOf("dong") >= 0){
		addr = sido+"|"+gugun;
	}
	obj.src = "/immovable/js/region.js.php?addr="+addr+"&id="+selectId+"&selectIndex="+selectIndex;
}

function schApt(sido, gugun, dong, position, selectId, selectIndex){
	var addr = "";
	var obj = scriptInsert();
	addr = sido+"|"+gugun+"|"+dong;
	obj.src = "/immovable/js/apt.js.php?addr="+addr+"&position="+position+"&id="+selectId+"&selectIndex="+selectIndex;
}

function schSubway(city, route, selectId, selectIndex){
	var subway = "";
	var obj = scriptInsert();
	if(selectId.indexOf("station") > -1){
		subway = city+"|"+route;
	}else
	if(selectId.indexOf("subway") > -1){
		subway = city;
	}
	obj.src = "/immovable/js/subway.js.php?subway="+subway+"&id="+selectId+"&selectIndex="+selectIndex;
}

function searchView(src){
	var obj = scriptInsert();
	obj.src	= src;
}

function sidoSearch(selected){
	var src = "/immovable/js/kria_sido.js.php?selected="+selected;
	searchView(src);
}

function gugunSearch(sido, selected){
	var src = "/immovable/js/kria_gugun.js.php?sido="+sido+"&selected="+selected;
	//script_sub.src = "/immovable/js/kria_dong.js.php?sido="+sido;
	setTimeout("searchView('"+src+"')", 100);
}

function dongSearch(gugun, selected){
	var sido	= document.getElementById("sido").value;
	var src = "/immovable/js/kria_dong.js.php?sido="+sido+"&gugun="+gugun+"&selected="+selected;
	setTimeout("searchView('"+src+"')", 100);
}

function aptSearch(dong, selected, category){
	var sido	= document.getElementById("sido").value;
	var gugun	= document.getElementById("gugun").value;
	var obj 	= scriptInsert();
	obj.src = "/immovable/js/kria_apt.js.php?sido="+sido+"&gugun="+gugun+"&dong="+dong+"&selected="+selected+"&category="+category;
}

function number_format(number,decimals ){
	var number_str = String(number);
	var new_number_str = '';
	number_info = number_str.split('.');
	number_info_int = number_info[0];
	if (decimals != null )	{
		if (decimals > 0)
			new_number_str = '.' + ((decimals > 0) ?Math.round(Number('0.' +number_info[1]) * Math.pow(10, decimals)):'');
		else if (decimals < 0)
			number_info_int = String(Math.round(Number(number_info[0]) / Math.pow(10, decimals *(-1))) *Math.pow(10, decimals*(-1)));
	}
	len = number_info_int.length;
	for (i = len; i >= 0; i--) {
		if ( (len - i) > 1 && (len - i) % 3 == 1)  new_number_str = ',' + new_number_str;
		new_number_str = number_info_int.substring(i, i+1) +  new_number_str;
	}
	return new_number_str;
}

function operation(target, pyeongName, squareName){
	var pyeong = document.getElementById(pyeongName);
	var square = document.getElementById(squareName);
	var pyeong_number = Number(pyeong.value ? pyeong.value : 0);
	var square_number = Number(square.value ? square.value : 0);
	var number = 3.3058;

	if(target == "pyeong"){
		if(pyeong_number || pyeong_number > 0){
			square.value = pyeong_number * number;
		}else{
			//pyeong.value = 0;
			square.value = 0;
		}
	}else if(target == "square"){
		if(square_number || square_number > 0){
			pyeong.value = Math.round(square_number / number);
		}else{
			//pyeong.value = 0;
			square.value = 0;
		}
	}
}

function calculateChg(chg){
	if(chg == 1){
		operation('pyeong', 'calculate_01', 'calculate_02')
	}else
	if(chg == 2){
		operation('square', 'calculate_02', 'calculate_01')
	}
}

function nusonPop(dom_code){
	var winObject	= null;
	var w		= 1115; //새로띄울 화면의 넓이
	var h		= 673; //새로띄울 화면의 높이
	winToTop	= (screen.height) ? (screen.height-h)/2 : 0;
	winToLeft	= (screen.width) ? (screen.width-w)/2 : 0;
	var settings	='toolbar=0,directories=0,status=no,menubar=0,scrollbars=no,resizable=no,height='+h+',width='+w+',left='+winToLeft+',top='+winToTop+'';
	var noson	= "/immovable/popup/"+dom_code+"/popup_nosun.html";
	winObject	= window.open(noson, "nosun", settings);
}

function postPop(form, zip, addr, code, area){
	var winObject	= null;
	var w		= 370; //새로띄울 화면의 넓이
	var h		= 317; //새로띄울 화면의 높이
	var what	= form + "/" + zip + "/" + addr + "/" + code;
	winToTop	= (screen.height) ? (screen.height-h)/2 : 0;
	winToLeft	= (screen.width) ? (screen.width-w)/2 : 0;
	var settings	='toolbar=0,directories=0,status=no,menubar=0,scrollbars=no,resizable=no,height='+h+',width='+w+',left='+winToLeft+',top='+winToTop+'';
	winObject	= window.open("/immovable/popup/post.php?what="+what+"&area="+area, "post", settings);
}

function paging(frm, pgnum){
	frm.pgnum.value = pgnum;
	frm.submit();
}

function inputDate(str1, str2, sdate, edate) {
	today		= new Date();
	now_year	= today.getFullYear();
	now_month	= today.getMonth()+1;
	now_day		= today.getDate();

	month_temp	= now_month-1;
	switch(month_temp) {
		case(1):	day_temp = 31; break;
		case(2):	day_temp = 28; break;
		case(3):	day_temp = 31; break;
		case(4):	day_temp = 30; break;
		case(5):	day_temp = 31; break;
		case(6):	day_temp = 30; break;
		case(7):	day_temp = 31; break;
		case(8):	day_temp = 31; break;
		case(9):	day_temp = 30; break;
		case(10):	day_temp = 31; break;
		case(11):	day_temp = 30; break;
		case(12):	day_temp = 31; break;
		default:	day_temp = 31; break;
	}

	Day		= now_day;
	Mon		= now_month;
	theYear		= now_year;

	if(str1 == 'd') {
		opt_day	= now_day-str2;
		if(opt_day>0) {
			Day	= opt_day;
		} else {
			opt_month	= now_month-1;
			Day		= day_temp+opt_day;
			if(opt_month>0) {
				Mon	= opt_month;
			} else {
				theYear	= now_year-1;
				Mon	= 12;
			}
		}
	} else if(str1 == 'm') {
		opt_month	= now_month-str2;
		if(opt_month>0) {
			Mon	= opt_month;
		} else {
			theYear	= now_year-1;
			Mon	= 12+opt_month;
		}
	} else if(str1 == 'y') {
		theYear	= now_year-str2;
	}

	if(Mon<10) {
		Mon='0'+Mon;
	}
	if(Day<10) {
		Day='0'+Day;
	}
	the_date	= theYear+'-'+Mon+'-'+Day;
	sdate.value	= the_date;

	if(now_month<10) {
		now_month	= '0'+now_month;
	}
	if(now_day<10) {
		now_day		= '0'+now_day;
	}
	now_date	= now_year+'-'+now_month+'-'+now_day;
	edate.value	= now_date;

	if(str1=='w') {
		sdate.value='';
		edate.value='';
	}
}

function imagereSize(image, reSizeWrite, reSizeHeight){
	//var image = event.srcElement;
	var tmpWidth = image.tmpWidth ? image.tmpWidth : image.width;
	var tmpHeight = image.tmpHeight ? image.tmpHeight : image.height;
	if(tmpWidth > reSizeWrite){
		tmpHeight	= tmpHeight * (reSizeWrite / tmpWidth);
		if(tmpHeight > reSizeHeight){
			image.width	= reSizeWrite * (reSizeHeight / tmpHeight);
			image.height	= reSizeHeight;
		}else{
			image.width	= reSizeWrite;
			image.height	= tmpHeight;
		}
	}else
	if(tmpHeight > reSizeHeight){
		tmpWidth	= reSizeWrite * (reSizeHeight / image.height);
		if(tmpWidth > reSizeHeight){
			image.height	= reSizeHeight * (reSizeWrite / tmpWidth);
			image.width	= reSizeWrite;
		}else{
			image.height	= reSizeHeight;
			image.width	= tmpWrite;
		}
	}
	image.style.display	= "";
}

function imageLoadError(image){
	//var image = event.srcElement;
	image.style.display='none';
}

function view(image){
	var opt	= "";
	var src	= image.src;
	var tmpWidth = image.tmpWidth ? image.tmpWidth : 0;
	var tmpHeight = image.tmpHeight ? image.tmpHeight : 0;
	if(!tmpWidth || !tmpHeight){
		var image = new Image();
		image.src = src;
		tmpWidth = image.width;
		tmpHeight = image.height;
	}

	if(tmpWidth > 0 && tmpHeight > 0){
		opt	= "width="+tmpWidth+", height="+tmpHeight;
	}
	var win = window.open("about:blank", "blank", opt);
	win.document.open();
	win.document.writeln("<html>");
	win.document.writeln("<head><title>이미지 상세보기</title></head>");
	win.document.writeln("<body topmargin=0 leftmargin=0>");
	win.document.write("<img src=\"");
	win.document.write(src);
	win.document.writeln("\" border=0 onClick='self.close();'>");
	win.document.writeln("</body>");
	win.document.writeln("</html>");
	win.document.close();
}

function textMaxLength(field, maxlength){
	if(field.value.length > maxlength){
		field.value = field.value.substring(0, maxlength);
	}
}

function jsFlash(file_path, width, height){
	document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\""+width+"\" height=\""+height+"\">");
	document.write("<param name=\"movie\" value=\""+file_path+"\">");
	document.write("<param name=\"quality\" value=\"high\">");
	document.write("<param name=\"wmode\" value=\"transparent\">");
	document.write("<embed src=\""+file_path+"\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\""+width+"\" height=\""+height+"\">");
	document.write("</embed>");
	document.write("</object>");
}

function interForm(){
	var win	= window.open("/immovable/enterprise/member.php", "join", "width=726, height=592, status=yes, scrollbars=yes");
	win.focus();
}


/* 지도 서비스 */
function miniMap(address, x, y){
	var width	= 211;
	var height	= 138;
	resizeMap(address, x, y, width, height)
}

function largeMap(address, x, y){
	var width	= 730;
	var height	= 400;
	resizeMap(address, x, y, width, height)
}

/*   
function resizeMap(address, x, y, width, height){
	var mapUrl	= "http://lbcmap.com/loveseoul/map/image_map.asp";
	var src		= "";
	if(x && y){
		src	= mapUrl+"?w="+width+"&h="+height+"&x="+x+"&y="+y;
	}else
	if(address){
		src	= mapUrl+"?w="+width+"&h="+height+"&address="+encodeURI(address);
	}

	var iframeHtml	= "<iframe src='"+src+"' width='"+width+"' height='"+height+"' frameborder=0 scrolling='no'></iframe>";
	document.writeln(iframeHtml);
}

function map(idx, address){
	var win	= window.open("/immovable/popup/map.php?idx=" + idx + "&address=" + encodeURI(address), "map", "width=810, height=514");
	win.focus();
}


function lbcmap(address, x, y, domain){
	//var mapUrl	= "http://lbcmap.com/loveseoul/map/realty_onsale.asp?";
	var mapUrl	= "http://map.loveseoul.kr/map/index.php?code=land&";
	var mapWindow	= null;
	mapUrl		= mapUrl+"address="+encodeURI(address)+"&x="+x+"&y="+y+"&domain="+domain;
	mapWindow	= window.open(mapUrl, "lbcmap", "");
	mapWindow.focus();
}

*/

///  네이버 API지도 변경

function resizeMap(address, x, y, width, height){
//	var mapUrl	= "http://lbcmap.com/loveseoul/map/image_map.asp";
    var mapUrl      = "http://www.loveseoul.kr/map/n_map_site.php";

	var src		= "";
	if(x && y){
		src	= mapUrl+"?w="+width+"&h="+height+"&x="+x+"&y="+y;
	}else
	if(address){
//		src	= mapUrl+"?w="+width+"&h="+height+"&address="+encodeURI(address);
		src	= mapUrl+"?w="+width+"&h="+height+"&query="+address;
	}

	var iframeHtml	= "<iframe src='"+src+"' width='"+width+"' height='"+height+"' frameborder=0 scrolling='no'></iframe>";
	document.writeln(iframeHtml);

}


function map(idx, address){
//	var win	= window.open("/immovable/popup/map.php?idx=" + idx + "&address=" + encodeURI(address), "map", "width=810, height=514");
	var win	= window.open("/immovable/popup/map.php?w=810&h=514&idx=" + idx + "&address=" + address, "map", "width=810, height=514");
	win.focus();
}

function lbcmap(address, idx){
	var win	= window.open("http://www.loveseoul.kr/map/immovable.php?idx=" + idx + "&address=" + address, "map");
	win.focus();
}

/*   2010.1.6
function lbcmap(address, x, y, domain){
	//var mapUrl	= "http://lbcmap.com/loveseoul/map/realty_onsale.asp?";
	var mapUrl	= "http://map.loveseoul.kr/map/index.php?code=land&";
	var mapWindow	= null;
	mapUrl		= mapUrl+"address="+encodeURI(address)+"&x="+x+"&y="+y+"&domain="+domain;
	mapWindow	= window.open(mapUrl, "lbcmap", "");
	mapWindow.focus();
}
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////

/* 지도 서비스 */

function immovableSearch(frm){
	if(frm.unity_search.value == ""){
		alert("검색할 검색어를 입력해 주세요.");
		frm.unity_search.focus();
		return false;
	}
}

function mInsert(){
	var winObject	= null;
	var w		= 300; //새로띄울 화면의 넓이
	var h		= 410; //새로띄울 화면의 높이
	var settings	='toolbar=0,directories=0,status=no,menubar=0,scrollbars=no,resizable=no,height='+h+',width='+w;
	winObject	= window.open("/immovable/popup/kria.php", "inst", settings);
	self.close();
}

function msgView(contentsId){
	var layer	= document.getElementById(contentsId);
	var tempIFrame  = document.createElement('iframe');
	tempIFrame.style.border	= '0px';
	tempIFrame.style.width	= '100%';
	tempIFrame.style.height	= '100px';
	tempIFrame.scrolling	= 'no';
	tempIFrame.frameBorder	= '0';
	layer.parentNode.appendChild(tempIFrame);

	tempIFrame.contentWindow.document.open();
	tempIFrame.contentWindow.document.writeln("<html>");
	tempIFrame.contentWindow.document.writeln("<link href='/immovable/css/text.css' rel='stylesheet' type='text/css'>");
	tempIFrame.contentWindow.document.writeln("<body topmargin=0 leftmargin=0>");
	tempIFrame.contentWindow.document.writeln(layer.innerHTML);
	tempIFrame.contentWindow.document.writeln("</body>");
	tempIFrame.contentWindow.document.writeln("</html>");
	tempIFrame.contentWindow.document.close();
	tempIFrame.contentWindow.onload = function(){
		tempIFrame.style.height = tempIFrame.contentWindow.document.body.scrollHeight;
	}
}

