/*------------------------------------------------------*/
/* updated 2010/05 */
/*------------------------------------------------------*/
/*------------------------------------------------------*/
/* promotion.js */
/*------------------------------------------------------*/

/* bnr --------------------------------- */

/* var ==================== */

var promHtml = "promotion_data.html";
var promTimeout = 10000;
var promArray = new Array();
var promNum;
var promURL;

/* document load ==================== */

$(window).bind("load",function(){
							   
	$("#topflash .bnrarea").hide();

	$.ajax({
		url: promHtml,
		type: "GET",
		dataType: "html",
		cache: false,
		timeout: promTimeout,

		error: function(){
			promError();
		},

		success: function(html){
			promSuccess(html);
		}

	});

});

/* xml error ==================== */

function promError() {
}

/* xml success ==================== */

function promSuccess(html) {
	if($("object#topflash").size() == 0){
		getPromInfo(html);
		setPromShow();
	}
}

/* promotion info ==================== */

function getPromInfo(html) {
	$(html).find("#promotions_f tr:not(:first)").each(function(i) {
		promArray[i] = new Object();
		promArray[i].href = jQuery(this).find("td.url a").attr("href");
		promArray[i].target = jQuery(this).find("td.url a").attr("target");
		promArray[i].src = jQuery(this).find("td.thumbImg img").attr("src");
		promArray[i].alt = jQuery(this).find("td.title").text();
	});
}

/* set promotion ==================== */
function setPromShow() {
	$(promArray).each(function(i) {
		promNum = i + 1;
		promURL = promArray[i].href;
		$("#topflash .bnrarea").append('<li class="bnr' + promNum + '"><a href="' + promArray[i].href + '" target="' + promArray[i].target + '"><img src="' + promArray[i].src + '" alt="' + promArray[i].alt + '" width="150" height="45" /></a></li>');
	});
	$("#topflash .bnrarea").fadeIn(500);
}




/*------------------------------------------------------*/
/* End */
/*------------------------------------------------------*/

