﻿var s;
function jsLoadProdBrand() {
	var q = "dt=brand";
	$.getJSON("/services/query.aspx", q, function (data) {
		var ul = $("<ul></ul>");
		$.each(data, function (i, b) {
			if ((b.brand_id.toLowerCase() != brand_7sign_pop.toLowerCase())) {
				$(ul).append("<li><a  ><img src='/images/brand/" + b.brand_id + "/thumbnail.png' alt='" + b['name_' + _711.language] + "' title='" + b['name_' + _711.language] + "' height='65' width='65' ref='" + b.brand_id + "'/></a></li>");
			}
		});
		$('#brand > div.wrapper').append(ul);
		$('#brand').infiniteCarousel();

		jsBindBrand();
		$('#brand > div.wrapper li').not('.cloned, .empty').first().children('a').click();

	});
}

function jsLoadProduct(brand_id) {
	var q = "dt=product&brand_id=" + brand_id;
	$.getJSON("/services/query.aspx", q, function (data) {
		var ul = $("<ul></ul>");
		var _remark;
		$.each(data, function (i, b) {

			_remark = '';
			b.remark += '';
			if (b.remark.indexOf('H') >= 0)
				_remark = 'hot';
			if (b.remark.indexOf('N') >= 0)
				_remark = 'new';

			$(ul).append("<li><div class='prod_remark " + _remark + "'></div><a href='/product.aspx?brand=" + b.brand_alias + "&product=" + b.alias + "' ><img src='/images/product/" + b.product_id + "/thumbnail.png' alt='" + b['name_' + _711.language] + "' title='" + b['name_' + _711.language] + "' height='100' width='100' ref='" + b.product_id + "'/></a></li>");
		});
		$('#item > div.wrapper').append(ul);
		$('#item').infiniteCarousel();
	});
}


function jsBindBrand() {
	$('#brand div.wrapper a').click(function () {

		if ($(this).hasClass('current'))
			return;

		$('.iCarousel div.wrapper a').removeClass('current');
		$(this).addClass('current');
		var brand_id = $(this).children('img').attr('ref');
		$('#item div.wrapper a').unbind('click');
		$('#item').html('<div class="wrapper"></div>');

		jsLoadProduct(brand_id);
	});
}

function jsBindProduct(brand_id) {
	$('#item div.wrapper a').click(function () {

	});
}


$(function () {
	jsLoadProdBrand();

});

