// global var
var THEME_URI = 'http://www.bagbrandname.com/store/app/views/themes/cool/';
var OLD_BASE_URI = 'http://static.weloveshopping.com/shop/';
var SHOP_ID = '189600';
var SHOP_NAME = 'ขายกระเป๋าแบรนด์เนม';
var BASE_URI = 'http://www.bagbrandname.com/store';
var JSON_DATA = {"product_on_cart":null};
var SHOP_DISABLED_TEXT = 'y';
var SHOP_DISABLED_MOUSE = 'y';
var SHOP_DISABLED_MOUSE_MSG = 'ลิขสิทธิ์ BagBrandName.com';
var SHOP_PRODUCT_PREVIEW = '1';
var IS_TRANSLATE = true ;
var SHOP_POPUP_OPEN = 'n';
var SHOP_POPUP_OPTION = '1,0,1,0,0,0,550,413,500,500';
var SHOP_ADMIN_SHORTCUT = '{"add":["article-block","product-list"],"update":null,"del":null,"manage":null,"showfirst":"1"}';
var SHOP_CLIENT_CART = '2';
var SHOP_CARTMEMBER = 'n';
var MEMBER_MID = 'MEMBER_MID';
var SHOP_COOKIE_NAME = 'cart_cookie189600';
var SHOP_CLIENT_CHAT = '0';
var SITE_URL = 'weloveshopping.com';
var WWW_SITE_URL = 'www.weloveshopping.com';
var YOUSTORE_SITE_URL = 'youstore.weloveshopping.com';
/* ------------------------------- start redir ------------------------------- */
/*var main_url = window.location.href;
var is_welove = main_url.indexOf('.weloveshopping.com');
if(is_welove > 0)
{
if (!getCookie("loadtl")) {
setCookie("loadtl",'yes');
rnd = rand_x(1,3);
if(rnd == 1) // ------------------------------- edit here -------------------------------
{
document.location = 'http://wls.truelife.com/tl_crm.php?url=' + main_url;
}
}
}
*//* ------------------------------- end redir ------------------------------- */
if(MEMBER_MID == 'MEMBER_MID') {
MEMBER_MID = '';
}
base_real = BASE_URI.replace("/store","");
now_url = location.href.replace("/store/home","");
now_url = now_url.replace("/store/","");
popup_option = SHOP_POPUP_OPTION;
popup_option = popup_option.split(',');
popup_show_type = (typeof popup_option[0] != "undefined") ? popup_option[0] : '1';
//if(now_url==base_real) {
if(SHOP_POPUP_OPEN=='y') {
if (popup_show_type == '0') {
if (now_url == base_real) {
window.open('http://www.bagbrandname.com/store/popup/','pop','location=0,directories=0,fullscreen=0,menubar=1,resizable=0,scrollbars=0,toolbar=0,width=550,height=413,left=500,top=500');/* popup zone*/
}
} else {
window.open('http://www.bagbrandname.com/store/popup/','pop','location=0,directories=0,fullscreen=0,menubar=1,resizable=0,scrollbars=0,toolbar=0,width=550,height=413,left=500,top=500');/* popup zone*/
}
}
//}
function rand_x(l,u) { return Math.floor((Math.random() * (u-l+1))+l); }
function setHome()
{
document.body.style.behavior='url(#default#homepage)';
document.body.setHomePage(BASE_URI);
}
function addToFavorites()
{
var fav_title = SHOP_NAME + ' : weloveshopping.com';
if (document.all) window.external.AddFavorite(BASE_URI,fav_title)
else if (window.sidebar) window.sidebar.addPanel(fav_title, BASE_URI, ""); // firefox
}
var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{
if(popUpWin)
{
if(!popUpWin.closed) popUpWin.close();
}
popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}
function Popup(pname,purl,w,h,s){
LeftPosition = (screen.width) ? (screen.width-w-8)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h-50)/2 : 0;
myWinName = window.open(purl,pname,"width="+w+",height="+h+",top="+TopPosition+",left="+LeftPosition+",resizable=no,scrollbars="+s);
if (parseInt(navigator.appVersion) >= 4) {
myWinName.window.focus();
}
return myWinName;
}
var clock_img = THEME_URI+"../images/icon_clock_2.gif";
$(document).ready(function(){
/*if( (getCookie("uniqueID") == null) || (getCookie("uniqueID") == '') || (typeof(getCookie("uniqueID")) == 'undefined') ) {
setCookie("uniqueID",rand (999999));
}*/
$('#caroufredsel').carouFredSel({
auto: true,
items: {
visible: 3,
start: $('#caroufredsel span a img:first')
},
scroll: 1,
prev: "#prev",
next: "#next"
});
$('.extraImg').click(function(){
//alert($(this).find('img').html());
var img = $(this).find('img').attr('src');
$('#showFull').hide();
$('#showFull').attr('src',img).fadeIn();
resizeShowImg();
return false;
});
if(SHOP_CLIENT_CHAT == 1){
$('#smartchat').show();
}else{
$('#smartchat').hide();
}
$('#product-list li[class=pro-item] div[class=pro-desc] a, #product-list li[class=pro-item] div[class=pro-image] a').click(function(){
if($(this).attr('class')!='enlarge') {
var firstclick = $.cookie('firstclick');
if(firstclick == null) {
$.cookie('firstclick', '1', { path: '/', expires: 1 });
window.open('http://www.weloveshopping.com/crm.php?url=' + $(this).attr('href'));
return false;
}
}
});
//poll form check
$('#pollFrm').submit(function(){
comment = $(this).find('#comment');
comment_by = $(this).find('#comment_by');
if(comment.val()=='') {
alert('กรุณาเลือกผลโหวต และกรอกชื่อผู้ส่ง');
comment.focus();
return false;
}
if(comment_by.val()=='') {
alert('กรุณาเลือกผลโหวต และกรอกชื่อผู้ส่ง');
comment_by.focus();
return false;
}
});
// pay date
$('#timepicker').jtimepicker({
secView:false,
minInterval:1,
orientation:"horizontal",
clockIcon:clock_img,
hourLabel:"ชั่วโมง",
minLabel:"นาที",
hourCombo:"hour",
minCombo:"minute"
});
$('#paydate').datepicker({ buttonText: 'เลือกวัน' });
// ready queue
setMouseMove(); // ยืนยันความเป็นคน
setKeyPress(); // ยืนยันความเป็นคน
cartIni(); // cart system
if (IS_TRANSLATE) {
languageIni(); //language system
}
// end ready queue
$("#send").click(function () {
var email = $("#email").val();
var newsletter = $('input[name=newsletter]:checked').val();
var uri = OLD_BASE_URI+"s_savemailajax.php";
$.get(uri, { shopid: SHOP_ID, email: email, need: newsletter },
function(data){
alert("e-mail saved.");
$("#email").val('');
});
});
/* ======== cartorder/shippingaddress/ =========*/
$('#shipping_address').change(function(){
json_obj = $('#shipping_address :selected').attr('rel');
if(json_obj!='') {
json_val = eval(json_obj);
$('#name').val(json_val[0].name);
$('#address').val(json_val[0].address + ' ' + json_val[0].city);
$('#district').val(json_val[0].district);
$('#province').val(json_val[0].province);
//$('#country').val(json_val[0].country);
$('#postcode').val(json_val[0].postcode);
$('#contact_tel').val(json_val[0].contact_tel);
$('#myemail').val(json_val[0].email);
$('#other_info').val(json_val[0].other_info);
}
});
/* auto */
method_val = $("input[name='shipping_method']:checked").val();
checkMethod(method_val);
/* click */
$("input[name='shipping_method']").click(function() {
checkMethod($(this).val());
});
/* ======== cartorder/payment/ =========*/
$('input[name=payment_method]').change(function(){
payment_val = $('input[name=payment_method]:checked').val();
if(payment_val == "wetrust") {
$(".wetrust").find("input").removeAttr('disabled');
}
else if( (payment_val == "BankTrans") || (payment_val == "paysbuy") || (payment_val == "paypal") ) {
$(".wetrust").find("input").attr('disabled','disabled');
}
});
$('.payment_tips').slideUp(); // init
$('input[name=payment_wetrust]').change(function(){
payment_val = $('input[name=payment_wetrust]:checked').val();
detail_wetrust = '#detail_'+payment_val;
//alert($('.payment_tips'));
$('.payment_tips').slideUp();
$(detail_wetrust).slideDown();
});
// thumb view
$('.more_img').click(function(){
el = $(this).attr('src');
$('#main_img').attr('src',el);
});
/* ===== shop disable text & mouse =====*/
if(SHOP_DISABLED_MOUSE=='y') {
// protect image
if($.browser.safari) {
$(window).bind('load', function() {
$('.pro-image img').protectImage();
});
} else {
$(window).bind('load', function() {
$('.pro-image img').mask();
});
}
if(SHOP_DISABLED_MOUSE_MSG=='') {
mouse_msg = 'Right click disabled.';
} else {
mouse_msg = SHOP_DISABLED_MOUSE_MSG;
}
// disable right click
$(this).bind("contextmenu", function(e) {
alert(mouse_msg);
e.preventDefault();
});
}
(function($){
var methods = {
enable: function() {
return $(this)
.removeAttr('unselectable')
.css({
'-webkit-user-select': 'auto',
'-khtml-user-select': 'auto',
'-moz-user-select': 'auto',
'-o-user-select': 'auto',
'-user-select': 'auto'
})
.each(function() {
this.onselectstart = function() {};
});
},
disable: function() {
return $(this)
.attr('unselectable', 'on')
.css({
'-webkit-user-select': 'none',
'-khtml-user-select': 'none',
'-moz-user-select': 'none',
'-o-user-select': 'none',
'-user-select': 'none'
})
.each(function() {
this.onselectstart = function() { return false; };
});
}
};
$.fn.textSelect = function( method ) {
// Method calling logic
if ( methods[method] ) {
return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
} else {
console.log( 'Method ' + method + ' does not exist on jQuery.textSelect' );
}
}
})(jQuery);
if(SHOP_DISABLED_TEXT=='y') {
$('#container').textSelect('disable');
/*var browser_detect = navigator.userAgent.toLowerCase();
var url_detect = document.URL.toLowerCase();
var disabled_flag = true;
if(browser_detect.indexOf('safari') > -1 && url_detect.indexOf('/cartorder/shoppingcart') > -1)
{
// is safari
disabled_flag = false;
}
if(disabled_flag == true){
// disable text select
$("#container").disableTextSelect();
$('#container').bind('click',function() {
$("#container").disableTextSelect();
});
$('input, select, textarea').bind('click',function() {
$(this).focus();
$("#container").enableTextSelect();
});
}*/
}
});
function checkMethod(method_val) {
if(method_val==1) {
$('#newcontact').find('input').attr('disabled','disabled');
$('#newcontact').find('textarea').attr('disabled','disabled');
//$('#shipping_address').removeAttr('disabled');
}
else if(method_val==2) {
$('#newcontact').find('input').removeAttr('disabled');
$('#newcontact').find('textarea').removeAttr('disabled');
//$('#shipping_address').attr('disabled','disabled');
}
}
function checkShipping() {
method_val = $("input[name='shipping_method']:checked").val();
if(method_val==1) {
temp_val = $("#shipping_address option:selected").attr("rel"); //.val();
$('#db_contact').val(temp_val);
}
else if(method_val==2) {
if(confirm('ต้องการเก็บข้อมูลการจัดส่งสินค้าที่เพิ่มเข้ามาใหม่ไว้ใช้ในครั้งต่อไป?')) {
$('#saveContact').val(1);
}
else {
$('#saveContact').val(0);
}
}
}
function checkTransport(form)
{
// transport option
transport_option = $('#transport_option :selected').val();
if(transport_option!='#') {
form.submit();
return true;
} else {
alert('โปรดเลือกรูปแบบค่าจัดส่ง');
$('#transport_option').focus();
return false;
}
}
function setMouseMove () {
document.onmousemove = function () {
if(($.cookie('m'+SHOP_ID)*1)==0) {
$.cookie('m'+SHOP_ID,1);
}
}
}
function setKeyPress() {
document.onkeypress = function () {
if(($.cookie('k'+SHOP_ID)*1)==0) {
$.cookie('k'+SHOP_ID,1);
}
}
}
function summaryCheck(form) {
if (typeof setConfirmOrder==="function"){
setConfirmOrder();
}
var img = '
';
//form.submit();
$.blockUI({
theme: true,
title: 'ข้อความจากระบบ',
message: img + '