
function EditBanner(id)
{
	location.href="edit-details.php?bannerid="+id;
}

function EditNewsArticle(id)
{
	location.href="news.php?type=news&articleid="+id;
}

function EditDistributer(id)
{
	location.href="distributers.php?distributerid="+id;
}

function DeleteNewsArticle(frm){
	
	if(confirm("Are you sure you want to delete this news story?\n\nYou will NOT be able to undo this action.")){
		document.getElementById("DeleteNewsStory").submit();
	}
}

function DeleteDistributer(frm){
	
	if(confirm("Are you sure you want to delete this distributer?\n\nYou will NOT be able to undo this action.")){
		document.getElementById("DeleteDistributer").submit();
	}
}

function logout()
{
	var frm=document.getElementById("logout_frm");

	frm.submit();
}

function HighlightRow(row)
{
	row.style.backgroundColor="#84d3fb";
}

function UnHighlightRow(row)
{
	row.style.backgroundColor="#ffffff";
}

function HighlightCell(row)
{
	row.style.backgroundColor="#eaeaea";
}

function UnHighlightCell(row)
{
	row.style.backgroundColor="#ffffff";
}

function EditProduct(id)
{
	location.href="shop.php?product="+id;
}

function DeleteBanner(frm){
	
	if(confirm("Are you sure you want to delete this banner?")){
		document.getElementById("DeleteBanner").submit();
	}
}

function EditCategory(id)
{
	location.href="categories.php?categoryid="+id;
}


function EditSubcategory(id)
{
	location.href="subcategories.php?subcategoryid="+id;
}

function DeleteCategoryImage(frm){
	
	if(confirm("Are you sure you want to delete this image?")){
		document.getElementById("DeleteCategoryImage").submit();
	}
}

function DeleteProductVariation(frm){
	
	if(confirm("Are you sure you want to delete this product variation?")){
		document.getElementById("DeleteProductVariation").submit();
	}
}

function DeleteSubcategory(frm){
	
	if(confirm("Are you sure you want to delete this product?  This will delete any associated product variations and cannot be undone.")){
		document.getElementById("DeleteSubcategory").submit();
	}
}

function DeleteSubcategoryImage1(frm){
	
	if(confirm("Are you sure you want to delete this image?")){
		document.getElementById("DeleteSubcategoryImage1").submit();
	}
}

function DeleteSubcategoryImage2(frm){
	
	if(confirm("Are you sure you want to delete this image?")){
		document.getElementById("DeleteSubcategoryImage2").submit();
	}
}



function DeleteDocument(frm){
	
	if(confirm("Are you sure you want to delete this document?")){
		document.getElementById("DeleteDocumentForm").submit();
	}
}


function EditDownloadableDocument(documentid,adddocumenttype)
{
	location.href="subcategories.php?documentid=" + documentid + "&adddocumenttype=" + adddocumenttype;
}

function EditHomepage(adminregionid)
{
	location.href="homepage.php?adminregionid=" + adminregionid;
}

function EditContact(adminregionid, regionName)
{
	location.href="contact.php?adminregionid=" + adminregionid+ "&regionName="+regionName;
}

function EditProductVariation(id)
{
	location.href="subcategories.php?productvariationid="+id;
}

function EditRegions(categoryid,regionid,currentstate)
{
	if(confirm("Are you sure you want to update regions for this category?  This will update all products and product variations within this category.")){
		
		document.getElementById("UpdateCategoryRegion").categoryid.value= categoryid;
		document.getElementById("UpdateCategoryRegion").currentstatus.value= currentstate;
		document.getElementById("UpdateCategoryRegion").regiontochange.value= regionid;
		
		document.getElementById("UpdateCategoryRegion").submit();
	}
}

function EditProducts(productid,regionid,currentstate,parentstate)
{
	//Check first that the category isn't set to 'No' - if it is, then they can't update this product
	if(parentstate==0){
		if(currentstate==0){
			alert ("You cannot activate this product in this region, as its category is not available in this region.  If you want this product to be available, you must first update the parent category.");	
		}
	} 
	else {
		if(confirm("Are you sure you want to update regions for this product?  This will update all product variations for this product.")){
			
			document.getElementById("UpdateProductRegion").productid.value= productid;
			document.getElementById("UpdateProductRegion").currentstatus.value= currentstate;
			document.getElementById("UpdateProductRegion").regiontochange.value= regionid;
			document.getElementById("UpdateProductRegion").submit();
		}
	}

}

function EditVariation(variationid,regionid,currentstate,parentstate)
{
	if(parentstate==0){
		if(currentstate==0){
			alert ("You cannot activate this product variation in this region, as its parent product is not available in this region.  If you want this product to be available, you must first update the parent product.");	
		}
	} 
	else {
		if(confirm("Are you sure you want to update regions for this product variation?")){
			document.getElementById("UpdateVariationRegion").variationid.value= variationid;
			document.getElementById("UpdateVariationRegion").currentstatus.value= currentstate;
			document.getElementById("UpdateVariationRegion").regiontochange.value= regionid;
			document.getElementById("UpdateVariationRegion").submit();
		}
	}
}

function DocTypeBoxes(variationid){
	
	var frm=document.getElementById("variationdocumentaddform");
	var doctype = frm.TypeOfDocument.value;
	//alert(variationid);
	location.href="subcategories.php?action=addDocument&variationid="+variationid+"&adddocumenttype="+doctype;
}


function DocTypeBoxesEdit(documentid){
	
	var frm=document.getElementById("updatedocumentsform");
	var doctype = frm.TypeOfDocument.value;
	
	location.href="subcategories.php?documentid="+documentid+"&adddocumenttype="+doctype;
}

function DeleteThisCategory(frm){
	
	if(confirm("Are you sure you want to delete this category?  \n\nThis will delete any products and variations within this category, and cannot be undone.")){
		document.getElementById("DeleteThisCategory").submit();
	}
}

function MoveCatsUp(categoryid,currentorderid,newid,neworderid)
{
	//if(confirm("Are you sure you want to move this category up?")){
		
		document.getElementById("MoveCatsUp").CurrentID.value = categoryid;
		document.getElementById("MoveCatsUp").CurrentOrderID.value = currentorderid;
		document.getElementById("MoveCatsUp").IDToChangeWith.value = newid;
		document.getElementById("MoveCatsUp").OrderIDToChangeWith.value = neworderid;
		
		document.getElementById("MoveCatsUp").submit();
		
	//}
}

function MoveCatsDown(categoryid,currentorderid,newid,neworderid)
{
	//if(confirm("Are you sure you want to move this category down?")){
		
		document.getElementById("MoveCatsDown").CurrentID.value = categoryid;
		document.getElementById("MoveCatsDown").CurrentOrderID.value = currentorderid;
		document.getElementById("MoveCatsDown").IDToChangeWith.value = newid;
		document.getElementById("MoveCatsDown").OrderIDToChangeWith.value = neworderid;
		
		document.getElementById("MoveCatsDown").submit();
		
	//}
}





