var newitemwtmp, myTimer, my2Timer;
var newitemmove = 50;
var newsboxheight = 116;
var moveid = new Array('','newitem','packages','recommend','resume','newcsm','inpackage');

function $(tagId) { 
	return document.getElementById(tagId); 
}

function stripPx(a) { 
	return parseFloat(a.substring(0,(a.length - 2))); 
}

function movenewitem(a,b,c,d,e,f) { 
	if ($(moveid[e])) { 
		if (myTimer != undefined) { 
			z.left = newitemwtmp + "px"; return; 
		} 
		z = $(moveid[e]).style; 
		y = stripPx(z.left); 
		w = newitemwtmp = y + a * b / c; 
		g = e; h = a; 
		i = (d - c) * b / c;
		if (((a < 0) && (Math.abs(w) <= i)) || ((a > 0) && (w <= 0))) { 
			if (myTimer == undefined) { 
				f ? document.images["mb_" + ((a > 0) ? "b" : "n") + g].src = "/" + "img/movebutton/" + ((a > 0) ? "b" : "n") + "_" + ((f == 1) ? "s" : "n") + ".png" : myTimer = setInterval("movenewitemstart(h,w,g,i)",20);
			} else { 
				myTimer = undefined; newitemmove = 50;
			} 
		} else { 
			return false; 
		} 
	} 
}

function movenewitemstart(a,w,u,b) {
	z = $(moveid[u]).style; 
	y = stripPx(z.left); 
	newitemmove -= 7; if (newitemmove <= 0) { newitemmove = 1; } 
	var y = y + a * newitemmove; 
	z.left = y + "px"; 
	if (((a < 0) && (w >= y)) || ((a > 0) && (w <= y))) { 
		z.left = w + "px"; 
		newitemmove = 50; 
		clearInterval(myTimer); 
		myTimer = undefined; 
		document.images["mb_b" + u].src = "/" + "img/movebutton/b_" + ((w == 0) ? "d" : "n") + ".png";
		document.images["mb_n" + u].src = "/" + "img/movebutton/n_" + ((Math.abs(w) >= b) ? "d" : "n") + ".png";
	} 
}

function changepic(a) { 
	for (i = 1; i <= a; i++) { 
		if (document.images["pic" + i].src) { 
			document.images["pic" + i].src = "/pic/" + picarray[i]; 
		} 
	} 
}

function checkuser(g) { var a = $("email1").value; var b = $("email2").value; var c = $("pass1").value; var d = $("pass2").value; var e = document.user.subscribe; var f = 0; if (a && b && (a === b) && a.match(/.+@.+\..+/) && c && d && (c === d) && (c.length >= 8)) { f = 1; } if (g == 1) { if (f) { e.disabled = false; } else { e.disabled = true; } } }
function loginuser() { var a = $("email").value; var b = $("pass").value; var c = document.user.loginbutton; if (a && a.match(/.+@.+\..+/) && b && (b.length >= 8)) { c.disabled = false; } else { c.disabled = true; } }

function changepref(a) { 
	var b = $("cngmail"); var c = $("cngpass1"); var d = $("nowpass"); var e = $("cngpass2"); var f = $("cngpass3"); var g = $("delpass"); 
	var h = $("changemail2").style; var i = $("changepass2").style; var j = $("changepass3").style; 
	var k = document.user.cngmail; var l = document.user.nowpass; var m = document.user.delpass; var n = document.user.changeprefs; 
	if (a == "mail") { 
		d.value = e.value = f.value = g.value = ""; 
		d.style.background = e.style.background = f.style.background = g.style.background = "#CCCCCC"; 
		b.style.background = c.style.background = "#FFFFFF";
		l.disabled = m.disabled = true; 
		h.visibility = 'visible'; i.visibility = 'collapse'; j.visibility = 'collapse'; k.disabled = false; 
		b.focus();
	} 
	else if (a == "pass") { 
		b.value = c.value = g.value = ""; 
		b.style.background = c.style.background = g.style.background = "#CCCCCC"; 
		d.style.background = e.style.background = f.style.background = "#FFFFFF";
		k.disabled = m.disabled = true; 
		h.visibility = 'collapse'; i.visibility = 'visible'; j.visibility = 'visible'; l.disabled = false; 
		d.focus();
	} 
	else if (a == "delete") { 
		b.value = c.value = d.value = e.value = f.value = ""; 
		b.style.background = c.style.background = d.style.background = e.style.background = f.style.background = "#CCCCCC"; 
		g.style.background = "#FFFFFF";
		l.disabled = k.disabled = true; h.visibility = 'collapse'; i.visibility = 'collapse'; j.visibility = 'collapse'; m.disabled = false; 
		g.focus();
	} 
	else if ((a == 1) && (k.disabled == false)) { if (b.value && b.value.match(/.+@.+\..+/) && c.value && (c.value.length >= 8)) { n.disabled = false; } else { n.disabled = true; } } 
	else if ((a == 2) && (l.disabled == false)) { if (d.value && (d.value.length >= 8) && e.value && (e.value.length >= 8) && f.value && (f.value.length >= 8)) { n.disabled = false; } else { n.disabled = true; } } 
	else if ((a == 3) && (m.disabled == false)) { if (g.value && (g.value.length >= 8)) { n.disabled = false; } else { n.disabled = true; } } 
}

function ocitems(a) { var b = $(a).style; if (b.display == "none") { b.display = "block"; } else { b.display = "none"; } }

function occattbl(a) {
	var b = $(a + "t").style; 
	var c = $(a + "b1").style; 
	var d = $(a + "b2").style; 
	if (b.display == "none") { 
		b.display = "block"; 
		c.display = "none"; 
		d.display = "block"; 
	} else { 
		b.display = "none"; 
		c.display = "block"; 
		d.display = "none"; 
	}
}

function ocnews() {
	var a = $("newsbox").style;
	var b = $("newsbox2").style;
	var c = $("newsclose").style;
	if (a.display === "none") {
		b.display = "block";
		c.display = "block";
		a.display = "block";
		my2Timer = setInterval("ocingnews(\'newsbox\',0,newsboxheight,\'none')",1);
	} else {
		b.display = "none";
		c.display = "none";
		my2Timer = setInterval("ocingnews(\'newsbox\',newsboxheight,0,\'none')",1);
	}
}

function ocingnews(a,b,c,d) {
	var z = $(a).style;
	var e = stripPx(z.height);
	var f = 20; // step
	if (b < c) {
		e += f;
		if (e >= newsboxheight) { 
			z.height = newsboxheight + "px";
			clearInterval(my2Timer); 
			return false;
		} else {
			z.height = e + "px";
		}
	} else {
		e -= f;
		if (e <= 0) {
			z.height = c + "px";
			z.display = "none";
			clearInterval(my2Timer); 
			return false;
		} else {
			z.height = e + "px";
		}
	}
}

function ocbutton2() {
	var a = $("mbutton2").style;
	var b = $("mbutton2o").style;
	var c = $("mbutton2c").style;
	var d = $("mbutton2c2").style;
	if (a.display === "none") {
		a.display = "block";
		b.display = "none";
		c.display = "block";
		d.display = "block";
	} else {
		a.display = "none";
		b.display = "block";
		c.display = "none";
		d.display = "none";
	}
}

function ocbutton3() {
	var a = $("mbutton3").style;
	var b = $("mbutton3o").style;
	var c = $("mbutton3c").style;
	if (a.display === "none") {
		a.display = "block";
		b.display = "none";
		c.display = "block";
	} else {
		a.display = "none";
		b.display = "block";
		c.display = "none";
	}
}

function cartdelete(a) {
	document.cartform.elements[a].value = "";
	document.cartform.recal.click();
}

