// JavaScript Document

function shoppingCartCheckOut()
{
	if(location.href.indexOf("valkenstore.com/Shopping-Cart_3") != -1)
	{
		if(document.getElementById('checkout') != null)
		{
			document.getElementById('checkout').style.color="#FFFFFF";
			document.getElementById('checkout').style.background="#009800";
		}
	}
}
	
function hideTab(category)
{
	if (location.href.indexOf("checkout.netsuite.com/app/center/nlvisitor.nl") != -1)
	{
		//alert(category);
		if(category == "Retail")
		{
			var tdElement = document.getElementById('tllistcol_-47_-519_3');
			if(tdElement != null)
			{
				tdElement.style.display = 'none';
			}
		}
	}
}	

function newCustomer()
{
	if(location.href.indexOf('checkout.netsuite.com/s.nl') != -1)
	{
		//alert('checkout.sandbox.netsuite.com');
		if(document.getElementById('newcust') != null && document.newcust.submitter != null)
		{
			//alert('registration form');
			var customerForm = document.getElementById('newcust');
			//alert('attaching onsubmit event');				
			document.newcust.submitter.onclick = function(){
				if(document.forms['newcust'].elements['custentity_interested_in_mma_fs_inp'].checked || document.forms['newcust'].elements['custentity_interested_in_paintball_fs_inp'].checked || document.forms['newcust'].elements['custentityinterested_in_racing_fs_inp'].checked || document.forms['newcust'].elements['custentity_interested_in_hockey_fs_inp'].checked){
					document.forms['newcust'].elements['new'].value='T';
					if(document.forms['newcust'].confirmSpinLock.value == 1 && checkmandatoryfields()) { 
						document.forms['newcust'].confirmSpinLock.value = 0;
						document.forms['newcust'].submit(); 
					}
					return false;return false;
				} else{
					alert('PLEASE SELECT A SPORT YOU ARE INTERESTED IN');
					return false;
				}
			}
		}
	}
}
	
function couponRemoveRetail()
{
	if (location.href.indexOf("checkout.netsuite.com/s.nl") != -1)
	{
		if(document.getElementById('change') == null)
		{
			if(document.getElementById('applycoupon') != null)
			{
				var td = document.getElementById('applycoupon').parentNode;
				//alert(td.innerHTML);
				var tr = td.parentNode;
				//alert(tr.innerHTML);
				var tbody = tr.parentNode;
				//alert(tbody.innerHTML);
				var tabl = tbody.parentNode;
				//alert(tabl.innerHTML);
				td = tabl.parentNode;
				//alert(td.innerHTML);
				tr = td.parentNode;
				//alert(tr.innerHTML);
				tbody = tr.parentNode;
				//alert(tbody.innerHTML);
				tabl = tbody.parentNode;
				//alert(tabl.innerHTML);
				tabl.style.display = 'none';
			}
		}
	}
}
	
/*Adding Residential option to webstore so that customers can specity if the newly added or edited address is residential address or not*/
function addResidential()
{
	if(location.href.indexOf("checkout.netsuite.com/s.nl") != -1 || location.href.indexOf("checkout.netsuite.com/app") != -1)
	{
		if(document.getElementById('main_form') != null)
		{
			if(document.getElementById('defaultbilling_fs_inp') != null)
			{
				//alert('address form');
				if(document.getElementById('isresidential') != null)
				{
					//alert('Removing Residential Ele');
					var rEle = document.getElementById('isresidential');
					var rForm = document.getElementById('main_form');
					rForm.removeChild(rEle);
					//alert('Adding Residential Ele');
					var rTbody = (((document.getElementById('defaultbilling_fs_inp').parentNode).parentNode).parentNode).parentNode;
					//alert(rTbody.innerHTML);
					var rTr = document.createElement('tr');
					var rTd1 = document.createElement('td');
					var rTd2 = document.createElement('td');					
					
					rTd1.setAttribute('align', 'right');
					rTd2.setAttribute('class', 'smalltextnolink');
					
					rTd1.innerHTML = '<span id="isresidential_fs" class="checkbox_unck" style="white-space: nowrap"><input id="isresidential" name="isresidential" value="T" checked="checked" class="checkbox" type="checkbox"><img class="checkboximage" src="/images/nav/ns_x.gif"></img></span>';
					rTd2.innerHTML = '<span id="isresidential_fs_lbl" style="white-space: wrap;" class="checkboxSpan smalltextnolink"><A class="smalltextnolink">This address is residential address</A></span>';
					
					rTr.appendChild(rTd1);
					rTr.appendChild(rTd2);
					rTbody.appendChild(rTr);
					
					rTr.style.display = 'none';
				}
			}
		}
	}
}
