
$(document).ready(function(){

	 $("a.zoom1").fancybox({
	 'overlayOpacity' : 0.7,
	 'overlayColor' : '#FFF'
	 }); 

	var letterValue = getUrlVars()["Letter"];
	if  (letterValue == undefined)
	{
		$("div[id='linkLetterList']").css("display", "none");
	}
	else
	{
	$("div[id='linkLetterList']").css("display", "block");
	}
	

   $(".atoz").click(function ()
   {
   
   if  ($("div[id='linkLetterList']").css("display") == "none")
   {
   $("div[id='linkLetterList']").fadeIn("slow");
   }
   else
   {
   $("div[id='linkLetterList']").fadeOut("slow");
   }
   });

   function getUrlVars()
   {
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
    }

});

function alertselected(numberOfItems){
        if (numberOfItems.value == "artists")
        {
        window.location = "gallery_artists.aspx"
        }
        if (numberOfItems.value == "books")
        {
        window.location = "gallery_books.aspx"
        }
    }

    function alertselectedAristSort(numberOfItems) {

         var artistID = getParameterByName("aId");

        if (numberOfItems.value == "0") {
            window.location = "artist.aspx?aId="+ artistID +"&sortby=0"
        }
        if (numberOfItems.value == "1") {
            window.location = "artist.aspx?aId="+ artistID +"&sortby=1"
        }
        if (numberOfItems.value == "2") {
            window.location = "artist.aspx?aId="+ artistID +"&sortby=2"
        }
    }

    function getParameterByName(name) {
        name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
        var regexS = "[\\?&]" + name + "=([^&#]*)";
        var regex = new RegExp(regexS);
        var results = regex.exec(window.location.href);
        if (results == null)
            return "";
        else
            return results[1];
    }


function updateBasket(numberOfItems){
      
       completeURL = "mycollection.aspx?qryChange=1&";
       errorFound = "false";
       
       for(var i = 0; i < numberOfItems; i++) 
       {
            if (parseInt($("input[id='" +i+ "']").val()))
            {
            
                inputVal = parseInt($("input[id='" +i+ "']").val());
                qtyVal = parseInt($("input[id='iquantity" +i+ "']").val());
                
                if (!(parseInt($("input[id='" +i+ "']").val()) > parseInt($("input[id='iquantity" +i+ "']").val())))
                {
                        completeURL = completeURL + "itemID" +  $("input[id='" +i+ "']").attr("name") + "=" +  $("input[id='" +i+ "']").val() + "&" ;
                 }
                else
                {
                alert("The number of book items requested is currently greater than the number of items in stock which is "+ qtyVal +". Please revise your order" );
                 }
                }

                                  else
                 {
                 errorFound = "true";
                 alert("You have entered an incorrect quantity value, please enter only numeric values");
                 }
       }
       
       if (errorFound = "false")
       {
       window.location = completeURL;
       }
       else (errorFound = "true")
       {
              completeURL = "mycollection.aspx?qryChange=0";
       window.location = completeURL;
       }
}


   

  