$(function() {
	//root
	try {
		if ($.browser.flash) {
			swfobject.embedSWF('/swf/banner.swf?xmlpath=' + root_xmlpath, "banner", "978", "300", "9.0.0", "/i/expressInstall.swf", {}, {wmode:"opaque"}, {wmode:"opaque"});
		} else {
			$.get(root_jsonpath, function(js) {
				try {
					eval(js)

					$.each(root_json, function(i, j) {
						var cls = j.current ? ' class="active"' : '';

						$('#banner .in').append('<a href="'+j.link+'"><img src="' + j.image + '" alt="' + j.title + '" id="imgitem' + j.id + '" ' + cls+ '/></a>');
						$('#switch').append('<a href="'+j.link+'" id="item' + j.id + '" ' + cls + ' title="'+j.title+'">' + (i + 1) + '</a>');
					});

					$('#switch a').click(function() {
						var id = $(this).attr('id');

						if(this.className !== 'active') {
							$('#banner .active').animate({top:'-300px'}, {duration:500, easing:'easeOutCubic'});
							$('#banner .active').removeClass('active');
							$('#switch .active').removeClass('active');
							$('#img'+id).css('top','300px').animate({top:'0'}, {duration:400, easing:'easeOutCubic'});
							$('#img'+id).addClass('active');
							$(this).addClass('active');

						} else {
							return false;
						}

						return false;
					});
				} catch(e) {

				}
			});
		}
	} catch(e) {
	}

	//menu
	try {
		$.each(banner_json, function(i, val) {

			if (!val.link) {
				$("#banner_" + i).closest("div.pop").addClass("no-banner");
				$("#banner_" + i).remove();
			}

			$('#banner_' + i).append('<a href="' + val.link + '" class="description" target="_top"><img src="' + val.image+ '" alt="" />' + val.text + '</a>');
		});
	} catch(e) {
	}

	//inner
	try {
		var position = new Array('left', 'center', 'right');
		var j = 0;
		
		$.each(inner_json, function(i, val) {
			$('.b-promo .promo-' + position[j++] + ' .shadow-box').append('<a href="' + val.link + '" class="sh-in"><img src="' + val.preview + '" class="img"><img src="' + val.image + '" class="img-wide"></a>');
		});
	} catch(e) {
	
	try {
		var position = new Array('left', 'center', 'right');
		var j = 0;

		$.each(footer_json, function(i, val) {
			$('.b-promo .promo-' + position[j++] + ' .shadow-box').append('<a href="' + val.link + '" class="sh-in"><img src="' + val.preview + '" class="img"><img src="' + val.image + '" class="img-wide"></a>');
		});

	} catch(e) {
	}}
});

