$(document).ready(function(){	
	$("div#showmain").cycle({
		fx: 'scrollHorz',
		speed: 800,
		timeout: 2000,
		pause: 0,
		next: "#homeright",
		prev: "#homeleft"
	});
});

$(document).ready(function(){
	$("#minislides").cycle({
		fx: "fade",
		speed: 500,
		timeout: 4000,
		pause: 1,
		next: "#nextmini",
		prev: "#prevmini",
		pager: "#navmini"
	});
});

function showel(show)
{
	document.getElementById(show).style.display = "block";
}

function hideel(hide)
{
	document.getElementById(hide).style.display = "none";
}

function sameaddy(el)
{
	if (el.checked)
	{
		showel('shipaddy');
		hideel('ccaddress');	
	}
	else
	{
		hideel('shipaddy');
		showel('ccaddress');
	}
}

function showimgmids(obj)
{
	switch(obj)
	{
	case "imgfrontmid":
		showel('imgfrontmid');
		hideel('imginsidemid');
		hideel('imgbackmid');
		hideel('imgrangemid');
		hideel('img1mid');
		hideel('img2mid');
		hideel('img3mid');
		hideel('img4mid');
		hideel('imgfeature1mid');
		hideel('imgfeature2mid');
		hideel('imgfeature3mid');
		hideel('imgfeature4mid');
		hideel('imgfeature5mid');
		hideel('imgfeature6mid');
		hideel('imgfeature7mid');
		hideel('imgfeature8mid');
		break;
	case "imginsidemid":
		hideel('imgfrontmid');
		showel('imginsidemid');
		hideel('imgbackmid');
		hideel('imgrangemid');
		hideel('img1mid');
		hideel('img2mid');
		hideel('img3mid');
		hideel('img4mid');
		hideel('imgfeature1mid');
		hideel('imgfeature2mid');
		hideel('imgfeature3mid');
		hideel('imgfeature4mid');
		hideel('imgfeature5mid');
		hideel('imgfeature6mid');
		hideel('imgfeature7mid');
		hideel('imgfeature8mid');
		break;
	case "imgbackmid":
		hideel('imgfrontmid');
		hideel('imginsidemid');
		showel('imgbackmid');
		hideel('imgrangemid');
		hideel('img1mid');
		hideel('img2mid');
		hideel('img3mid');
		hideel('img4mid');
		hideel('imgfeature1mid');
		hideel('imgfeature2mid');
		hideel('imgfeature3mid');
		hideel('imgfeature4mid');
		hideel('imgfeature5mid');
		hideel('imgfeature6mid');
		hideel('imgfeature7mid');
		hideel('imgfeature8mid');
		break;
	case "imgrangemid":
		hideel('imgfrontmid');
		hideel('imginsidemid');
		hideel('imgbackmid');
		showel('imgrangemid');
		hideel('img1mid');
		hideel('img2mid');
		hideel('img3mid');
		hideel('img4mid');
		hideel('imgfeature1mid');
		hideel('imgfeature2mid');
		hideel('imgfeature3mid');
		hideel('imgfeature4mid');
		hideel('imgfeature5mid');
		hideel('imgfeature6mid');
		hideel('imgfeature7mid');
		hideel('imgfeature8mid');
		break;
	case "img1mid":
		hideel('imgfrontmid');
		hideel('imginsidemid');
		hideel('imgbackmid');
		hideel('imgrangemid');
		showel('img1mid');
		hideel('img2mid');
		hideel('img3mid');
		hideel('img4mid');
		hideel('imgfeature1mid');
		hideel('imgfeature2mid');
		hideel('imgfeature3mid');
		hideel('imgfeature4mid');
		hideel('imgfeature5mid');
		hideel('imgfeature6mid');
		hideel('imgfeature7mid');
		hideel('imgfeature8mid');
		break;
	case "img2mid":
		hideel('imgfrontmid');
		hideel('imginsidemid');
		hideel('imgbackmid');
		hideel('imgrangemid');
		hideel('img1mid');
		showel('img2mid');
		hideel('img3mid');
		hideel('img4mid');
		hideel('imgfeature1mid');
		hideel('imgfeature2mid');
		hideel('imgfeature3mid');
		hideel('imgfeature4mid');
		hideel('imgfeature5mid');
		hideel('imgfeature6mid');
		hideel('imgfeature7mid');
		hideel('imgfeature8mid');
		break;
	case "img3mid":
		hideel('imgfrontmid');
		hideel('imginsidemid');
		hideel('imgbackmid');
		hideel('imgrangemid');
		hideel('img1mid');
		hideel('img2mid');
		showel('img3mid');
		hideel('img4mid');
		hideel('imgfeature1mid');
		hideel('imgfeature2mid');
		hideel('imgfeature3mid');
		hideel('imgfeature4mid');
		hideel('imgfeature5mid');
		hideel('imgfeature6mid');
		hideel('imgfeature7mid');
		hideel('imgfeature8mid');
		break;
	case "img4mid":
		hideel('imgfrontmid');
		hideel('imginsidemid');
		hideel('imgbackmid');
		hideel('imgrangemid');
		hideel('img1mid');
		hideel('img2mid');
		hideel('img3mid');
		showel('img4mid');
		hideel('imgfeature1mid');
		hideel('imgfeature2mid');
		hideel('imgfeature3mid');
		hideel('imgfeature4mid');
		hideel('imgfeature5mid');
		hideel('imgfeature6mid');
		hideel('imgfeature7mid');
		hideel('imgfeature8mid');
		break;
	case "imgfeature1mid":
		hideel('imgfrontmid');
		hideel('imginsidemid');
		hideel('imgbackmid');
		hideel('imgrangemid');
		hideel('img1mid');
		hideel('img2mid');
		hideel('img3mid');
		hideel('img4mid');
		showel('imgfeature1mid');
		hideel('imgfeature2mid');
		hideel('imgfeature3mid');
		hideel('imgfeature4mid');
		hideel('imgfeature5mid');
		hideel('imgfeature6mid');
		hideel('imgfeature7mid');
		hideel('imgfeature8mid');
		break;
	case "imgfeature2mid":
		hideel('imgfrontmid');
		hideel('imginsidemid');
		hideel('imgbackmid');
		hideel('imgrangemid');
		hideel('img1mid');
		hideel('img2mid');
		hideel('img3mid');
		hideel('img4mid');
		hideel('imgfeature1mid');
		showel('imgfeature2mid');
		hideel('imgfeature3mid');
		hideel('imgfeature4mid');
		hideel('imgfeature5mid');
		hideel('imgfeature6mid');
		hideel('imgfeature7mid');
		hideel('imgfeature8mid');
		break;
	case "imgfeature3mid":
		hideel('imgfrontmid');
		hideel('imginsidemid');
		hideel('imgbackmid');
		hideel('imgrangemid');
		hideel('img1mid');
		hideel('img2mid');
		hideel('img3mid');
		hideel('img4mid');
		hideel('imgfeature1mid');
		hideel('imgfeature2mid');
		showel('imgfeature3mid');
		hideel('imgfeature4mid');
		hideel('imgfeature5mid');
		hideel('imgfeature6mid');
		hideel('imgfeature7mid');
		hideel('imgfeature8mid');
		break;
	case "imgfeature4mid":
		hideel('imgfrontmid');
		hideel('imginsidemid');
		hideel('imgbackmid');
		hideel('imgrangemid');
		hideel('img1mid');
		hideel('img2mid');
		hideel('img3mid');
		hideel('img4mid');
		hideel('imgfeature1mid');
		hideel('imgfeature2mid');
		hideel('imgfeature3mid');
		showel('imgfeature4mid');
		hideel('imgfeature5mid');
		hideel('imgfeature6mid');
		hideel('imgfeature7mid');
		hideel('imgfeature8mid');
		break;
	case "imgfeature5mid":
		hideel('imgfrontmid');
		hideel('imginsidemid');
		hideel('imgbackmid');
		hideel('imgrangemid');
		hideel('img1mid');
		hideel('img2mid');
		hideel('img3mid');
		hideel('img4mid');
		hideel('imgfeature1mid');
		hideel('imgfeature2mid');
		hideel('imgfeature3mid');
		hideel('imgfeature4mid');
		showel('imgfeature5mid');
		hideel('imgfeature6mid');
		hideel('imgfeature7mid');
		hideel('imgfeature8mid');
		break;
	case "imgfeature6mid":
		hideel('imgfrontmid');
		hideel('imginsidemid');
		hideel('imgbackmid');
		hideel('imgrangemid');
		hideel('img1mid');
		hideel('img2mid');
		hideel('img3mid');
		hideel('img4mid');
		hideel('imgfeature1mid');
		hideel('imgfeature2mid');
		hideel('imgfeature3mid');
		hideel('imgfeature4mid');
		hideel('imgfeature5mid');
		showel('imgfeature6mid');
		hideel('imgfeature7mid');
		hideel('imgfeature8mid');
		break;
	case "imgfeature7mid":
		hideel('imgfrontmid');
		hideel('imginsidemid');
		hideel('imgbackmid');
		hideel('imgrangemid');
		hideel('img1mid');
		hideel('img2mid');
		hideel('img3mid');
		hideel('img4mid');
		hideel('imgfeature1mid');
		hideel('imgfeature2mid');
		hideel('imgfeature3mid');
		hideel('imgfeature4mid');
		hideel('imgfeature5mid');
		hideel('imgfeature6mid');
		showel('imgfeature7mid');
		hideel('imgfeature8mid');
		break;
	case "imgfeature8mid":
		hideel('imgfrontmid');
		hideel('imginsidemid');
		hideel('imgbackmid');
		hideel('imgrangemid');
		hideel('img1mid');
		hideel('img2mid');
		hideel('img3mid');
		hideel('img4mid');
		hideel('imgfeature1mid');
		hideel('imgfeature2mid');
		hideel('imgfeature3mid');
		hideel('imgfeature4mid');
		hideel('imgfeature5mid');
		hideel('imgfeature6mid');
		hideel('imgfeature7mid');
		showel('imgfeature8mid');
		break;
	}
}

function searchFocus(e,text)
{
	if (e && (e.value == "") || (e.value == text))
	{
		e.value = "";
	}
}

function searchBlur(e,text)
{
	if (e && (e.value == ""))
	{
		e.value = text;
	}
}

function nextfield(el)
{
	if (el.value.length == el.maxLength)
	{
		el.parentNode.getElementsByTagName("input")[1].focus();
	}
}

function changeview(type)
{
	if (type == "adminitems")
	{
		category = document.manageitems.cat.value;
		section = document.manageitems.sec.value;
		viewby = document.manageitems.viewby.value;
		pagesize = document.manageitems.pagesize.value;
		location.href = "main.f?cat=" + category + "&sec=" + section + "&viewby=" + viewby + "&ps=" + pagesize + "&p=1";
	}
	else if (type == "adminusers")
	{
		category = document.manageusers.cat.value;
		section = document.manageusers.sec.value;
		viewuser = document.manageusers.viewuser.value;
		pagesize = document.manageusers.pagesize.value;
		location.href = "main.f?cat=" + category + "&sec=" + section + "&viewuser=" + viewuser + "&ps=" + pagesize + "&p=1";
	}
	else if (type == "adminlog")
	{
		category = document.managelog.cat.value;
		section = document.managelog.sec.value;
		viewlog = document.managelog.viewlog.value;
		pagesize = document.managelog.pagesize.value;
		location.href = "main.f?cat=" + category + "&sec=" + section + "&viewlog=" + viewlog + "&ps=" + pagesize + "&p=1";
	}
	else if (type == "adminmail")
	{
		category = document.managemail.cat.value;
		section = document.managemail.sec.value;
		viewmail = document.managemail.viewmail.value;
		pagesize = document.managemail.pagesize.value;
		location.href = "main.f?cat=" + category + "&sec=" + section + "&viewmail=" + viewmail + "&ps=" + pagesize + "&p=1";
	}
	else if (type == "adminorders")
	{
		category = document.manageorders.cat.value;
		section = document.manageorders.sec.value;
		vieworders = document.manageorders.vieworders.value;
		pagesize = document.manageorders.pagesize.value;
		location.href = "main.f?cat=" + category + "&sec=" + section + "&vieworders=" + vieworders + "&ps=" + pagesize + "&p=1";
	}
}

function changepagesize(type)
{
	if (type == "adminitems")
	{
		category = document.manageitems.cat.value;
		section = document.manageitems.sec.value;
		viewby = document.manageitems.viewby.value;
		pagesize = document.manageitems.pagesize.value;
		q = document.manageitems.q.value;
		location.href = "main.f?cat=" + category + "&sec=" + section + "&viewby=" + viewby + "&ps=" + pagesize + "&p=1&q=" + q;
	}
	else if (type == "adminusers")
	{
		category = document.manageusers.cat.value;
		section = document.manageusers.sec.value;
		viewuser = document.manageusers.viewuser.value;
		pagesize = document.manageusers.pagesize.value;
		q = document.manageusers.q.value;
		location.href = "main.f?cat=" + category + "&sec=" + section + "&viewuser=" + viewuser + "&ps=" + pagesize + "&p=1&q=" + q;
	}
	else if (type == "adminlog")
	{
		category = document.managelog.cat.value;
		section = document.managelog.sec.value;
		viewlog = document.managelog.viewlog.value;
		pagesize = document.managelog.pagesize.value;
		q = document.managelog.q.value;
		location.href = "main.f?cat=" + category + "&sec=" + section + "&viewlog=" + viewlog + "&ps=" + pagesize + "&p=1&q=" + q;
	}
	else if (type == "adminmail")
	{
		category = document.managemail.cat.value;
		section = document.managemail.sec.value;
		viewmail = document.managemail.viewmail.value;
		pagesize = document.managemail.pagesize.value;
		q = document.managemail.q.value;
		location.href = "main.f?cat=" + category + "&sec=" + section + "&viewmail=" + viewmail + "&ps=" + pagesize + "&p=1&q=" + q;
	}
	else if (type == "adminorders")
	{
		category = document.manageorders.cat.value;
		section = document.manageorders.sec.value;
		vieworders = document.manageorders.vieworders.value;
		pagesize = document.manageorders.pagesize.value;
		q = document.manageorders.q.value;
		location.href = "main.f?cat=" + category + "&sec=" + section + "&vieworders=" + vieworders + "&ps=" + pagesize + "&p=1&q=" + q;
	}
}

function itempgsize()
{
	cat = document.managegrandshow.cat.value;
	q = document.managegrandshow.q.value;
	shopby = document.managegrandshow.shopby.value;
	refineby = document.managegrandshow.refineby.value;
	kind = document.managegrandshow.kind.value;
	what = document.managegrandshow.what.value;
	sortby = document.managegrandshow.viewsortby.value;
	pgsize = document.managegrandshow.viewpgsize.value;
	location.href = "main.f?cat=" + cat + "&q=" + q + "&shopby=" + shopby + "&refineby=" + refineby + "&kind=" + kind + "&is=" + what + "&sortby=" + sortby + "&ps=" + pgsize + "&p=1";
}

function itemsortby()
{
	cat = document.managegrandshow.cat.value;
	q = document.managegrandshow.q.value;
	shopby = document.managegrandshow.shopby.value;
	refineby = document.managegrandshow.refineby.value;
	kind = document.managegrandshow.kind.value;
	what = document.managegrandshow.what.value;
	sortby = document.managegrandshow.viewsortby.value;
	pgsize = document.managegrandshow.viewpgsize.value;
	location.href = "main.f?cat=" + cat + "&q=" + q + "&shopby=" + shopby + "&refineby=" + refineby + "&kind=" + kind + "&is=" + what + "&sortby=" + sortby + "&ps=" + pgsize + "&p=1";
}

function changecolor(el,state)
{
	if (el.id == "adminmenu" && state == "over")
	el.style.backgroundColor = "#f1f1f1";
	else if (el.id == "adminmenu" && state == "out")
	el.style.backgroundColor = "#ffffff";
	
	else if (el.id == "prodborder" && state == "over")
	el.style.borderColor = "#000000";
	else if (el.id == "prodborder" && state == "out")
	el.style.borderColor = "#d3d3d3";
	
	else if (el.id == "myaccount" && state == "over")
	el.style.backgroundColor = "#e8f9f8";
	else if (el.id == "myaccount" && state == "out")
	el.style.backgroundColor = "#ffffff";
	
	else if (el.id == "userborder" && state == "over")
	el.style.borderColor = "#3d8582";
	else if (el.id == "userborder" && state == "out")
	el.style.borderColor = "#86c1bf";
	
	else if (el.id == "adminuserborder" && state == "over")
	el.style.borderColor = "#9e9e9e";
	else if (el.id == "adminuserborder" && state == "out")
	el.style.borderColor = "#d4d4d4";
	
	else if (el.id == "userbordercheckout" && state == "over")
	el.style.borderColor = "#858585";
	else if (el.id == "userbordercheckout" && state == "out")
	el.style.borderColor = "#d4d4d4";
}

function delconfirm(deltype,type)
{
	if (deltype == "adminuser")
	{
		if (confirm("Remove " + type + " from the system permanently?"))
		{
			return true;
		}
		else return false;
	}
	else if (deltype == "adminproducts")
	{
		if (confirm("Remove " + type + " from the inventory permanently?"))
		{
			return true;
		}
		else return false;
	}
	else if (deltype == "useraddy")
	{
		if (confirm("Remove " + type + " from your address book permanently?"))
		{
			return true;	
		}
		else return false;
	}
	else if (deltype == "userpayment")
	{
		if (confirm("Remove " + type + " from your account permanently?"))
		{
			return true;
		}
		else return false;
	}
	else if (deltype == "mail")
	{
		if (confirm("Remove " + type + " from your inbox?"))
		{
			return true;
		}
		else return false;
	}
	else if (deltype == "orders")
	{
		if (confirm("Remove order " + type + " from the record?"))
		{
			return true;	
		}
		else return false;
	}
}

function updateqty(pid,itemid)
{
	qtytoupdate = document.getElementById("qtyorder"+itemid).value;
	location.href = "main.f?cat=bag&act=updateqty&qtyval=" + qtytoupdate + "&pid=" + pid;
}

function checkevent(e,pid)
{
	var e = (e && e.target) || (event && event.srcElement)
	
	if (e.id != "delprod")
	{
		edit('manage',pid);
	}
	else if (e.id == "delprod")
	{
		e.cancel;
	}
	else if (e.id == "duplicate")
	{
		e.cancel;	
	}
}

function edit(section,id)
{
	location.href = "main.f?cat=admin&sec=" + section + "&act=edit&id=" + id;
}

/*var active_element;
var bIsMSIE = false;
function autoui() 
{

	if (navigator.appName == "Microsoft Internet Explorer") 
	{
		active_element = document.activeElement;
		document.onfocusout = closeWnd;
		bIsMSIE = true;
	}
	else 
	{ 
		window.onblur = closeWnd; 
	}
}
function closeWnd() 
{
	if (window.opener != null)
	{
		if (bIsMSIE && (active_element != document.activeElement)) 
		{
			active_element = document.activeElement;
		}
		else 
		{
			window.close();
		}
	}
}*/

function removeimg(imgtype)
{	
	switch(imgtype)
	{
	case "imgthumb":
		imgdes = "Thumbnail Image";
		break;
	case "imgfrontsm":
		imgdes = "Front (Small-Size) Image";
		break;
	case "imgfrontmid":
		imgdes = "Front (Mid-Size) Image";
		break;
	case "imgfront":
		imgdes = "Front (Large-Size) Image";
		break;
	case "imginsidesm":
		imgdes = "Inside (Small-Size) Image";
		break;
	case "imginsidemid":
		imgdes = "Inside (Mid-Size) Image";
		break;
	case "imginside":
		imgdes = "Inside (Large-Size) Image";
		break;
	case "imgbacksm":
		imgdes = "Back (Small-Size) Image";
		break;
	case "imgbackmid":
		imgdes = "Back (Mid-Size) Image";
		break;
	case "imgback":
		imgdes = "Back (Large-Size) Image";
		break;
	case "imgrangesm":
		imgdes = "Product Range (Small-Size) Image";
		break;
	case "imgrangemid":
		imgdes = "Product Range (Mid-Size) Image";
		break;
	case "imgrange":
		imgdes = "Product Range (Large-Size) Image";
		break;
	case "img1sm":
		imgdes = "Image 1 (Small-Size) Image";
		break;
	case "img1mid":
		imgdes = "Image 1 (Mid-Size) Image";
		break;
	case "img1":
		imgdes = "Image 1 (Large-Size) Image";
		break;
	case "img2sm":
		imgdes = "Image 2 (Small-Size) Image";
		break;
	case "img2mid":
		imgdes = "Image 2 (Mid-Size) Image";
		break;
	case "img2":
		imgdes = "Image 2 (Large-Size) Image";
		break;
	case "img3sm":
		imgdes = "Image 3 (Small-Size) Image";
		break;
	case "img3mid":
		imgdes = "Image 3 (Mid-Size) Image";
		break;
	case "img3":
		imgdes = "Image 3 (Large-Size) Image";
		break;
	case "img4sm":
		imgdes = "Image 4 (Small-Size) Image";
		break;
	case "img4mid":
		imgdes = "Image 4 (Mid-Size) Image";
		break;
	case "img4":
		imgdes = "Image 4 (Large-Size) Image";
		break;
	case "imgfeature1sm":
		imgdes = "Feature 1 (Small-Size) Image";
		break;
	case "imgfeature1mid":
		imgdes = "Feature 1 (Mid-Size) Image";
		break;
	case "imgfeature1":
		imgdes = "Feature 1 (Large-Size) Image";
		break;
	case "imgfeature2sm":
		imgdes = "Feature 2 (Small-Size) Image";
		break;
	case "imgfeature2mid":
		imgdes = "Feature 2 (Mid-Size) Image";
		break;
	case "imgfeature2":
		imgdes = "Feature 2 (Large-Size) Image";
		break;
	case "imgfeature3sm":
		imgdes = "Feature 3 (Small-Size) Image";
		break;
	case "imgfeature3mid":
		imgdes = "Feature 3 (Mid-Size) Image";
		break;
	case "imgfeature3":
		imgdes = "Feature 3 (Large-Size) Image";
		break;
	case "imgfeature4sm":
		imgdes = "Feature 4 (Small-Size) Image";
		break;
	case "imgfeature4mid":
		imgdes = "Feature 4 (Mid-Size) Image";
		break;
	case "imgfeature4":
		imgdes = "Feature 4 (Large-Size) Image";
		break;
	case "imgfeature5sm":
		imgdes = "Feature 5 (Small-Size) Image";
		break;
	case "imgfeature5mid":
		imgdes = "Feature 5 (Mid-Size) Image";
		break;
	case "imgfeature5":
		imgdes = "Feature 5 (Large-Size) Image";
		break;
	case "imgfeature6sm":
		imgdes = "Feature 6 (Small-Size) Image";
		break;
	case "imgfeature6mid":
		imgdes = "Feature 6 (Mid-Size) Image";
		break;
	case "imgfeature6":
		imgdes = "Feature 6 (Large-Size) Image";
		break;
	case "imgfeature7sm":
		imgdes = "Feature 7 (Small-Size) Image";
		break;
	case "imgfeature7mid":
		imgdes = "Feature 7 (Mid-Size) Image";
		break;
	case "imgfeature7":
		imgdes = "Feature 7 (Large-Size) Image";
		break;
	case "imgfeature8sm":
		imgdes = "Feature 8 (Small-Size) Image";
		break;
	case "imgfeature8mid":
		imgdes = "Feature 8 (Mid-Size) Image";
		break;
	case "imgfeature8":
		imgdes = "Feature 8 (Large-Size) Image";
		break;
	}
	
	if (confirm("Remove " + imgdes + " from this product?"))
	{
		return true;
	}	
	else return false;
}

function windowpop(url)
{
	window.open(url,"imageupload","toolbar=0,menubar=0,resizable=0,height=170,width=480,screenX=300,screenY=200");
}