function myToggleNext(a) {
	$(a).next().slideToggle("fast");
	if (!window.nextTg) {
		window.nextTg = function() {
			var $this = $(".tg");
			if (!$this.is(":animated")) $this.slideUp("fast");
		}
		$(document).click(window.nextTg);
	}
	return false;
}

function mySetMods(e, xid, image, color, sizes) {
	var $cprice = $(e).parents(".cprice");
	if (color)
	$(".ccolor", $cprice).children("a").children("span").css("background", "#" + color);
	else
	$(".ccolor", $cprice).children("a").children("span").css("background", "transparent");
	if (image) {
		var $e = $(e);
		var $a = $(".cimage", $cprice).attr("src", image).parent().eq(0);
		$a.attr("href", $e.attr("xx-image"));
		$a.attr("x-image", $e.attr("xx-image"));
		$a.attr("x-width", $e.attr("xx-width"));
		$a.attr("x-height", $e.attr("xx-height"));
	}
	if (true)
	sizes = sizes.split(",");
	var sz = {};
	var cs = $(".csize", $cprice).children("a").children("b").text();
	var cv = typeof(cs) === "undefined" ? "" : cs.toLowerCase();
	for (var i = 0; i < sizes.length; i ++) sz[sizes[i]] = sizes[i];
	if (typeof(sz[cv]) === "undefined") {
		for (cv in sz) break;
		cs = cv.toUpperCase();
	}
	$(".csize", $cprice).children(".tg").children("a").each(function() {
		var s = $(this).attr("sz");
		if (typeof(sz[s]) !== "undefined") {
			if (!cs) {
				cs = $(this).text();
				cv = cs.toLowerCase();
			}
			$(this).show();
		} else $(this).hide();
	});
	$(".csize", $cprice).children("a").children("b").text(cs);
	$("input.cs", $cprice).attr("value", cs ? cs.toLowerCase() : "");
	$("input.cm", $cprice).attr("value", xid);
	return false;
}

function mySetSize(e, s) {
	var $cprice = $(e).parents(".cprice");
	$(".csize", $cprice).children("a").children("b").text($(e).text());
	$("input.cs", $cprice).attr("value", s);
	return false;
}

function myInit() {
	if (typeof($) === "undefined") return setTimeout(arguments.callee, 100);
	$(document).ready(function() {
		$(".my-mods").click(function() {
			var src = $(this).children("img").attr("src");
			src = src.substr(0, src.lastIndexOf("/")) + "/rc=124,124,0,0_i.jpg";
			$(this).parent().children("img").eq(0).each(function() {
				if (this.parentNode.tagName == "A") this.parentNode.href = src;
				$(this).attr("src", src);
			});
		});
	});
}

function myInitColorPicker() {
	if (typeof($) === "undefined") return setTimeout(arguments.callee, 100);
	$(document).ready(function() {
		$(".color-picker").each(function() {
			var id = this.id;
			$(this).ColorPicker({
				onChange: function(hsb, hex, rgb) {
					$("#" + id).attr("value", hex);
				},
				onSubmit: function(hsb, hex, rgb, el) {
					$(el).val(hex);
					$(el).ColorPickerHide();
				},
				onBeforeShow: function () {
					$(this).ColorPickerSetColor(this.value);
				}
			}).bind('keyup', function() {
				$(this).ColorPickerSetColor(this.value);
			});
		});
	});
}

function myMainTabs(o, id) {
	var $block = $("#mt-" + id);
	if ($block.is(":visible")) return false;
	$(".w>a").removeClass("active");
	$(o).addClass("active");
	$(".w1").hide();
	$block.show();
	return false;
}

function myMainInfo(e, o, html) {
	var $op = $("#op");
	if (window.optx) clearTimeout(window.optx);
	if (!o) return window.optx = setTimeout(function() { $op.hide() }, 100);
	if (!$op.data("events")) {
		$op.mouseover(function() { if (window.optx) clearTimeout(window.optx); });
		$op.mouseout(function() { if (window.optx) clearTimeout(window.optx); window.optx = setTimeout(function() { $op.hide() }, 100); });
	}
	if (!$(o).data("events")) {
		$(o).mousemove(function(e) {
			if (navigator.appVersion.indexOf("MSIE") > 0) {
				if (document && document.body && document.body.clientWidth && document.body.clientWidth > 1300) {
					e.pageX -= (document.body.clientWidth - 1300) / 2;
				}
			}
			$op.css({ top: e.pageY + 10, left: e.pageX + 10 });
		});
	}
	if (e) {
		e = $.event.fix(e);
		if (navigator.appVersion.indexOf("MSIE") > 0) {
			if (document && document.body && document.body.clientWidth && document.body.clientWidth > 1300) {
				e.pageX -= (document.body.clientWidth - 1300) / 2;
			}
		}
		$op.css({ top: e.pageY + 10, left: e.pageX + 10 });
	} else {
		$op.offset($(o).offset());
	}
	$(".pc", $op).html(html);
	if (!$op.is(":visible")) $op.show();
	if (navigator.appVersion.indexOf("MSIE 6.0") > 0) {
		$(".pl img.png, .pr img.png", $op).each(function() {
			if (typeof(this.xsrc) === "undefined") return;
			this.runtimeStyle.height = "0px";
			this.runtimeStyle.filter = "";
			var src = this.xsrc;
			var $this = $(this);
			var height = $this.parent().height();
			this.runtimeStyle.height = height + "px";
			this.src = "/images/x.gif";
			this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
		});
	}
	else if ($op.is(":animated")) setTimeout(function() { $op.show() }, 1000);
}

function myMainInfo2(e, o, html) {
	var $op = $("#op2");
	if (window.optx) clearTimeout(window.optx);
	if (!o) return window.optx = setTimeout(function() { $op.hide() }, 100);
	if (!$op.data("events")) {
		$op.mouseover(function() { if (window.optx) clearTimeout(window.optx); });
		$op.mouseout(function() { if (window.optx) clearTimeout(window.optx); window.optx = setTimeout(function() { $op.hide() }, 100); });
	}
	if (!$(o).data("events")) {
		$(o).mousemove(function(e) {
			if (navigator.appVersion.indexOf("MSIE") > 0) {
				if (document && document.body && document.body.clientWidth && document.body.clientWidth > 1300) {
					e.pageX -= (document.body.clientWidth - 1300) / 2;
				}
			}
			$op.css({ top: e.pageY - 330, left: e.pageX + 10 });
		});
	}
	if (e) {
		e = $.event.fix(e);
		if (navigator.appVersion.indexOf("MSIE") > 0) {
			if (document && document.body && document.body.clientWidth && document.body.clientWidth > 1300) {
				e.pageX -= (document.body.clientWidth - 1300) / 2;
			}
		}
		$op.css({ top: e.pageY - 330, left: e.pageX + 10 });
	} else {
		$op.offset($(o).offset());
	}
	$(".pc2", $op).html(html);
	if (!$op.is(":visible")) $op.show();
	else if ($op.is(":animated")) setTimeout(function() { $op.show() }, 1000);
}

function myCart(a) {
	var href = a.href;
	var $cprice = $(a).parents(".myprice");
	var q = $("input.csin", $cprice).attr("value");
	if (q && parseInt(q) > 0) {
		href += "&q=" + parseInt(q);
	}
	var mods = $("input.cm", $cprice).attr("value");
	if (mods) {
		href += "&mods=" + encodeURIComponent(mods);
	}
	var size = $("input.cs", $cprice).attr("value");
	if (size) {
		href += "&size=" + encodeURIComponent(size);
	}
	location.href = href;
	return false;
}

function myAlert(text) {
	if (typeof(window.myAlertText) === "undefined") window.myAlertText = "";
	else window.myAlertText += "<br>";
	window.myAlertText += text;
}

function myOform() {
	var form = document.getElementById("theForm");
	if (!form) return;
	return;
	if (form.deliver && form.deliver.value && form.payment && form.payment.value) document.getElementById("oform").disabled = false;
	else document.getElementById("oform").disabled = true;
}

var window_onload = window.onload;
window.onload = function() {
	if (typeof(window_onload) === "function") window_onload();
	if (navigator.appVersion.indexOf("MSIE 6.0") > 0) {
		$("img.png").each(function() {
			if (typeof(this.xsrc) === "undefined") this.xsrc = this.src;
			var src = this.src;
			var $this = $(this);
			var width = $this.width();
			var height = $this.height();
			if (!width && this.style.width) width = parseInt(this.style.width);
			if (!height && this.style.height) height = parseInt(this.style.height);
			this.runtimeStyle.width = width + "px";
			this.runtimeStyle.height = height + "px";
			this.src = "/images/x.gif";
			this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
		});
	}
	if (window.myAlertText) {
		myMainInfo(null, document.getElementById("alert"), window.myAlertText);
		setTimeout(myMainInfo, 2000);
	}
};

myInit();

