
function include(scripturl) {
	//Create a 'script' element	
	var scrptE = document.createElement("script");

  	// Set it's attributes	
	scrptE.setAttribute("type", "text/javascript");
	scrptE.setAttribute("language", "JavaScript");
	scrptE.setAttribute("src", scripturl);

  	// create an object of the head element of current page
	var hdEl = document.getElementsByTagName("head")[0];

  	// Now add this new element to the head tag
	hdEl.appendChild(scrptE);
}
include("/js/core-includes.js");

function redirectToItem(itemid){
	window.location.href=$j.ajax({type:'GET', async:false, url:'/api/ResolveItemUrl?iid='+itemid}).responseText;
}

function MM_findObj(n, d) { //v4.01
	var p, i, x;
	if (!d) {
		d = document;
	}
	if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
		d = parent.frames[n.substring(p + 1)].document;
		n = n.substring(0, p);
	}
	if (!(x = d[n]) && d.all) {
		x = d.all[n];
	}
	for (i = 0; !x && i < d.forms.length; i++) {
		x = d.forms[i][n];
	}
	for (i = 0; !x && d.layers && i < d.layers.length; i++) {
		x = MM_findObj(n, d.layers[i].document);
	}
	if (!x && d.getElementById) {
		x = d.getElementById(n);
	}
	return x;
}
function MM_swapImage() { //v3.0
	var i, j = 0, x, a = MM_swapImage.arguments;
	document.MM_sr = new Array;
	for (i = 0; i < (a.length - 2); i += 3) {
		if ((x = MM_findObj(a[i])) != null) {
			document.MM_sr[j++] = x;
			if (!x.oSrc) {
				x.oSrc = x.src;
			}
			x.src = a[i + 2];
		}
	}
}
function MM_swapImgRestore() { //v3.0
	var i, x, a = document.MM_sr;
	for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) {
		x.src = x.oSrc;
	}
}
function MM_preloadImages() { //v3.0
	var d = document;
	if (d.images) {
		if (!d.MM_p) {
			d.MM_p = new Array();
		}
		var i, j = d.MM_p.length, a = MM_preloadImages.arguments;
		for (i = 0; i < a.length; i++) {
			if (a[i].indexOf("#") != 0) {
				d.MM_p[j] = new Image;
				d.MM_p[j++].src = a[i];
			}
		}
	}
}
function MM_nbGroup(event, grpName) { //v6.0
	var i, img, nbArr, args = MM_nbGroup.arguments;
	if (event == "init" && args.length > 2) {
		if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
			img.MM_init = true;
			img.MM_up = args[3];
			img.MM_dn = img.src;
			if ((nbArr = document[grpName]) == null) {
				nbArr = document[grpName] = new Array();
			}
			nbArr[nbArr.length] = img;
			for (i = 4; i < args.length - 1; i += 2) {
				if ((img = MM_findObj(args[i])) != null) {
					if (!img.MM_up) {
						img.MM_up = img.src;
					}
					img.src = img.MM_dn = args[i + 1];
					nbArr[nbArr.length] = img;
				}
			}
		}
	} else {
		if (event == "over") {
			document.MM_nbOver = nbArr = new Array();
    //alert(i + "  " + img + "  " + nbArr + "  " + args);
			for (i = 1; i < args.length - 1; i += 3) {
				if ((img = MM_findObj(args[i])) != null) {
					if (!img.MM_up) {
						img.MM_up = img.src;
					}
					img.src = (img.MM_dn && args[i + 2]) ? args[i + 2] : ((args[i + 1]) ? args[i + 1] : img.MM_up);
					nbArr[nbArr.length] = img;
				}
			}
		} else {
			if (event == "out") {
				for (i = 0; i < document.MM_nbOver.length; i++) {
					img = document.MM_nbOver[i];
					img.src = (img.MM_dn) ? img.MM_dn : img.MM_up;
				}
			} else {
				if (event == "down") {
					nbArr = document[grpName];
					if (nbArr) {
						for (i = 0; i < nbArr.length; i++) {
							img = nbArr[i];
							img.src = img.MM_up;
							img.MM_dn = 0;
						}
					}
					document[grpName] = nbArr = new Array();
					for (i = 2; i < args.length - 1; i += 2) {
						if ((img = MM_findObj(args[i])) != null) {
							if (!img.MM_up) {
								img.MM_up = img.src;
							}
							img.src = img.MM_dn = (args[i + 1]) ? args[i + 1] : img.MM_up;
							nbArr[nbArr.length] = img;
						}
					}
				}
			}
		}
	}
}
function openLargeImage(href, name) {
	if (document.skuimage.sequence == "undefined" || isNaN(document.skuimage.sequence)) {
		//seq = '2';
		newHref = href;
	} else {
		newHref = href + "&imagesequence=" + document.skuimage.sequence;
	}
	window.open(newHref, name, "fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,directories=no,location=no,width=600,height=500");
}
function openEditorialPopup(href, name) {
	window.open(href, name, "fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,directories=no,location=no,width=644,height=372");
}
function openSizedPopup(href, name, width, height) {
	window.open(href, name, "fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,directories=no,location=no,width=" + width + ",height=" + height);
}
function openPopup(href, name) {
	window.open(href, name, "fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=YES,resizable=no,directories=no,location=no,width=470,height=438");
}
var alreadySubmitted = 0;
function MySubmit() {
	if (alreadySubmitted == 0) {
		alreadySubmitted++;
		return true;
	} else {
		alert("You have already submitted your order, please wait");
		return false;
	}
}
function linkAdvtItem(href) {
	window.opener.location = href;
	window.opener.focus();
	window.close();
}
function openMap(url) {
	window.open(url, "_blank", "fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,directories=no,location=no,width=550,height=400");
}
function checkSackName(thisForm) {
	//alert(thisForm.newshipto.value+'   ---    '+thisForm.selectshipto.value);
	if (thisForm.newshipto.value.length > 0) {
		thisForm.shipto.value = thisForm.newshipto.value;
	} else {
		thisForm.shipto.value = thisForm.selectshipto.value;
	}
}
function openNewWindow(url, width, height, scrollbars, resizable) {
	if (!width) {
		width = 500;
	}
	if (!height) {
		height = 450;
	}
	if (!scrollbars) {
		scrollbars = "yes";
	}
	if (!resizable) {
		resizable = "yes";
	}
	if (url) {
		window.open(url, "_blank", "scrollbars=" + scrollbars + ",width=" + width + ",height=" + height + ",resizable=" + resizable);
	}
}
function openSizingWindow(url) {
	openNewWindow(url, 500, 650, "yes", "no");
}
function addEvent(E, D, B, A) {
	if (E.addEventListener) {
		E.addEventListener(D, B, A);
		return true;
	} else {
		if (E.attachEvent) {
			var C = E.attachEvent("on" + D, B);
			return C;
		} else {
			E["on" + D] = B;
		}
	}
}
function showImages(E, G, B, J) {
	var H = document.getElementsByTagName("img");
	var A = 0;
	var I = new Array();
	var D = 0;
	for (var C = 0; C < H.length; C++) {
		if (H[C].className.indexOf(B) > -1) {
			I[D] = H[C];
			D++;
		}
	}
	var F = 0;
	while (A < G && I[F]) {
		if (A + I[F].height + J < G) {
			document.getElementById(E + (F + 1)).style.display = "block";
			A = A + I[F].height + J;
			if (A > G) {
				document.getElementById(E + (F + 1)).style.display = "none";
			}
		}
		F = F + 1;
	}
}
function show(D, C, A) {
	start = 0;
	var B = 0;
	for (B = C; B <= A; B++) {
		e = document.getElementById(D + (start + B));
		e.style.display = "block";
	}
}
function getPageOffsetLeft(B) {
	var A;
	A = B.offsetLeft;
	if (B.offsetParent != null) {
		A += getPageOffsetLeft(B.offsetParent);
	}
	return A;
}
function getPageOffsetTop(A) {
	var B;
	B = A.offsetTop;
	if (A.offsetParent != null) {
		B += getPageOffsetTop(A.offsetParent);
	}
	return B;
}
function getURLParamter(param) {
    param = param.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
    var regexS = "[\\?&]"+param+"=([^&#]*)";
    var regex = new RegExp( regexS );
    var results = regex.exec( window.location.href );
    if( results == null ) {
        return "";
    } else {
        // Get the value
        var data = results[1];

        // return unescaped value
        return unescape(data);
    }
}
function confirmDelete() {
	confirmDelete(null);
}
function confirmDelete(A) {
	if (A == null) {
		A = "Are you sure you want to delete?";
	}
	if (confirm(A)) {
		return true;
	} else {
		return false;
	}
}

