	function InvokeAction(A)
	{
		document.forms[2].action += A;
		document.forms[2].submit();
	}
	
	function InvokeIdAction(Formid , A) {
		document.getElementById(Formid).action += A;
		document.getElementById(Formid).submit();
	}

	function DecreaseQuantity(Formid, Seqno)
	{
	    document.forms[Formid]['Quantity_' + Seqno].value = parseInt(document.forms[Formid]['Quantity_' + Seqno].value) - 1;

		var re = new RegExp(/^[0-9]+$/);
		if (document.forms[Formid]['Quantity_' + Seqno].value < 1 || !re.test(document.forms[Formid]['Quantity_' + Seqno].value))
		{
		    document.forms[Formid]['Quantity_' + Seqno].value = 1;
		}
	}

	function IncreaseQuantity(Formid, Seqno)
	{
	    document.forms[Formid]['Quantity_' + Seqno].value = parseInt(document.forms[Formid]['Quantity_' + Seqno].value) + 1;

		var re = new RegExp(/^[0-9]+$/);
		if (document.forms[Formid]['Quantity_' + Seqno].value < 1 || !re.test(document.forms[Formid]['Quantity_' + Seqno].value))
		{
		    document.forms[Formid]['Quantity_' + Seqno].value = 1;
		}
	}

	function CartAddPhoto(PhotoId)
	{
		location.href = 'ViewPhoto.asp?Action=Add&PhotoId=' + PhotoId;
	}

	function CartRemoveItem(i)
	{
		if (confirm('Are you sure you want to remove this photo from your lightbox?'))
		{
			InvokeAction('Delete&Seqno=' + i);
		}
	}

	function CartRemoveBook(Formid, i) {
	    if (confirm('Are you sure you want to remove this product?')) {
	        InvokeIdAction(Formid, 'Delete&Seqno=' + i);
	    }
	}

	function ViewCart()
	{
		location.href = 'Lightbox.asp';
	}

	function OrderForm()
	{
		location.href = 'OrderForm.asp';
	}

	function EditCustomer()
	{
		location.href = 'EditCustomer.asp';
	}

	function ViewCustomer()
	{
		location.href = 'ViewCustomer.asp';
	}

	function Register()
	{
		location.href = 'Register.asp';
	}

	function SetPassword()
	{
		location.href = 'SetPassword.asp';
	}
	
	function ViewGallery(GalleryId)
	{
		location.href = 'ViewGallery.asp?GalleryId=' + GalleryId;
	}
	
	function ViewLightbox(LightboxId)
	{
		location.href = 'Lightbox.asp?LightboxId=' + LightboxId;
	}
	
	function NewLightbox()
	{
		location.href = 'Lightbox.asp?Action=NewLightbox';
	}

	function RemoveLightbox(LightboxId)
	{
		if (confirm('Are you sure you want to remove this lightbox?'))
		{
			location.href = 'Lightbox.asp?Action=Remove&LightboxId=' + LightboxId;
		}
	}
		
	function SubmitQuery()
	{
		var Query = document.getElementById('Query').value;

		if (Query.length > 0)
		{
			location.href = 'SearchResults.asp?Query=' + Query;
		}
		else
		{
			return false;
		}
    }

    function startDropItem(elementId) {
        if (document.getElementById(elementId).style.display == 'none') {
            document.getElementById(elementId).style.display = 'block';
            if (document.getElementById(elementId + '-preview') != null)
                document.getElementById(elementId + '-preview').style.display = 'none';
        }
        else {
            document.getElementById(elementId).style.display = 'none';
            if (document.getElementById(elementId + '-preview') != null)
                document.getElementById(elementId + '-preview').style.display = 'block';
        }
    }

    function CartAddProductDirectly(ProductId) {
        //InvokeAction('AddDirectly&ProductId=' + ProductId);
        location.href = 'ViewBooks.asp?Action=AddDirectly&ProductId=' + ProductId;
    }

    function FilterBooks(productGroupId, priceRange) {
        var CurrProductGroupId;
        var CurrPriceRange;

        jQuery('.priceFilter').each(function () {
            jQuery(this).removeClass('active');
        });
        if (productGroupId != '') {
            CurrProductGroupId = productGroupId;
        }
        if (priceRange != '') {
            CurrPriceRange = priceRange;
        }
        if (CurrPriceRange != '') {
            jQuery('#priceFilter_' + CurrPriceRange).addClass('active');
        }
        if (priceRange == 'clear') { CurrPriceRange = 'clear'; }

        document.getElementById('OutputBooks').innerHTML = '<img src="Images/ajax-loader.gif" alt="loader" />';
        jQuery("#" + 'OutputBooks').load("Includes/Ajax/Books.asp?GroupId=" + CurrProductGroupId + '&priceRange=' + CurrPriceRange);
    }
