// code once dom has loaded (so all html/content, not images )
var ieCC = "dummy=" + new Date().getTime();

function disableActions() {
    var links = document.getElementsByTagName("a");
    var curID;
    for (i=0; i < links.length; i++){
       	var link = links[i];
        
        if($(link).hasClassName("ajax")){
				// disable all links marked for ajax interaction...
				link.onclick = function() {return false;}
				link.href = " ";
	    		curID = link.id;

		        if($(link).hasClassName("funcBasketAdd")){
					$(link).observe('click', function(event){
						alert(curID);
									 BasketAdd(curID);
	 								});
				}
		        if($(link).hasClassName("funcBasketPlus")){
					$(link).observe('click',function(event){
									  BasketPlus(curID);
	 								});
				}
	
		        if($(link).hasClassName("funcBasketMinus")){
					$(link).observe('click',function(event){
									BasketMinus(curID);
	 								});
				}
	
		        if($(link).hasClassName("funcBasketRemove")){
					$(link).observe('click',function(event){
									 BasketRemove(curID);
	 								});
				}

		}
    }
}
// could have put these on the observe functions really....but might need them else where on page 
 function BasketAdd(prodID){
 		new Ajax.Updater("basket_inner" ,'includes/basket/basket.php?' + ieCC, {
	  		method: 'post',
	 		parameters: {ajax : "yes", bask_mode: "add_prod", bask_prodid: prodID}
		}); 
			//showBasket();
 }
 function BasketPlus(prodID){
 		new Ajax.Updater("basket_inner" ,'includes/basket/basket.php?' + ieCC, {
	  		method: 'post',
	 		parameters: {ajax : "yes", bask_mode: "qadd", bask_prodid: prodID}
		});
		//	showBasket();
		//disableActions();
 }
 function BasketMinus(prodID){
 	 	new Ajax.Updater("basket_inner" ,'includes/basket/basket.php?' + ieCC, {
	  		method: 'post',
	 		parameters: {ajax : "yes", bask_mode: "qminus", bask_prodid: prodID}
		});
		//	showBasket();
 } 
 function BasketRemove(prodID){
  		new Ajax.Updater("basket_inner" ,'includes/basket/basket.php?' + ieCC, {
	  		method: 'post',
	 		parameters: {ajax : "yes", bask_mode: "remove", bask_prodid: prodID}
		});
		//	showBasket();
 }
 function showBasket(){
 //alert("show ran ");
 	 	new Ajax.Updater("basket_inner" ,'includes/basket/basket.php?' + ieCC, {
	  		method: 'post',
	 		parameters: {ajax : "yes", bask_mode: "show"}
		});
		
 }
 
 /// ok all done lets start the page!
document.observe("dom:loaded", function() {
	// this is dont to initialise the ajax links, if it is available
	showBasket();
	//disableActions();
});
