/**
 * products.js
 * script for products pages
 * lastupdate: 2009/09/09 19:39
 */

(function($){

	/**
	 * build product modal anchors
	 */
	function buildProductModalAnchors(){
		//anchor selector
		var $anchors = $("#product_detail a.popupbox");
		//default options(size)
		var options = {
			width: 640,
			height: 600
		}
		//anchors action
		$anchors.each(function(idx){
			var $this = $(this);
			var href = $this.attr("href");
			if(href){
				//build up query for thickbox
				var query = "";
				if(href.indexOf("?") < 0){
					query = "?";
				}else{
					query = "&";
				}
				query += "TB_iframe=true";
				for (var n in options){
					query += "&" + encodeURIComponent(n) + "=" + encodeURIComponent(options[n]);
				}
				$this.attr("href", href + query)
			}
		});
		tb_init($anchors);
	}

	//on dom ready
	$(function(){
		//build product modal anchors
		buildProductModalAnchors();
	});

})(jQuery);
