(function($){

var glr = {
  
    ondomready: function() {
        glr.links();
		//glr.paypal();
		glr.donate();
        glr.billing();
		//$('#content blockquote').children(":first").addClass("reviewBook");
        //$("hr").replaceWith('<div class="hr"></div>'); 
    },
	
    paypal: function(){ 
	    $("#PPAL_OSEL").hide();
	},
	
    billing: function(){ 
	    $("#billingsame").click(function() {
				//if ($('#billgsame:checked')) {
					$('#Customer_BillFirstName').val($('#Customer_ShipFirstName').val());
					$('#Customer_BillLastName').val($('#Customer_ShipLastName').val());
					$('#Customer_BillEmail').val($('#Customer_ShipEmail').val());
					$('#Customer_BillPhone').val($('#Customer_ShipPhone').val());
					$('#Customer_BillCompany').val($('#Customer_ShipCompany').val());
					$('#Customer_BillAddress').val($('#Customer_ShipAddress').val());
					$('#Customer_BillCity').val($('#Customer_ShipCity').val());
					//$('#Customer_BillStateSelect').val($('#Customer_ShipStateSelect').val());
					$('#Customer_BillState').val($('#Customer_ShipState').val());
					$('#Customer_BillZip').val($('#Customer_ShipZip').val());
					//$('#Customer_BillCountry').val($('#Customer_ShipCountry').val());
                    $('[@name=Customer_BillCountry]').val($('[@name=Customer_ShipCountry]').val());
					$('[@name=Customer_BillStateSelect]').val($('[@name=Customer_ShipStateSelect]').val());
					
				//}
			return false;
        });
	},	
	
	donate: function(){
		$(".donate").click(function() {
			var donation = $('[@name=donate_amount]').val() 
			window.location = "http://store.glreview.com/merchant2/merchant.mvc?Screen=BASK&Store_Code=GLRWOS&Action=ADPR&Product_Code=DONATION&Attributes=Yes&Quantity=" + donation;								
			return false;						
	    });
	},
	
    links: function(){ 
      $("a").each(function(x,link){
         if (link.className.indexOf("new_window") > -1 ) {
           $(link).click(function(){
              // prevent doubleclicking
              $(link).removeClass("clicking")
              $(link).addClass("clicking");
              glr.new_window(link);
              $(link).removeClass("clicking");
              return false;
          });
       }
     })

    },
	
    new_window: function(link) {
      var url = link.href || link;
      var nw = window.open(url, "newwin", 'width=890,height=700,directories=yes,toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes');
      if (nw) {nw.focus();}
    },
	
    last:''
   
}

window.glr = glr;

$(document).ready(function(){glr.ondomready();});

})(jQuery);

