var queryParam = {};

$(document).ready(function () {
	$('#lyTopFlash').flash({ swf:'/flash/main.swf', height:375, width:"100%", params: {wmode: 'transparent'} });  
	$('#bannerFlash').flash({ swf:'/flash/main_banner.swf', height:140, width: 600, params: {wmode: 'transparent'} });  
	$('#linkFlash').flash({ swf:'/flash/main_link.swf', height:80, width: 907 });

	bbsListNotice({"id":"notice","sf":"","sv":"","page":1,"auth":AUTH,"limit":4});
	bbsListNotice({"id":"press","sf":"","sv":"","page":1,"auth":AUTH,"limit":4});

	document.onfocusin=bluring;
})

function bluring(){
	if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus();
}

//목록불러오기
function bbsListNotice( params ) {
	var procFile = "/system/lib/getXmlBbsList.php";
	$.get(procFile, {q:$.toJSON(params)}, function(xmlDataSet) { 
		if( xmlDataSet ) {
			bbsListBrowseXML(xmlDataSet, params); 
		}
	}, "xml");
}

function bbsListBrowseXMLClear( params ) {
	var rowId = 0;
	$("#bbsList"+params.id+" tr").each(function() { 
		$(this).remove();
	});
}

function bbsListBrowseXML( xmlDataSet, params ) {
	var count = 0;
	if( $(xmlDataSet).find("ARTICLE").length > 0 ) {
		bbsListBrowseXMLClear( params );
		$(xmlDataSet).find("ARTICLE").each(function() {
			if( params.limit > count ) {
				xmlThisRow = this;
				$("#bbsList"+params.id).each(function() {
					var tds = "<tr>";

					for(var i = 0; i < 2; i++){
						switch( i ) {
							case 0: 
								textId = "BBS_TITLE";
								tds += "<td class=\"title\">";
								tds += "<a href=\"/activity/bbs/"+params.id+"/view?aid="+$("ID_BBS",xmlThisRow).text()+"\">";
								tds += $(textId,xmlThisRow).text().substring(0,28)+"</a></td>";
							break;	
							case 1: 
								textId = "BBS_WRITE_DATE";
								tds += "<td class=\"date\">"+$(textId,xmlThisRow).text().replace(/-/g,".")+"</td>";
							break;
							default:
								textId = "";
						}
					}
					tds += "</tr>";
					$(this).append(tds);
				});
			} else {
				return;
			}
			count++;
		});
	}
}
