// Remove Paypal and divider
var buttons = document.getElementById('thirdPartyCheckoutButtonsTable');

if (buttons){
	if (buttons.childNodes.length > 0) {
		child= buttons.firstChild;
	}
	
	while(child) {
		if (child.childNodes.length > 0) {
			var grandchild = child.firstChild;
			var s;
			
			while (grandchild) {
				s = grandchild.innerHTML;
				if (s) {
					if (s.indexOf("paypal") != -1){
						if (grandchild.childNodes.length > 0) {            		
							var columns = grandchild.firstChild;
							while (columns) {
								s = columns.innerHTML;
								if (s) {
									if (s.indexOf("ws-button-divider") != -1 || s.indexOf("paypal") != -1){
										columns.innerHTML = "";
									}
								}
								columns=columns.nextSibling;
							}
						}
					}
				}
				grandchild = grandchild.nextSibling;
			}
		}
		child = child.nextSibling;
	}
}


// Remove Second buried PayPal
var t;
var tables = document.getElementsByTagName('table');
for(t in tables){
	var s=tables[t].innerHTML;
	if (s){
		if (s.indexOf("<table") == -1 && s.indexOf("Fast, Secure Checkout with PayPal") != -1){
			// we are at the innermost table and it has PayPal
			//alert(tables[t].innerHTML);
			tables[t].innerHTML="<tr><td></td></tr>"
		}
	}
}



// Remove new PayPal in payment options
$(function(){
    var $partner = $("img[src*='paypal.com']");
    if ($partner.length) {
        $partner.closest('td').hide();
    }
})

$(function(){
    var $partner = $("input[name='sPayMeth'][value='7']");
    var $string = $("input[name='sPayMeth'][value='7']").closest('tr').html();
	if($string)
	{
		if($string.indexOf('PayPal') != -1)
		{
			if ($partner.length) {
				$partner.closest('tr').hide();
			}
		}
	}
})
