function showElement(el) {
	$(el).setStyle({
		visibility: 'visible'
	});
	
}

function hideElement(el) {
	$(el).setStyle({
		visibility:'hidden'
	})
}

function delitem(itemid) {
	document.forms['del'].delid.value=itemid;
	document.forms['del'].submit();
}

function carter(){
 document.reload.submit();
}

function showCart(){

 rn=Math.floor(Math.random()*1001);

 Dialog.alert({url: "/index.php?id=104&rn="+rn, options: {method: 'get'}},  
               {className: "alphacube", width:400, okLabel: "Continue...", ok:function(win) {carter(); return true;}, showEffectOptions: {duration: 0.2}, hideEffectOptions: {duration: 0.2}});
}

function showFBCart(){

 rn=Math.floor(Math.random()*1001);

 Dialog.alert({url: "/index.php?id=207&rn="+rn, options: {method: 'get'}},  
               {className: "alphacube", width:400, okLabel: "Continue...", ok:function(win) {carter(); return true;}, showEffectOptions: {duration: 0.2}, hideEffectOptions: {duration: 0.2}});
}

function addCart(item, ed, src){
 rn=Math.floor(Math.random()*1001);

 if(ed){
  Dialog.alert({url: "/index.php?id=104&p="+item+"&ed="+ed+"&rn="+rn+"&src="+src, options: {method: 'get'}},  
               {className: "alphacube", width:400, okLabel: "Continue...", ok:function(win) {carter(); return true;},
                showEffectOptions: {duration: 0.2}, hideEffectOptions: {duration: 0.2}});
 }else{
  alert('ERROR adding this book to the shopping cart. Please contact IAP.');
 }

}

function updateCart(){
 document.getElementById('cb').value='Working...';
 document.getElementById('cb').disabled=true;
 rn=Math.floor(Math.random()*1001);
 url = '/index.php?id=106&rn='+rn;
 new Ajax.Request(url, { 
  parameters: $('uc').serialize(true),
  onSuccess: function(response){
   document.getElementById('cart-contents').innerHTML=response.responseText;
   document.getElementById('cb').value='Update';
   document.getElementById('cb').disabled=false;
  },
  onFailure: function(){
   alert('Error updating cart...')
  }
 }
 );
}

var page=1;

function leftClick(){
 if(page>=1 && page<3){
  new Effect.Move('scrollinner', { x: -700, y: 0, mode: 'relative' });
  page=page+1;
  setArrows();
 }
}

function rightClick(){
 if(page>1 && page<=3){
  new Effect.Move('scrollinner', { x: 700, y: 0, mode: 'relative' });
  page=page-1;
  setArrows();
 }
}

function setArrows(){
 li='/assets/images/l-arrow-off.gif';
 ri='/assets/images/r-arrow-off.gif';
 if(page>=1 && page<3){ li='/assets/images/l-arrow.gif'; }
 if(page>1 && page<=3){ ri='/assets/images/r-arrow.gif'; }
 document.lr.src=li;
 document.rr.src=ri;
}

function autoScroll(){
 if(page<3){
  leftClick();
  setTimeout('autoScroll()',10000);
 }
}






function showBox(act, prod){
 rn=Math.floor(Math.random()*1001);
 Dialog.alert({url: "/index.php?id=126&a="+act+"&p="+prod+"&rn="+rn, options: {method: 'get'}},  
               {className: "alphacube", width:350, okLabel: "Cancel", ok:function(win) {return true;}, showEffectOptions: {duration: 0.2}, hideEffectOptions: {duration: 0.2}});
}


function checkReadTerms() { 
   if (document.getElementById('readTerms').checked) // some logic to determine if it is ok to go
    {document.getElementById('paynow').disabled = false;}
  else // in case it was enabled and the user changed their mind
    {document.getElementById('paynow').disabled = true;} 
}


