/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
function pageBack() {
var a = window.location.href;
if (/#top/.test(a)) {
window.history.go( - 2);
window.location.load(window.location.href)
} else {
window.history.back();
window.location.load(window.location.href)
}
}
function isEmail(email)
{
return $isvalidemail=/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i.test(email);
}
function checkEmail(value) {
// contributed by Scott Gonzalez: http://projects.scottsplayground.com/iri/
return /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i.test(value);
}
var userFastLoginCallback = null;
var userFastLoginDialog = null;
var userFastLogin = function() {
return {
exec: function(callback) {
userFastLoginCallback = callback;
$.ajax({
url: '/index.php?m=wap&c=user&a=isLoginAjax',
type: 'GET',
dataType: 'json',
cache: false,
async: false,
success: function(retdat) {
if (retdat.status == 1) {
userFastLoginCallback(retdat.user);
} else {
$.Prompt('Please login After.',3);
// if (userFastLoginDialog == null) {
// $.ajax({
// url: '/index.php?m=m&c=user&a=loginAjax',
// type: 'GET',
// dataType: 'html',
// cache: false,
// async: false,
// success: function(retdat) {
// $('body').append(retdat);
// userFastLoginDialog = $('#dlgUserFastLogin').dialog({
// drag: 'div.dlg-header',
// buttons: '.dlg-close'
// });
// userFastLoginDialog.open();
// }
// });
// } else {
// userFastLoginDialog.open();
// }
}
}
});
}
};
}();
$.fn.newMobileSlide = function(options) {
function testTransform3d() {
var supported = false;
var div = $('
Transform Test
');
$('body').append(div);
div.css({
'transform': "translate3d(3px,0,0)",
'-moz-transform': "translate3d(3px,0,0)",
'-webkit-transform': "translate3d(3px,0,0)",
'-o-transform': "translate3d(3px,0,0)",
'-ms-transform': "translate3d(3px,0,0)"
});
supported = (div.offset().left - $(div[0].offsetParent).offset().left === 3);
div.empty().remove();
return supported
}
function testTransform() {
var supported = false;
var div = $('Transform Test
');
$('body').append(div);
div.css({
'transform': "translate(3px,0)",
'-moz-transform': "translate(3px,0)",
'-webkit-transform': "translate(3px,0)",
'-o-transform': "translate(3px,0)",
'-ms-transform': "translate(3px,0)"
});
supported = (div.offset().left - $(div[0].offsetParent).offset().left === 3);
div.empty().remove();
return supported
}
var supportTransform3d = testTransform3d(),
supportTransform = testTransform(),
isAndroid = (/android/gi).test(navigator.appVersion),
gv1 = supportTransform3d ? 'translate3d(': 'translate(',
gv2 = supportTransform3d ? ',0)': ')',
resizeEvent = ('onorientationchange' in window) ? 'orientationchange': 'resize',
iwidth = window.innerWidth;
touch = {};
$.touchSlider = function(container, options) {
$.extend(this, {
container: null,
displaySlide: null,
contentSlide: null,
panels: null,
trigger: null,
curTriggerClass: 'current',
contentWidth: 0,
imgWidth: 320,
imgNoResize: 0,
left: 0,
visible: 1,
margin: 0,
curIndex: 0,
stepsSlide: true,
steps: 1,
distance: 0,
duration: 300,
len: 5,
loop: false,
play: false,
interval: 3000,
useTransform: !isAndroid,
imgWidthChange: false,
maxImgWidth: 640,
visibleIntChange: false,
lazy: '.lazyimg',
lazyIndex: 1,
callback: null,
prev: null,
next: null,
activePnCls: 'none'
},
options);
this.findEl() && this.init() && this.increaseEvent()
};
$.extend($.touchSlider.prototype, {
reset: function(options) {
$.extend(this, options || {});
this.init()
},
findEl: function() {
var container = this.container = $(this.container);
if (!container.length) {
return null
}
this.displaySlide = this.displaySlide && container.find(this.displaySlide) || container.children().first();
if (!this.displaySlide.length) {
return null
}
this.contentSlide = this.contentSlide && container.find(this.contentSlide) || this.contentSlide.children().first();
if (!this.contentSlide.length) {
return null
}
this.panels = this.contentSlide.children();
this.trigger = this.trigger && container.find(this.trigger);
this.prev = this.prev && container.find(this.prev);
this.next = this.next && container.find(this.next);
return this
},
triggerInit: function() {
var trigger = this.trigger;
if (trigger && trigger.length) {
var temp = '',
childstu = trigger.children();
if (!childstu.length) {
for (var i = 0; i < this.pages; i++) {
temp += ''
}
trigger.html(temp)
}
this.triggers = trigger.children();
this.triggerSel = this.triggers[this.curIndex]
} else {
this.hasTrigger = false
}
return this
},
cssReset: function() {
this.displayWidth = this.displaySlide.width();
if (this.resize && this.imgWidthChange) {
this.contentSlide.css('width', '1200%')
}
var margin = this.margin,
contentWidth = 0,
imgWidth = this.imgWidth = this.imgWidthChange ? this.displaySlide.width() : this.imgWidth,
outWidth = this.outWidth = imgWidth + margin,
imgNoResize = this.imgNoResize,
len = this.len = this.panels.length;
this.visible = parseInt(this.displayWidth / outWidth);
this.steps = Math.min(this.steps, this.visible);
this.pages = Math.ceil(len / this.steps);
this.distance = this.steps * outWidth;
this.container.find('li').each(function(n, item) {
$(item).css('margin-right', margin + 'px');
$(item).css('width', imgWidth)
});
this.container.find('img').each(function(n, item) {
if(!imgNoResize)
$(item).css('width', imgWidth)
});
this.panels.each(function(n, item) {
contentWidth += outWidth
});
this.contentWidth = contentWidth;
this.triggerInit();
this._maxLeft = this.displayWidth - this.contentWidth;
return this
},
cssResize: function() {
this.resize = true;
var that = this;
setTimeout(function() {
if (iwidth == window.innerWidth || that.displaySlide.width() == 0) {
return this
} else {
iwidth = window.innerWidth;
that.init()
}
},
isAndroid ? 500 : 0);
return this
},
init: function() {
this.cssReset();
var contentWidth = this.contentWidth,
displaySlide = this.displaySlide,
contentSlide = this.contentSlide,
panels = this.panels,
useTransform = this.useTransform = supportTransform ? this.useTransform: false;
if (useTransform) {
displaySlide.css({
'-webkit-transform': 'translate3d(0,0,0)'
});
contentSlide.css({
'-webkit-backface-visibility': 'hidden'
});
contentSlide.css({
'-webkit-transform': gv1 + '0,0' + gv2
})
}
if (this.visible > 1) {
this.loop = false
}
this.updateArrow();
if (Math.ceil(this.len / this.visible) <= 1) {
this.trigger && this.trigger.hide()
}
if (this.loop && (this.len / this.visible > 1)) {
if (!this.resize) {
contentSlide.append(panels[0].cloneNode(true));
var lastp = panels[this.len - 1].cloneNode(true);
contentSlide.append(lastp)
}
contentWidth += this.outWidth * 2;
this.contentSlide.children(':last')[0].style.cssText += 'position:relative;left:' + ( - contentWidth) + 'px;'
}
contentSlide.css('width', contentWidth + 'px');
this.contentWidth = contentWidth;
this._loopMaxLeft = this.displayWidth - this.contentWidth + this.outWidth;
if (this.imgWidthChange) {
this.left = -this.curIndex * this.outWidth
} else if (this.left < this._maxLeft) {
this._maxLeft > 0 ? (this.left = 0) : (this.left = this._maxLeft)
}
this.setCoord(this.contentSlide, this.left);
return this
},
increaseEvent: function() {
var that = this,
_display = that.container[0],
prev = that.prev,
next = that.next,
triggers = that.triggers;
if (_display.addEventListener) {
_display.addEventListener('touchstart', that, false);
_display.addEventListener('touchmove', that, false);
_display.addEventListener('touchend', that, false);
_display.addEventListener('webkitTransitionEnd', that, false);
_display.addEventListener('msTransitionEnd', that, false);
_display.addEventListener('oTransitionEnd', that, false);
_display.addEventListener('transitionend', that, false)
}
window.addEventListener(resizeEvent, that, false);
if (that.play) {
that.begin()
}
if (prev && prev.length) {
prev.click(function(e) {
that.backward.call(that, e)
})
}
if (next && next.length) {
next.click(function(e) {
that.forward.call(that, e)
})
}
if (triggers) {
triggers.each(function(n, item) {
$(item).click(function() {
that.slideTo( - n * that.outWidth)
})
})
}
},
handleEvent: function(e) {
switch (e.type) {
case 'touchstart':
this.start(e);
break;
case 'touchmove':
this.move(e);
break;
case 'touchend':
case 'touchcancel':
this.end(e);
break;
case 'webkitTransitionEnd':
case 'msTransitionEnd':
case 'oTransitionEnd':
case 'transitionend':
this.transitionEnd(e);
break;
case resizeEvent:
this.cssResize();
break;
case 'click':
this.clickEve(e);
break
}
},
clickEve: function(e) {
if (this.prodDetail) {
this.stop();
this.play = false
} else return this
},
start: function(e) {
var et = e.touches[0];
this._start = new Date().getTime();
this._movestart = undefined;
this._disX = 0;
this._disY = 0;
this._coord = {
x: et.pageX,
y: et.pageY
}
},
move: function(e) {
if (e.touches.length > 1 || e.scale && e.scale !== 1) return;
var et = e.touches[0],
initLeft = this.left,
style = this.contentSlide[0].style,
tmleft;
this._disX = et.pageX - this._coord.x;
this._disY = et.pageY - this._coord.y;
if (typeof this._movestart == 'undefined') {
this._movestart = (this._movestart || Math.abs(this._disX) < Math.abs(this._disY))
}
if (!this._movestart) {
e.preventDefault();
this.stop();
tmleft = initLeft + this._disX;
style.webkitTransitionDuration = style.MozTransitionDuration = style.msTransitionDuration = style.OTransitionDuration = style.transitionDuration = 0;
this.setCoord(this.contentSlide, tmleft)
}
},
end: function(e) {
if (!this._movestart) {
this._end = new Date().getTime();
touch.speed = this.speed(this._disX, this._disY, (this._end - this._start));
var Slide = this.left + (this._disX > 0 ? this.distance: -this.distance),
_Slide = this.left + (this._disX > 0 ? touch.speed * this.duration: -touch.speed * this.duration);
this.leftSlide = (this.stepsSlide ? Slide: _Slide);
if (this._disX < -5) {
e.preventDefault();
this.forward()
} else if (this._disX > 5) {
e.preventDefault();
this.backward()
} else {
this.setCoord(this.contentSlide, this.left)
}
}
},
speed: function(disX, disY, time) {
return Math.sqrt(Math.pow(Math.abs(disX), 2) + Math.pow(Math.abs(disY), 2)) / time
},
backward: function(e) {
if (e && e.preventDefault) {
e.preventDefault()
}
var leftSlide = this.leftSlide;
if (leftSlide > 0 && !this.loop) {
this.left = 0
} else if (this.loop && leftSlide > this.distance) {} else {
this.left = leftSlide
}
this.slideTo(this.left)
},
forward: function(e) {
if (e && e.preventDefault) {
e.preventDefault()
}
var leftSlide = this.leftSlide;
if (leftSlide < this._maxLeft && !this.loop && this._maxLeft <= 0) {
this.left = this._maxLeft
} else if (this.loop && leftSlide < this._loopMaxLeft) {} else if (this._maxLeft > 0) {
this.left = 0
} else {
this.left = leftSlide
}
this.slideTo(this.left)
},
setCoord: function(obj, x) {
this.useTransform && obj.css("-webkit-transform", gv1 + x + 'px,0' + gv2) || obj.css("left", x)
},
slideTo: function(leftSlide, duration) {
var contentSlide = this.contentSlide,
style = contentSlide[0].style,
scrollx = this.left = leftSlide;
duration = (this.stepsSlide && touch.speed && Math.ceil(this.distance / touch.speed) < this.duration) ? Math.ceil(this.distance / touch.speed) : this.duration;
style.webkitTransitionDuration = style.MozTransitionDuration = style.msTransitionDuration = style.OTransitionDuration = style.transitionDuration = (duration || this.duration) + 'ms';
this.setCoord(contentSlide, scrollx);
if (!this.loop || (this.left != this.distance && this.left != this._loopMaxLeft)) {
this.curIndex = Math.ceil(Math.abs(this.left) / this.outWidth)
}
this.update();
this.updateArrow()
},
transitionEnd: function() {
var contentSlide = this.contentSlide,
style = contentSlide[0].style;
if (this.loop && (this.left > 0 || this.left < this._maxLeft)) {
if (this.left < this._maxLeft) {
this.left = 0
} else if (this.left > 0) {
this.left = this._maxLeft
}
this.curIndex = Math.ceil(Math.abs(this.left) / this.outWidth);
this.setCoord(contentSlide, this.left);
this.update();
this.updateArrow()
}
style.webkitTransitionDuration = style.MozTransitionDuration = style.msTransitionDuration = style.OTransitionDuration = style.transitionDuration = 0;
if (!this.loop && this.left == this._maxLeft) {
this.stop();
this.play = false
} else {
this.begin()
}
},
update: function() {
var triggers = this.triggers,
cls = this.curTriggerClass,
curIndex = this.curIndex;
if (triggers && triggers[curIndex]) {
this.triggerSel && ($(this.triggerSel).removeClass(cls));
$(triggers[curIndex]).addClass(cls);
this.triggerSel = triggers[curIndex]
}
},
updateArrow: function() {
var prev = this.prev,
next = this.next;
if (!prev || !prev.length || !next || !next.length) return;
if (this.loop) return;
var cur = this.curIndex,
cls = this.activePnCls;
cur <= 0 && prev.addClass(cls) || prev.removeClass(cls);
cur >= this._maxpage && next.addClass(cls) || next.removeClass(cls)
},
begin: function() {
var that = this;
this.leftSlide = -(this.curIndex + 1) * this.outWidth;
if (that.play && !that._playTimer) {
that.stop();
that._playTimer = setInterval(function() {
that.forward()
},
that.interval)
}
},
stop: function() {
var that = this;
if (that.play && that._playTimer) {
clearInterval(that._playTimer);
that._playTimer = null
}
}
});
new $.touchSlider(this, options)
};
$.zoomImgLayer = function(widthEl, heightEl) {
if ((widthEl / heightEl) > parseFloat(window.innerWidth / window.innerHeight)) {
var displayHeight = (heightEl / widthEl) * window.innerWidth;
var padTop = parseInt(window.innerHeight - displayHeight) / 2;
$('.zoom-img').width(window.innerWidth + 'px');
$('.zoom-img').height('auto');
$('.zoom-img').css('margin-top', padTop + 'px')
} else {
$('.zoom-img').width('100%');
$('.zoom-img').css('margin-top', '0')
}
};
function createAjaxLoading()
{
$('').appendTo(document.body).addClass('ajax_loading');
}
function removeAjaxLoading()
{
$('.ajax_loading').remove();
}
function pad(num, decimal, type) {
if(decimal==0)
return num;
var type = type ? type : 0;
var arrnum = num.split('.');
if (arrnum[1]) {
if (arrnum[1].length < decimal) {
var str = '';
for (var i = 0; i < decimal - arrnum[1].length; i++) {
str += '0';
}
num = num + str;
}
} else {
if (type == 1) {
if (num.length < decimal) {
var str = '';
for (var i = 0; i < decimal - num.length; i++) {
str += '0';
}
num = num + str;
}
} else {
var str = '';
for (var i = 0; i < decimal; i++) {
str += '0';
}
num = num + '.' + str;
}
}
return num;
}
function unique(arr)
{
//一个新的临时数组
var n = new Array();
//遍历当前数组
for(var i = 0; i < arr.length; i++)
{
//如果当前数组的第i已经保存进了临时数组,那么跳过,
//否则把当前项push到临时数组里面
if (n.indexOf(arr[i]) == -1) n.push(arr[i]);
}
return n;
}
Number.prototype.toFixed=function(len)
{
var add = 0;
var s,temp;
var s1 = this + "";
var start = s1.indexOf(".");
if(start!=-1)
{
if(s1.substr(start+len+1,1)>=5)add=1;
var temp = Math.pow(10,len);
s = Math.floor(this.mul(temp)) + add;
return s/temp;
}
else
{
return this;
}
}
function formatnumber(value, num){
value = parseFloat(value);
value = value.toFixed(num);
a = value.toString();
b = a.indexOf(".");
c = a.length;
if(num)
{
num = parseInt(num);
}
if (num == 0) {
if (b != -1) {
a = a.substring(0, b);
}
} else {//如果没有小数点
if (b == -1) {
a = a + ".";
for (i = 1; i <= num; i++) {
a = a + "0";
}
} else {//有小数点,超出位数自动截取,否则补0
a = a.substring(0, b + num + 1);
for (i = c; i <= b + num; i++) {
a = a + "0";
}
}
}
return a;
}
Number.prototype.mul = function (arg){
return accMul(arg, this);
}
function accMul(arg1,arg2){
var m=0,s1=arg1.toString(),
s2=arg2.toString();
try{
m+=s1.split(".")[1].length}catch(e){}
try{
m+=s2.split(".")[1].length}catch(e){}
return Number(s1.replace(".",""))*Number(s2.replace(".",""))/Math.pow(10,m)
}
$(function() {
$('.glike').click(function(event){
var _this = $(this);
var _val = parseInt(_this.find('font').text());
var goods_id = _this.attr('data_id');
$.ajax({
url :'/h-user-addFavorites.html',
type:'POST',
data:{
goods_id : goods_id
},
dataType: 'json',
cache: false,
success: function(res) {
if(res == 1){
//_this.tip('Add to favorite succeed.', 15, 0, 2000);
$.Prompt('Add to favorite succeed.');
_this.find('font').text(_val+1);
}else if(res== 2){
//_this.tip('Please Login first', 15, 0, 2000);
$.Prompt('Please Login first');
}else if(res== 3){
//_this.tip('Already added', 15, 0, 2000);
$.Prompt('Already added');
}else{
//_this.tip('Add to favorite failed.', 15, 0, 2000);
$.Prompt('Add to favorite failed.');
}
},
error:function(){
//alert('Connection failed, please refresh');
$.Prompt('Connection failed, please refresh');
},
beforeSend: function(){
createAjaxLoading();
},
complete: function(){
removeAjaxLoading();
}
})
event.stopPropagation();
});
});
function format_keywords(keywords)
{
// ; / @ : & = + $ , #
// %3b %2f %40 %3a %26 %3d %2b %24 %2c %23
keywords = keywords.replace(/"/g,"");
keywords = encodeURIComponent(keywords);
keywords = keywords.replace(/%25/ig,"%2525");
keywords = keywords.replace(/%3b/ig,"%253b");
keywords = keywords.replace(/%2f/ig,"%252f");
keywords = keywords.replace(/%40/ig,"%2540");
keywords = keywords.replace(/%3a/ig,"%253a");
keywords = keywords.replace(/%26/ig,"%2526");
keywords = keywords.replace(/%3d/ig,"%253d");
keywords = keywords.replace(/%2b/ig,"%252b");
keywords = keywords.replace(/%24/ig,"%2524");
keywords = keywords.replace(/%2c/ig,"%252c");
keywords = keywords.replace(/%23/ig,"%2523");
keywords = keywords.replace(/%3f/ig,"%253f");
keywords = keywords.replace(/%20/g,"+");
return keywords.toLowerCase() ;
}
function getImageThumbURL(pic, style, is_https, is_oss)
{
is_oss = true;
pic = pic.replace(/thumb\/[\d]+x[\d]+\//gi,'');
var el = document.createElement('a');
el.href = pic;
var info = el.pathname.split('/') ;
if(pic && style && style != "0x0" )
{
if(is_oss)
{
resize_w = 0;
resize_h = 0;
resize = style.split('x');
resize_w = parseInt(resize[0]);
if(typeof(resize[1])!='undefined')
{
resize_h = parseInt(resize[1]);
}
var url_query = "?x-oss-process=image/";
if(typeof(ymcart_oss_default_query)!=='undefined' && ymcart_oss_default_query!='')
{
var reg = /quality\,Q_[\d]+/i;
if(reg.test(ymcart_oss_default_query))
{
var matches = reg.exec(ymcart_oss_default_query);
url_query += matches[0];
var default_query = ymcart_oss_default_query.replace(/([\/]*)quality\,Q_[\d]+/i,'$1resize,m_lfit,w_'+resize_w+',h_'+resize_h);
url_query += '/'+default_query;
}
else
{
url_query += 'resize,m_lfit,w_'+resize_w+',h_'+resize_h+'/'+ymcart_oss_default_query;
}
}
else
{
url_query += 'resize,m_lfit,w_'+resize_w+',h_'+resize_h;
}
info[info.length-1] = info[info.length-1]+url_query;
}
else
{
info[1] = info[1] + '/thumb/' +style;
}
return (is_https? 'https:':'')+'//' + el.host + info.join('/');
}
else if(pic && (style == "0x0" || style==''))
{
return (is_https? 'https:':'')+'//' + el.host + el.pathname ;
}
else
{
ftp_domain = str_replace('http:','',"http://cn01.imgcdn.ymcart.com/");
if(style)
return (is_https? 'https:':'') + ftp_domain+"0/thumb/"+style+"/nopic.png";
else
return (is_https? 'https:':'') + ftp_domain+"0/nopic.png";
}
}
function price_currency(price,plus_symbol,currency)
{
if(typeof(currency)=='object')
{
if(typeof(currency.symbol_separator)=='string' && currency.symbol_separator !='')
{
price = String(price).replace(/\B(?=(\d{3})+(?!\d))/g, currency.symbol_separator);
}
}
else if(typeof(ymcart_currency_separator)=='string' && ymcart_currency_separator !='')
{
price = String(price).replace(/\B(?=(\d{3})+(?!\d))/g, ymcart_currency_separator);
}
if(typeof(plus_symbol)=='boolean' && plus_symbol == false)
{
return price;
}
if(typeof(currency)=='object')
{
if(typeof(currency.symbol_left)=='string' && currency.symbol_left !='')
{
price = currency.symbol_left+' '+price;
}
if(typeof(currency.symbol_right)=='string' && currency.symbol_right !='')
{
price = price+' '+currency.symbol_right;
}
}
else
{
if(typeof(ymcart_currency_lcoin)=='string' && ymcart_currency_lcoin !='')
{
price = ymcart_currency_lcoin+' '+price;
}
if(typeof(ymcart_currency_rcoin)=='string' && ymcart_currency_rcoin !='')
{
price = price+' '+ymcart_currency_rcoin;
}
}
return price;
}
function ymcartSetCookie(name,value,expiredays){
var exdate=new Date()
exdate.setDate(exdate.getDate()+expiredays)
document.cookie=name+ "=" +escape(value)+
((expiredays==null) ? "" : "; expires="+exdate.toGMTString())
}
function ymcartGetCookie(name){
var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
if(arr != null) return unescape(arr[2]); return null;
}
function initClientDetails(){
var d = new Date();
var gmtHours = d.getTimezoneOffset()/60;
var timezone = 'Etc/GMT';
if(gmtHours>0)
{
timezone = timezone+'+'+gmtHours;
}
else if(gmtHours<0)
{
timezone = timezone+''+gmtHours;
}
else
{
timezone = 'Etc/UTC';
}
ymcartSetCookie('ymcart_client_timezone',encodeURIComponent(timezone),1);
var date_time = '';
date_time += d.getFullYear() + "-";
date_time += (d.getMonth() + 1) + "-";
date_time += d.getDate() + " ";
date_time += d.getHours() + ":";
date_time += d.getMinutes() + ":";
date_time += d.getSeconds();
ymcartSetCookie('ymcart_client_broswer_date_time',date_time,1);
ymcartSetCookie('ymcart_client_screen_width',window.screen.width,1);
ymcartSetCookie('ymcart_client_screen_height',window.screen.height,1);
ymcartSetCookie('ymcart_client_broswer_language',navigator.language,1);
}
initClientDetails();