var theSecs = 0;
(function($) {
  
    jQuery.fn.countDown = function(o) {
        if ($(this).length == 0) { return false; }
        o = $.extend({
            countTime: 10000,
            displayFormat: "%%H%% %%M%% %%S%%",
            countActive: true,
            countStepper: -1,
            leadingZero: true,
            useId: true,
            pollTime: false,
            pollFrequency: 30,
            saletime: "",
            finishFunction: function() { }
        }, o || {});


        CountStepper = Math.ceil(o.countStepper);
        DisplayFormat = o.displayFormat;
        LeadingZero = o.leadingZero;
        CountActive = o.countActive;
        CountTime = o.countTime;
        UseId = o.useId;
        PollTime = o.pollTime;
        PollFrequency = o.pollFrequency;
        saleTime = o.saleTime;
        finishFunction = o.finishFunction;
        Elements = this;
        SetTimeOutPeriod = 990;
        //$.fn.countDown.CountBack(o.countTime);
        if (PollTime) {
            $.getJSON(getTimeUrl + "?callback=?", { "st": saleTime }, function(data) {
                if (data.status == -1) {
                    $.fn.countDown.CountBack(o.countTime);
                    return;
                } else {
                    $.fn.countDown.CountBack(data.seconds);
                    return;
                }
            });
         } else {
            $.fn.countDown.CountBack(o.countTime);
            return;
         }
    }

    function calcage(secs, num1, num2, id) {
        s = ((Math.floor(secs / num1)) % num2).toString();
        if ((LeadingZero && s.length < 2) || (id == "s" && s.length < 2))
            s = "0" + s;
        if (UseId) {
            return '<span id="' + id + '">' + s + '</span>';
        } else {
            return '<span>' + s + '</span>';
        }
    }


    $.fn.countDown.CountBack = function(secs) {
        if (secs < 0) {
            $('#cntdwn').hide();
            $('#starts').html('This collection is on sale now.').css("right", "20px");
            finishFunction.call(this);
            return;
        }
        //DisplayStr = DisplayFormat.replace(/%%D%%/g, calcage(secs,86400,100000, "d"));
        DisplayStr = DisplayFormat.replace(/%%H%%/g, calcage(secs, 3600, 48, "h"));
        DisplayStr = DisplayStr.replace(/%%M%%/g, calcage(secs, 60, 60, "m"));
        DisplayStr = DisplayStr.replace(/%%S%%/g, calcage(secs, 1, 60, "s"));
        $(Elements).html(DisplayStr);

        var doSetTimeout = false;

        if (PollTime && ((secs % 300) == 0 || secs == 120 || secs == 60 || secs == 30 || secs == 15)) {
            $.getJSON(getTimeUrl + "?callback=?", { "st": saleTime }, function(data) {
                if (data.status == -1) {
                    return;
                } else {
                    $.fn.countDown.CountBack(data.seconds);
                    return;
                }
            });
        } else {
            if (CountActive) { doSetTimeout = true; }
        }
        if (doSetTimeout) {
            setTimeout("$.fn.countDown.CountBack(" + (secs + CountStepper) + ")", SetTimeOutPeriod);
        }
    }
})(jQuery);

var int=0;(function($){$.fn.jCarouselLite=function(o){o=$.extend({btnPrev:null,btnNext:null,btnGo:null,curInd:null,mouseWheel:false,auto:null,speed:200,easing:null,vertical:false,circular:true,visible:3,start:0,scroll:1,beforeStart:null,afterEnd:null},o||{});return this.each(function(){var running=false,animCss=o.vertical?"top":"left",sizeCss=o.vertical?"height":"width";var div=$(this),ul=$("ul",div),tLi=$("li",ul),tl=tLi.size(),v=o.visible;if(tl<=1){if(o.btnPrev){$(o.btnPrev).hide()}
if(o.btnNext){$(o.btnNext).hide()}
if(o.curInd){$(o.curInd).hide()}
$('.carousel ul li').css("display","block");$('#share1').css({"left":"20px","bottom":"23px"})
if($(this).children("ul").children("li").hasClass("sold")){$('#share1').hide();}
return false;}
if(o.circular){ul.prepend(tLi.slice(tl-v-1+1).clone()).append(tLi.slice(0,v).clone());o.start+=v;}
$('.carousel ul li').css("display","block");var li=$("li",ul),itemLength=li.size(),curr=o.start;div.css("visibility","visible");if($(vis()).hasClass("sold")){$("#share1, #share2, #share3").hide();}
li.css({overflow:"hidden",float:o.vertical?"none":"left"});ul.css({margin:"0",padding:"0",position:"relative","list-style-type":"none","z-index":"1"});div.css({overflow:"hidden",position:"relative","z-index":"2",left:"0px"});var liSize=o.vertical?height(li):width(li);var ulSize=liSize*itemLength;var divSize=liSize*v;var int=null;li.css({width:li.width(),height:li.height()});ul.css(sizeCss,ulSize+"px").css(animCss,-(curr*liSize));div.css(sizeCss,divSize+"px");if(o.btnPrev)
$(o.btnPrev).click(function(){$.fn.jCarouselLite.stop();return go(curr-o.scroll);});if(o.btnNext)
$(o.btnNext).click(function(){$.fn.jCarouselLite.stop();return go(curr+o.scroll);});if(o.curInd)
$(o.curInd).append(li.slice(curr).attr("value"));if(o.btnGo)
$.each(o.btnGo,function(i,val){$(val).click(function(){return go(o.circular?o.visible+i:i);});});if(o.mouseWheel&&div.mousewheel)
div.mousewheel(function(e,d){return d>0?go(curr-o.scroll):go(curr+o.scroll);});if(o.auto)
window.int=setInterval(function(){go(curr+o.scroll);},o.auto+o.speed);function vis(){return li.slice(curr).slice(0,v);};function go(to){if(!running){if(o.beforeStart)
o.beforeStart.call(this,vis());if(o.circular){if(to<=o.start-v-1){ul.css(animCss,-((itemLength-(v*2))*liSize)+"px");curr=to==o.start-v-1?itemLength-(v*2)-1:itemLength-(v*2)-o.scroll;}else if(to>=itemLength-v+1){ul.css(animCss,-((v)*liSize)+"px");curr=to==itemLength-v+1?v+1:v+o.scroll;}else curr=to;}else{if(to<0||to>itemLength-v)return;else curr=to;}
if(o.curInd)
$(o.curInd).html(li.slice(curr).attr("value"));running=true;ul.animate(animCss=="left"?{left:-(curr*liSize)}:{top:-(curr*liSize)},o.speed,o.easing,function(){if(o.afterEnd)
o.afterEnd.call(this,vis());running=false;});if(!o.circular){$(o.btnPrev+","+o.btnNext).removeClass("disabled");$((curr-o.scroll<0&&o.btnPrev)||(curr+o.scroll>itemLength-v&&o.btnNext)||[]).addClass("disabled");}}
return false;};});};function css(el,prop){return parseInt($.css(el[0],prop))||0;};function width(el){return el[0].offsetWidth+css(el,'marginLeft')+css(el,'marginRight');};function height(el){return el[0].offsetHeight+css(el,'marginTop')+css(el,'marginBottom');};$.fn.jCarouselLite.stop=function(){int=window.clearInterval(int);}})(jQuery);(function($){$.facebox=function(data,klass){$.facebox.loading()
if(data.ajax)fillFaceboxFromAjax(data.ajax,klass)
else if(data.div)fillFaceboxFromHref(data.div,klass)
else if($.isFunction(data))data.call($)
else $.facebox.reveal(data,klass)}
$.extend($.facebox,{settings:{opacity:0.5,overlay:true,useIframe:false,frameWidth:476,frameHeight:571,loadingImage:'images/loading.gif',closeImage:'images/img-close.gif',imageTypes:['png','jpg','jpeg','gif'],faceboxHtml:'\
    <div id="facebox" style="display:none;"> \
      <div class="popup"> \
        <table> \
          <tbody> \
            <tr> \
              <td class="body"> \
                <div class="content"> \
                </div> \
              </td> \
            </tr> \
          </tbody> \
        </table> \
      </div> \
    </div>'},loading:function(){init()
if($('#facebox .loading').length==1)return true
showOverlay()
$('#facebox .content').empty()
$('#facebox .body').children().hide().end().append('<div class="loading"><img src="'+$.facebox.settings.loadingImage+'"/></div>')
$('#facebox').css({top:getPageScroll()[1]+(getPageHeight()/10),left:$(window).width()/2-205}).show()
$(document).bind('keydown.facebox',function(e){if(e.keyCode==27)$.facebox.close()
return true})
$(document).trigger('loading.facebox')},reveal:function(data,klass){$(document).trigger('beforeReveal.facebox')
if(klass)$('#facebox .content').addClass(klass)
$('#facebox .content').append(data)
$('#facebox .loading').remove()
$('#facebox .body').children().fadeIn('normal')
$('#facebox').css('left',$(window).width()/2-($('#facebox table').width()/2))
$(document).trigger('reveal.facebox').trigger('afterReveal.facebox')},close:function(){$(document).trigger('close.facebox')
return}})
$.fn.facebox=function(settings){init(settings)
function clickHandler(){$.facebox.loading(true)
var klass=this.rel.match(/facebox\[?\.(\w+)\]?/)
if(klass)klass=klass[1]
fillFaceboxFromHref(this.href,klass)
return false}
return this.bind('click.facebox',clickHandler)}
function init(settings){if($.facebox.settings.inited)return true
else $.facebox.settings.inited=true
$(document).trigger('init.facebox')
makeCompatible()
var imageTypes=$.facebox.settings.imageTypes.join('|')
$.facebox.settings.imageTypesRegexp=new RegExp('\.('+imageTypes+')$','i')
if(settings)$.extend($.facebox.settings,settings)
$('body').append($.facebox.settings.faceboxHtml)
var preload=[new Image(),new Image()]
preload[0].src=$.facebox.settings.closeImage
preload[1].src=$.facebox.settings.loadingImage
$('#facebox').find('.b:first, .bl, .br, .tl, .tr').each(function(){preload.push(new Image())
preload.slice(-1).src=$(this).css('background-image').replace(/url\((.+)\)/,'$1')})
$('#facebox .close').click($.facebox.close)
$('#facebox .close_image').attr('src',$.facebox.settings.closeImage)}
function getPageScroll(){var xScroll,yScroll;if(self.pageYOffset){yScroll=self.pageYOffset;xScroll=self.pageXOffset;}else if(document.documentElement&&document.documentElement.scrollTop){yScroll=document.documentElement.scrollTop;xScroll=document.documentElement.scrollLeft;}else if(document.body){yScroll=document.body.scrollTop;xScroll=document.body.scrollLeft;}
return new Array(xScroll,yScroll)}
function getPageHeight(){var windowHeight
if(self.innerHeight){windowHeight=self.innerHeight;}else if(document.documentElement&&document.documentElement.clientHeight){windowHeight=document.documentElement.clientHeight;}else if(document.body){windowHeight=document.body.clientHeight;}
return windowHeight}
function makeCompatible(){var $s=$.facebox.settings
$s.loadingImage=$s.loading_image||$s.loadingImage
$s.closeImage=$s.close_image||$s.closeImage
$s.imageTypes=$s.image_types||$s.imageTypes
$s.faceboxHtml=$s.facebox_html||$s.faceboxHtml}
function fillFaceboxFromHref(href,klass){if(href.match(/#/)){var url=window.location.href.split('#')[0]
var target=href.replace(url,'')
$.facebox.reveal($(target).show().replaceWith("<div id='facebox_moved'></div>"),klass)}else if(href.match($.facebox.settings.imageTypesRegexp)){fillFaceboxFromImage(href,klass)}else{fillFaceboxFromAjax(href,klass)}}
function fillFaceboxFromAjax(href,klass){if($.facebox.settings.useIframe==true){$.facebox.reveal('<iframe id="framed'+Math.round(Math.random()*1000)+'" name="framed'+Math.round(Math.random()*1000)+'" frameborder="0" hspace="0" scrolling="no" src="'+href+'" width="'+$.facebox.settings.frameWidth+'" height="'+$.facebox.settings.frameHeight+'"></iframe>',klass);}else{$.get(href,function(data){$.facebox.reveal(data,klass);})}}
function skipOverlay(){return $.facebox.settings.overlay==false||$.facebox.settings.opacity===null}
function showOverlay(){if(skipOverlay())return
if($('#facebox_overlay').length==0)
$("body").append('<div id="facebox_overlay" class="facebox_hide"></div>')
$('#facebox_overlay').hide().addClass("facebox_overlayBG").css('opacity',$.facebox.settings.opacity).show()
return false}
function hideOverlay(){if(skipOverlay())return
$('#facebox_overlay').hide(0,function(){$("#facebox_overlay").removeClass("facebox_overlayBG")
$("#facebox_overlay").addClass("facebox_hide")
$("#facebox_overlay").remove()})
return false}
$(document).bind('close.facebox',function(){$(document).unbind('keydown.facebox')
$('#facebox').fadeOut(function(){if($('#facebox_moved').length==0)$('#facebox .content').removeClass().addClass('content')
else $('#facebox_moved').replaceWith($('#facebox .content').children().hide())
hideOverlay()
$('#facebox .loading').remove()})})})(jQuery);jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options.expires=-1;}
var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;}
expires='; expires='+date.toUTCString();}
var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}}
return cookieValue;}};(function($){var check_element=function(name){var obj=null;var check_id=$('#'+name);var check_name=$('input[name='+name+']');if(check_id!=undefined)
obj=check_id;else if(check_name!=undefined)
obj=check_name;return obj;};$.fn.autotab_magic=function(focus){for(var i=0;i<this.length;i++){var n=i+1;var p=i-1;if(i>0&&n<this.length)
$(this[i]).autotab({target:$(this[n]),previous:$(this[p])});else if(i>0)
$(this[i]).autotab({previous:$(this[p])});else
$(this[i]).autotab({target:$(this[n])});if(focus!=null&&(isNaN(focus)&&focus==$(this[i]).attr('id'))||(!isNaN(focus)&&focus==i))
$(this[i]).focus();}};$.fn.autotab_filter=function(options){var defaults={format:'all',uppercase:false,lowercase:false,nospace:false,pattern:null};if(typeof options=='string'||typeof options=='function')
defaults.format=options;else
$.extend(defaults,options);for(var i=0;i<this.length;i++){$(this[i]).bind('keyup',function(e){var val=this.value;switch(defaults.format){case'text':var pattern=new RegExp('[0-9]+','g');val=val.replace(pattern,'');break;case'alpha':var pattern=new RegExp('[^a-zA-Z]+','g');val=val.replace(pattern,'');break;case'number':case'numeric':var pattern=new RegExp('[^0-9]+','g');val=val.replace(pattern,'');break;case'alphanumeric':var pattern=new RegExp('[^0-9a-zA-Z]+','g');val=val.replace(pattern,'');break;case'custom':var pattern=new RegExp(defaults.pattern,'g');var val=val.replace(pattern,'');break;case'all':default:if(typeof defaults.format=='function')
var val=defaults.format(val);break;}
if(defaults.nospace){var pattern=new RegExp('[ ]+','g');val=val.replace(pattern,'');}
if(defaults.uppercase)
val=val.toUpperCase();if(defaults.lowercase)
val=val.toLowerCase();if(val!=this.value)
this.value=val;});}};$.fn.autotab=function(options){var defaults={format:'all',maxlength:2147483647,uppercase:false,lowercase:false,nospace:false,target:null,previous:null,pattern:null};$.extend(defaults,options);if(typeof defaults.target=='string')
defaults.target=check_element(defaults.target);if(typeof defaults.previous=='string')
defaults.previous=check_element(defaults.previous);var maxlength=$(this).attr('maxlength');if(defaults.maxlength==2147483647&&maxlength!=2147483647)
defaults.maxlength=maxlength;else if(defaults.maxlength>0)
$(this).attr('maxlength',defaults.maxlength)
else
defaults.target=null;if(defaults.format!='all')
$(this).autotab_filter(defaults);return $(this).bind('keydown',function(e){if(e.which==8&&this.value.length==0&&defaults.previous)
defaults.previous.focus().val(defaults.previous.val());}).bind('keyup',function(e){var keys=[8,9,16,17,18,19,20,27,33,34,35,36,37,38,39,40,45,46,144,145];if(e.which!=8){var val=$(this).val();if($.inArray(e.which,keys)==-1&&val.length==defaults.maxlength&&defaults.target)
defaults.target.focus();}});};})(jQuery);