<!--
var xmlHttp;

function createXMLHttpRequest() {
    if (window.ActiveXObject) {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else if (window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();
    }
}

function doSearch(url) {
    createXMLHttpRequest();
    xmlHttp.onreadystatechange = handleStateChange;
    xmlHttp.open("GET", url, true);
    xmlHttp.send(null);
}

function handleStateChange() {
    if(xmlHttp.readyState == 4) {
        if(xmlHttp.status == 200) {
            clearPreviousResults();
            parseResults();
        }
    }
}

function clearPreviousResults() {
    //var header = document.getElementById("header");
    //if(header.hasChildNodes()) {
       // header.removeChild(header.childNodes[0]);
    //}
}

function parseResults() {
    var results = xmlHttp.responseXML;

    var property = null;
    var date = "";
    var icon = "";
    var wtext = "";
    var temp = "";
    var rainp = "";

    var wf = "";
    var loc = "";
    
    var properties = results.getElementsByTagName("property");
    var innerWeek = "<table width='230' border='0' cellspacing='0' cellpadding='0'> \n";
    var inner3Days = "<table width='362' border='0' cellspacing='0' cellpadding='0'> \n";

    daytitle = [ "¿À´Ã", "³»ÀÏ", "¸ð·¹"];

    for(var i = 0; i < properties.length; i++) {
        property = properties[i];

        date = property.getElementsByTagName("date")[0].firstChild.nodeValue;
        icon = flashTag("./wicon/icon"+property.getElementsByTagName("icon")[0].firstChild.nodeValue+".swf","35","35","icon"+i,"","transparent");
        wtext = (i < 3)?property.getElementsByTagName("wtext")[0].firstChild.nodeValue:"";
        temp = (i < 3)?property.getElementsByTagName("temp")[0].firstChild.nodeValue:"";
        rainp = (i < 3)?property.getElementsByTagName("rainp")[0].firstChild.nodeValue:"";
        
        if(i == 0){   
	   wf = property.getElementsByTagName("wf")[0].firstChild.nodeValue;
	   loc = property.getElementsByTagName("loc")[0].firstChild.nodeValue;

	   var innerShko = "<table width='362' border='0' cellspacing='0' cellpadding='0'> \n" +
	        "<tr align='center'> \n" + 
	        "  <td width='63'>"+ property.getElementsByTagName("swtext")[0].firstChild.nodeValue +"</td> \n" + 
	        "  <td width='55'>"+ property.getElementsByTagName("stemp")[0].firstChild.nodeValue +"</td> \n" +
	        "  <td width='61'>"+ property.getElementsByTagName("shumi")[0].firstChild.nodeValue +"</td> \n" +
	        "  <td width='70'>"+ property.getElementsByTagName("srain2")[0].firstChild.nodeValue +"</td> \n" +
	        "  <td width='59'>"+ property.getElementsByTagName("swdirk")[0].firstChild.nodeValue +"</td> \n" +
	        "  <td width='54'>"+ property.getElementsByTagName("swspeed")[0].firstChild.nodeValue +"</td> \n" +
	        "</tr> \n" +
	      "</table> \n";
        }
        innerWeek += "<tr align='center'>\n<td height='59'>" + date + "</td>\n<td>" + icon + "</td>\n</tr>\n";
        inner3Days += (i < 3)?"<tr>\n<td width='73' height='60' align='center'><strong>"+daytitle[i]+"</strong><br>\n" + date + "</td>\n<td width='120'><div align='center'>" + icon + "<br>"+ wtext +"</div></td>\n":"";
        inner3Days += (i < 3)?"<td width='80' align='center'>"+temp+"<br>(ÃÖ°í)</td>\n<td width='89' align='center'>" + rainp + "<br>\n(¿ÀÀü/¿ÀÈÄ)</td>\n</tr>\n":"";
    }

    putTag('wf', wf);
    putTag('locName1', loc);
    putTag('locName2', loc);
    putTag('locName3', loc);
    putTag('shko', innerShko);
    putTag('week', innerWeek+"</table>");
    putTag('f3days', inner3Days+"</table>");
}
function putTag(id, str){
   var obj = document.getElementById(id);
   if(obj == null) return;	
   obj.innerHTML = str;	
}
function flashTag(url,w,h,id,bg,win){
    var flashStr=
    "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='"+w+"' height='"+h+"' id='"+id+"' align='middle'>"+
    "<param name='movie' value='"+url+"' />"+
    "<param name='wmode' value='"+win+"' />"+
    "<param name='menu' value='false' />"+
    "<param name='quality' value='high' />"+
    "<param name='bgcolor' value='"+bg+"' />"+
    "<embed src='"+url+"' wmode='"+win+"' menu='false' quality='high' bgcolor='"+bg+"' width='"+w+"' height='"+h+"' name='"+id+"' align='middle' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"+
    "</object>";
    return flashStr;
}
//-->
