
$(document).ready(function() {


	// hide eflyer loading animation
	
	jQuery("#eflyer-loading").hide();
	
	// form submitting
	
	jQuery('.button-eflyer').click(function(e) {
		e.preventDefault(); // stop the link from working
		jQuery("#eflyer-form").submit();
		jQuery("#eflyer-loading").fadeIn('slow');
	return false;
	});
	
	// eflyer callback
	
	jQuery('#eflyer-form').ajaxForm(function(data) { 
	
		if (data==1){ 
			jqalert('Cool. You are now signed up to receive our weekly listings email.<br />Please check your email to confirm your subscription!');
			jQuery("#eflyer-loading").hide();
		} 
		else if (data==2){ 
			jqalert('Sorry, there was a problem. Perhaps you are signed up already?');
			jQuery("#eflyer-loading").hide();
		}
		else if (data==3){ 
			jqalert('Hey now, you have to type your email address in the box if you want to signup!');
			jQuery("#eflyer-loading").hide();
		}
	
	});
	
});

function nextPage()
{

	for (var i=0; i < document.gifted.type.length; i++)
   {
   if (document.gifted.type[i].checked)
      {
      var rad_val = document.gifted.type[i].value;
      }
   }
  
  
  document.location='/fabricfirst/gift/purchase/'+rad_val;
}




function ajaxSearch(text)
{

	if(text.length>3)
	{

			$.ajax({
  url: '/search/bar/'+text,
  success: function(data) {
    $('#search-results').html(data);

  }
}
)
}
else
{

	clearSearch();
}


}


function clearSearch()
{
	document.getElementById('search-results').innerHTML='';
}


		function submitSearch()
			{
			
					window.location="http://www.google.com/cse?sa=Search&siteurl=www.google.com/cse/home%253Fcx%253D011749711161905352126:edyydtlndqc&cx=011749711161905352126:edyydtlndqc&q="+document.getElementById('search').value;
			}
			
			
			
function scollNewsLeft()
{

	if(currentPosition==0)
	{
		return;
	}
  $('#slidery').animate({
   
    left: '+=864',

  }, 2000, function() {
    // Animation complete.
  });
  
  
  currentPosition--;
}


function scrollNewsRight()
{

	if(currentPosition==maxSlides)
	{
		return;
	}
	

  $('#slidery').animate({
   
    left: '-=864',

  }, 2000, function() {
    // Animation complete.
  });


	currentPosition++;


}

function newWindow(url)
{
	window.open(url);
}
function openUrl(url)
{
	document.location=url;
}
