/* show / hide layer */
 function sh(l) { $j('#'+l).css('display')=='none' ? $j('#'+l).css('display','block') : $j('#'+l).css('display','none'); }
 
// pre process
function fc_PreProcess() 
{
  // test required fields
  if( arguments.length == 2 )
  {
       if( $j( ("#"+arguments[1]+"_reward") ) != null && $j( ("#"+arguments[1]+"_reward") ).val() == "" ) { alert("Please select a reward for your purchase."); $j( ("#"+arguments[1]+"_reward") ).focus(); return false; }       
       if( $j( ("#"+arguments[1]+"_recipient") ).val() == "" ) { alert("Please enter a recipient."); $j( ("#"+arguments[1]+"_recipient") ).focus(); return false; }
  } // end argument check

  // return true on all else 
  return true;
} // end fc_PreProcess

/*
* fc_json.products[i].name,fc_json.products[i].code,fc_json.products[i].options,fc_json.products[i].quantity,fc_json.products[i].price_each,fc_json.products[i].price
*/
function fc_BuildFoxyCart() 
{
  fc_FoxyCart = '';
  fc_FoxyCart += '<p>you have <strong>'+fc_json.products.length+'</strong> items in your cart</p>';
  var plan_suffix = '';
  if( fc_json.products.length > 0 )
  {
    fc_FoxyCart += '<p class="products">';
    for( var i=0; i<fc_json.products.length;i++ )
    {
      
       if( fc_json.products[i].code.indexOf('_plan') > -1 ) { plan_suffix = '/month'; } else { plan_suffix = ''; }
       fc_FoxyCart += fc_json.products[i].name + ' <br/>........ <strong>' + fc_json.products[i].quantity + 'x$' + fc_json.products[i].price.toFixed(2) + plan_suffix + '</strong><br/>';
    }
    fc_FoxyCart += '</p>';
        // show links
        $j('#fc_cart_links').css('display','inline');
        $j('#fc_cart_default_text').css('display','none');
        /*
        $j("#fc_empty").css("display","inline");
        $j("#fc_checkout").css("display","inline");
      */    
  }
  else
  {
        // hide links
        $j('#fc_cart_links').css('display','none');
        $j('#fc_cart_default_text').css('display','inline');
        /*
        $j("#fc_empty").css("display","none");
        $j("#fc_checkout").css("display","none");
      */
  }
  
      $j("#fc_cart").html(fc_FoxyCart);
  
} // end fc_BuildFoxyCart


/* receipt download page */
function doDownload(order_id)
{
   // gift download popup link
   var has_gift = false; 
   // var url = 'http://dev.renewablechoice.net/download-pdf-gift.html?order_id='+order_id;
   for(var i=0; i < fc_json.products.length; i++)
   {
     if( fc_json.products[i].options['recipient'] != null && fc_json.products[i].options['recipient'] != undefined )
     {
       has_gift = true;
       break;
     }
   }
   if(has_gift)
   {
     document.getElementById('download_container').style.display = 'block';
     /*
     document.getElementById('download_link').setAttribute('href','javascript:;');
     document.getElementById('download_link').onclick = function() {
       window2 = window.open(url,'downloadPop','top=50,left=50,width=500,height=500,scrollbars=true');
       window2.focus();
     }
     */
   }
} // end doDownload