/*!
 * jQuery UI 1.8
 *
 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI
 */
/*
 * jQuery UI 1.8
 *
 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI
 */
jQuery.ui||(function(a){a.ui={version:"1.8",plugin:{add:function(c,d,f){var e=a.ui[c].prototype;for(var b in f){e.plugins[b]=e.plugins[b]||[];e.plugins[b].push([d,f[b]])}},call:function(b,d,c){var f=b.plugins[d];if(!f||!b.element[0].parentNode){return}for(var e=0;e<f.length;e++){if(b.options[f[e][0]]){f[e][1].apply(b.element,c)}}}},contains:function(d,c){return document.compareDocumentPosition?d.compareDocumentPosition(c)&16:d!==c&&d.contains(c)},hasScroll:function(e,c){if(a(e).css("overflow")=="hidden"){return false}var b=(c&&c=="left")?"scrollLeft":"scrollTop",d=false;if(e[b]>0){return true}e[b]=1;d=(e[b]>0);e[b]=0;return d},isOverAxis:function(c,b,d){return(c>b)&&(c<(b+d))},isOver:function(g,c,f,e,b,d){return a.ui.isOverAxis(g,f,b)&&a.ui.isOverAxis(c,e,d)},keyCode:{BACKSPACE:8,CAPS_LOCK:20,COMMA:188,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38}};a.fn.extend({_focus:a.fn.focus,focus:function(b,c){return typeof b==="number"?this.each(function(){var d=this;setTimeout(function(){a(d).focus();(c&&c.call(d))},b)}):this._focus.apply(this,arguments)},enableSelection:function(){return this.attr("unselectable","off").css("MozUserSelect","").unbind("selectstart.ui")},disableSelection:function(){return this.attr("unselectable","on").css("MozUserSelect","none").bind("selectstart.ui",function(){return false})},scrollParent:function(){var b;if((a.browser.msie&&(/(static|relative)/).test(this.css("position")))||(/absolute/).test(this.css("position"))){b=this.parents().filter(function(){return(/(relative|absolute|fixed)/).test(a.curCSS(this,"position",1))&&(/(auto|scroll)/).test(a.curCSS(this,"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0)}else{b=this.parents().filter(function(){return(/(auto|scroll)/).test(a.curCSS(this,"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0)}return(/fixed/).test(this.css("position"))||!b.length?a(document):b},zIndex:function(e){if(e!==undefined){return this.css("zIndex",e)}if(this.length){var c=a(this[0]),b,d;while(c.length&&c[0]!==document){b=c.css("position");if(b=="absolute"||b=="relative"||b=="fixed"){d=parseInt(c.css("zIndex"));if(!isNaN(d)&&d!=0){return d}}c=c.parent()}}return 0}});a.extend(a.expr[":"],{data:function(d,c,b){return !!a.data(d,b[3])},focusable:function(c){var d=c.nodeName.toLowerCase(),b=a.attr(c,"tabindex");return(/input|select|textarea|button|object/.test(d)?!c.disabled:"a"==d||"area"==d?c.href||!isNaN(b):!isNaN(b))&&!a(c)["area"==d?"parents":"closest"](":hidden").length},tabbable:function(c){var b=a.attr(c,"tabindex");return(isNaN(b)||b>=0)&&a(c).is(":focusable")}})})(jQuery);;/*!
 * jQuery UI Widget 1.8
 *
 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI/Widget
 */
/*
 * jQuery UI Widget 1.8
 *
 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI/Widget
 */
(function(b){var a=b.fn.remove;b.fn.remove=function(c,d){return this.each(function(){if(!d){if(!c||b.filter(c,[this]).length){b("*",this).add(this).each(function(){b(this).triggerHandler("remove")})}}return a.call(b(this),c,d)})};b.widget=function(d,f,c){var e=d.split(".")[0],h;d=d.split(".")[1];h=e+"-"+d;if(!c){c=f;f=b.Widget}b.expr[":"][h]=function(i){return !!b.data(i,d)};b[e]=b[e]||{};b[e][d]=function(i,j){if(arguments.length){this._createWidget(i,j)}};var g=new f();g.options=b.extend({},g.options);b[e][d].prototype=b.extend(true,g,{namespace:e,widgetName:d,widgetEventPrefix:b[e][d].prototype.widgetEventPrefix||d,widgetBaseClass:h},c);b.widget.bridge(d,b[e][d])};b.widget.bridge=function(d,c){b.fn[d]=function(g){var e=typeof g==="string",f=Array.prototype.slice.call(arguments,1),h=this;g=!e&&f.length?b.extend.apply(null,[true,g].concat(f)):g;if(e&&g.substring(0,1)==="_"){return h}if(e){this.each(function(){var i=b.data(this,d),j=i&&b.isFunction(i[g])?i[g].apply(i,f):i;if(j!==i&&j!==undefined){h=j;return false}})}else{this.each(function(){var i=b.data(this,d);if(i){if(g){i.option(g)}i._init()}else{b.data(this,d,new c(g,this))}})}return h}};b.Widget=function(c,d){if(arguments.length){this._createWidget(c,d)}};b.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:false},_createWidget:function(d,e){this.element=b(e).data(this.widgetName,this);this.options=b.extend(true,{},this.options,b.metadata&&b.metadata.get(e)[this.widgetName],d);var c=this;this.element.bind("remove."+this.widgetName,function(){c.destroy()});this._create();this._init()},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName);this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+"-disabled "+this.namespace+"-state-disabled")},widget:function(){return this.element},option:function(e,f){var d=e,c=this;if(arguments.length===0){return b.extend({},c.options)}if(typeof e==="string"){if(f===undefined){return this.options[e]}d={};d[e]=f}b.each(d,function(g,h){c._setOption(g,h)});return c},_setOption:function(c,d){this.options[c]=d;if(c==="disabled"){this.widget()[d?"addClass":"removeClass"](this.widgetBaseClass+"-disabled "+this.namespace+"-state-disabled").attr("aria-disabled",d)}return this},enable:function(){return this._setOption("disabled",false)},disable:function(){return this._setOption("disabled",true)},_trigger:function(d,e,f){var h=this.options[d];e=b.Event(e);e.type=(d===this.widgetEventPrefix?d:this.widgetEventPrefix+d).toLowerCase();f=f||{};if(e.originalEvent){for(var c=b.event.props.length,g;c;){g=b.event.props[--c];e[g]=e.originalEvent[g]}}this.element.trigger(e,f);return !(b.isFunction(h)&&h.call(this.element[0],e,f)===false||e.isDefaultPrevented())}}})(jQuery);;/*!
 * jQuery UI Mouse 1.8
 *
 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI/Mouse
 *
 * Depends:
 *    jquery.ui.widget.js
 */
/*
 * jQuery UI Mouse 1.8
 *
 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI/Mouse
 *
 * Depends:
 *    jquery.ui.widget.js
 */
(function(a){a.widget("ui.mouse",{options:{cancel:":input,option",distance:1,delay:0},_mouseInit:function(){var b=this;this.element.bind("mousedown."+this.widgetName,function(c){return b._mouseDown(c)}).bind("click."+this.widgetName,function(c){if(b._preventClickEvent){b._preventClickEvent=false;c.stopImmediatePropagation();return false}});this.started=false},_mouseDestroy:function(){this.element.unbind("."+this.widgetName)},_mouseDown:function(d){d.originalEvent=d.originalEvent||{};if(d.originalEvent.mouseHandled){return}(this._mouseStarted&&this._mouseUp(d));this._mouseDownEvent=d;var c=this,e=(d.which==1),b=(typeof this.options.cancel=="string"?a(d.target).parents().add(d.target).filter(this.options.cancel).length:false);if(!e||b||!this._mouseCapture(d)){return true}this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet){this._mouseDelayTimer=setTimeout(function(){c.mouseDelayMet=true},this.options.delay)}if(this._mouseDistanceMet(d)&&this._mouseDelayMet(d)){this._mouseStarted=(this._mouseStart(d)!==false);if(!this._mouseStarted){d.preventDefault();return true}}this._mouseMoveDelegate=function(f){return c._mouseMove(f)};this._mouseUpDelegate=function(f){return c._mouseUp(f)};a(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate);(a.browser.safari||d.preventDefault());d.originalEvent.mouseHandled=true;return true},_mouseMove:function(b){if(a.browser.msie&&!b.button){return this._mouseUp(b)}if(this._mouseStarted){this._mouseDrag(b);return b.preventDefault()}if(this._mouseDistanceMet(b)&&this._mouseDelayMet(b)){this._mouseStarted=(this._mouseStart(this._mouseDownEvent,b)!==false);(this._mouseStarted?this._mouseDrag(b):this._mouseUp(b))}return !this._mouseStarted},_mouseUp:function(b){a(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=false;this._preventClickEvent=(b.target==this._mouseDownEvent.target);this._mouseStop(b)}return false},_mouseDistanceMet:function(b){return(Math.max(Math.abs(this._mouseDownEvent.pageX-b.pageX),Math.abs(this._mouseDownEvent.pageY-b.pageY))>=this.options.distance)},_mouseDelayMet:function(b){return this.mouseDelayMet},_mouseStart:function(b){},_mouseDrag:function(b){},_mouseStop:function(b){},_mouseCapture:function(b){return true}})})(jQuery);;/*
 * jQuery UI Draggable 1.8
 *
 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI/Draggables
 *
 * Depends:
 *    jquery.ui.core.js
 *    jquery.ui.mouse.js
 *    jquery.ui.widget.js
 */
(function(a){a.widget("ui.draggable",a.ui.mouse,{widgetEventPrefix:"drag",options:{addClasses:true,appendTo:"parent",axis:false,connectToSortable:false,containment:false,cursor:"auto",cursorAt:false,grid:false,handle:false,helper:"original",iframeFix:false,opacity:false,refreshPositions:false,revert:false,revertDuration:500,scope:"default",scroll:true,scrollSensitivity:20,scrollSpeed:20,snap:false,snapMode:"both",snapTolerance:20,stack:false,zIndex:false},_create:function(){if(this.options.helper=="original"&&!(/^(?:r|a|f)/).test(this.element.css("position"))){this.element[0].style.position="relative"}(this.options.addClasses&&this.element.addClass("ui-draggable"));(this.options.disabled&&this.element.addClass("ui-draggable-disabled"));this._mouseInit()},destroy:function(){if(!this.element.data("draggable")){return}this.element.removeData("draggable").unbind(".draggable").removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled");this._mouseDestroy();return this},_mouseCapture:function(b){var c=this.options;if(this.helper||c.disabled||a(b.target).is(".ui-resizable-handle")){return false}this.handle=this._getHandle(b);if(!this.handle){return false}return true},_mouseStart:function(b){var c=this.options;this.helper=this._createHelper(b);this._cacheHelperProportions();if(a.ui.ddmanager){a.ui.ddmanager.current=this}this._cacheMargins();this.cssPosition=this.helper.css("position");this.scrollParent=this.helper.scrollParent();this.offset=this.positionAbs=this.element.offset();this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left};a.extend(this.offset,{click:{left:b.pageX-this.offset.left,top:b.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()});this.originalPosition=this.position=this._generatePosition(b);this.originalPageX=b.pageX;this.originalPageY=b.pageY;(c.cursorAt&&this._adjustOffsetFromHelper(c.cursorAt));if(c.containment){this._setContainment()}if(this._trigger("start",b)===false){this._clear();return false}this._cacheHelperProportions();if(a.ui.ddmanager&&!c.dropBehaviour){a.ui.ddmanager.prepareOffsets(this,b)}this.helper.addClass("ui-draggable-dragging");this._mouseDrag(b,true);return true},_mouseDrag:function(b,d){this.position=this._generatePosition(b);this.positionAbs=this._convertPositionTo("absolute");if(!d){var c=this._uiHash();if(this._trigger("drag",b,c)===false){this._mouseUp({});return false}this.position=c.position}if(!this.options.axis||this.options.axis!="y"){this.helper[0].style.left=this.position.left+"px"}if(!this.options.axis||this.options.axis!="x"){this.helper[0].style.top=this.position.top+"px"}if(a.ui.ddmanager){a.ui.ddmanager.drag(this,b)}return false},_mouseStop:function(c){var d=false;if(a.ui.ddmanager&&!this.options.dropBehaviour){d=a.ui.ddmanager.drop(this,c)}if(this.dropped){d=this.dropped;this.dropped=false}if(!this.element[0]||!this.element[0].parentNode){return false}if((this.options.revert=="invalid"&&!d)||(this.options.revert=="valid"&&d)||this.options.revert===true||(a.isFunction(this.options.revert)&&this.options.revert.call(this.element,d))){var b=this;a(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){if(b._trigger("stop",c)!==false){b._clear()}})}else{if(this._trigger("stop",c)!==false){this._clear()}}return false},cancel:function(){if(this.helper.is(".ui-draggable-dragging")){this._mouseUp({})}else{this._clear()}return this},_getHandle:function(b){var c=!this.options.handle||!a(this.options.handle,this.element).length?true:false;a(this.options.handle,this.element).find("*").andSelf().each(function(){if(this==b.target){c=true}});return c},_createHelper:function(c){var d=this.options;var b=a.isFunction(d.helper)?a(d.helper.apply(this.element[0],[c])):(d.helper=="clone"?this.element.clone():this.element);if(!b.parents("body").length){b.appendTo((d.appendTo=="parent"?this.element[0].parentNode:d.appendTo))}if(b[0]!=this.element[0]&&!(/(fixed|absolute)/).test(b.css("position"))){b.css("position","absolute")}return b},_adjustOffsetFromHelper:function(b){if(typeof b=="string"){b=b.split(" ")}if(a.isArray(b)){b={left:+b[0],top:+b[1]||0}}if("left" in b){this.offset.click.left=b.left+this.margins.left}if("right" in b){this.offset.click.left=this.helperProportions.width-b.right+this.margins.left}if("top" in b){this.offset.click.top=b.top+this.margins.top}if("bottom" in b){this.offset.click.top=this.helperProportions.height-b.bottom+this.margins.top}},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var b=this.offsetParent.offset();if(this.cssPosition=="absolute"&&this.scrollParent[0]!=document&&a.ui.contains(this.scrollParent[0],this.offsetParent[0])){b.left+=this.scrollParent.scrollLeft();b.top+=this.scrollParent.scrollTop()}if((this.offsetParent[0]==document.body)||(this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&a.browser.msie)){b={top:0,left:0}}return{top:b.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:b.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var b=this.element.position();return{top:b.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:b.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}else{return{top:0,left:0}}},_cacheMargins:function(){this.margins={left:(parseInt(this.element.css("marginLeft"),10)||0),top:(parseInt(this.element.css("marginTop"),10)||0)}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var e=this.options;if(e.containment=="parent"){e.containment=this.helper[0].parentNode}if(e.containment=="document"||e.containment=="window"){this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,a(e.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(a(e.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top]}if(!(/^(document|window|parent)$/).test(e.containment)&&e.containment.constructor!=Array){var c=a(e.containment)[0];if(!c){return}var d=a(e.containment).offset();var b=(a(c).css("overflow")!="hidden");this.containment=[d.left+(parseInt(a(c).css("borderLeftWidth"),10)||0)+(parseInt(a(c).css("paddingLeft"),10)||0)-this.margins.left,d.top+(parseInt(a(c).css("borderTopWidth"),10)||0)+(parseInt(a(c).css("paddingTop"),10)||0)-this.margins.top,d.left+(b?Math.max(c.scrollWidth,c.offsetWidth):c.offsetWidth)-(parseInt(a(c).css("borderLeftWidth"),10)||0)-(parseInt(a(c).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,d.top+(b?Math.max(c.scrollHeight,c.offsetHeight):c.offsetHeight)-(parseInt(a(c).css("borderTopWidth"),10)||0)-(parseInt(a(c).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top]}else{if(e.containment.constructor==Array){this.containment=e.containment}}},_convertPositionTo:function(f,h){if(!h){h=this.position}var c=f=="absolute"?1:-1;var e=this.options,b=this.cssPosition=="absolute"&&!(this.scrollParent[0]!=document&&a.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,g=(/(html|body)/i).test(b[0].tagName);return{top:(h.top+this.offset.relative.top*c+this.offset.parent.top*c-(a.browser.safari&&a.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():(g?0:b.scrollTop()))*c)),left:(h.left+this.offset.relative.left*c+this.offset.parent.left*c-(a.browser.safari&&a.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():g?0:b.scrollLeft())*c))}},_generatePosition:function(e){var h=this.options,b=this.cssPosition=="absolute"&&!(this.scrollParent[0]!=document&&a.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,i=(/(html|body)/i).test(b[0].tagName);var d=e.pageX;var c=e.pageY;if(this.originalPosition){if(this.containment){if(e.pageX-this.offset.click.left<this.containment[0]){d=this.containment[0]+this.offset.click.left}if(e.pageY-this.offset.click.top<this.containment[1]){c=this.containment[1]+this.offset.click.top}if(e.pageX-this.offset.click.left>this.containment[2]){d=this.containment[2]+this.offset.click.left}if(e.pageY-this.offset.click.top>this.containment[3]){c=this.containment[3]+this.offset.click.top}}if(h.grid){var g=this.originalPageY+Math.round((c-this.originalPageY)/h.grid[1])*h.grid[1];c=this.containment?(!(g-this.offset.click.top<this.containment[1]||g-this.offset.click.top>this.containment[3])?g:(!(g-this.offset.click.top<this.containment[1])?g-h.grid[1]:g+h.grid[1])):g;var f=this.originalPageX+Math.round((d-this.originalPageX)/h.grid[0])*h.grid[0];d=this.containment?(!(f-this.offset.click.left<this.containment[0]||f-this.offset.click.left>this.containment[2])?f:(!(f-this.offset.click.left<this.containment[0])?f-h.grid[0]:f+h.grid[0])):f}}return{top:(c-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+(a.browser.safari&&a.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():(i?0:b.scrollTop())))),left:(d-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(a.browser.safari&&a.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():i?0:b.scrollLeft())))}},_clear:function(){this.helper.removeClass("ui-draggable-dragging");if(this.helper[0]!=this.element[0]&&!this.cancelHelperRemoval){this.helper.remove()}this.helper=null;this.cancelHelperRemoval=false},_trigger:function(b,c,d){d=d||this._uiHash();a.ui.plugin.call(this,b,[c,d]);if(b=="drag"){this.positionAbs=this._convertPositionTo("absolute")}return a.Widget.prototype._trigger.call(this,b,c,d)},plugins:{},_uiHash:function(b){return{helper:this.helper,position:this.position,originalPosition:this.originalPosition,offset:this.positionAbs}}});a.extend(a.ui.draggable,{version:"1.8"});a.ui.plugin.add("draggable","connectToSortable",{start:function(c,e){var d=a(this).data("draggable"),f=d.options,b=a.extend({},e,{item:d.element});d.sortables=[];a(f.connectToSortable).each(function(){var g=a.data(this,"sortable");if(g&&!g.options.disabled){d.sortables.push({instance:g,shouldRevert:g.options.revert});g._refreshItems();g._trigger("activate",c,b)}})},stop:function(c,e){var d=a(this).data("draggable"),b=a.extend({},e,{item:d.element});a.each(d.sortables,function(){if(this.instance.isOver){this.instance.isOver=0;d.cancelHelperRemoval=true;this.instance.cancelHelperRemoval=false;if(this.shouldRevert){this.instance.options.revert=true}this.instance._mouseStop(c);this.instance.options.helper=this.instance.options._helper;if(d.options.helper=="original"){this.instance.currentItem.css({top:"auto",left:"auto"})}}else{this.instance.cancelHelperRemoval=false;this.instance._trigger("deactivate",c,b)}})},drag:function(c,f){var e=a(this).data("draggable"),b=this;var d=function(i){var n=this.offset.click.top,m=this.offset.click.left;var g=this.positionAbs.top,k=this.positionAbs.left;var j=i.height,l=i.width;var p=i.top,h=i.left;return a.ui.isOver(g+n,k+m,p,h,j,l)};a.each(e.sortables,function(g){this.instance.positionAbs=e.positionAbs;this.instance.helperProportions=e.helperProportions;this.instance.offset.click=e.offset.click;if(this.instance._intersectsWith(this.instance.containerCache)){if(!this.instance.isOver){this.instance.isOver=1;this.instance.currentItem=a(b).clone().appendTo(this.instance.element).data("sortable-item",true);this.instance.options._helper=this.instance.options.helper;this.instance.options.helper=function(){return f.helper[0]};c.target=this.instance.currentItem[0];this.instance._mouseCapture(c,true);this.instance._mouseStart(c,true,true);this.instance.offset.click.top=e.offset.click.top;this.instance.offset.click.left=e.offset.click.left;this.instance.offset.parent.left-=e.offset.parent.left-this.instance.offset.parent.left;this.instance.offset.parent.top-=e.offset.parent.top-this.instance.offset.parent.top;e._trigger("toSortable",c);e.dropped=this.instance.element;e.currentItem=e.element;this.instance.fromOutside=e}if(this.instance.currentItem){this.instance._mouseDrag(c)}}else{if(this.instance.isOver){this.instance.isOver=0;this.instance.cancelHelperRemoval=true;this.instance.options.revert=false;this.instance._trigger("out",c,this.instance._uiHash(this.instance));this.instance._mouseStop(c,true);this.instance.options.helper=this.instance.options._helper;this.instance.currentItem.remove();if(this.instance.placeholder){this.instance.placeholder.remove()}e._trigger("fromSortable",c);e.dropped=false}}})}});a.ui.plugin.add("draggable","cursor",{start:function(c,d){var b=a("body"),e=a(this).data("draggable").options;if(b.css("cursor")){e._cursor=b.css("cursor")}b.css("cursor",e.cursor)},stop:function(b,c){var d=a(this).data("draggable").options;if(d._cursor){a("body").css("cursor",d._cursor)}}});a.ui.plugin.add("draggable","iframeFix",{start:function(b,c){var d=a(this).data("draggable").options;a(d.iframeFix===true?"iframe":d.iframeFix).each(function(){a('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>').css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1000}).css(a(this).offset()).appendTo("body")})},stop:function(b,c){a("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)})}});a.ui.plugin.add("draggable","opacity",{start:function(c,d){var b=a(d.helper),e=a(this).data("draggable").options;if(b.css("opacity")){e._opacity=b.css("opacity")}b.css("opacity",e.opacity)},stop:function(b,c){var d=a(this).data("draggable").options;if(d._opacity){a(c.helper).css("opacity",d._opacity)}}});a.ui.plugin.add("draggable","scroll",{start:function(c,d){var b=a(this).data("draggable");if(b.scrollParent[0]!=document&&b.scrollParent[0].tagName!="HTML"){b.overflowOffset=b.scrollParent.offset()}},drag:function(d,e){var c=a(this).data("draggable"),f=c.options,b=false;if(c.scrollParent[0]!=document&&c.scrollParent[0].tagName!="HTML"){if(!f.axis||f.axis!="x"){if((c.overflowOffset.top+c.scrollParent[0].offsetHeight)-d.pageY<f.scrollSensitivity){c.scrollParent[0].scrollTop=b=c.scrollParent[0].scrollTop+f.scrollSpeed}else{if(d.pageY-c.overflowOffset.top<f.scrollSensitivity){c.scrollParent[0].scrollTop=b=c.scrollParent[0].scrollTop-f.scrollSpeed}}}if(!f.axis||f.axis!="y"){if((c.overflowOffset.left+c.scrollParent[0].offsetWidth)-d.pageX<f.scrollSensitivity){c.scrollParent[0].scrollLeft=b=c.scrollParent[0].scrollLeft+f.scrollSpeed}else{if(d.pageX-c.overflowOffset.left<f.scrollSensitivity){c.scrollParent[0].scrollLeft=b=c.scrollParent[0].scrollLeft-f.scrollSpeed}}}}else{if(!f.axis||f.axis!="x"){if(d.pageY-a(document).scrollTop()<f.scrollSensitivity){b=a(document).scrollTop(a(document).scrollTop()-f.scrollSpeed)}else{if(a(window).height()-(d.pageY-a(document).scrollTop())<f.scrollSensitivity){b=a(document).scrollTop(a(document).scrollTop()+f.scrollSpeed)}}}if(!f.axis||f.axis!="y"){if(d.pageX-a(document).scrollLeft()<f.scrollSensitivity){b=a(document).scrollLeft(a(document).scrollLeft()-f.scrollSpeed)}else{if(a(window).width()-(d.pageX-a(document).scrollLeft())<f.scrollSensitivity){b=a(document).scrollLeft(a(document).scrollLeft()+f.scrollSpeed)}}}}if(b!==false&&a.ui.ddmanager&&!f.dropBehaviour){a.ui.ddmanager.prepareOffsets(c,d)}}});a.ui.plugin.add("draggable","snap",{start:function(c,d){var b=a(this).data("draggable"),e=b.options;b.snapElements=[];a(e.snap.constructor!=String?(e.snap.items||":data(draggable)"):e.snap).each(function(){var g=a(this);var f=g.offset();if(this!=b.element[0]){b.snapElements.push({item:this,width:g.outerWidth(),height:g.outerHeight(),top:f.top,left:f.left})}})},drag:function(u,p){var g=a(this).data("draggable"),q=g.options;var y=q.snapTolerance;var x=p.offset.left,w=x+g.helperProportions.width,f=p.offset.top,e=f+g.helperProportions.height;for(var v=g.snapElements.length-1;v>=0;v--){var s=g.snapElements[v].left,n=s+g.snapElements[v].width,m=g.snapElements[v].top,A=m+g.snapElements[v].height;if(!((s-y<x&&x<n+y&&m-y<f&&f<A+y)||(s-y<x&&x<n+y&&m-y<e&&e<A+y)||(s-y<w&&w<n+y&&m-y<f&&f<A+y)||(s-y<w&&w<n+y&&m-y<e&&e<A+y))){if(g.snapElements[v].snapping){(g.options.snap.release&&g.options.snap.release.call(g.element,u,a.extend(g._uiHash(),{snapItem:g.snapElements[v].item})))}g.snapElements[v].snapping=false;continue}if(q.snapMode!="inner"){var c=Math.abs(m-e)<=y;var z=Math.abs(A-f)<=y;var j=Math.abs(s-w)<=y;var k=Math.abs(n-x)<=y;if(c){p.position.top=g._convertPositionTo("relative",{top:m-g.helperProportions.height,left:0}).top-g.margins.top}if(z){p.position.top=g._convertPositionTo("relative",{top:A,left:0}).top-g.margins.top}if(j){p.position.left=g._convertPositionTo("relative",{top:0,left:s-g.helperProportions.width}).left-g.margins.left}if(k){p.position.left=g._convertPositionTo("relative",{top:0,left:n}).left-g.margins.left}}var h=(c||z||j||k);if(q.snapMode!="outer"){var c=Math.abs(m-f)<=y;var z=Math.abs(A-e)<=y;var j=Math.abs(s-x)<=y;var k=Math.abs(n-w)<=y;if(c){p.position.top=g._convertPositionTo("relative",{top:m,left:0}).top-g.margins.top}if(z){p.position.top=g._convertPositionTo("relative",{top:A-g.helperProportions.height,left:0}).top-g.margins.top}if(j){p.position.left=g._convertPositionTo("relative",{top:0,left:s}).left-g.margins.left}if(k){p.position.left=g._convertPositionTo("relative",{top:0,left:n-g.helperProportions.width}).left-g.margins.left}}if(!g.snapElements[v].snapping&&(c||z||j||k||h)){(g.options.snap.snap&&g.options.snap.snap.call(g.element,u,a.extend(g._uiHash(),{snapItem:g.snapElements[v].item})))}g.snapElements[v].snapping=(c||z||j||k||h)}}});a.ui.plugin.add("draggable","stack",{start:function(c,d){var f=a(this).data("draggable").options;var e=a.makeArray(a(f.stack)).sort(function(h,g){return(parseInt(a(h).css("zIndex"),10)||0)-(parseInt(a(g).css("zIndex"),10)||0)});if(!e.length){return}var b=parseInt(e[0].style.zIndex)||0;a(e).each(function(g){this.style.zIndex=b+g});this[0].style.zIndex=b+e.length}});a.ui.plugin.add("draggable","zIndex",{start:function(c,d){var b=a(d.helper),e=a(this).data("draggable").options;if(b.css("zIndex")){e._zIndex=b.css("zIndex")}b.css("zIndex",e.zIndex)},stop:function(b,c){var d=a(this).data("draggable").options;if(d._zIndex){a(c.helper).css("zIndex",d._zIndex)}}})})(jQuery);;

var flag = false;
var shift_x;
var shift_y;

var lastZ = 100;

indicator_image = new Image();
indicator_image.src = "/_img/indicator.gif";

jQuery.fn.center = function(params) {

        var options = {

            vertical: true,
            horizontal: true

        }
        op = jQuery.extend(options, params);

   return this.each(function(){

        //initializing variables
        var $self = jQuery(this);
        //get the dimensions using dimensions plugin
        var width = $self.width();
        var height = $self.height();
        //get the paddings
        var paddingTop = parseInt($self.css("padding-top"));
        var paddingBottom = parseInt($self.css("padding-bottom"));
        //get the borders
        var borderTop = parseInt($self.css("border-top-width"));
        var borderBottom = parseInt($self.css("border-bottom-width"));
        //get the media of padding and borders
        var mediaBorder = (borderTop+borderBottom)/2;
        var mediaPadding = (paddingTop+paddingBottom)/2;
        // get the half minus of width and height
        var halfWidth = (width/2)*(-1)-mediaPadding-mediaBorder;
        var halfHeight = ((height/2)*(-1))-mediaPadding-mediaBorder;
        // initializing the css properties
                
        //aplying the css
        $(this).css('left','50%');
        $(this).css('top','50%');
        $(this).css('margin-left',halfWidth + 'px');
        $(this).css('margin-top',halfHeight + 'px');
   });

};


$(document).ready(function() {
    $('.popUpWindow').draggable();
})


//brand
function show_brand_window(method_name) {
    $('.popUpWindow').not( $('#brand_window') ).hide();
    $('#brand_window').show().center();
}
function hide_brand_window() {
    $('#brand_window').hide();
}
function search_brand() {
    if (window.XMLHttpRequest) {
        obj_req = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        obj_req = new ActiveXObject("Microsoft.XMLHTTP");
    }
	if (obj_req) {
		obj_req.onreadystatechange = result_search_brand;
		var brand = document.getElementById("brand").value;
		url = '/ajax_search_brand.php';
		url += '?brand='+brand;
		
		obj_req.open("POST", encodeURI(url+""),true);
		obj_req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		obj_req.setRequestHeader("Content-Length", url.length);
		obj_req.send(url);
	}
}
function result_search_brand()  {
    if (obj_req.readyState == 4) {  
		if (obj_req.status == 200) {
			response = obj_req.responseXML.documentElement;
			result_data = response.getElementsByTagName("exp_data")[0].firstChild.data;
			result_flag = response.getElementsByTagName("result_flag")[0].firstChild.data;
			if (result_flag == 1) {
				document.getElementById("div_brand").innerHTML = result_data;
				document.getElementById('div_brand').style.display = "block";
			} else {
				document.getElementById('div_brand').style.display = "none";
			}
		}
	}
}
function set_brand(title) {
	document.getElementById('brand').value = title;
	document.getElementById('div_brand').style.display = "none";
}

//region
function show_region_window(method_name) {
    $('.popUpWindow').not( $('#region_window') ).hide();
	$('#region_window').show().center();
}
function hide_region_window() {
	$('#region_window').hide();
}
function getit(value) {
	document.getElementById('region').value= value;
	hide_region_window();
}

function getit(value) {
	document.getElementById('region').value= value;
	hide_region_window();
}

//registration
function show_registration_window(method_name) {
    $('.popUpWindow').not( $('#registration_window') ).hide();
    $('#registration_window').show().center();
}
function hide_registration_window() {
    $('.popUpWindow').hide();
}
function http_registration_processor() {
    if (window.XMLHttpRequest) {
        obj_req = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        obj_req = new ActiveXObject("Microsoft.XMLHTTP");
    }
	if (obj_req) {
		obj_req.onreadystatechange = result_get_sent_registration;
		var reg_login = document.getElementById("reg_login").value;
		var reg_password = document.getElementById("reg_password").value;
		var reg_double_password = document.getElementById("reg_double_password").value;
		var reg_email = document.getElementById("reg_email").value;
		url = '/ajax_sent_registration.php';
		url += '?login='+reg_login;
		url += '&password='+reg_password;
		url += '&double_password='+reg_double_password;
		url += '&email='+reg_email;
		url += '&flag_auth=1';
		
		document.getElementById("result_registration_string").innerHTML =  "<img src=\"/_img/indicator.gif\"/> Wait...";
		obj_req.open("POST", encodeURI(url+""),true);
		obj_req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		obj_req.setRequestHeader("Content-Length", url.length);
		obj_req.send(url);
	}
}

function result_get_sent_registration()  {
    if (obj_req.readyState == 4) {  
		if (obj_req.status == 200) {
			response = obj_req.responseXML.documentElement;
			result_data = response.getElementsByTagName("message")[0].firstChild.data;
			result_flag = response.getElementsByTagName("result_flag")[0].firstChild.data;
			if (result_flag == 1) {
				document.getElementById("result_registration_string").innerHTML = "";
				document.getElementById("form_registration").innerHTML = "<b>"+result_data+"</b><br/>"+"<img src=\"/_img/indicator.gif\"/> Reload...";
				document.getElementById('form_registration_close').style.display = "block";

				setTimeout("location.reload();", 1000);

			} else {
				document.getElementById("result_registration_string").innerHTML = "<b>"+result_data+"</b>";
			}
		}
	}
}
//authorization

//registration
function show_authorization_window(method_name) {
    $('.popUpWindow').not( $('#authorization_window') ).hide();
	$('#authorization_window').show().center();
	
}
function hide_authorization_window() {
    $('#authorization_window').hide();
}
function http_authorization_processor() {
    if (window.XMLHttpRequest) {
        obj_req = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        obj_req = new ActiveXObject("Microsoft.XMLHTTP");
    }
	if (obj_req) {
		obj_req.onreadystatechange = result_get_sent_authorization;
		var au_login = document.getElementById("au_login").value;
		var au_password = document.getElementById("au_password").value;
		url = '/ajax_sent_authorization.php';
		url += '?login='+au_login;
		url += '&password='+au_password;
		url += '&flag_auth=1';

		document.getElementById("result_authorization_string").innerHTML =  "<img src=\"/_img/indicator.gif\"/> Wait...";

		obj_req.open("POST", encodeURI(url+""),true);
		obj_req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		obj_req.setRequestHeader("Content-Length", url.length);
		obj_req.send(url);

	}
}

function result_get_sent_authorization()  {
    if (obj_req.readyState == 4) {  
		if (obj_req.status == 200) {
			response = obj_req.responseXML.documentElement;
			result_data = response.getElementsByTagName("message")[0].firstChild.data;
			result_flag = response.getElementsByTagName("result_flag")[0].firstChild.data;
			if (result_flag == 1) {
				document.getElementById("result_authorization_string").innerHTML = "";
				document.getElementById("form_authorization").innerHTML = "<b>"+result_data+"</b><br/>"+"<img src=\"/_img/indicator.gif\"/> Reload...";
				setTimeout("document.location.reload();", 1000);
				document.getElementById('form_authorization_close').style.display = "block";


				document.getElementById('show_authorization_window').style.display = "none";
				document.getElementById('show_registration_window').style.display = "none";
				//document.getElementById('profile_window').style.display = "inline";
				document.getElementById('logout_window').style.display = "inline";				

				//fam_name = response.getElementsByTagName("fam_name")[0].firstChild.data;
				//document.getElementById("fam_name").innerHTML = fam_name;
				

			} else {
				document.getElementById("result_authorization_string").innerHTML = "<b>"+result_data+"</b>";
			}
		}
	}
}




//logout
function http_logout_processor() {
    if (window.XMLHttpRequest) {
        obj_req = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        obj_req = new ActiveXObject("Microsoft.XMLHTTP");
    }
	if (obj_req) {
		obj_req.onreadystatechange = result_get_logout;
		url = '/ajax_sent_logout.php';
		url += '?logout=1';
		obj_req.open("POST", encodeURI(url+""),true);
		obj_req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		obj_req.setRequestHeader("Content-Length", url.length);
		obj_req.send(url);

	}
}
function result_get_logout()  {
    if (obj_req.readyState == 4) {  
		if (obj_req.status == 200) {
			setTimeout("location.reload();", 1000);
		}
	}
}


//feedback
function show_feedback_window(method_name) 
{
    $('.popUpWindow').not( $('#feedback_window') ).hide();
	$('#feedback_window').show().center();
}
function hide_feedback_window() {
	$('#feedback_window').hide();
}
function http_feedback_processor() {
    if (window.XMLHttpRequest) {
        obj_req = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        obj_req = new ActiveXObject("Microsoft.XMLHTTP");
    }
	if (obj_req) {
		obj_req.onreadystatechange = result_get_sent_feedback;
		var fb_title = document.getElementById("fb_title").value;
		var fb_email = document.getElementById("fb_email").value;
		var fb_name = document.getElementById("fb_name").value;
		var fb_text = document.getElementById("fb_text").value;
		
		url = '/ajax_sent_feedback.php';
		url += '?title='+fb_title;
		url += '&email='+fb_email;
		url += '&name='+fb_name;
		url += '&text='+fb_text;
		document.getElementById("result_feedback_string").innerHTML =  "<img src=\"/_img/indicator.gif\"/> Wait...";

		obj_req.open("POST", encodeURI(url+""),true);
		obj_req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		obj_req.setRequestHeader("Content-Length", url.length);
		obj_req.send(url);

	}
}

function show_sent_pass_window(method_name) {

	$('#sent_pass_window').show().center();

}

function hide_sent_pass_window() {

	$('#sent_pass_window').hide();

}

function http_sent_pass_processor() {

    if (window.XMLHttpRequest) {

        obj_req = new XMLHttpRequest();

    } else if (window.ActiveXObject) {

        obj_req = new ActiveXObject("Microsoft.XMLHTTP");

    }

	if (obj_req) {

		obj_req.onreadystatechange = result_get_sent_pass;

		var email = document.getElementById("email").value;

		url = '/ajax_sent_pass.php';

		url += '?email='+email;



		document.getElementById("result_sent_pass_string").innerHTML =  "<img src=\"/_img/indicator.gif\"/> Wait...";



		obj_req.open("POST", encodeURI(url+""),true);

		obj_req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

		obj_req.setRequestHeader("Content-Length", url.length);

		obj_req.send(url);



	}

}

function result_get_sent_pass()  {

    if (obj_req.readyState == 4) {

		if (obj_req.status == 200) {

			response = obj_req.responseXML.documentElement;

			result_data = response.getElementsByTagName("message")[0].firstChild.data;

			result_flag = response.getElementsByTagName("result_flag")[0].firstChild.data;

			if (result_flag == 1) {

				document.getElementById("result_sent_pass_string").innerHTML = "";

				document.getElementById("form_sent_pass").innerHTML = "<b>"+result_data+"</b><br/>";

				document.getElementById('form_sent_pass_close').style.display = "block";

			} else {

				document.getElementById("result_sent_pass_string").innerHTML = "<b>"+result_data+"</b>";

			}

		}

	}

}




function result_get_sent_feedback()  {
    if (obj_req.readyState == 4) {  
		if (obj_req.status == 200) {
			response = obj_req.responseXML.documentElement;
			result_data = response.getElementsByTagName("message")[0].firstChild.data;
			result_flag = response.getElementsByTagName("result_flag")[0].firstChild.data;
			if (result_flag == 1) {
				document.getElementById("result_feedback_string").innerHTML = "";
				document.getElementById("form_feedback").innerHTML = "<b>"+result_data+"</b><br/>";
				document.getElementById('form_feedback_close').style.display = "block";
			} else {
				document.getElementById("result_feedback_string").innerHTML = "<b>"+result_data+"</b>";
			}
		}
	}
}

//subscribe
function show_subscribe_window(method_name) {
    $('.popUpWindow').not( $('#subscribe_window') ).hide();
    $('#subscribe_window').show().center();
}
function hide_subscribe_window() {
	$('#subscribe_window').hide();
    
}
function http_subscribe_processor() {
    if (window.XMLHttpRequest) {
        obj_req = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        obj_req = new ActiveXObject("Microsoft.XMLHTTP");
    }
	if (obj_req) {
		obj_req.onreadystatechange = result_get_sent_subscribe;
		var su_email = document.getElementById("su_email").value;
		
		url = '/ajax_sent_subscribe.php';
		url += '?email='+su_email;
		document.getElementById("result_subscribe_string").innerHTML =  "<img src=\"/_img/indicator.gif\"/> Wait...";

		obj_req.open("POST", encodeURI(url+""),true);
		obj_req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		obj_req.setRequestHeader("Content-Length", url.length);
		obj_req.send(url);

	}
}

function result_get_sent_subscribe()  {
    if (obj_req.readyState == 4) {  
		if (obj_req.status == 200) {
			response = obj_req.responseXML.documentElement;
			result_data = response.getElementsByTagName("message")[0].firstChild.data;
			result_flag = response.getElementsByTagName("result_flag")[0].firstChild.data;
			if (result_flag == 1) {
				document.getElementById("result_subscribe_string").innerHTML = "";
				document.getElementById("form_subscribe").innerHTML = "<b>"+result_data+"</b><br/>";
				document.getElementById('form_subscribe_close').style.display = "block";
			} else {
				document.getElementById("result_subscribe_string").innerHTML = "<b>"+result_data+"</b>";
			}
		}
	}
}

//shop
function search_shop() {
    if (window.XMLHttpRequest) {
        obj_req = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        obj_req = new ActiveXObject("Microsoft.XMLHTTP");
    }
	if (obj_req) {
		obj_req.onreadystatechange = result_search_shop;
		var shop = document.getElementById("shop").value;
		url = '/ajax_search_shop.php';
		url += '?shop='+shop;

		obj_req.open("POST", encodeURI(url+""),true);
		obj_req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		obj_req.setRequestHeader("Content-Length", url.length);
		obj_req.send(url);
	}
}
function result_search_shop()  {
    if (obj_req.readyState == 4) {  
		if (obj_req.status == 200) {
			response = obj_req.responseXML.documentElement;
			result_data = response.getElementsByTagName("exp_data")[0].firstChild.data;
			result_flag = response.getElementsByTagName("result_flag")[0].firstChild.data;
			if (result_flag == 1) {
				document.getElementById("div_shop").innerHTML = result_data;
				document.getElementById('div_shop').style.display = "block";
			} else {
				document.getElementById('div_shop').style.display = "none";
			}
		}
	}
}
function set_shop(title) {
	document.getElementById('shop').value = title;
	document.getElementById('div_shop').style.display = "none";
}

function make_slider(id,wdth,addwdth){
    if( $('#'+id+' ul').width()>wdth )
    {
        var container = $('#'+id);
        $('.slider', container).slider({
            max: ($('#'+id+' ul').width() - addwdth ),
            handle: '.handle',
            stop: function (event, ui) {
                $(this).siblings('ul').animate({'left' : ui.value * -1}, 500);
            },
            slide: function (event, ui) {
                $(this).siblings('ul').css('left', ui.value * -1);
            }
        });
    }
    else
    {
        $('#'+id+' .slider').hide();
    }
}

/*$(document).ready(function() {
						   
    
    if( $('div.sliderGallery-inner ul').width()>385 )
    {
        var container = $('div.sliderGallery-inner');
        $('.slider', container).slider({
            max: ($('div.sliderGallery-inner ul').width() - 364 ),
            handle: '.handle',
            stop: function (event, ui) {
                $(this).siblings('ul').animate({'left' : ui.value * -1}, 500);
            },
            slide: function (event, ui) {
                $(this).siblings('ul').css('left', ui.value * -1);
            }
        });
    }
    else
    {
        $('.sliderGallery-inner .slider').hide();
    }
    
    if( $('div.sliderGallery-inner2 ul').width()>384 )
    {
        var container = $('div.sliderGallery-inner2');
        $('.slider2', container).slider({
            max: ($('div.sliderGallery-inner ul').width() - 364 ),
            handle: '.handle2',
            stop: function (event, ui) {
                $(this).siblings('ul').animate({'left' : ui.value * -1}, 500);
            },
            slide: function (event, ui) {
                $(this).siblings('ul').css('left', ui.value * -1);
            }
        });
    }
    else
    {
        $('.sliderGallery-inner2 .slider').hide();
    }
    
    
    if( $('div.sliderGallery-main ul').width()>353 )
    {
        var container = $('div.sliderGallery-inner2');
        $('.slider', container).slider({
            max: ($('div.sliderGallery-main ul').width() - 364 ),
            handle: '.handle',
            stop: function (event, ui) {
                $(this).siblings('ul').animate({'left' : ui.value * -1}, 500);
            },
            slide: function (event, ui) {
                $(this).siblings('ul').css('left', ui.value * -1);
            }
        });
    }
    else
    {
        $('.sliderGallery-main .slider').hide();
    }
})*/

function formUl(id,width,classAdd){
    var idattr=id.replace('#','');
    var html="<ul id='list-"+idattr+"' class='select-list";
    if(classAdd)html+=classAdd;
    html+="' >";
    $(id).find('option').each(
    function(){
            html+='<li val="'+$(this).val()+'" style="width:'+width+'px;">';
            if(!classAdd)html+='<img class="select-img" src="'+$(this).attr('src')+'" width="15" height="15"  />';
            html+=$(this).html()+'</li>';
              }
    )
    html+="</ul>";
    return html;
}
function findval(id,val){
     var html='';
     $(id).find('option').each(
     function(){
      if($(this).val()==$(id).val()){
               html=$(this).html()
              }
            }
        )
     return html; 
}
function findsrc(id,val){
     var html='';
     $(id).find('option').each(
     function(){
      if($(this).val()==$(id).val()){
               html=$(this).attr('src')
              }
            }
        )
     return html; 
}
function addActions(id,id_s,id_l,use){
     $(id).find('li').each(
     function(){
     $(this).click(
     function(){
        $(id_s).val($(this).attr('val'));
        $(id_l).html($(this).html());
        $(id).css('display','none');
        if(use){check_store(1); recalc_total();}
     }
     )
     $(this).hover(
     function(){
            $(this).addClass('hover');
            },
     function(){
            $(this).removeClass('hover');
            }
            )
          }
        )
}
function change_select(id,classAdd,use){
   var t=$(id);
   t.css('display','none');
   var width=t.width(); 
   var attrid=t.attr('id');
   var html='<div class="container-select"'
   if(id=='#s1')html+=' style="z-index:1;"';
   html+='><a id="select-'+attrid+'" href="'+t.val()+'" class="select-bg';
   if(classAdd)html+=classAdd;
   html+=' input-bord">';
   if(!classAdd)html+='<img id="img-'+attrid+'" class="select-img" src="img" width="15" height="15" />';
   html+=findval(id,t.val())+'</a>'; 
   html+=formUl(id,width,classAdd);
   html+="</div>";
   t.after(html);
   $('#'+'select-'+attrid).css('width',width);
   if(!classAdd)$('#'+'img-'+attrid).attr('src',findsrc(id,t.val()));
   addActions("#list-"+attrid,'#'+attrid,'#'+'select-'+attrid,use);
   $('#'+'select-'+attrid).click(
   function(){
    if($('#'+'list-'+attrid).css('display')=='none')
    $('#'+'list-'+attrid).css('display','block');
    else $('#'+'list-'+attrid).css('display','none');
    return false;
   }
   )
}
 
 
 $(function() {
  var cssFix = function(){
  var u = navigator.userAgent.toLowerCase(),
  addClass = function(el,val){
    if(!el.className) {
      el.className = val;
    } else {
      var newCl = el.className;
      newCl+=(" "+val);
      el.className = newCl;
    }
  },
  is = function(t){return (u.indexOf(t)!=-1)};
  addClass(document.getElementsByTagName('html')[0],[
    (!(/opera|webtv/i.test(u))&&/msie (\d)/.test(u))?('ie ie'+RegExp.$1)
      :is('firefox/2')?'gecko ff2'
      :is('firefox/3')?'gecko ff3'
      :is('gecko/')?'gecko'
      :is('opera/9')?'opera opera9':/opera (\d)/.test(u)?'opera opera'+RegExp.$1
      :is('konqueror')?'konqueror'
      :is('applewebkit/')?'webkit safari'
      :is('mozilla/')?'gecko':'',
    (is('x11')||is('linux'))?' linux'
      :is('mac')?' mac'
      :is('win')?' win':''
  ].join(" "));
}();

  
  if($.browser.mozilla){
    var u = navigator.userAgent.toLowerCase();
    if(/firefox\/3.0/i.test(u)||/firefox\/3.1/i.test(u)||/firefox\/3.2/i.test(u)||/firefox\/3.3/i.test(u)||/firefox\/3.4/i.test(u))
    $(".sort-mnu").css("margin-top","-20px");                                                            
 }
 });
