/***************************************************************/
var EJEJC_CPOP = false;
var EJEJC_ECOM = true;
var EJEJC_INCHK = false;
var EJEJC_INITCSS = true;
var EJEJC_POSTCALL = true;
var EJEJC_BGCOLOR = "#000";
var EJEJC_OPACITY = 60;
var EJEJC_WIDTH = 700;
var EJEJC_DEFAULT_HEIGHT = 270;
var EJEJC_DELTA = 70;
var EJEJC_MAX_HEIGHT = jQuery(window).height() - EJEJC_DELTA;

var EJEJC_HEIGHT = EJEJC_DEFAULT_HEIGHT;
var EJEJC_BRDRCOLOR = "#444";
var EJEJC_BEACON = '';
var EJEJC_STATUS = '';
var EJEJC_CDOMAIN = '';
var EJEJC_DOMAIN = EJEJC_scriptDomain();
var EJEJC_PROT = "https://";
var EJEJC_clnt;
var EJEJC_ga = 'none';
var EJEJC_iframeContentIdNm = '';
var EJEJC_shw_ldng = true;
var EJEJC_te = new Array();
var EJEJC_countInCart = 0;
if (typeof window.location.protocol != "undefined") {
    if (window.location.protocol.indexOf("http:") === 0) {
        EJEJC_PROT = "http://"
    }
}
jQuery(document).ready(function () {
	
//	  EJEJC_countInCart = EJEJC_gc('ej_ejc_cart_count');
//    if (!EJEJC_countInCart) EJEJC_countInCart = 0;
//    jQuery('#countItems').html('(' + EJEJC_countInCart + ')').fadeIn('slow');  
	
	  jQuery('input.ej_ejc_timbler').click(function () {
	  	  return EJEJC_tlc(jQuery(this).parents('form')[0]);        
    });
    
    jQuery('a.ej_ejc_ithkbx').click(function () {
        return EJEJC_ilc(this)
    });
    jQuery('input.ej_ejc_ithkbx').click(function () {
        return EJEJC_ilc(jQuery(this).parents('form')[0])
    });
    jQuery('a.ej_ejc_jthkbx').click(function () {
        return EJEJC_jlc(this)
    });
    jQuery('input.ej_ejc_jthkbx').click(function () {
        return EJEJC_jlc(jQuery(this).parents('form')[0])
    });
    jQuery('a.ec_ejc_thkbx,input.ec_ejc_thkbx').each(function (i) {
    	  
        if (jQuery(this).attr("href")) {        	  
            if (!jQuery(this).attr("onClick")) {            	  
                jQuery(this).click(function () {                	  
                    return EJEJC_lc(this)
                })
            }
        } else {
            if (!jQuery(this).attr("onClick")) {
                jQuery(this).click(function () {
                    return EJEJC_lc(jQuery(this).parents('form')[0])
                })
            }
            if (jQuery(this).parents('form').length > 0) {
                if (jQuery(jQuery(this).parents('form')[0]).attr("action")) {
                    if (!jQuery(jQuery(this).parents('form')[0]).attr("onSubmit")) {
                        jQuery(jQuery(this).parents('form')[0]).submit(function () {
                            return EJEJC_lc(this)
                        })
                    }
                }
            }
        }
    });
    if (EJEJC_ECOM) {
    	  
        if (typeof _gat != "undefined" && typeof ejGATracker != "undefined") {
            EJEJC_ga = 'ga';
            EJEJC_loadContent(EJEJC_PROT + 'checkout.google.com/files/digital/ga_post.js', 'ejejcgcscript')
        } else if (window.urchinTracker && typeof _ulink != "undefined") {
            if (_ulink == "1") {
                EJEJC_ga = 'urchin';
                EJEJC_loadContent(EJEJC_PROT + 'checkout.google.com/files/digital/urchin_post.js', 'ejejcgcscript')
            }
        }
    }
});

function tev(v) {
    try {
        var e = document.getElementsByTagName('embed');
        if (v == false) {
            EJEJC_te.length = 0;
            for (var i = 0; i < e.length; i++) {
                if (e[i].getAttribute("wmode") != 'transparent' && e[i].getAttribute("wmode") != 'opaque' && e[i].style.visibility != 'hidden' && e[i].style.display != 'none') {
                    EJEJC_te[i] = true;
                    e[i].style.visibility = 'hidden'
                }
            }
        } else {
            for (var i = 0; i < e.length; i++) {
                if (EJEJC_te[i]) {
                    e[i].style.visibility = 'visible'
                }
            }
        }
    } catch(e) {}
}

function beforeEjunkieLoad() {
	
}

function EJEJC_jlc(a) {
    var r;
    r = EJEJC_cmn(a, "j", false);
    if (typeof r != "undefined") {
        return r
    }
}

function EJEJC_tlc(a) {
    var r;
    
    EJEJC_show(a, "j", true, function(callback){    	
    	jQuery(a).ajaxSubmit({
        success: function(responseText, statusText) { 
        	if (!responseText.error) {
          	var url = "https://www.e-junkie.com/ecom/gb.php?c=cart&i=" + responseText.ejunkie_id + "&cl=37114&ejc=2&amount=" + responseText.extraCost + "&on0=" + responseText.itemName + "&os0=" + responseText.itemId;
          	if (responseText.custom) {
          		url += "&custom=" + responseText.custom;          		
          	}
            callback(url);
        	} else {
        		jQuery("#EJEJC_iframeContent").html('<p class="error">Sorry, internal error was occurred! Please try again later.</p>');
        	}
        },
        dataType: 'json'
      });    
    });
}

function EJEJC_ilc(a) {
    var r;
    r = EJEJC_cmn(a, "i", false);
    if (typeof r != "undefined") {
        return r
    }
}

function EJEJC_cmn(a, b, c) {
    var m;
    m = false;
    if (navigator.appVersion.toLowerCase().indexOf("mobile") != -1 || navigator.appVersion.toLowerCase().indexOf("mini") != -1 || navigator.appVersion.toLowerCase().indexOf("msie 5.") != -1 || navigator.appVersion.toLowerCase().indexOf("msie 4.") != -1) {
        m = true
    }
    if (a.href) {
        if (m) {
            window.open(a.href)
        } else {
            EJEJC_show(a.href, b, c)
        }
        try {
            a.blur()
        } catch(e) {}
        return false
    } else if (a.action) {
        actOnForm(m, a, b, c);
        return false
    } else if (typeof a == 'object') {
        a = findForm(a);
        if (a != false) {
            actOnForm(m, a, b, c);
            return false
        } else {
            return true
        }
    } else {
        if (a.indexOf('http') === 0) {
            if (m) {
                window.open(a)
            } else {
                EJEJC_show(a, b, c)
            }
        } else {
            return true
        }
    }
}

function findForm(a) {
    if (a.action && a.action.indexOf("gb.php") != -1) {
        return (a)
    } else {
        if (a.parentNode) {
            return findForm(a.parentNode)
        } else {
            return false
        }
    }
}

function actOnForm(m, a, b, c) {
    if (m) {
        a.submit()
    } else {
        var l;
        var i;
        l = a.action;
        for (i = 0; i < a.length; i++) {
            if (a.elements[i].value) {
                if (a.elements[i].type == 'radio' && a.elements[i].checked != true) continue;
                l = l + '&' + a.elements[i].name + '=' + encodeURIComponent(a.elements[i].value)
            }
        }
        EJEJC_show(l, b, c)
    }
}

function EJEJC_show(b, c, d, beforeAddToCardFunc) {
    try {
        var t;
        
        var f = "<div class='close' id='EJEJC_closeWindowButton'></div>";// "<div id='EJEJC_title' style='width:" + (EJEJC_WIDTH) + "px; height:25px; background-color:#eee;  margin:0 0 1px 0;padding:0; border:0;'><div id='EJEJC_closeWindow' style='padding:1px 5px 1px 5px; margin:0; text-align:right; float:right; line-height:20px;'><a href='javascript:;' id='EJEJC_closeWindowButton' title='Close' style='text-decoration:none; font-family:Verdana, Arial; font-size:10px; color:#666;'>Close</a></div></div>";
        var g = "overflow-x:hidden;overflow-y:auto;scrollbar-face-color: #f4f4f0; scrollbar-shadow-color: #d0d0d0; scrollbar-highlight-color: #FFFFFF; scrollbar-3dlight-color: #4F4F82; scrollbar-darkshadow-color: #4F4F82; scrollbar-arrow-color: #666666; scrollbar-track-color: #CCCCCC;";
        var h = '';
        var i = EJEJC_OPACITY / 100;
        var j = EJEJC_DEFAULT_HEIGHT;
        var k = new Date();
        
        if (document.getElementById("EJEJC_overlay") == null) {
            tev(false);
//            if (navigator.appVersion.toLowerCase().indexOf("msie 6.") != -1) {
//            	  
//                h += "<iframe id='EJEJC_HideSelect' src='" + EJEJC_PROT + EJEJC_DOMAIN + "/ecom/blank.html' style='z-index:11099;position:absolute;top:0;left:0;background-color:#fff;border:none;filter:alpha(opacity=0);-moz-opacity: 0;opacity: 0;'></iframe>"
//            }
            h += "<div id='EJEJC_overlay' style='position:absolute;z-index:11100;top:0px;left:0px;";
            if (EJEJC_detectMacXFF()) {
                h += "background: url(" + EJEJC_PROT + EJEJC_DOMAIN + "/ecom/macffbg.png) repeat;"
            } else {
                h += "background-color:" + EJEJC_BGCOLOR + ";filter:alpha(opacity=" + EJEJC_OPACITY + ");-moz-opacity: " + i + ";opacity:" + i + ";"
            }
            h += "'></div>";
            h += "<div id='EJEJC_window' style='position:absolute;background:#ffffff;z-index:11102;border: 1px solid " + EJEJC_BRDRCOLOR + ";text-align:left;'></div>";
            jQuery("body").append(h);
            jQuery("#EJEJC_overlay").click(EJEJC_remove).bgiframe();
        }
        EJEJC_overlaySize();
        
        if (beforeAddToCardFunc) {
        	if (document.getElementById("EJEJC_iframeContent") == null) {
              jQuery("#EJEJC_window").append(f + "<div id='EJEJC_iframeContent' style='width:" + (EJEJC_WIDTH) + "px;min-height:" + (j) + "px;_height:" + (j) + "px;" + g + "'></div>")                
          }
        	EJEJC_pos();
          jQuery(window).resize(function () {
          	var height = jQuery(window).height() - EJEJC_DELTA;
            EJEJC_MAX_HEIGHT = (height < EJEJC_DEFAULT_HEIGHT) ? EJEJC_DEFAULT_HEIGHT : height;
            EJEJC_rezise_window_height();
            EJEJC_HEIGHT = jQuery('#EJEJC_iframeContent').height();
            EJEJC_overlaySize();
            EJEJC_pos()
          });
//          jQuery(window).scroll(EJEJC_pos);
          jQuery("#EJEJC_closeWindowButton").click(EJEJC_remove);
          document.onkeyup = function (e) {
              if (e == null) {
                  var a = event.keyCode
              } else {
                  var a = e.which;
                  if (!a) {
                      var a = e.keyCode
                  }
              }
              if (a == 27) {
                  EJEJC_remove()
              }
          };
          if (EJEJC_shw_ldng) EJEJC_ldng();
          beforeAddToCardFunc(function(response) {
          	b = response;
          	if (EJEJC_ga == 'urchin') {
                t = b.substring(7);
                urchinTracker(t)
            } else if (EJEJC_ga == 'ga') {
                t = b.substring(7);
                ejGATracker._trackPageview('t')
            }
            if (d == true) {
                b = EJEJC_cartify(b)
            }
            
            if (b.indexOf("?") === -1) {
                b = b + '?'
            }
            if (c == "j") {
            	  b = b + "&jsod=1&" + k.getTime();
            }
            if (c == "j") {
                EJEJC_loadContent(b, 'ejejcscript')
            }
          });
        	
        } else {
          if (EJEJC_ga == 'urchin') {
              t = b.substring(7);
              urchinTracker(t)
          } else if (EJEJC_ga == 'ga') {
              t = b.substring(7);
              ejGATracker._trackPageview('t')
          }
          if (d == true) {
              b = EJEJC_cartify(b)
          }
          
          if (b.indexOf("?") === -1) {
              b = b + '?'
          }
          if (c == "j") {
              b = b + "&jsod=1&" + k.getTime();
              if (document.getElementById("EJEJC_iframeContent") == null) {
                  jQuery("#EJEJC_window").append(f + "<div id='EJEJC_iframeContent' style='width:" + (EJEJC_WIDTH) + "px;min-height:" + (j) + "px;_height:" + (j) + "px;" + g + "'></div>")                
              }
          } else {
              b = b + "&iframe=1&" + k.getTime();
              EJEJC_iframeContentIdNm = "R" + Math.round(Math.random() * 1000) + "T" + k.getTime();
              document.getElementById("EJEJC_window").innerHTML = f + "<iframe frameborder='0' hspace='0' src='" + b + "' id='" + EJEJC_iframeContentIdNm + "' name='" + EJEJC_iframeContentIdNm + "' style='width:" + (EJEJC_WIDTH) + "px;height:" + (j) + "px;" + g + "'> </iframe>"
          }
          EJEJC_pos();
          jQuery(window).resize(function () {
            var height = jQuery(window).height() - EJEJC_DELTA;
            EJEJC_MAX_HEIGHT = (height < EJEJC_DEFAULT_HEIGHT) ? EJEJC_DEFAULT_HEIGHT : height;
            EJEJC_rezise_window_height();
            EJEJC_HEIGHT = jQuery('#EJEJC_iframeContent').height();
            EJEJC_overlaySize();
            EJEJC_pos()
          });
//          jQuery(window).scroll(EJEJC_pos);
          jQuery("#EJEJC_closeWindowButton").click(EJEJC_remove);
          document.onkeyup = function (e) {
              if (e == null) {
                  var a = event.keyCode
              } else {
                  var a = e.which;
                  if (!a) {
                      var a = e.keyCode
                  }
              }
              if (a == 27) {
                  EJEJC_remove()
              }
          };
          if (c == "j") {   
              EJEJC_loadContent(b, 'ejejcscript')
          }
        }
    } catch(e) {}
}

function EJEJC_ldng() {
    var t;
    t = document.getElementById("EJEJC_iframeContent");
    if (t) {
    	  EJEJC_HEIGHT = EJEJC_DEFAULT_HEIGHT;
    	  EJEJC_overlaySize();
        EJEJC_pos();
    	  jQuery(t).html("<center><img src='" + EJEJC_PROT + EJEJC_DOMAIN + "/ecom/ldng.gif' alt='Loading..' style='color:#000;margin:120px 0 0 0;'/><br/><font face='verdana' style='color:#000' size='1'>LOADING</font></center>").css({'height': EJEJC_DEFAULT_HEIGHT + "px", 'overflow': 'visible'});
//        jQuery("#EJEJC_iframeContent").css('overflow-y', 'hidden')
    }
}

function EJEJC_remove() {
    jQuery("#EJEJC_overlay").unbind();
    jQuery("#EJEJC_closeWindowButton").unbind();
    jQuery("#EJEJC_window").fadeOut("fast", function () {
        jQuery('#EJEJC_window,#EJEJC_overlay,#EJEJC_HideSelect').unbind().remove()
    });
    document.onkeyup = "";
    tev(true);
    return false
}

function EJEJC_detectMacXFF() {
    var a = navigator.userAgent.toLowerCase();
    if (a.indexOf('mac') != -1 && a.indexOf('firefox') != -1) {
        return true
    }
}

function EJEJC_overlaySize() {
    if (window.innerHeight && window.scrollMaxY || window.innerWidth && window.scrollMaxX) {
        yScroll = window.innerHeight + window.scrollMaxY;
        xScroll = window.innerWidth + window.scrollMaxX;
        var a = document.documentElement;
        var b = (a && a.clientWidth) || document.body.clientWidth || window.innerWidth || self.innerWidth;
        var c = (a && a.clientHeight) || document.body.clientHeight || window.innerHeight || self.innerHeight;
        xScroll -= (window.innerWidth - b);
        yScroll -= (window.innerHeight - c)
    } else if (document.body.scrollHeight > document.body.offsetHeight || document.body.scrollWidth > document.body.offsetWidth) {
        yScroll = document.body.scrollHeight;
        xScroll = document.body.scrollWidth
    } else {
        yScroll = document.body.offsetHeight;
        xScroll = document.body.clientWidth
    }
    jQuery("#EJEJC_overlay").css({
        "height": yScroll + "px",
        "width": xScroll + "px"
    });
    if (document.getElementById("EJEJC_HideSelect") != null) {
        jQuery("#EJEJC_HideSelect").css({
            "height": yScroll + "px",
            "width": xScroll + "px"
        })
    }
}

function EJEJC_pos() {
    var a = EJEJC_getPageSize();
    var b = EJEJC_getPageScrollTop();
    var top = (b[1] + (a[1] - EJEJC_HEIGHT) / 2);
    
    if (top < 0) {
    	top = 10;
    }
    
    jQuery("#EJEJC_window").css({
        width: EJEJC_WIDTH + "px",
        left: (b[0] + (a[0] - EJEJC_WIDTH) / 2) + "px",
        top: top + "px"
    })
}

function EJEJC_getPageScrollTop() {
    var a;
    var b;
    if (self.pageYOffset || self.pageXOffset) {
        a = self.pageYOffset;
        b = self.pageXOffset
    } else if (document.documentElement && document.documentElement.scrollTop || document.documentElement.scrollLeft) {
        a = document.documentElement.scrollTop;
        b = document.documentElement.scrollLeft
    } else if (document.body) {
        a = document.body.scrollTop;
        b = document.body.scrollLeft
    }
    arrayPageScroll = new Array(b, a);
    return arrayPageScroll
}

function EJEJC_getPageSize() {
    var a = document.documentElement;
    var w = document.body.clientWidth || window.innerWidth || self.innerWidth || (a && a.clientWidth);
    var h = window.innerHeight || self.innerHeight || (a && a.clientHeight) || document.body.clientHeight;
    arrayPageSize = new Array(w, h);
    return arrayPageSize
}

function EJEJC_setCookie(a, b, e) {	
	jQuery.cookie(a, b, { expires: 1, path: '/', domain: ''});
//    var t = new Date();
//    t.setTime(t.getTime());
//    var e = (e) ? "" : (new Date(t.getTime() + (1 * 24 * 60 * 60 * 1000))).toGMTString();
//    var d;
//    d = document.domain;
//    var c;
//    c = EJEJC_CDOMAIN;
//    
//    if (c == 'true') {} else if (c) {
//        if (c.indexOf(".") > 0) {
//            c = c.toLowerCase();
//            if (d.indexOf(c) + c.length == d.length) {
//                d = c
//            }
//        } else {}
//    } else {
//    	d = '';
////        d = EJEJC_baseDomain(d)
//        
//    }
////    document.cookie = a + "=" + encodeURIComponent(b) + ";expires=" + e + ";path=/;"
//    document.cookie = a + "=" + encodeURIComponent(b) + ";expires=" + e + ";path=/;domain=" + d + ";"
}

function EJEJC_gc(a) {
    var b = a + "=";
    var d = document.cookie.split(';');
    for (var i = 0; i < d.length; i++) {
        var c = d[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(b) == 0) return c.substring(b.length, c.length)
    }
    return null
}

function EJEJC_scriptDomain() {
    var d;
    var e;
    var i;
    var a;
    var b;
    b = 'www.e-junkie.com';
    try {
        var e = document.getElementsByTagName('script');
        for (var i = 0; i < e.length; i++) {
            if (e[i]) {
                d = e[i].src.split(/\//);
                if (d) {
                    if (d.length == 5) {
                        if ((d[3] == 'ecom') && (d[4] == 'box.js' || d[4] == 'box2.js')) {
                            a = EJEJC_baseDomain(d[2]);
                            if (a == 'e-junkie.com' || a == 'fatfreecart.com' || a == 'fatfreecartpro.com') {
                                b = d[2];
                                break
                            }
                        }
                    }
                }
            }
        }
    } catch(e) {}
    return (b)
}

function EJEJC_baseDomain(d) {
    var e;
    var s;
    var l;
    e = d.split(/\./);
    l = e.length;
    if (l <= 2) {
        s = d
    } else {
        s = e[l - 2] + "." + e[l - 1];
        if (e[l - 1].length == 2 || s == "blogspot.com" || s == "wordpress.com") {
            s = e[l - 3] + "." + s
        }
    }
    return (s)
}

function EJEJC_loadContent(a, b) {	
  if (jQuery('#ej_ejc_frm_1 input[name=custom]').length == 1) {
  	a += ";custom=" + jQuery('#ej_ejc_frm_1 input[name=custom]').val();
  	jQuery('#ej_ejc_frm_1 input[name=custom]').remove();
  } 
	
  if (EJEJC_shw_ldng) EJEJC_ldng();
  if (typeof(b) == "undefined") {
      b = 'ejejcscript'
  }
   
  var c = document.getElementsByTagName('head').item(0);
  try {
      var d = document.getElementById(b);
      if (d) {
          if (navigator.appVersion.toLowerCase().indexOf("msie 6.") != -1) {
              if (EJEJC_getbase() == null) {
                  c.removeChild(d)
              }
          } else {
              c.removeChild(d)
          }
      }
  } catch(e) {}
  script = document.createElement('script');
  script.src = a;
  script.type = 'text/javascript';
  script.id = b;
  c.appendChild(script);
}

function EJEJC_getbase() {
    var a = document.all.tags('BASE');
    return ((a && a.length) ? a[0].href : null)
}
if (window.EJEJC_config) EJEJC_config();
if (EJEJC_INITCSS) {
    jQuery("html").css('min-height', '100%').css('height', 'auto').css('height', '100%').css('padding', '0').css('margin', '0');
    jQuery("body").css('min-height', '100%').css('height', 'auto').css('height', '100%').css('padding', '0').css('margin', '0')
}
//if (EJEJC_ECOM) {
//    EJEJC_loadContent(EJEJC_PROT + EJEJC_DOMAIN + '/ecom/boxec22_enc.js', 'ejejcecomscript')
//}

/***************************************************************/

var ejejc_multi = new Array();
var ejejc_multi_pos = 0;
jQuery.fn.highlightFade = function (b) {
    var o = (b && b.constructor == String) ? {
        start: b
    } : b || {};
    var d = jQuery.highlightFade.defaults;
    var i = o['interval'] || d['interval'];
    var a = o['attr'] || d['attr'];
    var f = {
        'linear': function (s, e, t, c) {
            return parseInt(s + (c / t) * (e - s))
        },
        'sinusoidal': function (s, e, t, c) {
            return parseInt(s + Math.sin(((c / t) * 90) * (Math.PI / 180)) * (e - s))
        },
        'exponential': function (s, e, t, c) {
            return parseInt(s + (Math.pow(c / t, 2)) * (e - s))
        }
    };
    var t = (o['iterator'] && o['iterator'].constructor == Function) ? o['iterator'] : f[o['iterator']] || f[d['iterator']] || f['linear'];
    if (d['iterator'] && d['iterator'].constructor == Function) t = d['iterator'];
    return this.each(function () {
        if (!this.highlighting) this.highlighting = {};
        var e = (this.highlighting[a]) ? this.highlighting[a].end : jQuery.highlightFade.getBaseValue(this, a) || [255, 255, 255];
        var c = jQuery.highlightFade.getRGB(o['start'] || o['colour'] || o['color'] || d['start'] || [255, 255, 128]);
        var s = jQuery.speed(o['speed'] || d['speed']);
        var r = o['final'] || (this.highlighting[a] && this.highlighting[a].orig) ? this.highlighting[a].orig : jQuery.curCSS(this, a);
        if (o['end'] || d['end']) r = jQuery.highlightFade.asRGBString(e = jQuery.highlightFade.getRGB(o['end'] || d['end']));
        if (typeof o['final'] != 'undefined') r = o['final'];
        if (this.highlighting[a] && this.highlighting[a].timer) window.clearInterval(this.highlighting[a].timer);
        this.highlighting[a] = {
            steps: ((s.duration) / i),
            interval: i,
            currentStep: 0,
            start: c,
            end: e,
            orig: r,
            attr: a
        };
        jQuery.highlightFade(this, a, o['complete'], t)
    })
};
jQuery.highlightFade = function (e, a, o, t) {
    e.highlighting[a].timer = window.setInterval(function () {
        var b = t(e.highlighting[a].start[0], e.highlighting[a].end[0], e.highlighting[a].steps, e.highlighting[a].currentStep);
        var c = t(e.highlighting[a].start[1], e.highlighting[a].end[1], e.highlighting[a].steps, e.highlighting[a].currentStep);
        var d = t(e.highlighting[a].start[2], e.highlighting[a].end[2], e.highlighting[a].steps, e.highlighting[a].currentStep);
        jQuery(e).css(a, jQuery.highlightFade.asRGBString([b, c, d]));
        if (e.highlighting[a].currentStep++>=e.highlighting[a].steps) {
            jQuery(e).css(a, e.highlighting[a].orig || '');
            window.clearInterval(e.highlighting[a].timer);
            e.highlighting[a] = null;
            if (o && o.constructor == Function) o.call(e)
        }
    },
    e.highlighting[a].interval)
};
jQuery.highlightFade.defaults = {
    start: [255, 255, 128],
    interval: 50,
    speed: 400,
    attr: 'backgroundColor'
};
jQuery.highlightFade.getRGB = function (c, d) {
    return ([255, 255, 128])
};
jQuery.highlightFade.asRGBString = function (a) {
    return "rgb(" + a.join(",") + ")"
};
jQuery.highlightFade.getBaseValue = function (e, a, b) {
    return ([241, 241, 241])
};

function EJEJC_lc(a) {
    var r;
    r = EJEJC_cmn(a, "j", true);
    if (typeof r != "undefined") {
        return r
    }
}

function EJEJC_frm(a) {
    return EJEJC_lc(a)
}

function EJEJC_cartify(a) {
    var b;
    var d;
    var e;
    var f;
    var g = a.replace("?", "&").split('&');
    for (var i = 0; i < g.length; i++) {
        var c = g[i];
        if (c.substring(0, 3) == 'cl=') {
            f = c.substring(3);
            break
        }
    }
    
    EJEJC_clnt = f;
    b = EJEJC_gc('ej_ejc_cart_id' + f);
    d = EJEJC_gc('ej_ejc_cart_md5' + f);
    e = EJEJC_gc('ej_ejc_cart_currency' + f);
    ej_ejc_to_country = EJEJC_gc('ej_ejc_to_country' + f);
    ej_ejc_zipcode = EJEJC_gc('ej_ejc_zipcode' + f);
    if (b) {
        EJEJC_setCookie('ej_ejc_cart_id' + f, b);
        EJEJC_setCookie('ej_ejc_cart_md5' + f, d);
        EJEJC_setCookie('ej_ejc_cart_currency' + f, e);
        EJEJC_setCookie('ej_ejc_to_country' + f, ej_ejc_to_country);
        EJEJC_setCookie('ej_ejc_zipcode' + f, decodeURIComponent(ej_ejc_zipcode))
    }
    a = a + '&cart_md5=' + d + '&cart_id=' + b + '&cart_currency=' + e + '&to_country=' + ej_ejc_to_country + '&zipcode=' + ej_ejc_zipcode;
    return (a)
}

function EJEJC_implode() {
    var a;
    var b;
    var c;
    var d;
    var i = 0;
    a = b = c = d = '';
    while (document.ej_ejc_frm_1['ci_id_array[' + i + ']']) {
        a = a + document.ej_ejc_frm_1['ci_id_array[' + i + ']'].value;
        b = b + document.ej_ejc_frm_1['quantity_array[' + i + ']'].value.replace(",", "");
        d = d + document.ej_ejc_frm_1['cart_item_price_array[' + i + ']'].value.replace(",", ".");
        if (document.ej_ejc_frm_1['remove_array[' + i + ']'].checked == false) {
            c = c + "0"
        } else {
            c = c + "1"
        }
        if (document.ej_ejc_frm_1['ci_id_array[' + (i + 1) + ']']) {
            a = a + ',';
            b = b + ',';
            c = c + ',';
            d = d + ','
        }
        i++
    }
    return ('&cilist=' + a + '&qlist=' + b + '&rlist=' + c + '&ciplist=' + d)
}

function EJEJC_checkout(a, b, c, d, f) {
  function checkout() {
    var g;
    var i;
    var j;
    var k;
    var l;
    var h = '/' + EJEJC_DOMAIN + '/ecom/';
    var m = '/' + EJEJC_DOMAIN + '/ecom/checkout';
    var n;
    i = j = k = '';
    EJEJC_f = new Object();
    EJEJC_f.action = "https://" + EJEJC_DOMAIN + "/ecom/rp.php";
    l = encodeURIComponent(EJEJC_BEACON);
    if (b == 'gc') {
        if (window.getUrchinFieldValue) {
            if (EJEJC_ga == 'urchin') {
                try {
                    k = getUrchinFieldValue()
                } catch(e) {}
            } else if (EJEJC_ga == 'ga' && window.setUrchinInputCode) {
                try {
                    setUrchinInputCode(ejGATracker);
                    k = getUrchinFieldValue()
                } catch(e) {}
            }
        }
    }
    try {
        a += '&ec_url=' + encodeURIComponent(top.location.href)
    } catch(e) {}
    if (b == 'cc') {
        g = 'https://www.e-junkie.com'
    } else {
        g = EJEJC_PROT + EJEJC_DOMAIN
    }
    if (c == 'ff') {
        if (EJEJC_ga == 'urchin') {
            try {
                urchinTracker(m)
            } catch(e) {}
        } else if (EJEJC_ga == 'ga') {
            try {
                ejGATracker._trackPageview(m)
            } catch(e) {}
        }
        EJEJC_loadContent(g + '/ecom/ffstandard.php?' + a + '&adata=' + k, 'ejejcscript')
    } else {
        if (EJEJC_chktCheck2()) {
            EJEJC_ldng();
            if (EJEJC_ga == 'urchin' && window.__utmLinkPost) {
                try {
                    __utmLinkPost(EJEJC_f);
                    j = encodeURIComponent(EJEJC_f.action.substring(37));
                    i = _uacct
                } catch(e) {}
            } else if (EJEJC_ga == 'ga' && typeof ejGATracker._linkByPost != "undefined") {
                try {
                    ejGATracker._linkByPost(EJEJC_f);
                    j = encodeURIComponent('gajs=true&' + EJEJC_f.action.substring(37));
                    i = ejGATracker._getAccount()
                } catch(e) {}
            }
            if (b == 'gc') {
                n = 'GoogleCheckout';
                if (EJEJC_ga == 'urchin') {
                    try {
                        urchinTracker(h + n)
                    } catch(e) {}
                } else if (EJEJC_ga == 'ga') {
                    try {
                        ejGATracker._trackPageview(h + n)
                    } catch(e) {}
                }
                EJEJC_goto(g + '/gc' + c + '/CheckoutShoppingCart.php?' + a + '&adata=' + k + '&auser=' + i + '&astring=' + j + '&abeacon=' + l, EJEJC_CPOP)
            } else if (b == 'ec') {
                n = 'PayPalExpressCheckout';
                if (EJEJC_ga == 'urchin') {
                    try {
                        urchinTracker(h + n)
                    } catch(e) {}
                } else if (EJEJC_ga == 'ga') {
                    try {
                        ejGATracker._trackPageview(h + n)
                    } catch(e) {}
                }
                EJEJC_goto(g + '/ecom/express' + c + '.php?' + a + '&auser=' + i + '&astring=' + j + '&abeacon=' + l, EJEJC_CPOP)
            } else if (b == 'cc' || b == 'ej') {
                if (b == 'cc') n = 'CreditCardCheckout';
                else n = 'GiftCheckout';
                if (EJEJC_ga == 'urchin') {
                    try {
                        urchinTracker(h + n)
                    } catch(e) {}
                } else if (EJEJC_ga == 'ga') {
                    try {
                        ejGATracker._trackPageview(h + n)
                    } catch(e) {}
                }
                var o = g + '/ecom/' + b + c + '.php?' + a + (EJEJC_INCHK ? '&inchk=1' : '') + '&auser=' + i + '&astring=' + j + '&abeacon=' + l;
                if (EJEJC_INCHK) {
                    EJEJC_ilc(o)
                } else {
                    EJEJC_goto(o, EJEJC_CPOP)
                }
            } else {
                if (EJEJC_CPOP) {
                    EJEJC_remove();
                    a += "&pptarget=_blank"
                }
                if (b == 'tp') {
                    if (EJEJC_ga == 'urchin') {
                        try {
                            urchinTracker(h + 'TrialPayCheckout')
                        } catch(e) {}
                    } else if (EJEJC_ga == 'ga') {
                        try {
                            ejGATracker._trackPageview(h + 'TrialPayCheckout')
                        } catch(e) {}
                    }
                    EJEJC_loadContent(g + '/ecom/tp' + c + '.php?' + a + '&auser=' + i + '&astring=' + j + '&abeacon=' + l, 'ejejcscript')
                } else {
                    if (EJEJC_ga == 'urchin') {
                        try {
                            urchinTracker(h + 'PayPalCheckout')
                        } catch(e) {}
                    } else if (EJEJC_ga == 'ga') {
                        try {
                            ejGATracker._trackPageview(h + 'PayPalCheckout')
                        } catch(e) {}
                    }
                    EJEJC_loadContent(g + '/ecom/standard' + c + '.php?' + a + '&auser=' + i + '&astring=' + j + '&abeacon=' + l, 'ejejcscript')
                }
            }
        }
    }      
  }	
	
  if (jQuery('#ej_ejc_frm_1').valid()) {  	
    if (jQuery('#loginBlock').is(':visible')) {
      var params = {
        email: jQuery('#email').val(),
        password: jQuery('#password').val()
      }
      jQuery('#loginBlock').find('p.errorMsg').fadeOut('slow');
      jQuery.post(baseUrl + "users/login_process", params,
        function(data){
          if (data.valid) {
          	jQuery('#ej_ejc_frm_1').append('<input type="hidden" id="custom" name="custom" value="' + data.userId + '"/>')
          	checkout(); 
//            jQuery('#btnUpdtCart').click();            
//          	var intervalID = setInterval(function() {
//          	  if (jQuery('#ejejctable').length > 0) {
//          	  	clearInterval(intervalID);          	  	
//          	    checkout();         	    
//          	  }
//          	}, 10);
          } else {
            jQuery('#loginBlock').find('p.errorMsg').html(data.errorMsg).fadeIn('slow');
          }          
        },'json');
    } else if (jQuery('#registrationBlock').is(':visible')) {
    	EJEJC_setCookie('ej_ejc_user_pass', jQuery('#pass').val());
      checkout();
    } else {
    	checkout();
    }
  }
	
}

function EJEJC_goto(l, p) {
    if (p) {
        EJEJC_remove();
        window.open(l)
    } else {
        try {
            top.location.href = l
        } catch(e) {
            EJEJC_remove();
            window.open(l)
        }
    }
}

function EJEJC_rezise_window_height() {
	if (document.getElementById("ejejctable").offsetHeight > EJEJC_MAX_HEIGHT ) {
    jQuery("#EJEJC_iframeContent").css({'overflow-y': 'scroll', 'height': EJEJC_MAX_HEIGHT});        
    jQuery("#ejejctable").css('width', (EJEJC_WIDTH - 16) + 'px');
  } else {
    jQuery("#EJEJC_iframeContent").css({'overflow-y': 'visible', 'height': 'auto'});
    jQuery("#ejejctable").css('width', '100%');
  }
}

function EJEJC_callshown() {
    if (EJEJC_POSTCALL == true) {
        if (typeof EJEJC_POSTCALL != "undefined") {
            EJEJC_shown()
        }
    }
    if (document.getElementById("EJEJC_iframeContent").offsetHeight) {
    	EJEJC_rezise_window_height();
    }
}

function EJEJC_cartsize() {
    var a;
    var i;
    i = 0;
    a = EJEJC_gc('qty');
    if (!a) {
        while (document.ej_ejc_frm_1['quantity_array[' + i + ']']) {
            a += document.ej_ejc_frm_1['quantity_array[' + i + ']'].value - 0;
            i++
        }
        EJEJC_setCookie('ej_ejc_cartsize' + EJEJC_clnt, a)
    }
    return (a)
}

function EJEJC_cartamt() {
    var a;
    var i;
    i = 0;
    a = EJEJC_gc('amt');
    if (!a) {
        while (document.ej_ejc_frm_1['total_item_price_array[' + i + ']']) {
            a += document.ej_ejc_frm_1['total_item_price_array[' + i + ']'].value - 0;
            i++
        }
        a = Math.round(a * 100) / 100;
        EJEJC_setCookie('ej_ejc_cartamt' + EJEJC_clnt, a)
    }
    return (a)
}

function EJEJC_added(a) {
    var i;
    i = 0;
    while (document.ej_ejc_frm_1['item_number_array[' + i + ']']) {
        if (document.ej_ejc_frm_1['item_number_array[' + i + ']'].value == a) {
            return (i)
        }
        i++
    }
    return (false)
}

function EJEJC_multiAdd(a) {
    ejejc_multi = a;
    EJEJC_multiCall()
}

function EJEJC_multiCall() {
    var i = ejejc_multi_pos;
    if (ejejc_multi[i]) {
        if (i < ejejc_multi.length - 1) {
            ejejc_multi[i] += "&show_cntnt=no";
            EJEJC_shw_ldng = false
        } else {
            EJEJC_shw_ldng = true
        }
        ejejc_multi_pos++;
        EJEJC_show(ejejc_multi[i], "j", true);
        if (i == ejejc_multi.length - 1) {
            ejejc_multi_pos = 0
        }
    }
}
/***************************/
function EJEJC_shown() {
	jQuery('#tdHeader').parents('table').remove();
	jQuery('#fldZipcode').parents('tr:first').next().height(10);
	jQuery('#fldZipcode').attr('title', 'Please enter a valid ZIP/Postal Code, and press the UPDATE CART button').addClass('required').wrap("<span id='ejunkieZipCode'></span>");
	
	if (jQuery('#ejejctable').find('tr').length == 2) {
		jQuery('#btnContShop').remove();
		jQuery('#ejejctable').find('tr:first td').css({'text-align': 'center', 'padding-top': '20px'});		
	} else {					
		jQuery('#tdSell').load(baseUrl + 'users/login_register_form',function(){
			EJEJC_HEIGHT = jQuery('#EJEJC_iframeContent').height();
		  EJEJC_overlaySize();
      EJEJC_pos();
      
      jQuery('#hasAccount').click(function() {
        jQuery('#registrationBlock').hide();
        jQuery('#pass1').attr('disabled', 'disabled').removeClass('required').removeClass('error').next().hide();
        jQuery('#pass').attr('disabled', 'disabled').removeClass('required').removeClass('error').next().hide();    
        
        jQuery('#loginBlock').show();
        jQuery('#email').removeAttr('disabled').addClass('required').focus();
        jQuery('#password').removeAttr('disabled').addClass('required');
        EJEJC_HEIGHT = jQuery('#EJEJC_iframeContent').height();
        EJEJC_overlaySize();
        EJEJC_pos();
      });
      jQuery('#createAccount').click(function() {
        jQuery('#loginBlock').hide();
        jQuery('#email').attr('disabled', 'disabled').removeClass('required').removeClass('error').next().hide();
        jQuery('#password').attr('disabled', 'disabled').removeClass('required').removeClass('error').next().hide();
        
        jQuery('#registrationBlock').show();
        jQuery('#pass1').removeAttr('disabled').addClass('required');
        jQuery('#pass').removeAttr('disabled').addClass('required').focus();
        EJEJC_HEIGHT = jQuery('#EJEJC_iframeContent').height();
        EJEJC_overlaySize();
        EJEJC_pos();
      });
		});				
	}
	EJEJC_countInCart = jQuery('#ejejctable').find('tr[id^=td]').length;
	jQuery('#countItems').html('('+EJEJC_countInCart+')');
	EJEJC_setCookie('ej_ejc_cart_count', EJEJC_countInCart);
	
	jQuery('#ejejctable').parents('form').validate({
	  errorElement: 'span'
	});
	
}
/***************************/