if(!window.Jumei){window.Jumei=new Object()};window.debug=function($obj){if(window.console&&window.console.log){window.console.log($obj)}};window.parseBool=function(string){if(string=="true"||string==true){return true}else if(string=="false"||string==false){return false}};jQuery.fn.hasAttr=function(attr){var ret=jQuery(null).not(document);this.each(function(){if($(this).attr(attr)){ret=ret.add($(this))}});return ret};Jumei.Core={init:function(){Jumei.Core.enableMyJumeiNavigationMenu();Jumei.Core.enableBookmark();Jumei.Core.enableCopySharingToPasteboard();Jumei.Core.enableSubscribe();Jumei.Core.enableCommentScroller();Jumei.Core.enableGAVirtualPageViewTracking();Jumei.Core.enableEcommerceTracking()},enableMyJumeiNavigationMenu:function(){var $this=$('#my_jumei_navigation_link');if($this.length>0){var $verticalMenu=$('#my_jumei_navigation_menu');$this.mouseover(function(){var myJumeiOffset=$this.offset();$verticalMenu.css('top',myJumeiOffset.top+16).css('left',myJumeiOffset.left-8).css('display','block');$verticalMenu.show()});$verticalMenu.mouseleave(function(){$(this).hide()})}},enableBookmark:function(){var $this=$('#bookmark_us');if($this.length>0){$this.click(function(){
if($.browser.mozilla){window.sidebar.addPanel('酷团精品-酷团网','http://www.kutuan.com',"")}else if($.browser.msie){window.external.addFavorite('http://www.kutuan.com','酷团-酷团网')}else{alert('您的浏览器不支持点击收藏，请按快捷键Ctrl+d收藏酷团')}})}},enableCopySharingToPasteboard:function(){var $this=$("#share-copy-button");if($this.length>0){$this.click(function(){if($.browser.msie){var link=$("#share-copy-text");if(link&&link.length>0){var copied=document.getElementById("share-copy-text").createTextRange();copied.execCommand("Copy");alert('复制成功！')}}else{alert("对不起，您的浏览器不支持复制按钮，请选择左边文字进行复制和粘贴。")}})}},enableSubscribe:function(){if($("#form_subscribe").length>0){$("#form_subscribe").submit(function(){$.ajax({type:$(this).attr('method'),url:$(this).attr('action'),dataType:'json',data:$(this).serialize(),success:function(data){if(data.status==0){alert(data.msg)}else{alert('订阅成功！以后每天酷团的团购信息会发送到您的邮箱！')}}});return false})};if($("#tip-deal-subscribe-form").length>0){$("#tip-deal-subscribe-form").submit(function(){$.ajax({type:$(this).attr('method'),url:$(this).attr('action'),dataType:'json',data:$(this).serialize(),success:function(data){if(data.status==0){alert(data.msg)}else{$('#tip-deal-subscribe-body').html('<table><tr><td width="343" valign="middle" height="65px" align="right"><strong>订阅成功！每天特卖信息会发送到您的邮箱！</strong></td></tr></table>')}}});return false})};var $input_mail=$('#form_subscribe input[name=email]');if($input_mail.length>0){$input_mail.click(function(){if($input_mail.val()==='请输入您的邮箱'){$input_mail.val('');$input_mail.css('color','#333')}});$input_mail.blur(function(){if($input_mail.val()===''){$input_mail.val('请输入您的邮箱');$input_mail.css('color','#AEAEAE')}})};_$resubscribe=$('#resubscribe');if(_$resubscribe.length>0){_$resubscribe.find('a').click(function(){_$resubscribe.find('.text').css('display','none');_$resubscribe.find('.enter-address').show('fast');$('#enter-address-mail').focus()})}},enableCommentScroller:function(){var _currentCommentIndex=0;var _currentCommentRecord;var _currentComment;var _$currentComment;var _$lastComment;var _currentCommentHeight;var _$commentContainer=$('#sidebar_comment_container');var _$commentSource=$('#overall_comments .comment_content');if(_$commentContainer.length>0&&_$commentSource.length>0){var _commentRecords=new Array();_$commentSource.each(function(index){var comment={'title':$(this).find('.desc').html(),'comments':$(this).find('.content').html()};_commentRecords.push(comment)});if(_commentRecords.length>0){_$commentContainer.everyTime(4000,function(){_$commentContainer.children('p').remove();_currentCommentRecord=_commentRecords[(_currentCommentIndex++)%_commentRecords.length];with(_currentCommentRecord){comments=comments.length>30?comments.substr(0,30)+"...":comments;_currentComment="<div class='comment_content'>"+title+"<br  />"+"<div class='quote'>"+comments+"</div>"+"</div>";_$currentComment=$(_currentComment);_$commentContainer.append(_$currentComment);if(_currentCommentIndex==1){_$lastComment=_$currentComment}else{_$commentContainer.animate({'top':'-=110px'},'slow',function(){if(_$lastComment!=undefined&&_$lastComment.length>0){_$lastComment.remove()};_$lastComment=_$currentComment;_$commentContainer.css('top',0)})}}})}else{_$commentContainer.append("<p style='margin-left:10px'>没有评论</p>")}}},clearAdhocNotification:function(container,isRecursive){if(isRecursive==null){isRecursive==true};if(isRecursive){container.find('.notification_center').remove()}else{container.children('.notification_center').remove()}},postAdhocNotification:function(container,shouldAutoDismiss,position,notification,shouldForceShowNotification){var message=notification.message;var type=notification.type||"information";var shouldForceShowNotification=(shouldForceShowNotification!=undefined)?shouldForceShowNotification:false;var shouldAutoDismiss=(shouldAutoDismiss!=undefined)?shouldAutoDismiss:true;var position=(position!=undefined)?position:"append";var notification=$("<div class='notification_center'><div class='message'></div><div class='clear'></div></div>");$(notification).find(".message").html(message);if(type=="success"){$(notification).addClass('success_notification')}else if(type=="error"){$(notification).addClass('error_notification')}else if(type=="warning"){$(notification).addClass('warning_notification')}else if(type=="information"){$(notification).addClass('information_notification')}if(position=="prepend"){container.children('.notification_center').remove();container.prepend(notification)}else if(position=="append"){container.children('.notification_center').remove();container.append(notification)}else if(position=="before"){container.siblings('.notification_center').remove();container.before(notification)}else if(position=="after"){container.siblings('.notification_center').remove();container.after(notification)};if(shouldForceShowNotification){$(window).scrollTop($(notification).offset().top-50)}if(shouldAutoDismiss){$(notification).oneTime(1000,function(){$(notification).remove()})}},jsonToString:function(obj){var THIS=this;switch(typeof(obj)){case'string':return'"'+obj.replace(/(["\\])/g,'\\$1')+'"';case'array':return'['+obj.map(THIS.jsonToString).join(',')+']';case'object':if(obj instanceof Array){var strArr=[];var len=obj.length;for(var i=0;i<len;i++){strArr.push(THIS.jsonToString(obj[i]))}return'['+strArr.join(',')+']'}else if(obj==null){return'null'}else{var string=[];for(var property in obj)string.push(THIS.jsonToString(property)+':'+THIS.jsonToString(obj[property]));return String.fromCharCode(123)+string.join(',')+String.fromCharCode(125)}case'number':return obj;case false:return obj}},submitForm:function(obj,vars,checkCallback){var obj=$(obj);while(obj.size()){if(obj.is("form"))break;obj=obj.parent()}if(obj.is("form")){if(checkCallback&&!checkCallback(obj))return;if(vars){for(var k in vars){var e=$("[name="+k+"]",obj);if(!e.size())e=$("<input type='hidden' name='"+k+"' />").appendTo(obj);e.val(vars[k])}}obj.submit();return true}},copyToClipboard:function(obj){if(window.clipboardData!=undefined){window.clipboardData.setData('Text',$(obj).val());Jumei.Core.postAdhocNotification($("#view_url"),true,"append",{type:'success',isAttached:true,message:"分享链接已经拷贝到剪贴板中，您可以在其他网站中粘贴此链接"})}else{Jumei.Core.postAdhocNotification($("#view_url"),true,"append",{type:'success',isAttached:true,message:"您可以把选中的链接内容拷贝粘贴到想分享的网站中"});obj.focus();obj.select()}},lightbox:{popBox:'<div id="lightbox"><iframe id="lightbox_pal"></iframe></div>',init:function(data){$(Jumei.Core.lightbox.popBox).appendTo('body');if(data.obj){data.obj.appendTo($('#lightbox'));Jumei.Core.lightbox.fx(data)}else if(data.url){data.url=data.url+'&nocache'+Math.random();$("#lightbox").load(data.url,function(){Jumei.Core.lightbox.fx(data);data.callback?data.callback():function(){return true}})}else{$(Jumei.Core.lightbox[data.type](data.msg,data.state)).appendTo($('#lightbox'));Jumei.Core.lightbox.fx(data)}return false},fx:function(data){if(data.shadow&&!$('#lightbox_shadow')[0]){$('body').append('<div id="lightbox_shadow"><iframe frameborder="0"></iframe></div>')}if($('#lightbox_shadow')[0]){$('#lightbox_shadow').height($('body').outerHeight()>$(window).height()?$('body').outerHeight():$(window).height()).find('iframe').height($('#lightbox_shadow').height())}var pb=$('#lightbox');pb.css({left:'50%',margin:'-'+pb.height()/2+'px 0 0 -'+pb.width()/2+'px'});if(data.sTop){pb.css({top:data.sTop+'px',marginTop:'0px'})}if(!window.XMLHttpRequest){(function(pb){$(window).scroll(function(){pb.css({marginTop:0,top:(data.sTop?data.sTop:(($(window).height()-pb.height())/2-0))-0+$(window).scrollTop()+'px'})})})(pb);$(window).scroll()}$('#lightbox_pal').css({'height':pb.height(),width:pb.width()});window.onresize=(function(data){return function(){Jumei.Core.lightbox.fx(data)}})(data);pb=null},quit:function(){var arg=arguments;window.onresize=null;$('#lightbox').fadeOut('fast',function(){$('#lightbox').remove();if(arg.length==0||(typeof(arg[0])=='function'&&!arg[1])||arg.length==0){$('#lightbox_shadow').remove()}if(typeof(arg[0])=='function'){arg[0]()}arg=null});return false}},enableGAVirtualPageViewTracking:function(){with(window){if(typeof(window.RM_VIRTUAL)!='undefined'&&RM_VIRTUAL.length>0){var i;for(i=0;i<RM_VIRTUAL.length;i++){_gaq.push(["_trackPageview",RM_VIRTUAL[i]+".virtual"])}}}},hasEcommerceTrackingItem:false,enableEcommerceTracking:function(){var _$orderPaymentSuccess=$('#order_payment_success');if(_$orderPaymentSuccess.length>0){Jumei.Core.hasEcommerceTrackingItem=true;var orderId=_$orderPaymentSuccess.find('input[name="order_id"]').val();var orderInfo=_$orderPaymentSuccess.find('input[name="order_info"]').val();if(orderInfo!=null&&orderInfo.length>0){var data=jQuery.parseJSON(orderInfo);if(data.status==1){var order=data.order;with(order){window._gaq=window._gaq||[];_gaq.push(['_addTrans',order_id,'cosmetics.store.jumei',total_price,'',delivery_fee,'','','']);for(var item in item_details){with(item_details[item]){_gaq.push(['_addItem',order_id,deal_hash_id,deal_short_name,attribute_selections,deal_price,quantity])}}}}}}}};

