/* Copyright (c) 2006 Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
 * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
 *
 * $LastChangedDate: 2007-12-20 09:02:08 -0600 (Thu, 20 Dec 2007) $
 * $Rev: 4265 $
 *
 * Version: 3.0
 * 
 * Requires: $ 1.2.2+
 */

(function($) {

$.event.special.mousewheel = {
	setup: function() {
		var handler = $.event.special.mousewheel.handler;
		
		// Fix pageX, pageY, clientX and clientY for mozilla
		if ( $.browser.mozilla )
			$(this).bind('mousemove.mousewheel', function(event) {
				$.data(this, 'mwcursorposdata', {
					pageX: event.pageX,
					pageY: event.pageY,
					clientX: event.clientX,
					clientY: event.clientY
				});
			});
	
		if ( this.addEventListener )
			this.addEventListener( ($.browser.mozilla ? 'DOMMouseScroll' : 'mousewheel'), handler, false);
		else
			this.onmousewheel = handler;
	},
	
	teardown: function() {
		var handler = $.event.special.mousewheel.handler;
		
		$(this).unbind('mousemove.mousewheel');
		
		if ( this.removeEventListener )
			this.removeEventListener( ($.browser.mozilla ? 'DOMMouseScroll' : 'mousewheel'), handler, false);
		else
			this.onmousewheel = function(){};
		
		$.removeData(this, 'mwcursorposdata');
	},
	
	handler: function(event) {
		var args = Array.prototype.slice.call( arguments, 1 );
		
		event = $.event.fix(event || window.event);
		// Get correct pageX, pageY, clientX and clientY for mozilla
		$.extend( event, $.data(this, 'mwcursorposdata') || {} );
		var delta = 0, returnValue = true;
		
		if ( event.wheelDelta ) delta = event.wheelDelta/120;
		if ( event.detail     ) delta = -event.detail/3;
//		if ( $.browser.opera  ) delta = -event.wheelDelta;
		
		event.data  = event.data || {};
		event.type  = "mousewheel";
		
		// Add delta to the front of the arguments
		args.unshift(delta);
		// Add event to the front of the arguments
		args.unshift(event);

		return $.event.handle.apply(this, args);
	}
};

jQuery.fn.extend({
	mousewheel: function(fn) {
		return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel");
	},
	
	unmousewheel: function(fn) {
		return this.unbind("mousewheel", fn);
	}
});

})(jQuery);

/**
 * @license 
 * jQuery Tools 1.2.3 Overlay - Overlay base. Extend it.
 * 
 * NO COPYRIGHTS OR LICENSES. DO WHAT YOU LIKE.
 * 
 * http://flowplayer.org/tools/overlay/
 *
 * Since: March 2008
 * Date:    Mon Jun 7 13:43:53 2010 +0000 
 */
(function($) { 

	// static constructs
	$.tools = $.tools || {version: '1.2.3'};
	
	$.tools.overlay = {
		
		addEffect: function(name, loadFn, closeFn) {
			effects[name] = [loadFn, closeFn];	
		},
	
		conf: {  
			close: null,	
			closeOnClick: true,
			closeOnEsc: true,			
			closeSpeed: 'fast',
			effect: 'default',
			
			// since 1.2. fixed positioning not supported by IE6
			fixed: !$.browser.msie || $.browser.version > 6, 
			
			left: 'center',		
			load: false, // 1.2
			mask: null,  
			oneInstance: true,
			speed: 'normal',
			target: null, // target element to be overlayed. by default taken from [rel]  
			top: '10%'
		}
	};

	
	var instances = [], effects = {};
		
	// the default effect. nice and easy!
	$.tools.overlay.addEffect('default', 
		
		/* 
			onLoad/onClose functions must be called otherwise none of the 
			user supplied callback methods won't be called
		*/
		function(pos, onLoad) {
			
			var conf = this.getConf(),
				 w = $(window);				 
				
			if (!conf.fixed)  {
				pos.top += w.scrollTop();
				pos.left += w.scrollLeft();
			} 
				
			pos.position = conf.fixed ? 'fixed' : 'absolute';
			this.getOverlay().css(pos).fadeIn(conf.speed, onLoad); 
			
		}, function(onClose) {
			this.getOverlay().fadeOut(this.getConf().closeSpeed, onClose); 			
		}		
	);		

	
	function Overlay(trigger, conf) {		
		
		// private variables
		var self = this,
			 fire = trigger.add(self),
			 w = $(window), 
			 closers,            
			 overlay,
			 opened,
			 maskConf = $.tools.expose && (conf.mask || conf.expose),
			 uid = Math.random().toString().slice(10);		
		
			 
		// mask configuration
		if (maskConf) {			
			if (typeof maskConf == 'string') { maskConf = {color: maskConf}; }
			maskConf.closeOnClick = maskConf.closeOnEsc = false;
		}			 
		 
		// get overlay and triggerr
		var jq = conf.target || trigger.attr("rel");
		overlay = jq ? $(jq) : null || trigger;	
		
		// overlay not found. cannot continue
		if (!overlay.length) { throw "Could not find Overlay: " + jq; }
		
		// trigger's click event
		if (trigger && trigger.index(overlay) == -1) {
			trigger.click(function(e) {				
				self.load(e);
				return e.preventDefault();
			});
		}   			
		
		// API methods  
		$.extend(self, {

			load: function(e) {
				
				// can be opened only once
				if (self.isOpened()) { return self; }
				
				// find the effect
		 		var eff = effects[conf.effect];
		 		if (!eff) { throw "Overlay: cannot find effect : \"" + conf.effect + "\""; }
				
				// close other instances?
				if (conf.oneInstance) {
					$.each(instances, function() {
						this.close(e);
					});
				}
				
				// onBeforeLoad
				e = e || $.Event();
				e.type = "onBeforeLoad";
				fire.trigger(e);				
				if (e.isDefaultPrevented()) { return self; }				

				// opened
				opened = true;
				
				// possible mask effect
				if (maskConf) { $(overlay).expose(maskConf); }				
				
				// position & dimensions 
				var top = conf.top,					
					 left = conf.left,
					 oWidth = overlay.outerWidth({margin:true}),
					 oHeight = overlay.outerHeight({margin:true}); 
				
				if (typeof top == 'string')  {
					top = top == 'center' ? Math.max((w.height() - oHeight) / 2, 0) : 
						parseInt(top, 10) / 100 * w.height();			
				}				
				
				if (left == 'center') { left = Math.max((w.width() - oWidth) / 2, 0); }

				
		 		// load effect  		 		
				eff[0].call(self, {top: top, left: left}, function() {					
					if (opened) {
						e.type = "onLoad";
						fire.trigger(e);
					}
				}); 				

				// mask.click closes overlay
				if (maskConf && conf.closeOnClick) {
					$.mask.getMask().one("click", self.close); 
				}
				
				// when window is clicked outside overlay, we close
				if (conf.closeOnClick) {
					$(document).bind("click." + uid, function(e) { 
						if (!$(e.target).parents(overlay).length) { 
							self.close(e); 
						}
					});						
				}						
			
				// keyboard::escape
				if (conf.closeOnEsc) { 

					// one callback is enough if multiple instances are loaded simultaneously
					$(document).bind("keydown." + uid, function(e) {
						if (e.keyCode == 27) { 
							self.close(e);	 
						}
					});			
				}

				
				return self; 
			}, 
			
			close: function(e) {

				if (!self.isOpened()) { return self; }
				
				e = e || $.Event();
				e.type = "onBeforeClose";
				fire.trigger(e);				
				if (e.isDefaultPrevented()) { return; }				
				
				opened = false;
				
				// close effect
				effects[conf.effect][1].call(self, function() {
					e.type = "onClose";
					fire.trigger(e); 
				});
				
				// unbind the keyboard / clicking actions
				$(document).unbind("click." + uid).unbind("keydown." + uid);		  
				
				if (maskConf) {
					$.mask.close();		
				}
				 
				return self;
			}, 
			
			getOverlay: function() {
				return overlay;	
			},
			
			getTrigger: function() {
				return trigger;	
			},
			
			getClosers: function() {
				return closers;	
			},			

			isOpened: function()  {
				return opened;
			},
			
			// manipulate start, finish and speeds
			getConf: function() {
				return conf;	
			}			
			
		});
		
		// callbacks	
		$.each("onBeforeLoad,onStart,onLoad,onBeforeClose,onClose".split(","), function(i, name) {
				
			// configuration
			if ($.isFunction(conf[name])) { 
				$(self).bind(name, conf[name]); 
			}

			// API
			self[name] = function(fn) {
				$(self).bind(name, fn);
				return self;
			};
		});
		
		// close button
		closers = overlay.find(conf.close || ".close");		
		
		if (!closers.length && !conf.close) {
			closers = $('<a class="close"></a>');
			overlay.prepend(closers);	
		}		
		
		closers.click(function(e) { 
			self.close(e);  
		});	
		
		// autoload
		if (conf.load) { self.load(); }
		
	}
	
	// jQuery plugin initialization
	$.fn.overlay = function(conf) {   
		
		// already constructed --> return API
		var el = this.data("overlay");
		if (el) { return el; }	  		 
		
		if ($.isFunction(conf)) {
			conf = {onBeforeLoad: conf};	
		}

		conf = $.extend(true, {}, $.tools.overlay.conf, conf);
		
		this.each(function() {		
			el = new Overlay($(this), conf);
			instances.push(el);
			$(this).data("overlay", el);	
		});
		
		return conf.api ? el: this;		
	}; 
	
})(jQuery);


/**
 * @license 
 * jQuery Tools 1.2.3 / Overlay Apple effect. 
 * 
 * NO COPYRIGHTS OR LICENSES. DO WHAT YOU LIKE.
 * 
 * http://flowplayer.org/tools/overlay/apple.html
 *
 * Since: July 2009
 * Date:    Mon Jun 7 13:43:53 2010 +0000 
 */
(function($) { 

	// version number
	var t = $.tools.overlay,
		 w = $(window); 
		
	// extend global configuragion with effect specific defaults
	$.extend(t.conf, { 
		start: { 
			top: null,
			left: null
		},
		
		fadeInSpeed: 'fast',
		zIndex: 9999
	});			
	
	// utility function
	function getPosition(el) {
		var p = el.offset();
		return {
			top: p.top + el.height() / 2, 
			left: p.left + el.width() / 2
		}; 
	}
	
//{{{ load 

	var loadEffect = function(pos, onLoad) {
		
		var overlay = this.getOverlay(),
			 conf = this.getConf(),
			 trigger = this.getTrigger(),
			 self = this,
			 oWidth = overlay.outerWidth({margin:true}),
			 img = overlay.data("img");  
		
		
		// growing image is required.
		if (!img) { 
			var bg = overlay.css("backgroundImage");
			
			if (!bg) { 
				throw "background-image CSS property not set for overlay"; 
			}
			
			// url("bg.jpg") --> bg.jpg
			bg = bg.slice(bg.indexOf("(") + 1, bg.indexOf(")")).replace(/\"/g, "");
			overlay.css("backgroundImage", "none");
			
			img = $('<img src="' + bg + '"/>');
			img.css({border:0, display:'none'}).width(oWidth);			
			$('body').append(img); 
			overlay.data("img", img);
		}
		
		// initial top & left
		var itop = conf.start.top || Math.round(w.height() / 2), 
			 ileft = conf.start.left || Math.round(w.width() / 2);
		
		if (trigger) {
			var p = getPosition(trigger);
			itop = p.top;
			ileft = p.left;
		} 
			
		// initialize background image and make it visible
		img.css({
			position: 'absolute',
			top: itop, 
			left: ileft,
			width: 0,
			zIndex: conf.zIndex
		}).show();

		
		// put overlay into final position
		pos.top += w.scrollTop();
		pos.left += w.scrollLeft();		
		pos.position = 'absolute';
		overlay.css(pos);
		
		// begin growing
		img.animate({
			top: overlay.css("top"), 
			left: overlay.css("left"), 
			width: oWidth}, conf.speed, function() { 

			if (conf.fixed) {
				pos.top -= w.scrollTop();
				pos.left -= w.scrollLeft();
				pos.position = 'fixed';
				img.add(overlay).css(pos);
			}
			
			// set close button and content over the image
			overlay.css("zIndex", conf.zIndex + 1).fadeIn(conf.fadeInSpeed, function()  { 
					
				if (self.isOpened() && !$(this).index(overlay)) {	
					onLoad.call(); 
				} else {
					overlay.hide();	
				} 
			});
		});
		
	};
//}}}
	
	
	var closeEffect = function(onClose) {

		// variables
		var overlay = this.getOverlay().hide(), 
			 conf = this.getConf(),
			 trigger = this.getTrigger(),
			 img = overlay.data("img"),
			 
			 css = { 
			 	top: conf.start.top, 
			 	left: conf.start.left, 
			 	width: 0 
			 };
		
		// trigger position
		if (trigger) { $.extend(css, getPosition(trigger)); }
		
		
		// change from fixed to absolute position
		if (conf.fixed) {
			img.css({position: 'absolute'})
				.animate({ top: "+=" + w.scrollTop(), left: "+=" + w.scrollLeft()}, 0);
		}
		 
		// shrink image		
		img.animate(css, conf.closeSpeed, onClose);	
	};
	
	
	// add overlay effect	
	t.addEffect("apple", loadEffect, closeEffect); 
	
})(jQuery);	
		


/**
 * @license 
 * jQuery Tools 1.2.3 / Expose - Dim the lights
 * 
 * NO COPYRIGHTS OR LICENSES. DO WHAT YOU LIKE.
 * 
 * http://flowplayer.org/tools/toolbox/expose.html
 *
 * Since: Mar 2010
 * Date:    Mon Jun 7 13:43:53 2010 +0000 
 */
(function($) { 	

	// static constructs
	$.tools = $.tools || {version: '1.2.3'};
	
	var tool;
	
	tool = $.tools.expose = {
		
		conf: {	
			maskId: 'exposeMask',
			loadSpeed: 'slow',
			closeSpeed: 'fast',
			closeOnClick: true,
			closeOnEsc: true,
			
			// css settings
			zIndex: 9998,
			opacity: 0.5,
			startOpacity: 0,
			color: '#fff',
			
			// callbacks
			onLoad: null,
			onClose: null
		}
	};

	/* one of the greatest headaches in the tool. finally made it */
	function viewport() {
				
		// the horror case
		if ($.browser.msie) {
			
			// if there are no scrollbars then use window.height
			var d = $(document).height(), w = $(window).height();
			
			return [
				window.innerWidth || 							// ie7+
				document.documentElement.clientWidth || 	// ie6  
				document.body.clientWidth, 					// ie6 quirks mode
				d - w < 20 ? w : d
			];
		} 
		
		// other well behaving browsers
		return [$(document).width(), $(document).height()]; 
	} 
	
	function call(fn) {
		if (fn) { return fn.call($.mask); }
	}
	
	var mask, exposed, loaded, config, overlayIndex;		
	
	
	$.mask = {
		
		load: function(conf, els) {
			
			// already loaded ?
			if (loaded) { return this; }			
			
			// configuration
			if (typeof conf == 'string') {
				conf = {color: conf};	
			}
			
			// use latest config
			conf = conf || config;
			
			config = conf = $.extend($.extend({}, tool.conf), conf);

			// get the mask
			mask = $("#" + conf.maskId);
				
			// or create it
			if (!mask.length) {
				mask = $('<div/>').attr("id", conf.maskId);
				$(mask).addClass('overlay_mask');
				$(document.body).append(mask);
			}
			
			// set position and dimensions 			
			var size = viewport();
				
			mask.css({				
				position:'absolute', 
				top: 0, 
				left: 0,
				width: size[0],
				height: size[1],
				display: 'block',
				opacity: conf.startOpacity,					 		
				zIndex: conf.zIndex 
			});
			
			if (conf.color) {
				mask.css("backgroundColor", conf.color);	
			}			
			
			// onBeforeLoad
			if (call(conf.onBeforeLoad) === false) {
				return this;
			}
			
			// esc button
			if (conf.closeOnEsc) {						
				$(document).bind("keydown.mask", function(e) {							
					if (e.keyCode == 27) {
						$.mask.close(e);	
					}		
				});			
			}
			
			// mask click closes
			if (conf.closeOnClick) {
				mask.bind("click.mask", function(e)  {
					$.mask.close(e);		
				});					
			}			
			
			// resize mask when window is resized
			$(window).bind("resize.mask", function() {
				$.mask.fit();
			});
			
			// exposed elements
			if (els && els.length) {
				
				overlayIndex = els.eq(0).css("zIndex");

				// make sure element is positioned absolutely or relatively
				$.each(els, function() {
					var el = $(this);
					if (!/relative|absolute|fixed/i.test(el.css("position"))) {
						el.css("position", "relative");		
					}					
				});
			 
				// make elements sit on top of the mask
				exposed = els.css({ zIndex: Math.max(conf.zIndex + 1, overlayIndex == 'auto' ? 0 : overlayIndex)});			
			}	
			
			// reveal mask
			mask.css({display: 'block'}).fadeTo(conf.loadSpeed, conf.opacity, function() {
				$.mask.fit(); 
				call(conf.onLoad);
			});
			
			loaded = true;			
			return this;				
		},
		
		close: function() {
			if (loaded) {
				
				// onBeforeClose
				if (call(config.onBeforeClose) === false) { return this; }
					
				mask.fadeOut(config.closeSpeed, function()  {					
					call(config.onClose);					
					if (exposed) {
						exposed.css({zIndex: overlayIndex});
					}				
				});				
				
				// unbind various event listeners
				$(document).unbind("keydown.mask");
				mask.unbind("click.mask");
				$(window).unbind("resize.mask");
	
				loaded = false;
			}
			
			return this; 
		},
		
		fit: function() {
			if (loaded) {
				var size = viewport();				
				mask.css({width: size[0], height: size[1]});
			}				
		},
		
		getMask: function() {
			return mask;	
		},
		
		isLoaded: function() {
			return loaded;	
		}, 
		
		getConf: function() {
			return config;	
		},
		
		getExposed: function() {
			return exposed;	
		}		
	};
	
	$.fn.mask = function(conf) {
		$.mask.load(conf);
		return this;		
	};			
	
	$.fn.expose = function(conf) {
		$.mask.load(conf, this);
		return this;			
	};


})(jQuery);

		


/******************************************************************
SelectBox
editor : Park Kyoung ho
date : 20100512
edit : 20100608

edit List
 - input click container on/off
 - resizing
 - category section include

******************************************************************/

jQuery.fn.extend({
	selectbox: function(options) {
		return this.each(function() {
			new jQuery.SelectBox(this, options);
		});
	}
});

/* pawel maziarz: work around for ie logging */
if (!window.console) {
	var console = {
		log: function(msg) { 
	 }
	}
}
/* */

jQuery.SelectBox = function(selectobj, options) {
	if(navigator.userAgent.indexOf("iPhone") < 0)
	{
		var opt = options || {};
		opt.inputClass = opt.inputClass || "selectbox_category";
		opt.containerClass = opt.containerClass || "selectbox-wrapper";
		opt.hoverClass = opt.hoverClass || "current";
		opt.currentClass = opt.selectedClass || "selected"
		opt.debug = opt.debug || false;
		
		var elm_id = selectobj.id;
		var active = -1;
		var inFocus = false;
		var hasfocus = 0;
		var rows = 0;
		//jquery object for select element
		var $select = $(selectobj);
		// jquery container object
		var $container = setupContainer(opt);
		//jquery input object 
		var $input = setupInput(opt);
		// hide select and append newly created elements
		$select.hide().before($input).before($container);
		
		var $this = $container;
		
		init();
		
	}
		$input
		.click(function(event){
			if (!inFocus) {
				$container.toggle();
			}
			else
			{
				inFocus = false;
			}
		})
		.focus(function(event){
			if ($container.not(':visible')) {
				inFocus = true;
				/*
				$(document).click(function(event){
					if($(window).height()-event.clientY < $('#'+elm_id+'_container').height()+20)
					{
						$('#'+elm_id+'_container').css('top',"-"+($('#'+elm_id+'_container').height()-8)+"px")
					}
					else
					{
						if(opt.containerClass != "detail-selectbox-wrapper")
						{
							$('#'+elm_id+'_container').css('top',30+"px")
						}
					}
				});
				*/
			$container.show();
			$(".flashContainer").hide();
			$(".fullCategoryContainer").hide();
			}
			else
			{
				hideMe();
			}
		})
		.keydown(function(event) {	   
			switch(event.keyCode) {
				case 38: // up
					event.preventDefault();
					moveSelect(-1);
					break;
				case 40: // down
					event.preventDefault();
					moveSelect(1);
					break;
				//case 9:  // tab 
				case 13: // return
					event.preventDefault(); // seems not working in mac !
					$('li.'+opt.hoverClass).trigger('click');
					break;
				case 27: //escape
				  hideMe();
				  break;
			}
		})
		.blur(function() {
			if ($container.is(':visible') && hasfocus > 0 ) {
				if(opt.debug) console.log('container visible and has focus')
			} else {
				hideMe();	
			}
		});
	
	
		function hideMe() { 
			hasfocus = 0;
			$("#"+elm_id+'_wheel').hide();
			$container.hide(); 
			$(".flashContainer").show();
		}
		
		function init() {
			$container.append(getSelectOptions($input.attr('id'))).hide();
			var width = $input.width() - parseInt($container.css('border-width'));
			$container.width(width);
			
			//Option list Height Setting
			//$("#"+elm_id+"_ul").css({'height':(19*rows)+"px"});
			/*
			if($container.height() < 19*rows)
			{
				var wheel = document.createElement("img");
				var $wheel = $(wheel);
				$wheel.attr('id', elm_id+'_wheel');
				$wheel.attr('src', '/images/select_box_icon_wheel.gif');
				if(opt.containerClass == 'search-selectbox-wrapper')
				{
					$wheel.css({'top':($container.height())+'px', 'left':($container.width()+12)+'px', 'position':'absolute', 'display':'none'})
				}
				else
				{
					$wheel.css({'top':($container.height())+'px', 'left':($container.width()+2)+'px', 'position':'absolute', 'display':'none'})
				}
				$container.parent().append($wheel);
			}
			//scroll Handler Height setting
			$('#'+elm_id+'_handler-vert').css({'height':(parseInt($('#'+elm_id+'_scrollbar-vert').css('height'))/parseInt($("#"+elm_id+"_ul").css('height')))*parseInt($('#'+elm_id+'_scrollbar-vert').css('height'))+"px"});
			*/
		}
		
		function setupContainer(options) {
			var container = document.createElement("div");
			$container = $(container);
			$this = $(container);
			$container.attr('id', elm_id+'_container');
			$container.addClass(options.containerClass);
			/*
			var scrollbar = document.createElement("div");
			$scrollbar = $(scrollbar);
			$scrollbar.attr('id', elm_id+'_scrollbar-vert');
			$scrollbar.addClass("scrollbar-vert");
			$container.append($scrollbar);
			
			var handler = document.createElement("div");
			$handler = $(handler);
			$handler.attr('id', elm_id+'_handler-vert');
			$handler.addClass("handler-vert");
			$container.append($handler);
			*/
			return $container;
		}
		
		function setupInput(options) {
			var input = document.createElement("input");
			var $input = $(input);
			$input.attr("id", elm_id+"_input");
			$input.attr("type", "text");
			$input.addClass(options.inputClass);
			$input.attr("autocomplete", "off");
			$input.attr("readonly", "readonly");
			$input.attr("tabIndex", $select.attr("tabindex")); // "I" capital is important for ie
			
			return $input;	
		}
		
		function moveSelect(step) {
			var lis = $("li", $container);
			if (!lis) return;
	
			active += step;
	
			if (active < 0) {
				active = 0;
			} else if (active >= lis.size()) {
				active = lis.size() - 1;
			}
	
			lis.removeClass(opt.hoverClass);
	
			$(lis[active]).addClass(opt.hoverClass);
		}
		
		function setCurrent() {	
			var li = $("li."+opt.currentClass, $container).get(0);
			var ar = (''+li.id).split('_');
			var el = ar[ar.length-1];
			$select.val(el);
			$input.val($(li).html());
			return true;
		}
		
		// select value
		function getCurrentSelected() {
			return $select.val();
		}
		
		// input value
		function getCurrentValue() {
			return $input.val();
		}
		
		// option list UL creat
		function getSelectOptions(parentid) {
			var select_options = new Array();
			var ul = document.createElement('ul');
			$(ul).attr('id',elm_id+"_ul");
			$select.children('option').each(function() {
				var li = document.createElement('li');
				li.setAttribute('id', parentid + '_' + $(this).val());
				li.innerHTML = $(this).html();
				if ($(this).is(':selected')) {
					$input.val($(this).html());
					$(li).addClass(opt.currentClass);
				}
				ul.appendChild(li);
				$(li)
				.mouseover(function(event) {
					hasfocus = 1;
					if (opt.debug) console.log('over on : '+this.id);
					jQuery(event.target, $container).addClass(opt.hoverClass);
				})
				.mouseout(function(event) {
					hasfocus = -1;
					if (opt.debug) console.log('out on : '+this.id);
					jQuery(event.target, $container).removeClass(opt.hoverClass);
				})
				.click(function(event) {
				  var fl = $('li.'+opt.hoverClass, $container).get(0);
					if (opt.debug) console.log('click on :'+this.id);
					$('li.'+opt.currentClass).removeClass(opt.currentClass); 
					$(this).addClass(opt.currentClass);
					setCurrent();
					hideMe();
					if(elm_id.indexOf("category") > -1)
					{
						if(elm_id.indexOf("category1") > -1)
						{
							if($("#"+elm_id).val() != "")
							{
								$.get('/layouts/parts/categoryselectbox.html?_cid='+$("#"+elm_id).val()+'&_lv=1',function(data){
									$('#categorySelectboxContainer2').html(data);
								
									$('#categorySelectboxContainer3').html('<select name="category3" id="category3" tabindex="1" class="selectbox_category"><option value="" selected="selected">¼±ÅÃÇØÁÖ¼¼¿ä!</option></select>');
									$('#category3').selectbox();
								})
							}
							else
							{
								$('#categorySelectboxContainer2').html('<select name="category2" id="category2" tabindex="1" class="selectbox_category"><option value="" selected="selected">¼±ÅÃÇØÁÖ¼¼¿ä!</option></select>');
								$('#category2').selectbox();
								
								$('#categorySelectboxContainer3').html('<select name="category3" id="category3" tabindex="1" class="selectbox_category"><option value="" selected="selected">¼±ÅÃÇØÁÖ¼¼¿ä!</option></select>');
								$('#category3').selectbox();
							}
						}
						else if(elm_id.indexOf("category2") > -1)
						{
							if($("#"+elm_id).val() != "")
							{
								$.get('/layouts/parts/categoryselectbox.html?_cid='+$("#"+elm_id).val()+'&_lv=2',function(data){
									$('#categorySelectboxContainer3').html(data);
								})
							}
							else
							{
								$('#categorySelectboxContainer3').html('<select name="category3" id="category3" tabindex="1" class="selectbox_category"><option value="" selected="selected">¼±ÅÃÇØÁÖ¼¼¿ä!</option></select>');
								$('#category3').selectbox();
							}
						}
						else if(elm_id.indexOf("category3") > -1)
						{
							if($("#"+elm_id).val() != "")
							{
								location.href = "/shop/cate.html?cid=" + $("#"+elm_id).val();
							}
						}
					}
				});
				rows = rows+1
			});
			/*
			// container inside UL scroll Event
			$(ul).bind('mousewheel', function(event, delta) {
				
				var dir = delta > 0 ? 'Up' : 'Down',
					vel = Math.abs(delta);
				
				var currentTop			= $(ul).css('top');
				var dimTop				= parseInt(currentTop.replace("px", ""));
				var currentHeight		= $(ul).css('height');
				var dimHeight			= parseInt(currentHeight.replace("px", ""));
				var handleHeight 		= Math.floor(($('#'+elm_id+'_scrollbar-vert').height()/dimHeight)*$('#'+elm_id+'_scrollbar-vert').height());
				var handleMoveLimited 	= $('#'+elm_id+'_scrollbar-vert').height() - handleHeight;
				var handleMoveLimitedTop = parseInt($('#'+elm_id+'_scrollbar-vert').css('top'));
				var currentMoveLenght 	= dimHeight - parseInt($('#'+elm_id+'_scrollbar-vert').css('height')) + 1 + (handleMoveLimitedTop*2);
				var MoveParsent = (dimTop+19/currentMoveLenght)* -1;
				
				// option list height > list contianer = scroll true
				if(dimHeight > 150)
				{
					if(delta < 0)
					{
						if(dimTop >= (dimHeight-$('#'+elm_id+'_scrollbar-vert').height())* -1)
						{
							$(ul).css({'top':dimTop-19+"px"});
							
							// handler Move set
							MoveParsent = ((dimTop-19)/currentMoveLenght)* -1;
							$('#'+elm_id+'_handler-vert').css({'top':(Math.floor(handleMoveLimited*MoveParsent) + handleMoveLimitedTop)+"px"});
						}
					}
					else
					{
						if(dimTop < (dimHeight)-$('#'+elm_id+'_scrollbar-vert').height() && dimTop <= -10)
						{
							$(ul).css({'top':dimTop+19+"px"});
							
							// handler Move set
							MoveParsent = ((dimTop+19)/currentMoveLenght)* -1;
							$('#'+elm_id+'_handler-vert').css({'top':(Math.floor(handleMoveLimited*MoveParsent) + handleMoveLimitedTop)+"px"});
						}
					}
				}
				return false;
			});
			*/
			return ul;
		}
};


/******************************************************************
numberbox
editor : Park Kyoung ho
date : 20100521
edit : 20100608

edit List
 - parent Object type <span></span>
 - resizing
 - readonly button Event remove

******************************************************************/
jQuery.fn.extend({numberbox: function(options){return this.each(function(){new jQuery.NumberBox(this, options)})}});
if(!window.console){var console = {log:function(msg){	}}};

jQuery.NumberBox = function(selectobj, options) {
	var opt=options||{};
	opt.border=opt.border||"1px solid #CCC";opt.width=opt.width||"100px";opt.height=opt.height||"16px";	opt.fontSize=opt.fontSize||"11px"; opt.wheelEvent=opt.wheelEvent||false; opt.low=opt.low||0;
	opt.inputClass=opt.inputClass||"numberbox-wrapper";opt.buttonClass1=opt.buttonClass1||"numberbox-wrapper-button1";opt.buttonClass2=opt.buttonClass2||"numberbox-wrapper-button2";
	var elm_id = selectobj;
	var $this = $(selectobj);
	var limitVal = $this.val().trim().replace(/[^0-9]/g, "");
	var $input1 = setupInput1(opt, "_up", opt.buttonClass1);
	var $input2 = setupInput1(opt, "_down",  opt.buttonClass2);
	if($this.attr('readonly') == false)
	{
		$input1.click(function (event) {
			// 20100617 modified by sorisaem <sorisaem@gmail.com>
			var val = Number($this.val().trim().replace(/[^0-9]/g, ""));
			$this.val(val + 1);
			$this.focus();
		});

		$input2.click(function (event) {
			// 20100617 modified by sorisaem <sorisaem@gmail.com>
			var val = Number($this.val().trim().replace(/[^0-9]/g, ""));
			if (val > limitVal) {
				$this.val(val - 1);
			}
			$this.focus();
		});

		// 20100617 created by sorisaem <sorisaem@gmail.com>
		$this.blur(function (event) {
			$this.val(Number($this.val().trim().replace(/[^0-9]/g, "")));
		});

		// 20100617 modified by sorisaem <sorisaem@gmail.com>
		if (opt.wheelEvent) {
			$this.bind("mousewheel", function (event, delta) {
				var dir = delta > 0 ? "Up" : "Down";
				var val = Number($this.val().trim().replace(/[^0-9]/g, ""));
				
				if (delta > 0) {
					$this.val(val + 1);
				} else {
					if (val > limitVal) {
						$this.val(val - 1);
					}
				}
				$this.focus();
				return false
			});
		}
	}

	function init(){
		$this.addClass(opt.inputClass);
		$this.css({'width':opt.width,'height':opt.height,'font-size':opt.fontSize,'border':opt.border});
		$this.parent().append($input1);
		$this.parent().append($input2);
	}

	function setupInput1(options,t,c){	var input = document.createElement("input");var $input=$(input);$input.attr("id",elm_id+t);$input.addClass(c);$input.attr("type","button");$input.attr("value"," ");$input.attr("autocomplete","off");return $input;	}
	init();
};

/******************************************************************
detailimage
editor : Park Kyoung ho
date : 20100521
edit : 20100608

edit List
 - Image list UL used
******************************************************************/
jQuery.fn.extend({detailimage:function(options){return this.each(function(){new jQuery.DetailImage(this,options);});}});
if(!window.console){var console={log:function(msg){}}}
jQuery.DetailImage = function(object,options){
	var opt = options || {};
	var elm_ID = object.id;
	var $container = $(object);
	
	var imagePopupContainer = document.createElement('div');
	$(imagePopupContainer).attr('id','imagePopupContainer');
	$(imagePopupContainer).attr('class','apple_overlay');
	
	var imageContainer = document.createElement('div');
	$(imageContainer).attr('id','imageContainer');
	$(imageContainer).attr('class','imageContainer');
	
	
	var titleContainer = document.createElement('div');
	$(titleContainer).attr('id','titleContainer');
	$(titleContainer).attr('class','titleContainer');
	
	var thumbContainer = document.createElement('div');
	$(thumbContainer).attr('id','thumbContainer');
	$(thumbContainer).attr('class','thumbContainer');
	
	var $imagePopupContainer = $(imagePopupContainer);
	var $titleContainer = $(titleContainer);
	var $imageContainer = $(imageContainer);
	var $thumbContainer = $(thumbContainer);
	
	$titleContainer.html($('#'+elm_ID+' .title').html());
	$('#'+elm_ID+' .img').each(function(index,domEle){
		if(index == 0){
			var img = document.createElement('img');
			var $img = $(img);
			$img.attr('id', 'currentImage')
			$img.attr('alt', $('#'+elm_ID+' .title').html())
			$img.attr('rel', '#imagePopupContainer')
			$img.attr('src', $(domEle).attr('image'))
			$img.click(function(event){$("#detailTopContainer .imageContainer .image[rel]").overlay({effect: 'apple'}).close()});
			$imageContainer.append($img);
		}
		
		var thumb = document.createElement('img');
		var $thumb = $(thumb);
		$thumb.attr('id', 'thumbImage');$thumb.attr('alt', 'thumb'+index);$thumb.attr('src', $(domEle).attr('thumb'));
		$thumb.mouseover(function(){$("#currentImage").attr('src', $(domEle).attr('image'))});
		$thumbContainer.append($thumb);
	});
	
	$imagePopupContainer.append($titleContainer);
	$imagePopupContainer.append($imageContainer);
	$imagePopupContainer.append($thumbContainer);
	$(document.body).append($imagePopupContainer);
};



/******************************************************************
overfullname
editor : Park Kyoung ho
date : 20100620
edit : 20100620

edit List
 - target over Full text view
******************************************************************/
jQuery.fn.extend({overfullname:function(options){return this.each(function(){new jQuery.OverFullName(this,options);});}});
if(!window.console){var console={log:function(msg){}}}
jQuery.OverFullName = function(object,options){
	var opt = options || {};
	opt.containerClass = opt.containerClass||"overFullName";
	opt.target = opt.target||"rel";
	var el = object;
	var elm_ID = $(el).attr(opt.target);
	var $container = $(object);
	$container.mouseover(function (event) {
			$("."+opt.containerClass).remove();
			var div = document.createElement("div");
			$(div).attr('id',elm_ID);
			$(div).addClass(opt.containerClass);
			$(div).html($(el).html());
			$(div).css({'top':(event.pageY+15)+'px','left':(event.pageX+15)+'px'});
			$(document.body).append(div);
	})
	$container.mouseout(function(event){
		$("."+opt.containerClass).remove();
	});
};



/******************************************************************
tablechange
editor : Park Kyoung ho
date : 20100625
edit : 20100625

edit List
 - td css change
******************************************************************/
jQuery.fn.extend({tablechange:function(options){return this.each(function(){new jQuery.TableChange(this,options);});}});
if(!window.console){var console={log:function(msg){}}}
jQuery.TableChange = function(object,options){
	var opt = options || {};
	var el = object;
	var $tb = $(el).parent().parent();
	var $tr = $(el).parent();
	var $td = $(el);
	//$tb.parent().css({'float':'right'});
	
	if($(el).html()=="")
	{
		$(el).css({'margin':'0px','padding':'0px'});
	}
	
	if($(el).css('height'))
	{
		$(el).css({'height':$(el).css('height')});
	}
	else if($(el).attr('height'))
	{
		$(el).css({'height':$(el).attr('height')+"px"});
	}
	$(el).removeAttr('height');
	
	if($(el).css('width'))
	{
		$(el).css({'width':$(el).css('width')});
	}
	else if($(el).attr('width'))
	{
		$(el).css({'width':$(el).attr('width')+"px"});
	}
	$(el).removeAttr('width');
	
	if($(el).attr('align')=="right")
	{
		$(el).css({'text-align':$(el).attr('align')});
	}
	else if($(el).attr('align')=="left")
	{
		$(el).css({'text-align':'left'});
	}
	else if($(el).attr('align')=="center")
	{
		$(el).css({'text-align':$(el).attr('align')});
	}
	else
	{
		$(el).css({'text-align':'left'});
	}
	$(el).removeAttr('align');
	
	if($(el).css('background-color'))
	{
		$(el).css({'background-color':$(el).css('background-color')});
	}
	else if($(el).attr('bgcolor'))
	{
		$(el).css({'background-color':$(el).attr('bgcolor')});
	}
	$(el).removeAttr('bgcolor');
	
	if($tb.attr('cellspacing'))
	{
		$(el).css({'margin':$tb.attr('cellspacing')+"px"});
	}
	
	if($tb.attr('cellpadding'))
	{
		$(el).css({'padding':$tb.attr('cellpadding')+"px"});
	}
	
	$(el).removeAttr('align');
};


/******************************************************************
SlideRoll
editor : Park Kyoung ho
date : 20100910
******************************************************************/
jQuery.fn.extend({
	slideroll:function(options){
		return this.each(function(){
			new jQuery.SlideRoll(this,options);
		});
	}
});

if(!window.console){
	var console={log:function(msg){}}
}

jQuery.SlideRoll = function(object,options){
	var opt = options || {};
	opt.mainclass = opt.mainclass	|| "slide_container";
	opt.cropclass = opt.cropclass	|| "crop_container";
	opt.listclass = opt.listclass	|| "list_container";
	opt.itemclass = opt.itemclass	|| "items_container";
	opt.arrowwidth = opt.arrowwidth || 20;
	opt.borderSize = opt.borderSize || 10;
	opt.debugclass = opt.debugclass	|| "slide_debug_container";
	
	opt.itemmargin = opt.itemmargin	|| 3;
	opt.itemwidth = opt.itemwidth	|| $(object).find("."+opt.itemclass).width();
	opt.itemmarginwidth = opt.itemmarginwidth	|| opt.itemwidth+(opt.itemmargin*2);
	opt.itemheight = opt.itemheight	|| $(object).find("."+opt.itemclass).height();
	
	opt.listwidth = opt.listwidth || $(object).find("."+opt.listclass).children().length*opt.itemmarginwidth;
	opt.listheight = opt.listheight || opt.itemheight;
	
	opt.cropwidth = opt.cropwidth || parseInt(($(object).width()-(opt.arrowwidth*2))/opt.itemmarginwidth)*opt.itemmarginwidth;
	opt.cropheight = opt.cropheight || opt.itemheight;
	
	opt.width = opt.width || $(object).width();
	opt.innerwidth = opt.innerwidth || opt.width-(opt.borderSize*2);
	opt.height = opt.height || opt.itemheight+(opt.borderSize*4);
	opt.innerheight = opt.innerheight || opt.height-(opt.borderSize*2);
	
	opt.leftarrow = opt.leftarrow || "/images/slideroll/slideroll_arrow_left.gif";
	opt.rightarrow = opt.rightarrow || "/images/slideroll/slideroll_arrow_right.gif";
	
	opt.index = opt.index || "0";
	opt.position = opt.position || "0";
	opt.length = opt.length || $(object).find("."+opt.itemclass).length;
	opt.viewlength = opt.viewlength || parseInt(opt.cropwidth/opt.itemmarginwidth);
	opt.duration = opt.duration || 200;
	
	opt.scrollclass = opt.scrollclass || "scroll_container";
	opt.scroll_l = opt.scroll_l || "scroll_l";
	opt.scroll_r = opt.scroll_r || "scroll_r";
	opt.scroll_bar = opt.scroll_bar || "scroll_bar";
	opt.scroll_bar_l = opt.scroll_bar_l || "scroll_bar_l";
	opt.scroll_bar_r = opt.scroll_bar_r || "scroll_bar_r";
	if(opt.viewlength < opt.length) {
		opt.scrollbarwidth = opt.scrollbarwidth || opt.cropwidth/(opt.length-(opt.viewlength-1));
	} else {
		opt.scrollbarwidth = opt.scrollbarwidth || opt.cropwidth;
	}
	
	opt.slide_top_bg		= opt.slide_top_bg || "slide_top_bg";
	opt.slide_top_left		= opt.slide_top_left || "slide_top_left";
	opt.slide_top_right		= opt.slide_top_right || "slide_top_right";
	opt.slide_bottom_bg		= opt.slide_bottom_bg || "slide_bottom_bg";
	opt.slide_bottom_left	= opt.slide_bottom_left || "slide_bottom_left";
	opt.slide_bottom_right	= opt.slide_bottom_right || "slide_bottom_right";
	opt.slide_middle_bg		= opt.slide_middle_bg || "slide_middle_bg";
	opt.slide_middle_left	= opt.slide_middle_left || "slide_middle_left";
	opt.slide_middle_right	= opt.slide_middle_right || "slide_middle_right";
	
	opt.arrow_l = opt.arrow_l || "arrow_l";
	opt.arrow_r = opt.arrow_r || "arrow_r";
	
	opt.bg = opt.bg || true;
	
	opt.debug = opt.debug || false;
	
	opt.autoScroll = opt.autoScroll || true;
	opt.autoScrollduration = opt.autoScrollduration || 5000;
	
	var el = this;
	
	var sliderol_timer;
	//main container
	var $container = $(object);
	var container_css = '"width":"'+opt.width+'px","height":"'+opt.height+'px"';
	
	if(opt.bg)
	{
		//bg
		
		var bg_contain_css = '"width":"'+opt.innerwidth+'px","height":"'+opt.innerheight+'px"';
		var bg_contain = bgElementCreat("div","",opt.slide_middle_bg,bg_contain_css);
		
		var bg_top_left = bgElementCreat("div","",opt.slide_top_left,"");
		
		var bg_top_right_css = '"left":"'+opt.innerwidth+'px"';
		var bg_top_right = bgElementCreat("div","",opt.slide_top_right,bg_top_right_css);
		
		var bg_top_bg_css = '"width":"'+opt.innerwidth+'px"';
		var bg_top_bg =  bgElementCreat("div","",opt.slide_top_bg,bg_top_bg_css);
		
		var bg_middle_left_css = '"height":"'+opt.innerheight+'px"';
		var bg_middle_left = bgElementCreat("div","",opt.slide_middle_left,bg_middle_left_css);
		
		var bg_middle_right_css = '"height":"'+opt.innerheight+'px","left":"'+opt.innerwidth+'px"';
		var bg_middle_right = bgElementCreat("div","",opt.slide_middle_right,bg_middle_right_css);
		
		var bg_bottom_left_css = '"top":"'+opt.innerheight+'px"';
		var bg_bottom_left = bgElementCreat("div","",opt.slide_bottom_left,bg_bottom_left_css);
		
		var bg_bottom_right_css = '"left":"'+opt.innerwidth+'px","top":"'+opt.innerheight+'px"';
		var bg_bottom_right = bgElementCreat("div","",opt.slide_bottom_right,bg_bottom_right_css);
		
		var bg_bottom_bg_css = '"width":"'+opt.innerwidth+'px","top":"'+opt.innerheight+'px"';
		var bg_bottom_bg = bgElementCreat("div","",opt.slide_bottom_bg,bg_bottom_bg_css);
		
		$(bg_contain).append(bg_top_left);
		$(bg_contain).append(bg_top_right);
		$(bg_contain).append(bg_top_bg);
		$(bg_contain).append(bg_middle_left);
		$(bg_contain).append(bg_middle_right);
		$(bg_contain).append(bg_bottom_left);
		$(bg_contain).append(bg_bottom_right);
		$(bg_contain).append(bg_bottom_bg);
		
		$container.append(bg_contain);
	}
	
	
	//crop container
	var $crop = $(object).find("."+opt.cropclass);
	var crop_css = '"width":"'+opt.cropwidth+'px","height":"'+opt.cropheight+'px"';
	crop_css += ',"left":"'+parseInt(((opt.width-opt.cropwidth)/2))+'px"';
	crop_css += ',"top":"'+parseInt(((opt.height-opt.cropheight)/3))+'px"';
	$crop.css(jQuery.parseJSON("{"+crop_css+"}"));
	
	//list container
	var $list = $(object).find("."+opt.listclass);
	var list_css = '"width":"'+opt.listwidth+'px","height":"'+opt.listheight+'px"';
	$list.css(jQuery.parseJSON("{"+list_css+"}"));
	
	//item container
	var $item = $(object).find("."+opt.itemclass);
	var item_css = '"width":"'+opt.itemwidth+'px","height":"'+opt.itemheight+'px","padding":"0px '+opt.itemmargin+'px"';
	$item.css(jQuery.parseJSON("{"+item_css+"}"));
	
	//scroll container
	var scroll_css = '"width":"'+opt.cropwidth+'px","left":"'+parseInt(((opt.width-opt.cropwidth)/2))+'px"';
	scroll_css += ',"top":"'+parseInt(opt.height-(opt.height-opt.cropheight)/2)+'px"';
	var scroll_container = bgElementCreat("div","",opt.scrollclass,scroll_css);
	var scroll_l = bgElementCreat("div","",opt.scroll_l,"");
	var scroll_r = bgElementCreat("div","",opt.scroll_r,"");
	
	var scroll_bar_css = '"width":"'+opt.scrollbarwidth+'px"';
	var scroll_bar = bgElementCreat("div","",opt.scroll_bar,scroll_bar_css);
	var scroll_bar_l = bgElementCreat("div","",opt.scroll_bar_l,"");
	var scroll_bar_r = bgElementCreat("div","",opt.scroll_bar_r,"");
	$scroll_bar = $container.find("."+opt.scroll_bar);
	
	$(scroll_container).append(scroll_l);
	$(scroll_container).append(scroll_r);
	$(scroll_bar).append(scroll_bar_l);
	$(scroll_bar).append(scroll_bar_r);
	$(scroll_container).append(scroll_bar);
	$container.append(scroll_container);
	
	var arrow_l = bgElementCreat("img",opt.leftarrow,opt.arrow_l,"");
	$container.append(arrow_l);
	
	var leftP1 = parseInt($(arrow_l).width()/2);
	var leftP2 = 0+parseInt((opt.width-opt.cropwidth)/4);
	var leftP3 = parseInt($(arrow_l).height()/2);
	var leftP4 = parseInt(opt.height/2);
	
	var arrow_l_css = '"left":"'+(leftP2-leftP1)+'px","top":"'+(leftP4-leftP3)+'px"';
	$(arrow_l).css(jQuery.parseJSON("{"+arrow_l_css+"}"))
	$(arrow_l).bind("click",function(){
		slideAnime(1,$scroll_bar,$list,opt);
	})
	
	var arrow_r = bgElementCreat("img",opt.rightarrow,opt.arrow_r,"");
	$container.append(arrow_r);
	
	var rightP1 = parseInt($(arrow_r).width()/2);
	var rightP2 = 0+parseInt((opt.width-opt.cropwidth)/4);
	var rightP3 = parseInt($(arrow_r).height()/2);
	var rightP4 = parseInt(opt.height/2);
	
	var arrow_r_css = '"left":"'+(opt.width-rightP2-rightP1)+'px","top":"'+(rightP4-rightP3)+'px"';
	$(arrow_r).css(jQuery.parseJSON("{"+arrow_r_css+"}"))
	$(arrow_r).bind("click",function(){
		slideAnime(-1,$scroll_bar,$list,opt);
	})
	
	if(opt.debug)
	{
		var debugView = document.createElement("div");
		$(debugView).addClass(opt.debugclass);
		
		$(debugView).append("SlideRoll Debuger =========================================<br/><br/>");
		
		$(debugView).append(opt);
		$(debugView).append("base container target ["+opt.mainclass+"]<br/>");
		$(debugView).append("base container size ["+opt.width+"px x "+opt.height+"px]<br/>");
		$(debugView).append("base container css =======================================<br/>"+container_css.split(",").join(", ")+"<br/>=========================================================<br/><br/>");
		$(debugView).append("crop container target ["+opt.cropclass+"]<br/>");
		$(debugView).append("crop container size ["+opt.cropwidth+" x "+opt.cropheight+"]<br/>");
		$(debugView).append("crop container css =======================================<br/>"+crop_css.split(",").join(", ")+"<br/>=========================================================<br/><br/>");
		$(debugView).append("list container target ["+opt.listclass+"]<br/>");
		$(debugView).append("list container size ["+opt.listwidth+" x "+opt.listheight+"]<br/>");
		$(debugView).append("list container css =======================================<br/>"+list_css.split(",").join(", ")+"<br/>=========================================================<br/><br/>");
		$(debugView).append("item container target ["+opt.itemclass+"]<br/>");
		$(debugView).append("item container size ["+opt.itemwidth+" x "+opt.itemheight+"]<br/>");
		$(debugView).append("item container css =======================================<br/>"+item_css.split(",").join(", ")+"<br/>=========================================================<br/><br/>");
		$(debugView).append("left container target ["+($(arrow_l).attr("class"))+"]<br/>");
		$(debugView).append("left container size ["+$(arrow_l).width()+" x "+$(arrow_l).height()+"]<br/>");
		$(debugView).append("left container css =======================================<br/>"+(arrow_l_css).split(",").join(", ")+"<br/>=========================================================<br/><br/>");
		$(debugView).append("right container target ["+($(arrow_r).attr("class"))+"]<br/>");
		$(debugView).append("right container size ["+$(arrow_r).width()+" x "+$(arrow_r).height()+"]<br/>");
		$(debugView).append("right container css =======================================<br/>"+(arrow_r_css).split(",").join(", ")+"<br/>=========================================================<br/><br/>");
		
		$(document.body).append(debugView)
	}
	
	function slideAnime(guide,scrollTemp,listTemp,optTemp){
		optTemp.position = parseInt($list.css('left'));
		if(guide > 0){
			if(optTemp.position < 0) {
				optTemp.index = optTemp.index+1;
				
				listTemp.animate({"left":(optTemp.index*opt.itemmarginwidth)+"px"}, optTemp.duration);
				$(object).find('.'+opt.scroll_bar).animate({"left":(optTemp.index*optTemp.scrollbarwidth*-1)+"px"}, optTemp.duration);
			}
			else
			{
				optTemp.index = (optTemp.length - opt.viewlength) * -1;
				
				listTemp.animate({"left":(optTemp.index*opt.itemmarginwidth)+"px"}, optTemp.duration);
				$(object).find('.'+opt.scroll_bar).animate({"left":(optTemp.index*optTemp.scrollbarwidth*-1)+"px"}, optTemp.duration);
			}
		}
		else if(guide < 0)
		{
			if(optTemp.position > ((optTemp.length-parseInt(optTemp.cropwidth/optTemp.itemmarginwidth)) * optTemp.itemwidth * -1)) {
				optTemp.index = optTemp.index-1;
				
				listTemp.animate({"left":(optTemp.index*opt.itemmarginwidth)+"px"}, optTemp.duration);
				$(object).find('.'+opt.scroll_bar).animate({"left":(optTemp.index*opt.scrollbarwidth*-1)+"px"}, optTemp.duration);
			}
			else
			{
				optTemp.index = 0;
				
				listTemp.animate({"left":(optTemp.index*opt.itemmarginwidth)+"px"}, optTemp.duration);
				$(object).find('.'+opt.scroll_bar).animate({"left":(optTemp.index*opt.scrollbarwidth*-1)+"px"}, optTemp.duration);
			}
		}
			
		if(opt.debug)
		{
			$(debugView).append("index : "+optTemp.index+"<br/>")
			$(debugView).append("list : "+listTemp.css("left")+" to "+(optTemp.index*opt.itemmarginwidth)+"px<br/>")
			$(debugView).append("scroll : "+$(object).find('.'+opt.scroll_bar).css("left")+" to "+(optTemp.index*optTemp.scrollbarwidth*-1)+"px<br/><br/>")
		}
	}
	
	function bgElementCreat(elementNode,elementSource,classTemp,cssTemp){
		var elementTemp = document.createElement(elementNode);
		if(elementSource != ""){elementTemp.src = elementSource;}
		if(cssTemp != ""){$(elementTemp).css(jQuery.parseJSON("{"+cssTemp+"}"));}
		$(elementTemp).addClass(classTemp);
		
		return elementTemp;
	}
	
	
	function sliderol_timer_function(){
		if($container.is(':visible')){
			slideAnime(-1,$scroll_bar,$list,opt);
		}
	}
	
	function settimer(){
		if(opt.length > opt.viewlength)
		{
			sliderol_timer = window.setInterval(sliderol_timer_function, opt.autoScrollduration);
		}
	}
	
	function removtimer(){
		window.clearInterval(sliderol_timer);
	}
	
	$container.css(jQuery.parseJSON("{"+container_css+"}"));
	
	$container.bind("mouseover",function(){
		removtimer();
	}).bind("mouseout",function(){
		settimer();
	})
	
	settimer();
};

/*
 * jQuery history plugin
 *
 * Copyright (c) 2006 Taku Sano (Mikage Sawatari)
 * Licensed under the MIT License:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Modified by Lincoln Cooper to add Safari support and only call the callback once during initialization
 * for msie when no initial hash supplied.
 * API rewrite by Lauris Buk? is-Haberkorns
 */

(function($) {

function History()
{
	this._curHash = '';
	this._callback = function(hash){};
};

$.extend(History.prototype, {

	init: function(callback) {
		this._callback = callback;
		this._curHash = location.hash;

		if($.browser.msie) {
			// To stop the callback firing twice during initilization if no hash present
			if (this._curHash == '') {
				this._curHash = '#';
			}

			// add hidden iframe for IE
			$("body").prepend('<iframe id="jQuery_history" style="display: none;"></iframe>');
			var iframe = $("#jQuery_history")[0].contentWindow.document;
			iframe.open();
			iframe.close();
			iframe.location.hash = this._curHash;
		}
		else if ($.browser.safari) {
			// etablish back/forward stacks
			this._historyBackStack = [];
			this._historyBackStack.length = history.length;
			this._historyForwardStack = [];
			this._isFirst = true;
			this._dontCheck = false;
		}
		this._callback(this._curHash.replace(/^#/, ''));
		setInterval(this._check, 100);
	},

	add: function(hash) {
		// This makes the looping function do something
		this._historyBackStack.push(hash);

		this._historyForwardStack.length = 0; // clear forwardStack (true click occured)
		this._isFirst = true;
	},

	_check: function() {
		if($.browser.msie) {
			// On IE, check for location.hash of iframe
			var ihistory = $("#jQuery_history")[0];
			var iframe = ihistory.contentDocument || ihistory.contentWindow.document;
			var current_hash = iframe.location.hash;
			if(current_hash != $.history._curHash) {

				location.hash = current_hash;
				$.history._curHash = current_hash;
				$.history._callback(current_hash.replace(/^#/, ''));

			}
		} else if ($.browser.safari) {
			if (!$.history._dontCheck) {
				var historyDelta = history.length - $.history._historyBackStack.length;

				if (historyDelta) { // back or forward button has been pushed
					$.history._isFirst = false;
					if (historyDelta < 0) { // back button has been pushed
						// move items to forward stack
						for (var i = 0; i < Math.abs(historyDelta); i++) $.history._historyForwardStack.unshift($.history._historyBackStack.pop());
					} else { // forward button has been pushed
						// move items to back stack
						for (var i = 0; i < historyDelta; i++) $.history._historyBackStack.push($.history._historyForwardStack.shift());
					}
					var cachedHash = $.history._historyBackStack[$.history._historyBackStack.length - 1];
					if (cachedHash != undefined) {
						$.history._curHash = location.hash;
						$.history._callback(cachedHash);
					}
				} else if ($.history._historyBackStack[$.history._historyBackStack.length - 1] == undefined && !$.history._isFirst) {
					// back button has been pushed to beginning and URL already pointed to hash (e.g. a bookmark)
					// document.URL doesn't change in Safari
					if (document.URL.indexOf('#') >= 0) {
						$.history._callback(document.URL.split('#')[1]);
					} else {
						$.history._callback('');
					}
					$.history._isFirst = true;
				}
			}
		} else {
			// otherwise, check for location.hash
			var current_hash = location.hash;
			if(current_hash != $.history._curHash) {
				$.history._curHash = current_hash;
				$.history._callback(current_hash.replace(/^#/, ''));
			}
		}
	},

	load: function(hash) {
		var newhash;

		if ($.browser.safari) {
			newhash = hash;
		} else {
			newhash = '#' + hash;
			location.hash = newhash;
		}
		this._curHash = newhash;

		if ($.browser.msie) {
			var ihistory = $("#jQuery_history")[0]; // TODO: need contentDocument?
			var iframe = ihistory.contentWindow.document;
			iframe.open();
			iframe.close();
			iframe.location.hash = newhash;
			this._callback(hash);
		}
		else if ($.browser.safari) {
			this._dontCheck = true;
			// Manually keep track of the history values for Safari
			this.add(hash);

			// Wait a while before allowing checking so that Safari has time to update the "history" object
			// correctly (otherwise the check loop would detect a false change in hash).
			var fn = function() {$.history._dontCheck = false;};
			window.setTimeout(fn, 200);
			this._callback(hash);
			// N.B. "location.hash=" must be the last line of code for Safari as execution stops afterwards.
			//      By explicitly using the "location.hash" command (instead of using a variable set to "location.hash") the
			//      URL in the browser and the "history" object are both updated correctly.
			location.hash = newhash;
		}
		else {
		  this._callback(hash);
		}
	}
});

$(document).ready(function() {
	$.history = new History(); // singleton instance
});

})(jQuery);

