// JavaScript Document

function changeVals() {
	perPage = $("#perPage").val();
	$.ajax({
		method: "get",url: "php/change_perPage.php",data: "perPage="+perPage,
		success: function(html) {
			$("#List").html(html);
		}
	});
	
}

function gotopage(pageNumber) {
	$.ajax({
		method: "get",url: "php/goto_page.php",data: "start="+pageNumber,
		success: function(html) {
			$("#List").html(html);
		}
	});
}

function deleteArticle(a_id) {
	var c = confirm("Are you sure you want to delete this News Article?");
	if(c) {
		$.ajax({
			method: "get",url: "php/news-delete.php",data: "a_id="+a_id,
			success: function(html) {
				window.location = "./news.php"
	 		}
 		});
	}
}
$(document).ready(function(){
	
	var request=$("#request").val(),category=$("#category").val(),perPage=$("#perPage").val(),searchTerm
	var defaultSearchTerms = new Array("Search","Search Rotocraft","");
	
	$(".select").change(changeVals);
	
	
	$("a.atq").click( function() {
		//window.open( $(this).attr('href') );
		p_id = $(this).attr('rel') ;
		$.ajax({
			method: "get",url: "php/quote_addproduct.php",data: "p_id="+p_id,
			success: function(html) {
				$("#cart").html(html);
				$(name).animate({top:offset},{duration:1000,queue:false},{easing: "def"});
	 		}
 		});
	});
	
	$("a.removeProduct").click( function() {
		// id is U_Cart ID
		id = $(this).attr('rel') ;
		var d = $(this);
		$.ajax({
			method: "get",url: "php/quote_removeproduct.php",data: "id="+id,
			success: function(html) {
				d.parent().parent().hide("fast");
				$("#productCount").html(html);
				//$(name).animate({top:offset},{duration:1000,queue:false},{easing: "def"});
	 		}
 		});
	});
	
	// javascript helpers
	function qualifiedSearch(term)
	{
		for(var i=0;i<defaultSearchTerms.length;i++)
		{
			if(term == defaultSearchTerms[i]) 
			return false;
		}
  		return true;
	}
	
});
