	function InvokeAction(Element, A)
	{
		if (Element.form)
		{
			Element.form.action += A;
			Element.form.submit();
		}
		else
		{
			document.forms[Element].action += A;
			document.forms[Element].submit();
		}
	}

	function ClearText(Element, A)
	{
		if (A == "E-mail adres")
		{
			Element.value = '';
		}
		else if (A == "Productnaam")
		{
			Element.value = '';
		}
		else if (A == "Gebruikersnaam")
		{
			Element.value = '';
		}
	}

	function CartAddProduct(ProductId)
	{
		InvokeAction('Add&ProductId=' + ProductId);
	}

	function CartAddProductDirectly(ProductId)
	{
		location.href = 'ViewProduct.asp?Action=AddDirectly&ProductId=' + ProductId;
	}

	function CartRemoveItem(i)
	{
		if (confirm('Weet u zeker dat u dit product wilt verwijderen?'))
		{
			InvokeAction('Delete&Seqno=' + i);
		}
	}

	function ViewCart()
	{
		location.href = 'ShoppingCart.asp';
	}

	function ViewCompanyProduct(ProductId)
	{
		location.href = 'ViewCompanyProduct.asp?CompanyProductId=' + ProductId;
	}

	function ViewCompanyInfo()
	{
		location.href = 'ViewCompany.asp';
	}

	function DeleteShopProduct(ProductId)
	{
		location.href = 'DeleteCompanyProduct.asp?CompanyProductId=' + ProductId;
	}

	function EditCompanyProduct(ProductId)
	{
		location.href = 'EditCompanyProduct.asp?CompanyProductId=' + ProductId + '&Action=Load';
	}

	function EditCompanyProductStock(ProductId)
	{
		location.href = 'EditCompanyProductStock.asp?CompanyProductId=' + ProductId;
	}

	function ViewCompanyProducts()
	{
		location.href = 'ViewCompanyProducts.asp';
	}

   function CheckAllMatrixFieldsSet(SizeType, ColorType, SizeIsLeading, ColorIsLeading)
   {
      if ((SizeType.value != 0) || (ColorType.value != 0) /*&& (SizeIsLeading.checked || ColorIsLeading.checked)*/)
      {
         InvokeAction('EditProduct', 'BuildVersionMatrix');
      }
   }

   function SelectSizeAndColorColumnn(FieldName, valueId, SizeIsLeading, FieldFrom)
   {
      var SizeAndColors = document.getElementsByName(FieldName);
      for (i = 0; i < SizeAndColors.length; i++)
      {
         if (SizeIsLeading == "True")
         {
            if (SizeAndColors[i].value.split(",")[0] == valueId)
            {
               if (SizeAndColors[i].checked && !FieldFrom)
                  SizeAndColors[i].checked = false;
               else
                  SizeAndColors[i].checked = 'false';
            }
         }
         else
         {
            if (SizeAndColors[i].value.split(",")[1] == valueId)
            {
               if (SizeAndColors[i].checked && !FieldFrom)
                  SizeAndColors[i].checked = false;
               else
                  SizeAndColors[i].checked = 'checked';

            }
         }

      }
   }

   function SetLeadingPrice(FieldName, valueId, SizeIsLeading, FromField)
   {
      var txtField
      var SizeAndColors = document.getElementsByName(FieldName);
      for (i = 0; i < SizeAndColors.length; i++)
      {
         if (SizeIsLeading == "True")
         {
            if (SizeAndColors[i].value.split(",")[0] == valueId)
            {
               txtField = FromField.form.elements["Price"+SizeAndColors[i].value.split(",")[0]+""+SizeAndColors[i].value.split(",")[1]];
               txtField.value = FromField.value;
            }
         }
         else
         {
            if (SizeAndColors[i].value.split(",")[1] == valueId)
            {
               txtField = FromField.form.elements["Price"+SizeAndColors[i].value.split(",")[0]+""+SizeAndColors[i].value.split(",")[1]];
               txtField.value = FromField.value;
            }
         }
      }
   }

   function TurnOffLeading(LeadingName, isCheckedFieldFrom)
   {
      if (!isCheckedFieldFrom)
         document.getElementsByName("Leading"+LeadingName)[0].checked = false;
   }

   function CheckLeading(LeadingType, NonLeadinType)
   {
      if (LeadingType.checked)
         NonLeadinType.checked = false;
   }

   function SendCompanyProductImage(CompanyProductId)
   {
   	location.href = 'SendCompanyProductImage.asp';
   }

   function ManageSupply(ProductId)
   {
   	location.href = 'ManageProductSupply.asp?CompanyProductId=' + ProductId + '&Action=Load';
   }

   function AddCompanyProduct()
   {
   	location.href = 'AddCompanyProduct.asp';
   }

   function DeleteCompanyProduct(ProductId)
   {
   	location.href = 'DeleteCompanyProduct.asp?CompanyProductId=' + ProductId;
   }

   function ConfirmDeleteShopproduct(ProductId)
   {
   	location.href = 'DeleteCompanyProduct.asp?CompanyProductId=' + ProductId + '&Action=Delete';
   }

	function SwitchItems(PreviousItemId, CurrentItemId)
	{
	   location.href = 'ViewCompanyCategories.asp?Action=Switch&FirstItemId=' + PreviousItemId + '&SecondItemId=' + CurrentItemId;
	}

   function ViewCategory(CategoryId)
   {
   	location.href = 'ViewCompanyCategory.asp?CategoryId=' + CategoryId;
   }

   function EditCategory(CategoryId)
   {
   	location.href = 'EditCompanyCategory.asp?CategoryId=' + CategoryId + '&Action=Load';
   }

   function DeleteCategory(CategoryId)
   {
   	location.href = 'DeleteCompanyCategory.asp?CategoryId=' + CategoryId;
   }

   function AddCategory()
   {
   	location.href = 'AddCompanyCategory.asp';
   }

   function ViewCategories()
   {
   	location.href = 'ViewCompanyCategories.asp';
   }

   function AddProductsToCategory(CategoryId)
   {
   	location.href = 'AddProductsToCategory.asp?CategoryId=' + CategoryId;
   }

   function DeleteProductsToCategory(CategoryId)
   {
   	location.href = 'DeleteProductsToCategory.asp?CategoryId=' + CategoryId;
   }

   function AddSizeType()
   {
   	location.href = 'AddCompanySizeType.asp';
   }

   function ViewCompanySizeTypes()
   {
   	location.href = 'ViewCompanySizeTypes.asp';
   }

   function ViewSizeType(SizeTypeId)
   {
   	location.href = 'ViewCompanySizeType.asp?SizeTypeId=' + SizeTypeId + '&Action=Load';
   }

   function EditSizeType(SizeTypeId)
   {
   	location.href = 'EditCompanySizeType.asp?SizeTypeId=' + SizeTypeId + '&Action=Load';
   }

   function EditSizeTypeValues(SizeTypeId)
   {
   	location.href = 'EditCompanySizeTypeValues.asp?SizeTypeId=' + SizeTypeId + '&Action=Load';
   }

   function DeleteSizeType(SizeTypeId)
   {
   	location.href = 'DeleteCompanySizeType.asp?SizeTypeId=' + SizeTypeId;
   }

   function AddColorType()
   {
   	location.href = 'AddCompanyColorType.asp';
   }

   function ViewCompanyColorTypes()
   {
   	location.href = 'ViewCompanyColorTypes.asp';
   }

   function ViewColorType(ColorTypeId)
   {
   	location.href = 'ViewCompanyColorType.asp?ColorTypeId=' + ColorTypeId + '&Action=Load';
   }

   function EditColorType(ColorTypeId)
   {
   	location.href = 'EditCompanyColorType.asp?ColorTypeId=' + ColorTypeId + '&Action=Load';
   }

   function EditColorTypeValues(ColorTypeId)
   {
   	location.href = 'EditCompanyColorTypeValues.asp?ColorTypeId=' + ColorTypeId + '&Action=Load';
   }

   function DeleteColorType(ColorTypeId)
   {
   	location.href = 'DeleteCompanyColorType.asp?ColorTypeId=' + ColorTypeId;
   }

   function DeleteTypeValue(SizeOrColor, ValueId, TypeId)
   {
      location.href = 'ViewCompany' + SizeOrColor + 'Type.asp?Action=Delete&' + SizeOrColor + 'TypeId=' + TypeId + '&ValueId='+ValueId;
   }

   function MoveUp(SizeOrColor, ValueId, TypeId)
   {
      location.href = 'ViewCompany' + SizeOrColor + 'Type.asp?Action=MoveUp&' + SizeOrColor + 'TypeId=' + TypeId + '&ValueId='+ValueId;
   }

   function EditCompanyProductImages(ProductId)
   {
   	location.href = 'EditCompanyProductImages.asp?CompanyProductId=' + ProductId + '&Action=Load';
   }
   function AddCompanyProductImage(ProductId)
   {
      location.href = 'AddCompanyProductImage.asp?CompanyProductId=' + ProductId + '&Action=Load';
   }

   function GetCompanyProductApproval(ProductId)
   {
      location.href = 'ViewCompanyProduct.asp?CompanyProductId=' + ProductId + '&Action=GetApproval';
   }

	function ViewCustomerDetails()
	{
		location.href = 'ViewCustomerDetails.asp';
	}

	function EditCustomerDetails()
	{
		location.href = 'EditCustomerDetails.asp?Action=Load';
	}

	function EditCustomerPassword()
	{
		location.href = 'EditCustomerPassword.asp';
	}

	function CustomerLogOff()
	{
		location.href = 'CheckCustomerLogin.asp?Action=LogOff';
	}

	function AddToCart(ProductId)
	{
		location.href = 'ViewProduct.asp?ProductId=' + ProductId + '&Action=AddToCart';
	}



	function LoadPreview()
	{
		var List = document.getElementById('ImageList');
		var Found = false;

		for (var i = 0; i < List.options.length; i++)
		{
			if (List.options[i].selected)
			{
				if (!Found)
				{
					document.getElementById('Preview').src = 'Image.asp?s=preview&id=' + List.options[i].value;
					List.form.ImageId.value = List.options[i].value;
					Found = true;
				}
				else
				{
					List.options[i].selected = false;
				}
			}
		}
	}

	function SelectImage()
	{
		if (!window.opener.closed && document.BrowseForm.ImageField.value != "" && document.BrowseForm.ImageId.value != "")
		{		   
			eval('window.opener.SetImage_' + document.BrowseForm.ImageField.value + '(' + document.BrowseForm.ImageId.value + ')');
			window.close();
		}
		else
		{
				alert("Selecteer eerst een afbeelding!");
		}
	}
	
	function DeleteSelectedImage(ProductId)
	{
		if (!window.opener.closed && document.BrowseForm.ImageId.value != "")
		{	
			if (confirm("Weet u zeker dat uw de geselecteerde afbeelding wilt verwijderen?"))	   			
			{
				location.href = 'BrowseCompanyProductImages.asp?CompanyProductId=' + ProductId + '&ImageId=' + document.BrowseForm.ImageId.value + '&Action=Delete';			
			}
		}
		else
		{
				alert("Selecteer eerst een afbeelding!");
		}
	}

	function Cancel()
	{
		window.close();
	}

	function CorrectPrice(Field)
	{
	   Field.value = Field.value.replace(".",",");
	}

	function CheckVersionsAvailableAndAdd(FieldName, SizeField, ColorField, FormName)
	{
         var Versions = document.getElementsByName(FieldName);
	      var VersionExists = false;
	      			
         for (i = 0; i < Versions.length; i++)
         {
	         if (Versions[i].value == SizeField.value + "," + ColorField.value)
	         {
	            VersionExists = true;
	         }
         }
         if (SizeField.value == "")
         {
            alert("Selecteer een maat.");
         }
         else
         {
            if (ColorField.value == "")
            {
               alert("Selecteer een kleur.");
            }
            else
            {
               if (VersionExists)
               {
                  InvokeAction(FormName, "Save");
               }
               else
               {
                  alert("Deze combinatie kleur en maat is momenteel niet beschikbaar. \nVoor meer informatie kunt u contact opnemen met de klantenservice.");
               }
            }
         }
	}

	function ShowProductPrice(FieldId, SizeField, ColorField)
	{
	   var NewPrice;
	   var VersionId;
	   		
		if ((SizeField.value != "") && (ColorField.value != "")){
		   NewPrice = document.getElementById("VersionPrice" + SizeField.value + "" + ColorField.value).value;
		   document.getElementById(FieldId).value = NewPrice;
	
		   VersionId = document.getElementById("ProductVersionId" + SizeField.value + "" + ColorField.value).value;
		   document.getElementById("ProductVersionId").value = VersionId;
		}

	}

	function EmptySearchFieldWarning(SearchField, Form){
	   //alert("'"+document.getElementById(SearchFiedId).value+"'");
	   if (SearchField.value == "")
	   {
	      alert("U moet een zoekterm invullen.");
	   }
	   else
	   {
	      Form.submit();
	   }
	}

	function ConfirmShoppingCart()
	{
	   location.href = 'ViewShoppingCart.asp?Action=Confirm';
	}
	function ConfirmShoppingCartOrder()
	{
		if (document.getElementById('ChkTerms').checked)
		{
			location.href = 'ConfirmShoppingCart.asp?Action=Confirm';
		}
		else
		{
			alert("U moet akkoord gaan met de Algemene Voorwaarden!");
		}
	}

	function EditDeliveryAddress()
	{
	   location.href = 'EditDeliveryAddress.asp?Action=Load';
	}
	function AddDeliveryAddress()
	{
	   location.href = 'AddDeliveryAddress.asp?Action=Load';
	}
	function DeleteDeliveryAddress()
	{
	   location.href = 'ConfirmShoppingCart.asp?Action=DeleteDeliveryAddress';
	}

	function UseGiftCertificate()
	{
	   location.href = 'UseGiftCertificate.asp';
	}
	function RemoveGiftCertificate()
	{
	   location.href = 'ConfirmShoppingCart.asp?Action=RemoveGiftCertificate';
	}

	function DeleteGiftcertificateFromCart(CertificateId)
	{
		location.href = 'OrderOverview.asp?GiftcertificateId=' + CertificateId + '&Action=DeleteCertificate';
	}

	function PayCart()
	{
      location.href = 'OrderOverview.asp?Action=Pay';
   }
   
   function TurnOffFilter(Element)
	{  
	     Element.form.DateFromDay.value = "";
	     Element.form.DateFromMonth.value = "";
	     Element.form.DateFromYear.value = "";
	     
	     Element.form.DateToDay.value = "";
	     Element.form.DateToMonth.value = "";
	     Element.form.DateToYear.value = "";
	     
	     InvokeAction(Element, "TurnOffFilter");
	}