String.format = function () {
// The string containing the format items (e.g. "{0}")
// will and always has to be the first argument.
var theString = arguments[0];
// start with the second argument (i = 1)
for (var i = 1; i < arguments.length; i++) {
// "gm" = RegEx options for Global search (more than one instance)
// and for Multiline search
var regEx = new RegExp("\\{" + (i - 1) + "\\}", "gm");
theString = theString.replace(regEx, arguments[i]);
}
return theString;
}
/* Boolean ::: String.IsNullOrEmpty (String arg) */
String.IsNullOrEmpty = function (arg) {
if (arg === undefined || arg === null) { throw "Property or Arguments was Never Null"; } else {
if (typeof (arg) != "string") { throw "Property or Arguments was not 'String' Types"; }
else { return arg.IsNullOrEmpty(); }
}
};
String.prototype.IsNullOrEmpty = function () {
var arg = arguments[0] === undefined ? this.toString() : arguments[0];
if (arg === undefined || arg === null || arg === "") { return true; }
else {
if (typeof (arg) != "string") { throw "Property or Arguments was not 'String' Types"; }
return false;
}
};
String.prototype.bytes = function () {
var str = this;
var l = 0;
for (var i = 0; i < str.length; i++) l += (str.charCodeAt(i) > 128) ? 2 : 1;
return l;
}
function SetCartCount() {
$.ajax({
type: "POST",
url: '/Cart/Count',
cache:false,
async: false,
success: function (data) {
$("#cartCount").html(data);
}
});
}
function commaFormat(x) {
var i, j, y;
y = "";
x = String(x);
for (i = x.length - 1; i >= 0; i--) {
j = x.length - 1 - i;
flag = (j + 1) % 3;
if ((flag == 0) && (j != x.length - 1))
y = "," + x.charAt(i) + y;
else
y = x.charAt(i) + y;
}
return y
}
function AddWish(good_code,good_cyn,login_tf){
if(login_tf=="True"){
if(typecheck()=="Y") {
confirmBox("하이리빙 회원님은 mall.hiliving.co.kr에서 구매하실 수 있습니다.
하이리빙 쇼핑몰로 이동 하시겠습니까?",callbackmallgoodTrue,function(){},good_code)
}else{
data = { "good_code": good_code,"good_cyn":good_cyn };
$.ajax({
type:"POST"
,datatype:"json"
,url:'/Goods/AddWishList'
,data:data
,success:function(data){
infoBox(data);
if(data!=0){
confirmBox("위시리스트 상품이 담겼습니다.
위시리스트로 이동하시겠습니까?",wishhome,function(){})
}
},error:function(request){
errorBox(request.responseText);
}
});
}
}else{
window.location.href="https://0000902.mylshop.co.kr/mylshop/member/loginForm.action?link=http%3a%2f%2f0000902.m.mylshop.co.kr%3a8091";
}
}
function wishhome(){
window.location.href = "http://0000902.mylshop.co.kr/mylshop/shopCart/wishList.action";
}
var medicalMessage = ""
medicalMessage = medicalMessage + "본 상품코드는 자가소비용 상품코드입니다.
";
medicalMessage = medicalMessage + "의료기관에 판매 할 경우 반드시 ‘의료기기 보고용’으로 주문 해 주시기 바랍니다.
";
medicalMessage = medicalMessage + "본 상품 코드로 구매 후 의료기관에 판매 할 경우 법적 문제가 발생 할 수 있으며, 그 책임은 구입 한 회원에게 있습니다.
";
medicalMessage = medicalMessage + "동의하시겠습니까 ?
";
function AddCart(good_code,good_cyn,login_tf,option_tf){
//console.log(" good_code = [" + good_code + "]");
data = JSON.stringify({ "goodCode": good_code });
$.ajax({
type: "POST",
url: '/Goods/IsMedicalGoods',
datatype:"json",
contentType: 'application/json',
data: data,
success: function (data) {
//console.log(" data = [" + data + "]");
if (data == "1") {
confirmBox(medicalMessage, function(){ AddCartAction(good_code,good_cyn,login_tf,option_tf); }, function(){}, "")
} else {
AddCartAction(good_code,good_cyn,login_tf,option_tf);
}
},
error: function (a, b, c) {
console.log("오류발생");
}
});
}
function AddCartAction(good_code,good_cyn,login_tf,option_tf){
data = JSON.stringify({ "good_code": good_code,"good_cyn":good_cyn });
if(option_tf=="Y"){
confirmBox("옵션상품입니다.
상품상세페이지로 이동하시겠습니까?",callbackgoodTrue,function(){},good_code)
}else{
if(typecheck()=="Y") {
confirmBox("하이리빙 회원님은 mall.hiliving.co.kr에서 구매하실 수 있습니다.
하이리빙 쇼핑몰로 이동 하시겠습니까?",callbackmallgoodTrue,function(){},good_code)
}else{
$.ajax({
type:"POST"
,datatype:"json"
,contentType: 'application/json'
,url:'/Cart/AddCart'
,data:data
,success:function(data){
var result = "";
for (var i = 0; i < data.length; i++){
if(data[i].rtn_Message!=null){
result= data[i].rtn_Message;
alertBox(result);
}else{
confirmBox("장바구니에 상품이 담겼습니다.
장바구니로 이동하시겠습니까?",callbackMethodTrue,function(){})
}
}
SetCartCount();
},error:function(request){
errorBox(request.responseText);
}
});
}
}
}
function callbackMethodTrue(){
window.location.href='/Cart';
}
function callbackgoodTrue(good_code){
window.location.href='/Goods/Detail?good_code='+good_code;
}
function callbackmallgoodTrue(good_code){
if(Array.isArray(good_code)){
window.location.href='http://m.hiliving.co.kr';
}else{
if(typeof good_code=="undefined"){
window.location.href='http://m.hiliving.co.kr';
}else{
if(good_code.length<=6){
window.location.href='http://m.hiliving.co.kr/Goods/Details?goodcode='+good_code;
}else{
window.location.href='http://m.hiliving.co.kr';
}
}
}
}
function goOrder(_code, _cnt){
if( !(_code==undefined || _code==null || _code == "") ) {
data = JSON.stringify({ "goodCode": _code });
$.ajax({
type: "POST",
url: '/Goods/IsMedicalGoods',
datatype:"json",
contentType: 'application/json',
data: data,
success: function (data) {
//console.log(" data = [" + data + "]");
if (data == "1") {
confirmBox(medicalMessage, function(){ goOrderAction(_code, _cnt); }, function(){}, "")
} else {
goOrderAction(_code, _cnt);
}
},
error: function (a, b, c) {
console.log("오류발생");
}
});
} else {
goOrderAction(_code, _cnt);
}
}
function goOrderAction(_code, _cnt){
if(typecheck()=="Y") {
confirmBox("하이리빙 회원님은 mall.hiliving.co.kr에서 구매하실 수 있습니다.
하이리빙 쇼핑몰로 이동 하시겠습니까?",callbackmallgoodTrue,function(){},_code)
}else{
var codeData = { code : _code };
var cntData = { cnt : _cnt };
var url = "/Order/OrderWrite?" + $.param(codeData, true) + "&" + $.param(cntData, true);
location.href=url;
}
}
function setCookie(name, value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days* 60 * 60 * 1000));
var expires = "; expires=" + date.toGMTString();
} else {
var expires = "";
}
document.cookie = name + "=" + escape(value) + expires + "; path=/";
}
function LogOut() {
var url = "https://0000902.mylshop.co.kr/mylshop/member/logout.action?link=";
var id = "logOutFrame";
setCookie("GOOD_CODE", '',-1);
setCookie("GOOD_CNT", '',-1);
deleteCookie("SSO_SESSION_KEY", "/", ".mylshop.co.kr");
deleteCookie("SSO_SESSION_KEY", "/", ".mylshop.net");
deleteCookie("MYLSHOP_GUEST", "/", ".mylshop.co.kr");
deleteCookie("MYLSHOP_GUEST", "/", ".mylshop.net");
var iframe = document.createElement('iframe');
iframe.id = id;
iframe.style.display = "none";
iframe.src = url;
document.body.appendChild(iframe);
location.href = "/"
}
function deleteCookie(name, path, domain) {
if (getCookie(name)) {
document.cookie = name + "=" +
((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT" +
((path) ? "; path=" + path : "");
}
}
function getCookie(name) {
var dc = document.cookie;
var prefix = name + "=";
var begin = dc.indexOf("; " + prefix);
if (begin == -1) {
begin = dc.indexOf(prefix);
if (begin != 0) return null;
} else {
begin += 2;
}
var end = document.cookie.indexOf(";", begin);
if (end == -1) {
end = dc.length;
}
return unescape(dc.substring(begin + prefix.length, end));
}
$(function () {
$(".tab_content").hide();
$(".tab_content:first").show();
$("ul.direct_bth li").click(function () {
$("ul.direct_bth li").removeClass("active").children('div').css({
});
$(this).addClass("active").children('div').css({
});
$(".tab_content").hide()
var activeTab = $(this).attr("rel");
$("#" + activeTab).fadeIn();
});
$("a.parent_cate").click(function () {
var subUl = $(this).parent().find("ul[key=" + $(this).attr("key") + "]");
$(this).parent().parent().find("ul").hide();
$(this).parent().parent().find("ul").removeAttr("active");
$(this).parent().attr('class', 'subtitle');
$(subUl).fadeIn();
$(subUl).attr("active", "active");
$(this).parent().parent().children("li.subtitle").attr('class', 'subtitle');
$(this).parent().attr('class', 'subtitle sub_on');
});
});
$(document).on("keyup", "#mainSearchText", function (event) {
if (event.keyCode != 13)
AutoComplete();
if(event.keyCode===13){
CookiesetArray($("#mainSearchText").val());
window.location.href="/Home/Search?searchStr="+escape($("#mainSearchText").val());
}
});
function AutoComplete()
{
var keyword = $("#mainSearchText").val().trim();
$(".auto_word").empty();
if (event.keyCode != 13 && keyword != null && keyword.length > 0) {
$.ajax({
type: "POST",
url: '/Home/AutoComplete',
data: { "keyword": keyword },
async:false,
success: function (data) {
if (data.list.length > 0) {
$("#autocomplete").show();
var autoText = "";
var tmpAutoText = "