// JavaScript Document
jQuery.noConflict();
  jQuery(document).ready(function($)  {
    // category title removal in product page	
    if ($('#prodTitle .title3 ').size()) {
        $('#shopRightCont .title3').not('#prodTitle .title3').remove();
        $('#shopRightCont .title3').css('display', 'block');
    } else {
        $('#shopRightCont .title3').css('display', 'block');
    };
	if ($('.rating img').length ){
  var changedSrc = $('.rating img').attr("src").replace('CatalystImages', 'images')
  $('.rating img').attr("src", changedSrc);       
};
$(".blog-comment-container .comment br").remove();//remove line breaks in comment
$(".cartLink").wrap('<div class="emptyCart" />')
$('a[rel="blank"]').click(function(){
  this.target = "_blank";
});
      $("#mainTwitter").tweet({
        avatar_size: 0,
        count: 2,
        username: ["SensitiveSweets"],
        loading_text: "searching twitter...",
        refresh_interval: 100
      });
      if ($(".photogalleryNavigation a").length ) {
     $(".photogalleryNavigation a:contains('Next')").addClass("photoNext");
	 $(".photogalleryNavigation a:contains('Previous')").addClass("photoPrev");
      };
		$('.cartInputText, #DiscountCode, #ShippingOptions').live("change", function () {
                 //   Cufon.refresh();    
			$(".title3").css('display', 'block'); 
			Cufon.set('fontFamily', 'Museo 900').replace('.museo9')
			Cufon.set('fontFamily', 'Museo 700').replace('.title3')
			//  Cufon.set('fontFamily', 'Museo 700').replace('.title3')    
			});
			$('.cart .update').live("click", function () {
			$(".title3").css('display', 'block'); 
             Cufon.set('fontFamily', 'Museo 900').replace('.museo9')
			 Cufon.set('fontFamily', 'Museo 700').replace('.title3')
			//  Cufon.set('fontFamily', 'Museo 700').replace('.title3')     
			});
	//v2.0
	//slide buttons positionning
	if ($('#slideNav li').size()) {
	var  addy = 0; 	
	$("#slideNav li").each(function () {
    $(this).css('margin-top', addy+'px')
	addy = addy + 3 ;
	});
	}; 
	//fadein and out hovers
    $('a').not('.goBack a').hover(function () {
        $(this).children('.on').stop().animate({
            opacity: "1"
        }, 400);
		$(this).children('.off').stop().animate({
            opacity: "0"
        }, 500);
    }, function () {
		$(this).children('.off').stop().animate({
            opacity: "1"
        }, 400);
        $(this).children('.on').stop().animate({
            opacity: "0"
        }, 500);
    });
	//submits
	  $('.submit, .send').hover(function () {
        $(this).children('input').stop().animate({
            opacity: "1"
        }, 300);
    }, function () {
        $(this).children('input').stop().animate({
            opacity: "0"
        }, 300);
    });
	//go back (press)
	 $('.goBack').hover(function () {
        $(this).children('a').stop().animate({
            opacity: "1"
        }, 300);
    }, function () {
        $(this).children('a').stop().animate({
            opacity: "0"
        }, 300);
    });
	//form label fades
	$('.cat_textbox_small, .cat_textbox, textarea').not("#Amount").val(''); //clear fields on load (ff mainly)
    $('.cat_textbox_small, .cat_textbox, textarea').not('#Amount').focusin(function () {
        $(this).parent().children("label").fadeOut()
        $(this).parents('.captchaimg1').children("label").fadeOut()
    });
    $('.cat_textbox_small, .cat_textbox, textarea').focusout(function () {
        if ($(this).val() == '') {
            $(this).parent().children("label").fadeIn();
            $(this).parents('.captchaimg1').children("label").fadeIn()
        };
    });		
	//
	//log post caracter limiter rebuilder
    /*$('.postList').each(function () {
        var shortText = $(this).text() // get the text within the div
        .trim() // remove leading and trailing spaces
        .substring(0, 790) // get first 600 characters
        .split(" ") // separate characters into an array of words
        .slice(0, -1) // remove the last full or partial word
        .join(" ") + "..."; // combine into a single string and append "..."
        var postImage = $(this).children('img');
        $(this).text('');
        $(this).children().remove();
        $(this).append(postImage);
        $(this).append('<p></p>')
        $(this).children('p').append(shortText);
        //$(".post-list .post-body p").append(shortText);	
    });*/	
	  $('.announceWrap .announceListy div.summary').each(function () {
		//$(" .announceWrap .announceListy *:empty").remove(); //remove empty p tags 
        var shortText = $(this).text() // get the text within the div
        .trim() // remove leading and trailing spaces
        .substring(0, 150) // get first 600 characters
        .split(" ") // separate characters into an array of words
        .slice(0, -1) // remove the last full or partial word
        .join(" ") + "..."; // combine into a single string and append "..."
        var postImage = $(this).children('img');
        $(this).text('');
        $(this).children().remove();
       // $(this).append(postImage);
        $(this).append('<p></p>')
        $(this).children('p').append(shortText);
        //$(".post-list .post-body p").append(shortText);	
    });	
	//about our store slide thigny
	$("#abtStrSlider .top li:first-child, #abtStrSlider .slideNav li:first-child a").addClass('active');
	$("#abtStrSlider .slideNav li a").live('click', function(){
		if ($(this).is('.active') ){ }
		else {
		  var mrRef = $(this).attr('href');
		$('#abtStrSlider .slideNav li a.active').removeClass('active');
		$(this).addClass('active');
	    $("#abtStrSlider .top li.active").delay(250).animate({
            opacity: "0"
        }, 600);
	    $("#abtStrSlider .top li.active").removeClass('active')
		$('#abtStrSlider .top '+mrRef  ).addClass("active");
		$('#abtStrSlider .top '+mrRef ).animate({
            opacity: "1"
        }, 600); 
		};
		return false ;
		});	
		$('.mapUp').click(function() {
		 	 $.fancybox({
			 'scrolling': 'no',
			 'centerOnScroll': 	true,	
			 'href': 'http://maps.google.ca/maps?f=q&source=s_q&hl=en&geocode=&q=17431+Brookhurst+St.+Fountain+Valley,+CA.&aq=&sll=49.891235,-97.15369&sspn=33.830834,67.060547&vpsrc=0&ie=UTF8&hq=&hnear=17431+Brookhurst+St,+Fountain+Valley,+California+92708,+United+States&ll=33.70999,-117.954884&spn=0.02499,0.053644&z=14&iwloc=A&output=embed', 
			 'autoScale': true,
			 'type': 'iframe',
			 'frameWidth': 650, 
			 'frameHeight': 450,
			 'onComplete': function() { $("#fancybox-close").css('display', 'block')}
			 });
			 return false; 
			}); 
	$('#pricingTable a, .reviewBtn').not('a.noPop').fancybox({
        'titleShow'  : false,
        'transitionIn'  : 'elastic',
        'transitionOut' : 'elastic',
		'onComplete': function() { $("#fancybox-close").css('display', 'block')}
		});	
//blog post list show comments
		$('.comments').click(function() {
			var dummyLnk 
			dummylnk = $(this).attr('href')
			if ($(this).parents(':eq(2)').children('#coms'+dummylnk).is(':hidden')){
			//$(this).html('Hide Comments');
			//Cufon.replace('.showComs', { fontFamily: 'gtmBook' });
			$(this).parents(':eq(2)').children('#coms'+dummylnk).slideDown();
			return false;
			} else {
			//$(this).html('Show Comments');
			//Cufon.replace('.showComs', { fontFamily: 'gtmBook' });
			$(this).parents(':eq(2)').children('#coms'+dummylnk).slideUp();
			return false;
			}
		});
	});
//cart rewrite

//ajax rewrite ( outside doc ready )
/*
function AddToCart(j, w, t, B, l) {
    var h = w;
    var q = "";
    var f = document.getElementById("Units_" + w);
    var A = readCookie("CartID");
    var v = document.getElementById("Grouping_" + w);
    var F = document.getElementById("Related_" + w);
    var e = document.getElementById("catProdTd_" + w);
    var n = document.getElementById("catProdAttributes_" + w);
    var u = document.getElementById("catProdAttributes2_" + w);
    var s = document.getElementById("catProdInstructions_" + w);
    var c = "";
    var p = new Array();
    var C = false;
    var a = false;
    var m;
    var g = 0;
    var E;
    var d = true;
    if (f) {
        m = f.value;
        if (m < 0) {
            alert(Oshoplang.RemoveError);
            return false
        }
    } else {
        m = 1
    }
    if (A == null || A == "") {
        A = -1
    }
    E = document.getElementById("catCartSummary");
    if (v) {
        if (v.nodeName == "SELECT") {
            h = v.value
        } else {
            var r = v.getElementsByTagName("input");
            for (var z = 0; z < r.length; z++) {
                if (r[z].checked) {
                    h = r[z].value;
                    break
                }
            }
        }
    }
    if (F) {
        q = GetCheckListValue(F);
        if (q.length > 0) {
            g = q.split(",").length
        }
    }
    if (s) {
        c = s.value
    }
    if (n) {
        var o = n.getElementsByTagName("select");
        if (o) {
            if (c.length > 0) {
                c += ";"
            }
            for (var z = 0; z < o.length; z++) {
                if (o[z].value.length > 0) {
                    c += o[z].value + ";"
                }
            }
        }
    }
    if (u) {
        var D = 0;
        var o = u.getElementsByTagName("select");
        var y;
        var x;
        var k = "";
        if (o) {
            for (var z = 0; z < o.length; z++) {
                if (o[z].value.length > 0) {
                    p[D] = o[z].value + "|1";
                    D++
                } else {
                    if (o[z].getAttribute("mandatory")) {
                        alert(Oshoplang.ChooseAttribute);
                        return
                    }
                }
            }
        }
        var o = u.getElementsByTagName("input");
        if (o) {
            for (var z = 0; z < o.length; z++) {
                if (o[z].type == "checkbox" || o[z].type == "radio") {
                    if (k != o[z].getAttribute("name")) {
                        if (z > 0 && !x && o[z - 1].getAttribute("mandatory")) {
                            alert(Oshoplang.ChooseAttribute);
                            return
                        }
                        x = false
                    }
                    if (o[z].checked) {
                        p[D] = o[z].id + "|1";
                        D++;
                        x = true
                    }
                    k = o[z].getAttribute("name")
                } else {
                    if (o[z].value.length > 0) {
                        p[D] = o[z].id + "|" + o[z].value;
                        D++;
                        x = true
                    } else {
                        if (o[z].getAttribute("mandatory")) {
                            alert(Oshoplang.ChooseAttribute);
                            return
                        }
                    }
                }
            }
            if (o.length > 0 && (o[o.length - 1].type == "checkbox" || o[o.length - 1].type == "radio")) {
                if (!x && o[z - 1].getAttribute("mandatory")) {
                    alert(Oshoplang.ChooseAttribute);
                    return
                }
            }
        }
    }
    if (E) {
        if (E.getAttribute("Vertical") == "True") {
            C = true
        }
        if (E.getAttribute("Quote") == "True") {
            a = true
        }
    }
    var b = CMS.CatalogueRetrieve.ServerSideAddItemToOrder(A, j, h, m, q, p, c, C, B, a, t, d);
    if (b.value[4]) {
        g = b.value[4]
    }
    createCookie("CartID", b.value[0], 2);
    if (E) {
        E.innerHTML = b.value[2]
    }
    switch (b.value[1]) {
    case 0:
        if (!l) {
            if (e) {
                e.innerHTML = b.value[3];
                ProcessJS(e)
            }
             jQuery(".title3").css('display', 'block');
Cufon.refresh();

           // alert(g + Oshoplang.Added)


            function respConfirm() {
                var response = confirm(g + " Item(s) added to cart. Click ok to keep shopping or cancel to go to cart");
                // OR var response = window.confirm('Confirm Test: Continue?');
                if (response) {} else {
                    document.location = "/OrderRetrievev2.aspx?CatalogueID=" + j;
                }
            }

            respConfirm()
        } else {
            document.location = "/OrderRetrievev2.aspx?CatalogueID=" + j
            jQuery(".title3").css('display', 'block');
Cufon.refresh();

        }
        break;
    case 1:
        jQuery(".title3").css('display', 'block');
Cufon.refresh();

        alert(Oshoplang.OutOfStock);
        break;
    case 2:
        if (!l) {
            if (e) {
                e.innerHTML = b.value[3];
                ProcessJS(e)
            }
            jQuery(".title3").css('display', 'block');
Cufon.refresh();

            alert(g + Oshoplang.PreOrder)
        } else {
           jQuery(".title3").css('display', 'block');
Cufon.refresh();

            document.location = "/OrderRetrievev2.aspx?CatalogueID=" + j
        }
        break;
    case 3:
        alert(Oshoplang.MinLimit);
        break;
    case 4:
        alert(Oshoplang.MaxLimit);
        break
    }
    if (typeof AddProductExtras == "function") {
        AddProductExtras(j, h, b.value[1])
    }
}
function UpdateItemQuantity(d, i, f, e, j, l, g) {
    var b;
    var h;
    var a = false;
    var m = false;
    var k = true;
    b = document.getElementById("catCartDetails");
    h = document.getElementById("catCartSummary");
    if (h) {
        if (h.getAttribute("Vertical") == "True") {
            a = true
        }
        if (h.getAttribute("Quote") == "True") {
            m = true
        }
    }
    if (!IsNumeric(d)) {
        alert(Oshoplang.InvalidQuantity);
        return false
    }
    if (b) {
        var c;
        c = CMS.OrderRetrievev2.ServerSideUpdateItemQuanity(i, f, e, j, d, l, g, a, m, k);
		  jQuery(".title3").css('display', 'block');
Cufon.refresh();
        switch (c.value[0]) {
        case 0:
        case 2:
            b.innerHTML = c.value[1];
            if (h) {
                h.innerHTML = c.value[2]
            }
            break;
        case 1:
            alert(Oshoplang.OutOfStock);
            return;
        case 3:
            alert(Oshoplang.MinLimit);
            break;
        case 4:
            alert(Oshoplang.MaxLimit);
            break;
        case -1:
            b.innerHTML = c.value[1];
            if (h) {
                h.innerHTML = c.value[2]
            }
            alert(Oshoplang.CartEmpty);
            break
        }
    }
    if (typeof UpdateProductExtras == "function") {
        UpdateProductExtras(f, e, c.value[0])
		 jQuery(".title3").css('display', 'block');
     	Cufon.refresh();
    }

   jQuery(".title3").css('display', 'block');
	Cufon.refresh();
}
*/







/////Full script
/////
if (typeof jslang == "undefined") {
    LoadLangO("EN")
} else {
    if (jslang == "JP") {
        jslang = "JA"
    }
    if (jslang == "NO") {
        jslang = "NN"
    }
    if (jslang == "CS") {
        jslang = "CZ"
    }
    if (jslang == "SI") {
        jslang = "SL"
    }
    switch (jslang) {
    case "EN":
    case "IS":
    case "JA":
    case "NN":
    case "CS":
    case "FR":
    case "ES":
    case "DE":
    case "SL":
    case "SV":
        LoadLangO(jslang);
        break;
    default:
        LoadLangO("EN");
        break
    }
}
function LoadLangO(b) {
    var a = document.createElement("script");
    a.setAttribute("src", "/CatalystScripts/lang/" + b + "/Java_OnlineShopping_" + b + ".js");
    a.setAttribute("charset", charsetO(b));
    a.setAttribute("type", "text/javascript");
    document.getElementsByTagName("head")[0].appendChild(a)
}
function charsetO(a) {
    var b = "";
    switch (a) {
    case "JA":
        b = "shift-jis";
        break;
    case "IS":
    case "CS":
    case "SL":
    case "SV":
        b = "iso-8859-1";
        break;
    default:
        b = "utf-8";
        break
    }
    return b
}
function AddToCart(j, w, t, B, l) {
    var h = w;
    var q = "";
    var f = document.getElementById("Units_" + w);
    var A = readCookie("CartID");
    var v = document.getElementById("Grouping_" + w);
    var F = document.getElementById("Related_" + w);
    var e = document.getElementById("catProdTd_" + w);
    var n = document.getElementById("catProdAttributes_" + w);
    var u = document.getElementById("catProdAttributes2_" + w);
    var s = document.getElementById("catProdInstructions_" + w);
    var c = "";
    var p = new Array();
    var C = false;
    var a = false;
    var m;
    var g = 0;
    var E;
    var d = true;
    if (f) {
        m = f.value;
        if (m < 0) {
            alert(Oshoplang.RemoveError);
            return false
        }
    } else {
        m = 1
    }
    if (A == null || A == "") {
        A = -1
    }
    E = document.getElementById("catCartSummary");
    if (v) {
        if (v.nodeName == "SELECT") {
            h = v.value
        } else {
            var r = v.getElementsByTagName("input");
            for (var z = 0; z < r.length; z++) {
                if (r[z].checked) {
                    h = r[z].value;
                    break
                }
            }
        }
    }
    if (F) {
        q = GetCheckListValue(F);
        if (q.length > 0) {
            g = q.split(",").length
        }
    }
    if (s) {
        c = s.value
    }
    if (n) {
        var o = n.getElementsByTagName("select");
        if (o) {
            if (c.length > 0) {
                c += ";"
            }
            for (var z = 0; z < o.length; z++) {
                if (o[z].value.length > 0) {
                    c += o[z].value + ";"
                }
            }
        }
    }
    if (u) {
        var D = 0;
        var o = u.getElementsByTagName("select");
        var y;
        var x;
        var k = "";
        if (o) {
            for (var z = 0; z < o.length; z++) {
                if (o[z].value.length > 0) {
                    p[D] = o[z].value + "|1";
                    D++
                } else {
                    if (o[z].getAttribute("mandatory")) {
                        alert(Oshoplang.ChooseAttribute);
                        return
                    }
                }
            }
        }
        var o = u.getElementsByTagName("input");
        if (o) {
            for (var z = 0; z < o.length; z++) {
                if (o[z].type == "checkbox" || o[z].type == "radio") {
                    if (k != o[z].getAttribute("name")) {
                        if (z > 0 && !x && o[z - 1].getAttribute("mandatory")) {
                            alert(Oshoplang.ChooseAttribute);
                            return
                        }
                        x = false
                    }
                    if (o[z].checked) {
                        p[D] = o[z].id + "|1";
                        D++;
                        x = true
                    }
                    k = o[z].getAttribute("name")
                } else {
                    if (o[z].value.length > 0) {
                        p[D] = o[z].id + "|" + o[z].value;
                        D++;
                        x = true
                    } else {
                        if (o[z].getAttribute("mandatory")) {
                            alert(Oshoplang.ChooseAttribute);
                            return
                        }
                    }
                }
            }
            if (o.length > 0 && (o[o.length - 1].type == "checkbox" || o[o.length - 1].type == "radio")) {
                if (!x && o[z - 1].getAttribute("mandatory")) {
                    alert(Oshoplang.ChooseAttribute);
                    return
                }
            }
        }
    }
    if (E) {
        if (E.getAttribute("Vertical") == "True") {
            C = true
        }
        if (E.getAttribute("Quote") == "True") {
            a = true
        }
    }
    var b = CMS.CatalogueRetrieve.ServerSideAddItemToOrder(A, j, h, m, q, p, c, C, B, a, t, d);
    if (b.value[4]) {
        g = b.value[4]
    }
    createCookie("CartID", b.value[0], 2);
    if (E) {
        E.innerHTML = b.value[2]
    }
    switch (b.value[1]) {
    case 0:
        if (!l) {
            if (e) {
                e.innerHTML = b.value[3];
                ProcessJS(e)
            }
            alert(g + Oshoplang.Added)
        } else {
            document.location = "/OrderRetrievev2.aspx?CatalogueID=" + j
        }
        break;
    case 1:
        alert(Oshoplang.OutOfStock);
        break;
    case 2:
        if (!l) {
            if (e) {
                e.innerHTML = b.value[3];
                ProcessJS(e)
            }
            alert(g + Oshoplang.PreOrder)
        } else {
            document.location = "/OrderRetrievev2.aspx?CatalogueID=" + j
        }
        break;
    case 3:
        alert(Oshoplang.MinLimit);
        break;
    case 4:
        alert(Oshoplang.MaxLimit);
        break
    }
    if (typeof AddProductExtras == "function") {
        AddProductExtras(j, h, b.value[1])
    }
}
function DrawProduct(b, j, g, d, a) {
    var h = document.getElementById("Grouping_" + j);
    var c;
    var f = true;
    var i = h;
    while (f) {
        i = i.parentNode;
        if (i.id) {
            if (i.id.indexOf("catProdTd_") != -1) {
                c = i.id.substring(10);
                f = false
            }
        }
    }
    var e = CMS.CatalogueRetrieve.ServerSideDrawProduct(b, g, a, d);
    i.innerHTML = e.value;
    ProcessJS(i);
    if (e.value.indexOf("lightbox") != -1) {
        initLightbox()
    }
}
function UpdateItemQuantity(d, i, f, e, j, l, g) {
    var b;
    var h;
    var a = false;
    var m = false;
    var k = true;
    b = document.getElementById("catCartDetails");
    h = document.getElementById("catCartSummary");
    if (h) {
        if (h.getAttribute("Vertical") == "True") {
            a = true
        }
        if (h.getAttribute("Quote") == "True") {
            m = true
        }
    }
    if (!IsNumeric(d)) {
        alert(Oshoplang.InvalidQuantity);
        return false
    }
    if (b) {
        var c;
        c = CMS.OrderRetrievev2.ServerSideUpdateItemQuanity(i, f, e, j, d, l, g, a, m, k);
        switch (c.value[0]) {
        case 0:
        case 2:
            b.innerHTML = c.value[1];
            if (h) {
                h.innerHTML = c.value[2]
            }
            break;
        case 1:
            alert(Oshoplang.OutOfStock);
            return;
        case 3:
            alert(Oshoplang.MinLimit);
            break;
        case 4:
            alert(Oshoplang.MaxLimit);
            break;
        case -1:
            b.innerHTML = c.value[1];
            if (h) {
                h.innerHTML = c.value[2]
            }
            alert(Oshoplang.CartEmpty);
            break
        }
    }
    if (typeof UpdateProductExtras == "function") {
        UpdateProductExtras(f, e, c.value[0])
    }
	      //  alert('reloaded'); 
		   jQuery(".title3").css('display', 'block');
			//Cufon.set('fontFamily', 'Museo 900').replace('.museo9')
			 //Cufon.set('fontFamily', 'Museo 700').replace('.title3')
			//  Cufon.set('fontFamily', 'Museo 700').replace('.title3')

}
function ClearCart(e, c) {
    var d = document.getElementById("catCartDetails");
    var a = document.getElementById("catCartSummary");
    if (d) {
        var b = CMS.OrderRetrievev2.ServerSideDrawCartEmpty(e, c);
        d.innerHTML = b.value;
        alert(Oshoplang.CartUpdateSuccess)
    }
    if (a) {
        a.innerHTML = Oshoplang.CartEmpty
    }
    if (typeof UpdateProductExtras == "function") {
        UpdateProductExtras(c, -1, -1)
    }
}
function UpdateShipping(c, e, b) {
    var d = document.getElementById("catCartDetails");
    if (d) {
        var a = CMS.OrderRetrievev2.ServerSideUpdateShipping(e, c, b);
        if (a.value[0]) {
            d.innerHTML = a.value[2]
        }
        if (a.value[1].length > 0) {
            alert(a.value[1])
        }
    }
}
function ApplyDiscountCode(a, e, c) {
    var d = document.getElementById("catCartDetails");
    if (d) {
        var b = CMS.OrderRetrievev2.ServerSideApplyDiscountCode(e, a, c);
        if (b.value[0]) {
            d.innerHTML = b.value[2]
        }
        if (b.value[1].length > 0) {
            alert(b.value[1])
        }
    }
}
function ApplyGiftVoucher(e, d, b) {
    var c = document.getElementById("catCartDetails");
    if (c) {
        var a = CMS.OrderRetrievev2.ServerSideApplyGiftVoucher(d, e, b);
        if (a.value[0]) {
            c.innerHTML = a.value[2]
        }
        if (a.value[1].length > 0) {
            alert(a.value[1])
        }
    }
}
function ValidateCart(f) {
    var k = document.getElementById("ShippingOptions");
    if (k) {
        if (k.value < 1) {
            alert(Oshoplang.InvalidShip);
            return false
        }
    }
    var c = document.getElementById("shippingCountry");
    ccVal = "";
    if (c) {
        ccVal = c.value
    }
    var a = document.getElementById("shippingState");
    var l = "";
    if (a) {
        l = a[a.selectedIndex].text;
        if (a.value < 1) {
            alert(Oshoplang.ChooseState);
            return false
        }
    }
    var j = document.getElementById("shippingPostcode");
    var h = "";
    if (j) {
        h = j.value;
        if (j.value.length < 1) {
            alert(Oshoplang.EnterZip);
            return false
        }
    }
    var g = document.getElementById("shippingCalc");
    if (g) {
        var b = false;
        var e = g.getElementsByTagName("input");
        if (e.length > 0) {
            for (var d = 0; d < e.length; d++) {
                if (e[d].checked) {
                    b = true;
                    break
                }
            }
        }
        if (!b) {
            alert(Oshoplang.ChooseShip);
            return false
        }
    }
    if (ccVal.length > 0 || l.length > 0 || h.length > 0) {
        CMS.OrderRetrievev2.ServerSideSetShippingAddress(f, ccVal, l, h)
    }
    return true
}
function CheckGiftVoucherSelected(d) {
    var a = document.getElementById("RecipientName");
    var c = document.getElementById("RecipientEmail");
    var b = document.getElementById("Message");
    if (!a || !c || !b) {
        alert(Oshoplang.IncorrectGForm);
        return false
    } else {
        if (a.value.length < 1) {
            alert(Oshoplang.EnterGName);
            return false
        } else {
            if (!checkEmailShop(c.value)) {
                alert(Oshoplang.InvalidGEmail);
                return false
            } else {
                if (b.value.length < 1) {
                    alert(Oshoplang.EnterGMessage);
                    return false
                }
            }
        }
    }
    CMS.OrderRetrievev2.ServerSideRegisterGiftVoucher(d, a.value, c.value, b.value)
}
function SetShippingCountry(h, e, d) {
    var g = document.getElementById("shippingPostcode");
    var f = "";
    var a = document.getElementById("shippingState");
    var i = "";
    var b = document.getElementById("catCartDetails");
    if (b) {
        if (g) {
            f = g.value
        }
        if (a) {
            if (a.selectedIndex > 0) {
                i = a[a.selectedIndex].text
            }
        }
        var c = CMS.OrderRetrievev2.ServerSideSetShippingCountry(e, h, i, f, d);
        b.innerHTML = c.value
    }
}
function RetrieveShippingCosts(g, f) {
    var i = document.getElementById("shippingPostcode");
    var h = "";
    var c = document.getElementById("shippingCountry");
    var j = "";
    var a = document.getElementById("shippingState");
    var k = "";
    var b = document.getElementById("catCartDetails");
    var d = false;
    var l = document.getElementById("shippingIsResidential");
    if (b) {
        if (c) {
            j = c.value
        }
        if (a) {
            k = a[a.selectedIndex].text
        }
        if (l) {
            d = l.checked
        }
        if (i) {
            h = i.value
        }
        var e = CMS.OrderRetrievev2.ServerSideRetrieveShipping(g, j, k, h, f, d);
        b.innerHTML = e.value
    }
}
function SaveShipping(c, f, e, b) {
    var d = document.getElementById("catCartDetails");
    if (d) {
        var a = CMS.OrderRetrievev2.ServerSideSaveShipping(f, c, e, b);
        d.innerHTML = a.value
    }
}
function ApplyTaxRate(m, i, g, d, f) {
    var b = document.getElementById("catCartDetails");
    if (b) {
        var c = document.getElementById("shippingCountry");
        var l = "";
        if (c) {
            l = c.value
        }
        var j = document.getElementById("shippingPostcode");
        var h = "";
        if (j) {
            h = j.value
        }
        var a = document.getElementById("shippingState");
        var k = "";
        if (a) {
            if (a.selectedIndex > 0) {
                k = a[a.selectedIndex].text
            }
        }
        var e = CMS.OrderRetrievev2.ServerSideUpdateTaxCode(i, m, g, d, f, l, k, h, true);
        b.innerHTML = e.value
    }
}
function RefreshCart() {
    var c = readCookie("CartID");
    var b = document.getElementById("catCartDetails");
    if (b && c != null && c != "") {
        var a = CMS.OrderRetrievev2.ServerSideReDrawShoppingCart(c);
        b.innerHTML = a.value
    }
}
function IsNumeric(b) {
    for (var a = 0; a < b.length; a++) {
        if (b.charCodeAt(a) < 48 || b.charCodeAt(a) > 57) {
            return false
        }
    }
    return true
}
function GetCheckListValue(e) {
    var a = e.getElementsByTagName("td");
    var d;
    var c = "";
    for (var b = 0; b < a.length; b++) {
        d = a[b].childNodes[0];
        if (d.checked) {
            c = c + "," + d.value
        }
    }
    if (c.substring(0, 1) == ",") {
        return c.substring(1)
    } else {
        return c
    }
}
function checkEmailShop(b) {
    if (b.length > 0) {
        var a = /^.+@.+\..{2,4}$/;
        if (!(a.test(b))) {
            return false
        } else {
            var c = /[\(\)\<\>\,\;\:\\\"\[\]]/;
            if (b.match(c)) {
                return false
            }
        }
    } else {
        return false
    }
    return true
}
function ProcessJS(ele) {
    var t = "";
    var x = ele.getElementsByTagName("script");
    for (var i = 0; i < x.length; i++) {
        t = t + x[i].text
    }
    if (t != "") {
        eval(t)
    }
}
function CCPopup(b) {
    var a = window.open("http://www.xe.com/ecc/input.cgi?Template=sw&" + b, "", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,height=170,width=600");
    a.focus()
}
if (typeof zoom == "undefined") {
    zoom = {
        x: 0,
        y: 0,
        offsetx: null,
        offsety: null,
        targetobj: null,
        dragapproved: 0,
        z: null,
        container: null,
        top_pos: 130,
        left_pos: 162,
        max_width: 1900,
        min_width: 10,
        time_length: 1,
        step: -1,
        img_act_width: 0,
        img_act_height: 0,
        img_org_width: 0,
        img_org_height: 0,
        original_time: 0,
        zoomingImg: null,
        initialize: function (a, b) {
            this.container = document.getElementById(b);
            this.zoomingImg = a;
            this.z = document.getElementById(this.zoomingImg);
            this.container.onmousedown = this.drag;
            this.container.onmousemove = this.moveit;
            this.container.onmouseup = function () {
                this.dragapproved = 0
            };
            this.container.onmouseout = function () {
                this.dragapproved = 0
            };
            this.img_act_width = parseInt(this.z.width) ? parseInt(this.z.width) : parseInt(this.z.style.width);
            this.img_act_height = parseInt(this.z.height) ? parseInt(this.z.height) : parseInt(this.z.style.height);
            this.InitStep();
            this.original_time = this.time_length;
            if (this.z.width != 0) {
                this.z.style.width = this.z.width + "px"
            }
            if (this.z.height != 0) {
                this.z.style.height = this.z.height + "px"
            }
            this.min_width = parseInt(this.z.width) ? parseInt(this.z.width) : parseInt(this.z.style.width)
        },
        moveit: function (b) {
            var a = window.event ? window.event : b;
            if (this.dragapproved == 1) {
                this.targetobj.style.left = this.offsetx + a.clientX - this.x + "px";
                this.targetobj.style.top = this.offsety + a.clientY - this.y + "px";
                return false
            }
        },
        drag: function (b) {
            var a = window.event ? window.event : b;
            this.targetobj = window.event ? event.srcElement : b.target;
            if (this.targetobj.className == "drag") {
                this.dragapproved = 1;
                if (isNaN(parseInt(this.targetobj.style.left))) {
                    this.targetobj.style.left = 0
                }
                if (isNaN(parseInt(this.targetobj.style.top))) {
                    this.targetobj.style.top = 0
                }
                this.offsetx = parseInt(this.targetobj.style.left);
                this.offsety = parseInt(this.targetobj.style.top);
                this.x = a.clientX;
                this.y = a.clientY;
                if (a.preventDefault) {
                    a.preventDefault()
                }
            }
        },
        InitStep: function () {
            var a = new Image();
            a.src = document.getElementById(this.zoomingImg).src;
            this.img_org_width = a.width;
            this.img_org_height = a.height;
            this.step = parseInt((this.img_org_width - this.img_act_width) / this.img_act_width);
            if (this.step < 0) {
                this.step = 10
            }
        },
        zoom_out: function (b) {
            if (parseInt(this.z.style.width) == 0) {
                this.z.border = 0
            }
            if (parseInt(this.z.style.width) != 0) {
                if (parseInt(this.z.style.width) > this.min_width) {
                    var a = parseInt(this.z.style.width);
                    this.z.style.width = this.img_act_width + (b * this.step) + "px";
                    this.z.style.height = (Math.round(parseInt(this.z.style.width) * ((this.img_act_height) / (this.img_act_width)))) + "px"
                } else {
                    this.set_original()
                }
            }
        },
        zoom_in: function (b) {
            if (parseInt(this.z.style.width) == 0) {
                this.z.border = 0
            }
            if (parseInt(this.z.style.width) != 0) {
                if (parseInt(this.z.style.width) < this.max_width) {
                    var a = parseInt(this.z.style.width);
                    this.z.style.width = this.img_act_width + (b * this.step) + "px";
                    this.z.style.height = (Math.round(parseInt(this.z.style.width) * ((this.img_act_height) / (this.img_act_width)))) + "px"
                } else {}
            }
        },
        set_original: function () {
            this.z.style.width = this.img_act_width + "px";
            this.z.style.height = this.img_act_height + "px";
            this.z.style.left = 0;
            this.z.style.top = 0
        }
    }
}
var mouseover = false;
var SliderDefaultOrientation = "horizontal";
var SliderClassName = "slider";
var slider = {};
var ori;
var dist;
var lastdisplayvalue = 0;
var dec;
var val;
var from;
var to;

function AddLoadEvent(a) {
    var b = window.onload;
    if (typeof window.onload != "function") {
        window.onload = a
    } else {
        window.onload = function () {
            b();
            a()
        }
    }
}
function GetElementsByClass(e) {
    var f = new Array();
    var d = document.getElementsByTagName("*");
    var a = d.length;
    var g = new RegExp("\\b" + e + "\\b");
    for (var c = 0, b = 0; c < a; c++) {
        if (g.test(d[c].className)) {
            f[b] = d[c];
            b++
        }
    }
    return f
}
function Left(a, b) {
    if (!(a = document.getElementById(a))) {
        return 0
    }
    if (a.style && (typeof (a.style.left) == "string")) {
        if (typeof (b) == "number") {
            a.style.left = b + "px"
        } else {
            b = parseInt(a.style.left);
            if (isNaN(b)) {
                b = 0
            }
        }
    } else {
        if (a.style && a.style.pixelLeft) {
            if (typeof (b) == "number") {
                a.style.pixelLeft = b
            } else {
                b = a.style.pixelLeft
            }
        }
    }
    return b
}
function Top(a, b) {
    if (!(a = document.getElementById(a))) {
        return 0
    }
    if (a.style && (typeof (a.style.top) == "string")) {
        if (typeof (b) == "number") {
            a.style.top = b + "px"
        } else {
            b = parseInt(a.style.top);
            if (isNaN(b)) {
                b = 0
            }
        }
    } else {
        if (a.style && a.style.pixelTop) {
            if (typeof (b) == "number") {
                a.style.pixelTop = b
            } else {
                b = a.style.pixelTop
            }
        }
    }
    return b
}
function moveSlider(d) {
    var d = (!d) ? window.event : d;
    if (mouseover) {
        slider.x = slider.startOffsetX + d.screenX;
        slider.y = slider.startOffsetY + d.screenY;
        if (slider.x > slider.xMax) {
            slider.x = slider.xMax
        }
        if (slider.x < 0) {
            slider.x = 0
        }
        if (slider.y > slider.yMax) {
            slider.y = slider.yMax
        }
        if (slider.y < 0) {
            slider.y = 0
        }
        Left(slider.id, slider.x);
        Top(slider.id, slider.y);
        var b = slider.x + slider.y;
        var c = (slider.distance / slider.valuecount) * Math.round(slider.valuecount * b / slider.distance);
        var a = Math.round((c * slider.scale + slider.from) * Math.pow(10, slider.decimals)) / Math.pow(10, slider.decimals);
        if (a > 0) {
            if (lastdisplayvalue < a) {
                zoom.zoom_in(slider.x)
            } else {
                if (lastdisplayvalue > a) {
                    zoom.zoom_out(slider.x)
                }
            }
        } else {
            zoom.set_original()
        }
        lastdisplayvalue = a;
        return false
    }
    return
}
function slide(b) {
    if (!b) {
        b = window.event
    }
    slider = (b.target) ? b.target : b.srcElement;
    slider.distance = dist ? dist : DefaultSliderLength;
    var a = ((ori == "horizontal") || (ori == "vertical")) ? ori : SliderDefaultOrientation;
    slider.decimals = dec ? dec : 0;
    slider.valuecount = val ? val : slider.distance + 1;
    from = from ? from : 0;
    to = to ? to : slider.distance;
    slider.scale = (to - from) / slider.distance;
    if (a == "vertical") {
        slider.from = to;
        slider.xMax = 0;
        slider.yMax = slider.distance;
        slider.scale = -slider.scale
    } else {
        slider.from = from;
        slider.xMax = slider.distance;
        slider.yMax = 0
    }
    slider.startOffsetX = Left(slider.id) - b.screenX;
    slider.startOffsetY = Top(slider.id) - b.screenY;
    mouseover = true;
    document.onmousemove = moveSlider;
    document.onmouseup = sliderMouseUp;
    return false
}
function sliderMouseUp() {
    if (mouseover) {
        var a = (lastdisplayvalue) ? lastdisplayvalue : 0;
        var b = (a - slider.from) / (slider.scale);
        if (slider.yMax == 0) {
            b = (b > slider.xMax) ? slider.xMax : b;
            b = (b < 0) ? 0 : b;
            Left(slider.id, b)
        }
        if (slider.xMax == 0) {
            b = (b > slider.yMax) ? slider.yMax : b;
            b = (b < 0) ? 0 : b;
            Top(slider.id, b)
        }
        if (document.removeEventListener) {
            document.removeEventListener("mousemove", moveSlider, false);
            document.removeEventListener("mouseup", sliderMouseUp, false)
        } else {
            if (document.detachEvent) {
                document.detachEvent("onmousemove", moveSlider);
                document.detachEvent("onmouseup", sliderMouseUp);
                document.releaseCapture()
            }
        }
    }
    mouseover = false
}
function Init() {
    sliders = GetElementsByClass(SliderClassName);
    for (var a = 0; a < sliders.length; a++) {
        sliders[a].onmousedown = slide
    }
};

//empty cart 
function UpdateProductExtras(c, p, res) {
    if(res == '-1')
        document.getElementById('catCartDetails').innerHTML = '<div class="system-error-message"> Shopping Cart is empty.<br /><br /><a href="/">Go back to home page</a></div>';
}
var currenturl ="{ module_url,CatalogueID}";
if (currenturl == "") {
        document.getElementById('catCartDetails').innerHTML = '<div class="system-error-message"> Shopping Cart is empty.<br /><br /><a href="/">Go back to home page</a></div>';
}
