var lt = '<xsl:text disable-output-escaping="yes">&lt;</xsl:text>';
var gt = '<xsl:text disable-output-escaping="yes">&gt;</xsl:text>';

function dosearch()
{
//	document.frmMain.search.value='1';
	// We fudge the search capability and simply change the page name to search results and submit..
	document.frmMain.pagename.value='searchresults';
	document.frmMain.selecteditem.value = '';
	document.frmMain.selectedtype.value = '';
	document.frmMain.submit();
	return(false);
}

function dologin()
{
	document.frmMain.logginin.value = '1';
	document.frmMain.submit();
	return(false);
}

function dologout()
{
	document.frmMain.logginout.value='1';
	document.frmMain.submit();
	return(false);
}

function duplicateitem(type, item)
{
	document.frmMain.selecteditem.value = item;
	document.frmMain.selectedtype.value = type;
	document.frmMain.duplicateit.value = '1';
	document.frmMain.submit();
	return(false);
}

function deleteitem(type, item)
{
	if (!confirm('Do you really want to delete this ' + type + '?'))
		return;

	document.frmMain.selecteditem.value = item;
	document.frmMain.selectedtype.value = type;
	document.frmMain.deleteit.value = '1';
	document.frmMain.submit();
	return(false);
}

function uploadimage(itemid, itemimageid)
{
	// Allow the user to upload an image and attach it to the selected item
	var sURL = '_common/uploadimage.aspx?itemimageid='
				+ itemimageid
				+ '&itemid=' + itemid;
	window.open(sURL,'uploadimage','width=400,height=250');
}

function uploadphoto(itemid, itemimageid)
{
	// Allow the user to upload an image and attach it to the selected item
//	var sURL = '_common/uploadphotos/default.aspx?itemimageid='
//				+ itemimageid
//				+ '&itemid=' + itemid;
	var sURL = '_common/uploadphoto.aspx?itemimageid='
				+ itemimageid
				+ '&itemid=' + itemid;
	window.open(sURL,'uploadphoto','width=400,height=250');
}

function uploadfile(itemid, itemdownloadid, sitename)
{
	// Allow the user to upload an image and attach it to the selected item
	var sURL = '_common/uploadfile.aspx?itemdownloadid='
				+ itemdownloadid
				+ '&itemid=' + itemid
				+ '&folder=_content/downloads/' + sitename;
	window.open(sURL,'uploadfile','width=400,height=250');
}

function imageproperties(itemid, itemimageid)
{
	// Allow the user to adjust display properties for the image - alignment, etc
//	window.open('_common/imageproperties.aspx?itemimageid=' + itemimageid '&itemid=' + itemid,'uploadimage','width=400,height=250');
}

function uploadcategoryimage(categoryid, itemimageid)
{
	// Allow the user to upload an image and attach it to the selected item
	var sURL = '_common/uploadimage.aspx?itemimageid=' + itemimageid + '&categoryid=' + categoryid;
	window.open(sURL,'uploadimage','width=400,height=250');
}

function editcategory(categoryid)
{
//			window.open('editcategory.aspx?selectedtype=category' + amp + 'selecteditem=' + categoryid,'addcategory','width=550,height=150');
	document.frmMain.selectedtype.value = 'category';
	document.frmMain.selecteditem.value = categoryid;
	document.frmMain.selectedparent.value = '';
	document.frmMain.mode.value = 'editcategory'
	document.frmMain.submit();
	return(false);
}

function edititem(itemid, parent)
{
//			window.open('edititem.aspx?selecteditem=' + itemid + amp + 'selectedtype=item','edititem','width=700,height=500,toolbar=yes,status=yes');
	document.frmMain.selectedtype.value = 'item';
	document.frmMain.selecteditem.value = itemid;
	document.frmMain.selectedparent.value = parent;
	document.frmMain.mode.value = 'edititem';
	document.frmMain.submit();
	return(false);
}

function additem(categoryid)
{
//			window.open('edititem.aspx?selectedtype=item' + amp + 'selectedparent=' + categoryid,'edititem','width=700,height=500,toolbar=yes,status=yes');
	document.frmMain.selectedparent.value = categoryid
	document.frmMain.selectedtype.value = 'item';
	document.frmMain.selecteditem.value = 0;
	document.frmMain.mode.value = 'edititem'
	document.frmMain.submit();
	return(false);
}

function addcategory(siteid, parentcategoryid, parentcategoryname)
{
	document.frmMain.selectedparent.value = siteid
	document.frmMain.selectedtype.value = 'category';
	document.frmMain.selecteditem.value = 0;
	document.frmMain.mode.value = 'editcategory'
	document.frmMain.selectedparentcategory.value = parentcategoryid;
	document.frmMain.parentcategoryname.value = parentcategoryname;
	document.frmMain.submit();
	return(false);
}

function selectitem(item, type, parent)
{
	document.frmMain.selecteditem.value = item;
	document.frmMain.selectedtype.value = type;
	document.frmMain.selectedparent.value = parent;
	document.frmMain.mode.value='';
	document.frmMain.submit();
	return(false);
}

function selectitemandpage(item, type, parent, page)
{
	document.frmMain.selecteditem.value = item;
	document.frmMain.selectedtype.value = type;
	document.frmMain.selectedparent.value = parent;
	document.frmMain.pagename.value = page;
	document.frmMain.mode.value='';
	document.frmMain.submit();
	return(false);
}
 
//		function edititem(itemid)
//		{
//			window.open('edititem.aspx?selecteditem=' + itemid + amp + 'selectedtype=item','edititem','width=700,height=500,toolbar=yes,status=yes');
//			return(false);
//		}

function addproduct(categoryid)
{
//	window.open('product_details.aspx?selectedtype=item' + '&selectedparent=' + categoryid,'additem','width=700,height=500,toolbar=yes,status=yes');
	return(false);
}

function editproduct(itemid)
{
//	window.open('product_details.aspx?selecteditem=' + itemid + '&selectedtype=item','edititem','width=550,height=450');
	return(false);
}

function additemtoorder(itemid, qty)
{
	document.frmMain.addtoorder.value=itemid;
	document.frmMain.addtoorderqty.value=qty;
	document.frmMain.submit();
}

function cards_clearorder()
{
	document.frmMain.clearorderbasket.value = "1";
	document.frmMain.submit();
}