function setPng24(obj) {
    obj.width=obj.height=1;
    obj.className=obj.className.replace(/\bpng24\b/i,'');
    obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');";
    obj.src='';
    return '';
}

function inserKeyWord(tempSS) { //¸ðÆú·ÎÁö ¸®½ºÆ® °Ë»ö

    var compStr ="";
    //°ø¹é¹®ÀÚ Á¦°Å
    for(i=0;i<tempSS.length; i++){
        if(' ' != tempSS.charAt(i)){
            compStr = compStr+tempSS.charAt(i);
        }
    }
    //°ø¹é¹®ÀÚ Á¦°Å ¿Ï·á

    document.getElementById('textfieldK').value  = compStr;
    document.getElementById('keywordTemp').value = compStr;
    jQuery('#key1SearchBt').click();
}

function selectDefualt(){ //Selectbox ÃÊ±âÈ­
    //alert('selectDefualt');
    document.getElementById("city").options[0].selected= true;
    document.getElementById("district").options[0].selected= true;
    document.getElementById("dong").options[0].selected= true;
    document.getElementById('textfieldA').value="";
}

function displayMapForMain(num) {
    mapFrame.displayMap(num);
}
function setMode(num) {
    mapFrame.setMode(num);
}

function viewDetailMopoResult(mopoName) {

    if(jQuery('#key2').css('display') != 'none') {
        if(jQuery('#city').val() == '') {
            var citySave = jQuery('#citySave').html();
            var pos = citySave.indexOf(',');
            citySave = citySave.substring(0,pos);
            jQuery('#city').val(addressStandard(citySave));
        }
        jQuery('#textfieldKTemp').val(jQuery('#city').val());
        jQuery('#textfieldK').val('');
        jQuery('#district').val('');
        jQuery('#dong').val('');
        jQuery('#textfieldA').val(mopoName);

        callMethod();
        //jQuery('#key2SearchBt').click();
    } else {                //key1
        jQuery('#textfieldKTemp').val(jQuery('#textfieldK').val());
        jQuery('#gangnam').val(jQuery('#textfieldK').val());

        jQuery('#textfieldK').val('');
        jQuery('#key1').hide();
        jQuery('#key2').show();

        //½Ã/µµ ÀÚµ¿ ¼±ÅÃ ÈÄ ±¸ ¸®½ºÆ®¸¦ °»½Å
        jQuery('#city').val(addressStandard(jQuery('#textfieldKTemp').val()));
        getAddressSelect('city',callMethod);

        jQuery('#district').val('');
        jQuery('#dong').val('');
        jQuery('#textfieldA').val(mopoName);
    }
}
/*function callMethod() {
    jQuery('#key2SearchBt').click();
}*/
function callMethod() {
        var paramsArray = {
        'city':  jQuery('#city').val(),
        'district' : '',
        'dong' : '',
        'searchKeyWord': encodeURIComponent(jQuery('#textfieldA').val()),
        'xcode': jQuery('#initXcodeValue').val(),
        'ycode': jQuery('#initYcodeValue').val(),
        'mopologyFlag' : '1'
        };
    //alert(paramsArray.mopologyFlag);
        //console.log(paramsArray);
        jQuery('#pagingKeyword').val(jQuery('#textfieldA').val());
        searchAct(1,paramsArray,0);
}

function levelBox_right() {
    jQuery('#levelBox_right').find('a:first').click(function(){

        var curlevel = Math.floor(jQuery('#levelboxJS').slider('option','value')/9) + 1;
        var sliderPercent = ((curlevel)*9);
        if(sliderPercent < 100 && sliderPercent > 0) {
            setMode(1);

            jQuery('#forDebugArea').html(sliderPercent);
            //displayMap
            jQuery('#levelboxJS').slider('value',sliderPercent);

            var val = 12- (Math.floor(jQuery('#levelboxJS').slider('value')/9)) ;
            if(val > 5) {
                val = 5;
            }
            displayOnly(val);
        }
    });
    jQuery('#levelBox_right').find('a:last').click(function(){
        var curlevel = Math.floor(jQuery('#levelboxJS').slider('option','value')/9) + 1;
        var sliderPercent = ((curlevel-2)*9);
        if(sliderPercent < 100 && sliderPercent >= 0) {
            setMode(2);

            jQuery('#forDebugArea').html(sliderPercent);

            jQuery('#levelboxJS').slider('value',sliderPercent);

            var val = 12- Math.floor(((jQuery('#levelboxJS').slider('value'))/9));
            if(val > 5) {
                val = 5;
            }
            displayOnly(val);
        }
    });
}

function keywordCheck(strKeyword){
    var keyString = [ 
        "¼­¿ï", "¼­¿ï½Ã", "¼­¿ïÆ¯º°½Ã",
        "ºÎ»ê", "ºÎ»ê½Ã", "ºÎ»ê±¤¿ª½Ã",
        "ÀÎÃµ", "ÀÎÃµ½Ã", "ÀÎÃµ±¤¿ª½Ã",
        "´ë±¸", "´ë±¸½Ã", "´ë±¸±¤¿ª½Ã",
        "´ëÀü", "´ëÀü½Ã", "´ëÀü±¤¿ª½Ã",
        "±¤ÁÖ", "±¤ÁÖ½Ã", "±¤ÁÖ±¤¿ª½Ã",
        "¿ï»ê", "¿ï»ê½Ã", "¿ï»ê±¤¿ª½Ã",
        "°æ±â", "°æ±âµµ",
        "°æºÏ", "°æ»óºÏµµ",
        "°æ³²", "°æ»ó³²µµ",
        "ÀüºÏ", "Àü¶óºÏµµ",
        "Àü³²", "Àü¶ó³²µµ",
        "ÃæºÏ", "ÃæÃ»ºÏµµ",
        "Ãæ³²", "ÃæÃ»³²µµ",
        "°­¿ø", "°­¿øµµ",
        "Á¦ÁÖ", "Á¦ÁÖµµ",
        "°­³²"];
    var result = jQuery.inArray(strKeyword, keyString);
    //alert(result);
    //alert('kor:javascript representative search_keyword');
    if (result == "-1"){
        return false;
    } else {
        return true;
    }
}

function backToTheme() {

    if(jQuery('#gangnam').val() == '°­³²') {
        jQuery('#textfieldK').val(jQuery('#gangnam').val());
        viewtab(2);
        jQuery('#gangnam').val('');
        jQuery('#key1SearchBt').click();
    } else {
        jQuery('#textfieldA').val('');
        jQuery('#key2SearchBt').click();
    }
}

function searchResult1(html,totalCount, searchResultMsgValue) {
	
    var first = jQuery("#first").val();
	var mapType = jQuery('#mapType').val();
    html += '<div class="listtop">';

    html += '	<div class="box2">';
    if (first == "N") {
        html += '<div class="tit2"><img src="../images/icon_03.gif" alt=""   /> <span class="b1"></span> <a id="searchResultMsg" style="color:gray">';
        if(searchResultMsgValue == '1') {
            html += ' &nbsp;&nbsp;<a href="#none" onclick=\'backToTheme();\'><img name="themeRe" src="../images/tema_re.gif" align="absbottom" alt=""  /></a>';
        } else {
            html += ' &nbsp;°Ë»ö°á°ú';
        }
        html += '</a> </div>';
    } else {
        // ÃÖÃÊ ·Îµù ½Ã °Ë»ö »ó´Ü (Áö¿ò)
        html += '<div class="tit2"></div>';
    }
    html += '		<div class="ico"><img src="../images/wi_fi_ico.gif"  alt="" /></div><div class="tit"> ³» ÁÖº¯ ' +
            '<span class="b1">olleh WiFi zone ÃÑ</span> <span id="searchTotalCount" class="b2">'+totalCount+'°³</span></div>';
    html += '		<div class="menu">';
    html += '			<div class="m1"><a href="#" onclick="initSearch(); return false;" ><img src="../images/wifizone_view.gif"  alt="" /></a></div>';
    html += '			<div class="m2"><img src="../images/ico_check_over.gif"  alt=""  /> °¡±î¿î °Å¸®¼ø</div>';
    html += '		</div>';
    html += '	</div>';
    html += '</div>';
    if(mapType == "ilban"){
    	html += '<div class="listcon4" >';
    } else {
    	html += '<div class="listcon" >';
    }
    html += '<ul id="conthiUl">' +
            '</ul>' +
            '</div>';

    if(mopolKeyword(jQuery('#textfieldA').val())) {
        html = html.replace("³» ÁÖº¯","");
    }

    return html;
}

function mopolKeyword(data) {
    var list = [
                 "±¹°¡±â°ü"
				,"°ü°ø¼­"
				,"±³À°"
				,"±ÝÀ¶"
				,"¹®È­"
				,"¼îÇÎ"
				,"¼÷¹Ú"
				,"¿Ü½Ä/Ä«Æä"
				,"¿î¼Û(°íÁ¤)"
				,"¿î¼Û(ÀÌµ¿)"
				,"ÀÇ·á"
				,"Á¾±³"
				,"¿Á¿Ü"
				,"»ýÈ°"
				];

    for(var i=0;i<list.length;i++) {
        list[i] = data;
        return true;
    }
    
    return false;
    
}

function textAreaLengthCheck(val, maxLengthByte) {
	
	//alert("val : [" + val + "]");
	
    var tempByteLength = 0, cutByteLength = 0;
    for(var i = 0; i < val.length; i++) {
        if(escape(val.charAt(i)).length > 4) {
            tempByteLength += 2;
        } else {
            tempByteLength++;
        }

        if(tempByteLength < maxLengthByte) {
            cutByteLength++;
        }
    }
    //alert(tempByteLength);
    if(tempByteLength > maxLengthByte) {
        //val = val.substring(0, (cutByteLength%2==1)?cutByteLength:cutByteLength+1) + '..';
        val = val.substring(0, val.length-5) + '...';
    }
    return val;
}

function noResultSearch(html) {
    html += '<div class="listcon3">';
    html += '    <div class="ntit">';
    html += '    <span class="red"></span>¿¡ ´ëÇÑ °Ë»ö°á°ú°¡ ¾ø½À´Ï´Ù.';
    html += '    </div>';
    html += '    <div class="scon">';
    html += '    <p>';
    html += '    - ´Ü¾î°¡ Á¤È®ÇÑÁö È®ÀÎÇØÁÖ¼¼¿ä.';
    html += '    </p>';
    html += '    <p>';
    html += '    - ¹Ý°æ¼³Á¤À» º¯°æÇØ¼­ ´Ù½Ã °Ë»öÇØÁÖ¼¼¿ä.';
    html += '    </p>';
    html += '    <p>';
    html += '    &nbsp;&nbsp;<a onclick="initSearch(); return false;" href="/index.action"><img alt="" src="../images/wifizone_view.gif" complete="complete"/></a>';
    html += '    </p>';
    /*html += '    <p>';
    html += '    - °Ë»öÇÏ½Å ´Ü¾î°¡ ¿ÍÀÌÆÄÀÌ °¡´ÉÇÑ Àå¼ÒÀÎµ¥<br/>';
    html += '      <span class="tex"> Á¸Ã£±â ¼­ºñ½º¿¡ ¹Ý¿µµÇÁö ¾ÊÀº °÷ÀÌ ÀÖ´Ù¸é</span><br/>';
    html += '       <span class="tex">¾Ë·ÁÁÖ¼¼¿ä.</span>';
    html += '       </p>';*/
    html += '       </div>';
    /*html += '    <div class="request"><a href="#none"><img src="../images/ico_request.gif"   alt="" /></div>';*/
    html += '</div>';
    return html;
}

function searchAct(pageNo, paramsArray, isAuto) {
	
	//isAuto ===    1 (auto) or 0
    //ÇöÀç Map ·¹º§ °¡Á®¿È
    var curMapLevel = Math.floor(jQuery('#levelboxJS').slider("option", "value")/9) + 1;

    var tempKeyword = jQuery("#textfieldK").val();    
    if( tempKeyword == "" )    	
    	tempKeyword = jQuery('#city').val();

    if( keywordCheck( tempKeyword ) ) {

    	//1. Å°¿öµå °Ë»öÀÎ °æ¿ì °Ë»ö¾î°¡ Æ¯¼ö¾îÀÎ °æ¿ì
    	//2. ÁÖ¼Ò°Ë»ö½Ã "½Ã/µµ" ¸¸ ¼±ÅÃÇÏ°í ¾Æ¹«°Íµµ ¼±ÅÃ/ÀÔ·Â ¾ÈµÈ °æ¿ì´Â
    	//°Ë»ö ÈÄ ¿ìÃøÀÇ Áöµµ ½½¶óÀÌ´õ ·¹º§ÀÌ º¯µ¿µÇ¸é ¾ÈµÈ´Ù.
    	//alert("Æ¯¼ö¾î [" + tempKeyword + "] ½½¶óÀÌ´õ °íÁ¤!!");
    	
    } else {
    	
    	if(curMapLevel < mapFrame.Constant.boundUnderLevel) {
    		
        	jQuery('#levelboxJS').slider('value',81);
            mapFrame.mapObj.setZoomLevel(curMapLevel);
            mapFrame.curMapLevel = curMapLevel = 10;        
            
        }
    	
    }    
    
    //alert(tempKeyword);
	
    if(jQuery('#key1').css("display") != 'none' && document.getElementById('textfieldK').value=='' && isAuto=='0' && jQuery('#first').val() == 'N') {
        
    	autoSearchAddressSearch(1,jQuery('#initCityValue').val(),jQuery('#initDistrictValue').val(),jQuery('#initDongValue').val());
    
    } else {
    	
        if(isAuto == '0') {
            jQuery('#first').val('N');
        }
        
        var html = '';        
        paramsArray['curMapLevel'] = curMapLevel;
        paramsArray['currPage'] = pageNo;
        paramsArray['pageUnit'] = 5;
        
        // ÀüÃ¼ ¸ÊÀÇ °æ¿ì  7°³ Ãâ·Â
        var mapType = jQuery('#mapType').val();
        if (mapType == "ilban"){
            paramsArray['listUnit'] = 4;
        } else {
            paramsArray['listUnit'] = 7;
        }

        //console.log(paramsArray);

        var URL        = '/addressSearchList.action';
        var strKeyword = jQuery("#textfieldK").val();

        var recursiveDecoded = decodeURIComponent(jQuery.param(paramsArray));
        jQuery('#forDebugArea').html('http://211.62.41.187'+URL+"?"+recursiveDecoded);
        //alert(paramsArray.mopologyFlag);

        jQuery.post(URL, paramsArray, function(resultSet) {

        	var clickedItem = 0;
        	
            if(resultSet.searchList.length == 0) {
                
            	html = noResultSearch(html);
            	
                jQuery('#conthi').html(html);
                jQuery('#conthi').find('a:last').click(function() {
                    mistakeshow('e_mail_inquire', '3');
                });
                if(jQuery('#key1').css("display") != 'none') {
                    jQuery('#conthi').find('span:first').html(jQuery('#textfieldK').val());
                } else {
                    jQuery('#conthi').find('span:first').html(jQuery('#textfieldA').val());
                }
                
            } else {
                
            	// ¸ðÆú·ÎÁö °Ë»ö °á°ú ¸®½º Æ® Ãâ·Â!!
                if (keywordCheck(strKeyword)== true || (jQuery('#city').val() != '' && jQuery('#district').val() == '' && jQuery('#dong').val() =='' && (jQuery('#key2').css("display") != 'none') && jQuery('#textfieldA').val() == '')) {
                    if(jQuery('#key2').css("display") != 'none') {
                        if (jQuery('#city').val() != '')
                        	strKeyword = jQuery('#city').val();
                    }
                    html += '<div class="listtop">';                                                                                    //¹®¼ºÁø
                    html += '<div class="box2">';
                    html += '<div class="tit2"><img src="../images/icon_03.gif" alt="" /> <span id="citySave" class="b1">'+textAreaLengthCheck(strKeyword)+' <a style="font-weight:normal">°Ë»ö°á°ú</a></span>';
                    //
                    html += '</div>';
                    html += '<div style="clear:both;">';
                    html += '<div class="ico"><img src="../images/wi_fi_ico.gif" alt="" /></div><div class="tit"> <span class="b1">olleh WiFi ZONE ÃÑ</span> <span class="b2">'+resultSet.TotalCount+' °³</span></div>';
                    html += '</div>';
                    html += '<div class="menu">';
                    html += '<div class="m1"><a href="#" onclick="initSearch(); return false;" ><img src="../images/wifizone_view.gif"  alt="" /></a></div>';
                    html += '<div class="m2"><img src="../images/ico_check_over.gif"  alt=""  /> °¡±î¿î °Å¸®¼ø</div>';
                    html += '</div>';
                    html += '</div>';
                    html += '</div>';
                    html += '<div class="listcon2" >';
                    html += '<ul>';
                    //
                    jQuery.each(resultSet.searchList,function(i,data){
                        html += '<li>';
                        html += '<div class="tit">';
                        html += "<a href='#none' class='rollover' onclick='viewDetailMopoResult(\"" + (data.mopo == "½ºÆ®¸®Æ®" ? "Street" : data.mopo) + "\");'>";
                        html += '<img src="../images/wi_fi2_ico.gif"  align="absmiddle" alt="" />';
                        html += '<img src="../images/wi_fi2_over_ico.gif" align="absmiddle" alt="" class="over"/>'+data.mopo+'</span>';
                        html += '<span class="number">'+data.mopology_num+'</span></a>';
                        html += '</div>';
                        html += '</li>';
                        //¸ðÆú·ÎÁö ÇüÅÂ °Ë»ö °á°ú
                    });
                    jQuery('#conthi').html(html);
                    
                } else{

                    if(jQuery('#textfieldKTemp').val() == '')  {
                        html = searchResult1(html,resultSet.TotalCount,'0');
                    } else {
                        html = searchResult1(html,resultSet.TotalCount,'1');
                        jQuery('#textfieldKTemp').val('');
                    }
                    jQuery('#conthi').html(html);

                    //°Ë»ö °á°ú Ãâ·Â !!!
                    //jQuery('#conthi').append('<div class="listcon"><ul>');                    
                    jQuery.each(resultSet.searchList,function(i,data){
                        html = '';
                        //if (mapType == "ilban"){                        
                        if(i < resultSet.searchList.length) {
                            if (i > resultSet.searchList.length-2) {
                                html += '<li class="end">';
                            } else {
                                html += '<li>';
                            }                            
                       
                            html += '<div class="tit">';
                            //
                            //±âÁ¸ ¼Ò½º¸¦ ¾Æ·¡ 3ÁÙ·Î ±³Ã¼ : 2011-04-15
                            //html += '<a href="#none" class="rollover">';
                            //html += '<img src="../images/wi_fi2_ico.gif"       align="absmiddle" alt=""             />';
                            //html += '<img src="../images/wi_fi2_over_ico.gif"  align="absmiddle" alt="" class="over"/>'+textAreaLengthCheck(data.zone_name_tr,36)+'</a></div>';
                            //html += '<div class="add">'+textAreaLengthCheck(data.address_tr,76)+'</div>';
                            //
                            html += '<a href="#none" name="atit">';                            
                            html += '<img src="../images/wi_fi2_ico.gif"  align="absmiddle" alt="" />'+textAreaLengthCheck(data.zone_name_tr,36)+'</a></div>';
                            html += '<div class="add">'+textAreaLengthCheck(data.address_tr,76)+'</div>';
                            //
                            html += '<div class="km">'+data.distance+'m </div>';
                            html += '<div class="ico">';
                            if(data.zone_flag == '2' || data.zone_flag == '3') {
                                html += '<a href="#none"><img src="../images/ico_finger.gif"  alt="" /></a>';
                            }
                            if(data.zone_flag == '1' || data.zone_flag == '3') {
                                html += '&nbsp;<a href="#none"><img src="../images/ico_star.gif"  alt="" /></a>';
                            }
                            if(data.homepage != '-' && data.homepage != '' && data.homepage != 'null') {
                                html += '&nbsp;<a href="#none"><img name="homepageImg" src="../images/ico_homepage.gif"  alt="" /></a>';
                            }
                            if(data.tour_journal != '-' && data.tour_journal != '' && data.tour_journal != 'null') {
                                html += '&nbsp;<a href="#none"><img src="../images/ico_visit.gif"  alt="" onclick="goTour(\'' + data.tour_journal + '\')" /></a>';
                            }
                            html += '</div>';
                            html += '</li>';
                            
                            jQuery('#conthiUl').append(html);
                            
                            //jQuery('#conthi').find('li:last').find('a:first').click(function() {
                            //    mapFrame.moving(data.xcode,data.ycode,data.zone_id);                                                              
                            //});
                            
                            // hover µî·Ï : 2011-04-15 Ãß°¡
                            //
                            jQuery('#conthi a[name=atit]').each(function(){
                            	
                            	jQuery(this).hover(
                            		//On hover over                                    		 
                            		function() {                                    		
                            			
                            			jQuery(this).find('img').attr("src","/images/wi_fi2_over_ico.gif");
                            			jQuery(this).css("color","#b10101");
                            			
                            		//On hover Out	
                            	}, 	function(){
                            			
                            			if( jQuery(this).attr("value") != "selected" ) {
                            				
                            				jQuery(this).find('img').attr("src","/images/wi_fi2_ico.gif");
                            				jQuery(this).css("color","#333333");
                            				
                            			}
                            		
                            	});
                            	
                            });
                            //
                            jQuery('#conthi').find('li:last').find('a:first').click(function() {
                            	
                            	// ÀüÃ¼ ÃÊ±âÈ­
                            	jQuery('#conthi a[name=atit]').each(function(){
                            		
                            		jQuery(this).attr("value", "");
                            		jQuery(this).find('img').attr("src","/images/wi_fi2_ico.gif");
                            		jQuery(this).css("color","#333333");
                            		
                            	});
                            	
                            	// ¼±ÅÃµÈ °ª Ç¥½Ã
                            	jQuery(this).attr("value", "selected");
                            	jQuery(this).find('img').attr("src","/images/wi_fi2_over_ico.gif");
                            	jQuery(this).css("color","#b10101");
                            	
                            	mapFrame.moving(data.xcode, data.ycode, data.zone_id);
                            	
                            });
                            //
                            // hover µî·Ï : 2011-04-15 Ãß°¡
                            
                            jQuery('#conthi').find('li:last').find("img[name='homepageImg']").click(function() {
                                window.open(data.homepage,'','');
                            });
                        }
                    });

                    //jQuery('#conthiUI').find('li:last').addClass("end");
                    //jQuery('#conthi').append('</ul></div>'); 

                    if(isAuto == '1') {  
                    	
                    	// ÃÖÃÊ ·Îµù ½Ã¿¡´Â olleh wifi zone ±ÛÀÚ¸¦ Áö¿î´Ù.
                        //jQuery('#conthi').find('span:first').html(' ' + jQuery('#initDongValue').val());
                        var a = jQuery('#conthi').find('div[class="tit"]:first').html();
                            a = a.replace("³» ÁÖº¯", '');
                            
                        jQuery('#conthi').find('div[class="tit"]:first').html(a);
                        
                    } else {
                        
                    	if(jQuery('#key1').css("display") != 'none') {
                    		
                        	//2012-01-31 °Ë»ö¾î°¡ ±æ°æ¿ì ¸»ÁÙÀÓ Ã³¸®
                    		var tKeyword = jQuery('#textfieldK').val();
                    		if(tKeyword.length > 13)
                    			tKeyword = tKeyword.substring(0, 13) + "..";
                    		
                    		jQuery('#conthi').find('span:first').html(' ' + tKeyword);
                            var a = jQuery('#conthi').find('div[class="tit"]:first').html();
                                a = a.replace("³» ÁÖº¯", '');
                            jQuery('#conthi').find('div[class="tit"]:first').html(a);
                            
                        } else {
                            
                        	var localValue = jQuery('#city').val() + ' ' + jQuery('#district').val() + ' ' + jQuery('#dong').val();
                            if(localValue.length >= 15) {
                                localValue = localValue.substring(0,15) + '.. ';
                            }
                            
                        	//2012-01-31 °Ë»ö¾î°¡ ±æ°æ¿ì ¸»ÁÙÀÓ Ã³¸®
                    		var aKeyword = jQuery('#textfieldA').val();
                    		if(aKeyword.length > 13)
                    			aKeyword = aKeyword.substring(0, 13) + "..";
                    		
                            //jQuery('#conthi').find('span:first').html('<a style="font-weight:bold">'+ localValue + '</a> ' + aKeyword);
                    		jQuery('#conthi').find('span:first').html(' ' + aKeyword);
                        
                        }
                    
                    }
                    
                    jQuery('#conthi').append(genPaging(resultSet.TotalCount,pageNo));

                    // °Ë»ö °á°ú Áöµµ¿¡ Àü´Þ.
                    try {
                    	
                        mapFrame.searchResultData = resultSet.searchList;
                        
                        var first = document.getElementById('first').value;
                        if(first == 'N') {
                        	
                        	//°Ë»ö ÈÄ ÃÖÃÊ·Î º¸¿©ÁÙ »ó¼¼ ·¹ÀÌ¾î
                            mapFrame.curCmd = 0;
                            mapFrame.initSearchData(resultSet.mapDataList);
                            
                        }
                        
                    } catch(e) {
                    	
                        //alert(e);
                    	
                    }
                    
                }
                
            }
            
        },'json');
        
    }
    
}

function bindKeySearchBt(){

	//°Ë»ö ¹öÆ° Å¬¸¯½Ã ÀÌº¥Æ® Ã³¸®
    jQuery('#key1SearchBt').click(function(){
        /*        var URL = '&'+escape(encodeURIComponent('searchKeyWord'))+'='+escape(encodeURIComponent(jQuery('#textfieldK').val()));
         URL = URL+'&xcode='+jQuery('#initXcodeValue').val()+'&ycode='+jQuery('#initYcodeValue').val();
         URL = URL+'&r=613';
         */
        var paramsArray = {
            'searchKeyWord': encodeURIComponent(jQuery('#textfieldK').val()),
            'xcode': jQuery('#initXcodeValue').val(),
            'ycode': jQuery('#initYcodeValue').val()
        };
        //console.log(paramsArray);
        jQuery('#pagingKeyword').val(jQuery('#textfieldK').val());
        
        jQuery('#searchListK').empty();
        jQuery('#searchListK').css("display","none");
        
        searchAct(1,paramsArray,0);
    });

    jQuery('#key2').find('a:last').click(function(){
        if(document.getElementById('textfieldA').value==''&& document.getElementById('city').value==''&&document.getElementById('district').value==''&&document.getElementById('dong').value=='') {
            alert('Áö¿ªÀ» ¼±ÅÃÇØ ÁÖ¼¼¿ä');
        } else {
            jQuery('#pagingKeyword').val(jQuery('#textfieldA').val());
            
            jQuery('#searchListA').empty();
            jQuery('#searchListA').css("display","none");
            
            addressSearch(1);
        }
    });
}

function addressSearch(pageNo) {
    /*    var URL = '&'+escape(encodeURIComponent('city'))+'='+escape(encodeURIComponent(document.getElementById('city').value));
     URL = URL+'&'+escape(encodeURIComponent('district'))+'='+ escape(encodeURIComponent(document.getElementById('district').value));
     URL = URL+'&'+escape(encodeURIComponent('dong'))+'='+escape(encodeURIComponent(document.getElementById('dong').value));
     URL = URL+'&xcode='+jQuery('#initXcodeValue').val()+'&ycode='+jQuery('#initYcodeValue').val();
     URL = URL+'&'+escape(encodeURIComponent('searchKeyWord'))+'='+escape(encodeURIComponent(jQuery('#textfieldA').val()));
     */
    var paramsArray = new Array();
    paramsArray = {
        'city':encodeURIComponent(document.getElementById('city').value),
        'district' : encodeURIComponent(document.getElementById('district').value),
        'dong': encodeURIComponent(document.getElementById('dong').value),
        'searchKeyWord': encodeURIComponent(jQuery('#textfieldA').val()),
        'xcode': jQuery('#initXcodeValue').val(),
        'ycode': jQuery('#initYcodeValue').val()
    };

    searchAct(pageNo,paramsArray,0);
}

function replaceAutoDong(dong) {
    if(dong.indexOf('Á¦1') > -1) {
        dong = dong.replace('Á¦1','1');
    } else if(dong.indexOf('Á¦2') > -1) {
        dong = dong.replace('Á¦2','2');
    }
    return dong;
}

function enterKeyEvent(objId,btId){
    jQuery('#'+objId).bind('keydown',function(e){
        if(e.which == 13) {
        	if (btId == 'key1SearchBt') {
                jQuery('#searchListK').empty();
	    		jQuery('#searchListK').css({"display":"none"});
                jQuery('#key1').focus();
        	} else if (btId == 'key2SearchBt') {
                jQuery('#searchListA').empty();
	    		jQuery('#searchListA').css({"display":"none"});
                jQuery('#key2').focus();
        	} else { // logic error
        	}
            jQuery('#'+btId).click();
        }
    });
}

function autoSearchAddressSearch(pageNo,city,district,dong) {
    dong = replaceAutoDong(dong);
    var paramsArray = {
        'city':encodeURIComponent(jQuery('#initCityValue').val()),
        'district' : encodeURIComponent(jQuery('#initDistrictValue').val()),
        'dong': encodeURIComponent(jQuery('#initDongValue').val()),
        'first': encodeURIComponent('Y'),
        'xcode': jQuery('#initXcodeValue').val(),
        'ycode': jQuery('#initYcodeValue').val()
    };

    searchAct(pageNo,paramsArray,1);
    jQuery('#first').val('Y');
}

function genPaging(totalcnt,pageNo) {
    var wrapDiv = jQuery("<div class='paddingWrap'></div>");
    var innerHTML = paging(totalcnt,pageNo,5);
    jQuery(wrapDiv).html(innerHTML);
    jQuery('#conthi').append(wrapDiv);

}

function paging(allsize, pageNo, pageSize) {

    pageSize = 4;
    var pageListSize = 5;
    if(allsize.indexOf(',') > -1) {
        allsize = allsize.replace(',','');
    }
    var totalPage = Math.ceil(allsize/pageSize);

    var totalPageList = Math.ceil(totalPage/pageListSize);
    var pageList = Math.ceil(pageNo/pageListSize);
    if (pageList < 1)
        pageList = 1;
    if (pageList > totalPageList)
        pageList = totalPageList;
    var startPageList = (pageList - 1) * pageListSize + 1;
    var endPageList = startPageList + pageListSize - 1;

    if (startPageList < 1)
        startPageList = 1;
    if (endPageList > totalPage)
        endPageList = totalPage;
    if (endPageList < 1)
        endPageList = 1;
    var innerHTML = '';
    innerHTML += getPageItemLink((startPageList - 1), '<img src="/images/btn_prev.gif"  style="vertical-align:bottom;"  alt="ÀÌÀü" /> ', (startPageList > 1), '');
    for (var i = startPageList; i <= endPageList; i++) {
        innerHTML += getPageItemLink2(i, null, (pageNo != i), ((pageNo == i)? 'strong': ''),endPageList);
        if(i != endPageList) {
            innerHTML += " <img src='/images/paging_line.gif' style='vertical-align:bottom;'  alt=''  /> ";
        }
    }
    innerHTML += getPageItemLink((endPageList + 1),'<img src="/images/btn_next.gif" style="vertical-align:bottom;" alt="´ÙÀ½"/>',(endPageList < totalPage), '');
    return innerHTML;
}

function getPageItemLink2(pageNo, text, useLink, className,endPageList) {

    var result = '';
    if (useLink) {
    
    	result +=  '<a href="javascript:page_click(' + pageNo + ')">' +
                ((text != null && text != '')? text: pageNo) +
                '</a>';

    } else {
    	
        result += ' ' + pageNo;
        
    }
    
    return result;
    
}

function getPageItemLink(pageNo, text, useLink, className) {

	if (useLink) {
		
        return '<a href="javascript:page_click(' + pageNo + ')">' +
                ((text != null && text != '')? text: pageNo) +
                '</a>';
    } else {
    	
        return '';
        
    }
	
}

function page_click(cpage) {

    if(jQuery('#textfieldK').val() != jQuery('#pagingKeyword').val()) {
        jQuery('#textfieldK').val(jQuery('#pagingKeyword').val());
    }

    var URL = '';
    var paramsArray = new Array();
    
    if(jQuery('#first').val() == 'Y') {
    
    	paramsArray = {
            'city'     : encodeURIComponent(jQuery('#initCityValue').val()),
            'district' : encodeURIComponent(jQuery('#initDistrictValue').val()),
            'dong'     : encodeURIComponent(jQuery('#initDongValue').val()),
            'first'    : encodeURIComponent('Y'),
            'xcode'    : jQuery('#initXcodeValue').val(),
            'ycode'    : jQuery('#initYcodeValue').val()
        };

    	searchAct(cpage, paramsArray, 1);
    	
    } else if(jQuery('#key1').css("display") != 'none') {
        
    	paramsArray = {
            //'dong': encodeURIComponent(jQuery('#initDongValue').val()),
            //'first': encodeURIComponent('Y'),
            'searchKeyWord' : encodeURI(jQuery('#textfieldK').val()),
            'xcode'         : jQuery('#initXcodeValue').val(),
            'ycode'         : jQuery('#initYcodeValue').val()
        };

    	//console.log(paramsArray);
        searchAct(cpage, paramsArray, 0);
        
    } else {

    	// paging
        var searchWord = jQuery('#textfieldA').val();
        
        paramsArray = {
            'city'         : encodeURIComponent(document.getElementById('city').value),
            'district'     : encodeURIComponent(document.getElementById('district').value),
            'dong'         : encodeURIComponent(document.getElementById('dong').value),
            'searchKeyWord': encodeURIComponent(searchWord),
            'xcode'        : jQuery('#initXcodeValue').val(),
            'ycode'        : jQuery('#initYcodeValue').val()
        };
        
        searchAct(cpage, paramsArray, 0);
        
    }
    
}

function addressStandard(val) {
	
    if(val == "¼­¿ï" || val == "¼­¿ï½Ã" || val =="°­³²")  {
        val = "¼­¿ïÆ¯º°½Ã";
    } else if(val == "ºÎ»ê" || val == "ºÎ»ê½Ã") {
        val = "ºÎ»ê±¤¿ª½Ã";
    } else if(val == "ÀÎÃµ" || val == "ÀÎÃµ½Ã") {
        val = "ÀÎÃµ±¤¿ª½Ã";
    } else if(val == "´ë±¸" || val == "´ë±¸½Ã") {
        val = "´ë±¸±¤¿ª½Ã";
    } else if(val == "´ëÀü" || val == "´ëÀü½Ã") {
        val = "´ëÀü±¤¿ª½Ã";
    } else if(val =="±¤ÁÖ"  || val == "±¤ÁÖ½Ã") {
        val = "±¤ÁÖ±¤¿ª½Ã";
    } else if(val =="¿ï»ê" || val == "¿ï»ê½Ã") {
        val = "¿ï»ê±¤¿ª½Ã";
    } else if(val =="°æ±â") {
        val = "°æ±âµµ";
    } else if(val =="°æºÏ") {
        val = "°æ»óºÏµµ";
    } else if(val =="°æ³²") {
        val = ",°æ»ó³²µµ";
    } else if(val =="ÀüºÏ") {
        val =  "Àü¶óºÏµµ";
    } else if(val =="Àü³²") {
        val =  "Àü¶ó³²µµ";
    }  else if(val =="ÃæºÏ") {
        val =  "ÃæÃ»ºÏµµ";
    }  else if(val =="Ãæ³²") {
        val =  "ÃæÃ»³²µµ";
    }  else if(val =="°­¿ø") {
        val =  "°­¿øµµ";
    } else if(val =="Á¦ÁÖ") {
        val =  "Á¦ÁÖµµ";
    }
    return val;
    
}

/**
 * initTotalCnt() : Á¸Ã£±â ÁöµµÈ­¸é mapFrame »ó´Ü¿¡ ±ÝÀÏÀÇ ÀüÃ¼ Á¸ Ä«¿îÆ® Ç¥½Ã ÈÄ Å°¿öµå °Ë»ö ½Ç½Ã
 * @param initTotCnt
 * @param initCity
 * @param initDistrict
 * @param initDong
 * @param mapType
 * @param tourFlag
 */
function initTotalCnt(initTotCnt, initCity, initDistrict, initDong, mapType, tourFlag) {
	
    jQuery(".numb").empty();
    var strHtml = "";
    for(var i=0; i<initTotCnt.length; i++){
        if('1' == initTotCnt.charAt(i)){
            strHtml +=	"<img src=\'/images/1.gif\'>";
        }else if('2' == initTotCnt.charAt(i)){
            strHtml +=	"<img src=\'/images/2.gif\'>";
        }else if('3' == initTotCnt.charAt(i)){
            strHtml +=	"<img src=\'/images/3.gif\'>";
        }else if('4' == initTotCnt.charAt(i)){
            strHtml +=	"<img src=\'/images/4.gif\'>";
        }else if('5' == initTotCnt.charAt(i)){
            strHtml +=	"<img src=\'/images/5.gif\'>";
        }else if('6' == initTotCnt.charAt(i)){
            strHtml +=	"<img src=\'/images/6.gif\'>";
        }else if('7' == initTotCnt.charAt(i)){
            strHtml +=	"<img src=\'/images/7.gif\'>";
        }else if('8' == initTotCnt.charAt(i)){
            strHtml +=	"<img src=\'/images/8.gif\'>";
        }else if('9' == initTotCnt.charAt(i)){
            strHtml +=	"<img src=\'/images/9.gif\'>";
        }else if('0' == initTotCnt.charAt(i)){
            strHtml +=	"<img src=\'/images/0.gif\'>";
        }else {
            strHtml +=	"<span class=\"r_mgin3\"><img src=\"../images/comma.png\" class=\"png24\" ></span>";
        }
    }
    jQuery(".numb").append(strHtml);
    
    
    if( ! tourFlag ) {
	    if(initCity != '')  {
	        autoSearchAddressSearch(1, initCity, initDistrict, initDong);
	    }
    }
}

/**
 * initTotalCnt_4_tour() : initTotalCnt() ¸¦ È£ÃâÇÏµÈ ±ÝÀÏÀÇ ÀüÃ¼ Á¸ °Ç¼ö¸¸ Ç¥±âÇÏµµ·Ï Ã³¸®ÇÔ (Å½¹æ±â -> Á¸Ã£±â ¸ÞÀÎ ÀÌµ¿½Ã ÇÊ¿äÇÔ)
 * @param initTotCnt
 * @param initCity
 * @param initDistrict
 * @param initDong
 * @param mapType
 */
function initTotalCnt_4_tour(initTotCnt,initCity,initDistrict,initDong, mapType){
	
	initTotalCnt(initTotCnt,initCity,initDistrict,initDong, mapType, true);
	
}

// °Ë»ö ¹× Áöµµ ÃÊ±âÈ­. 
function initSearch() {
	
    //window.location.reload();
	window.location.href = "/index.action";
	
}

//Å½¹æ±â
function goTour(goURL) {

	document.dummy.method = "post";
	document.dummy.action = "/tour.action";
	document.dummy.tour_contents_url.value = goURL;
	document.dummy.submit();
	
}

