/*******************************
/**  CLIENT SCRIPTS FOR ESHOP **
*******************************/



function WarehouseChange(dropdown)
{
    var myindex  = dropdown.selectedIndex
    var SelValue = dropdown.options[myindex].value
    
    if ( SelValue = 0 )
    {
		document.getElementById('YourPriceLabel').value = "Your Price:";
    }
    else
	{
		document.getElementById('YourPriceLabel').value = "Warehouse Price:";
	}
                
    return true;
}


function PopupLogin()
{
			if ( (event.which && event.which == 13) || (event.keyCode && event.keyCode == 13) ) 
			{
				event.cancelBubble = true;
				event.returnValue = false;
				
				document.loginform.submit();
				
			}
			else
			{
				return true;
			}

}

function PopupTrackOrder()
{
			if ( (event.which && event.which == 13) || (event.keyCode && event.keyCode == 13) )
			{
				event.cancelBubble = true;
				event.returnValue = false;
				
				document.trackorderform.submit();
			}
			else
			{
				return true;
			}
}

function PopupTrackOrder2()
{
			if ( (event.which && event.which == 13) || (event.keyCode && event.keyCode == 13) )
			{
				event.cancelBubble = true;
				event.returnValue = false;
				
				document.trackorderform2.submit();
			}
			else
			{
				return true;
			}
}

function CheckoutLogin()
		{
			if ( (event.which && event.which == 13) || (event.keyCode && event.keyCode == 13) ) 
			{
				event.cancelBubble = true;
				event.returnValue = false;
				
				document.CheckOut.LoginButton.click();
				
			}
			else
			{
				return true;
			}
		
		}
		
		
function SendPassClick()
		{
			if ( (event.which && event.which == 13) || (event.keyCode && event.keyCode == 13) ) 
			{
				event.cancelBubble = true;
				event.returnValue = false;
				
				document.forms[0].ForgotButton.click();
				
			}
			else
			{
				return true;
			}
		
		}
		

function ShipCalcClick()
		{
			if ( (event.which && event.which == 13) || (event.keyCode && event.keyCode == 13) ) 
			{
				event.cancelBubble = true;
				event.returnValue = false;
				
				document.Form1.scalc_RatesButton2.click();
				
			}
			else
			{
				return true;
			}
		
		}
		
		
		function Retry1Click()
		{
			if ( (event.which && event.which == 13) || (event.keyCode && event.keyCode == 13) ) 
			{
				event.cancelBubble = true;
				event.returnValue = false;
				
				document.SearchForm.RetryButton.click();
				
			}
			else
			{
				return true;
			}
		
		}
		
		function Retry2Click()
		{
			if ( (event.which && event.which == 13) || (event.keyCode && event.keyCode == 13) ) 
			{
				event.cancelBubble = true;
				event.returnValue = false;
				
				document.SearchForm.RetryButton2.click();
				
			}
			else
			{
				return true;
			}
		
		}

function ShowCurrent2()
{
	var pos = document.ManageSideForm.LinkTypeList[0].checked;
	
	if ( pos )
	{
			// Microsoft Internet Explorer
			if (document.all)
			{
				document.all.ManualLinkDiv.style.visibility="visible";
				document.all.ProductLinkDiv.style.visibility="hidden";
			}
			// Netscape Navigator
			else
			{
				document.ManualLinkDiv.visibility="visible";
				document.ProductLinkDiv.visibility="hide";
			}
	}
	else
	{
			// Microsoft Internet Explorer
			if (document.all)
			{
				document.all.ProductLinkDiv.style.visibility="visible";
				document.all.ManualLinkDiv.style.visibility="hidden";
			}
			// Netscape Navigator
			else
			{
				document.ProductLinkDiv.visibility="visible";
				document.ManualLinkDiv.visibility="hide";				
			}
	}

}

function ShowCert()
{
	var pos = document.CheckOut.PaymentTypeList[4].checked;
	
	if ( pos )
	{
			// Microsoft Internet Explorer
			if (document.all)
			{
				document.all.GiftCertDiv.style.visibility="visible";
				
			}
			// Netscape Navigator
			else
			{
				document.GiftCertDiv.visibility="visible";
				
			}
	}
	else
	{
			// Microsoft Internet Explorer
			if (document.all)
			{
				document.all.GiftCertDiv.style.visibility="hidden";
				
			}
			// Netscape Navigator
			else
			{
				document.GiftCertDiv.visibility="hidden";
				
			}
	}

}

function ShowCertAlt()
{
	var pos = document.AltAddr.PaymentTypeList[4].checked;
	
	if ( pos )
	{
			// Microsoft Internet Explorer
			if (document.all)
			{
				document.all.GiftCertDiv.style.visibility="visible";
				
			}
			// Netscape Navigator
			else
			{
				document.GiftCertDiv.visibility="visible";
				
			}
	}
	else
	{
			// Microsoft Internet Explorer
			if (document.all)
			{
				document.all.GiftCertDiv.style.visibility="hidden";
				
			}
			// Netscape Navigator
			else
			{
				document.GiftCertDiv.visibility="hidden";
				
			}
	}

}



function ShowCountyG()
{
	
	var pos;
	
	var amt = document.gcheckoutform.State.options.length;
	var curropt;
			
	var x = 0;
	
	while ( x < amt )
	{
		curropt = document.gcheckoutform.State.options[document.gcheckoutform.State.selectedIndex].value;
			
		if ( curropt == 'NY')
		{// Microsoft Internet Explorer
			if (document.all)
			{
						
				document.all.CountyDiv.style.visibility="visible";
				
				break;
				
			}
			// Netscape Navigator
			else
			{
				document.CountyDiv.visibility="visible";
				break;
			}
		}
		else
		{
			// Microsoft Internet Explorer
			if (document.all)
			{
				document.all.CountyDiv.style.visibility="hidden";
				
			}
			// Netscape Navigator
			else
			{
				document.CountyDiv.visibility="hidden";				
			}
			
		}	
		x++;
				
	} 
	
}


function ShowCounty()
{
	//alert('in here');
	var pos;
	
	var amt = document.CheckOut.State.options.length;
	var curropt;
			
	var x = 0;
	
	while ( x < amt )
	{
		curropt = document.CheckOut.State.options[document.CheckOut.State.selectedIndex].value;
		//alert('in here2');
			
		if ( curropt == 'NY')
		{// Microsoft Internet Explorer
			if (document.all)
			{
						
				document.all.CountyDiv.style.visibility="visible";
				//alert('in here3');
				
				break;
				
			}
			// Netscape Navigator
			else
			{
				document.CountyDiv.visibility="visible";
				//alert('in here4');
				break;
			}
		}
		else
		{
			// Microsoft Internet Explorer
			if (document.all)
			{
				document.all.CountyDiv.style.visibility="hidden";
				
			}
			// Netscape Navigator
			else
			{
				document.CountyDiv.visibility="hidden";
				
			}
		}	
		x++;
				
	} 
	
}

function ShowAuthCounty()
{
	
	var pos;
	
	var amt = document.AuthForm.State.options.length;
	var curropt;
			
	var x = 0;
	
	while ( x < amt )
	{
		curropt = document.AuthForm.State.options[document.AuthForm.State.selectedIndex].value;
			
		if ( curropt == 'NY')
		{// Microsoft Internet Explorer
			if (document.all)
			{
						
				document.all.CountyDiv.style.visibility="visible";
				
				break;
				
			}
			// Netscape Navigator
			else
			{
				document.CountyDiv.visibility="visible";
				break;
			}
		}
		else
		{
			// Microsoft Internet Explorer
			if (document.all)
			{
				document.all.CountyDiv.style.visibility="hidden";
				
			}
			// Netscape Navigator
			else
			{
				document.CountyDiv.visibility="hidden";
				
			}
		}	
		x++;
				
	} 
	
}

function ShowsAuthCounty()
{
	
	var pos;
	
	var amt = document.AuthForm.sState.options.length;
	var curropt;
			
	var x = 0;
	
	while ( x < amt )
	{
		curropt = document.AuthForm.sState.options[document.AuthForm.sState.selectedIndex].value;
			
		if ( curropt == 'NY')
		{// Microsoft Internet Explorer
			if (document.all)
			{
						
				document.all.sCountyDiv.style.visibility="visible";
				
				break;
				
			}
			// Netscape Navigator
			else
			{
				document.sCountyDiv.visibility="visible";
				break;
			}
		}
		else
		{
			// Microsoft Internet Explorer
			if (document.all)
			{
				document.all.sCountyDiv.style.visibility="hidden";
				
			}
			// Netscape Navigator
			else
			{
				document.sCountyDiv.visibility="hidden";				
			}
		}	
		x++;
				
	} 
	
}


function ShowsCounty()
{
	
	var pos;
	
	var amt = document.CheckOut.sState.options.length;
	var curropt;
			
	var x = 0;
	
	while ( x < amt )
	{
		curropt = document.CheckOut.sState.options[document.CheckOut.sState.selectedIndex].value;
			
		if ( curropt == 'NY')
		{// Microsoft Internet Explorer
			if (document.all)
			{
						
				document.all.sCountyDiv.style.visibility="visible";
				
				break;
				
			}
			// Netscape Navigator
			else
			{
				document.sCountyDiv.visibility="visible";
				break;
			}
		}
		else
		{
			// Microsoft Internet Explorer
			if (document.all)
			{
				document.all.sCountyDiv.style.visibility="hidden";
				
			}
			// Netscape Navigator
			else
			{
				document.sCountyDiv.visibility="hidden";				
			}
		}	
		x++;
				
	} 
	
}


function ShowCountyAddr()
{
	
	var pos;
	
	var amt = document.AltAddr.State.options.length;
	var curropt;
			
	var x = 0;
	
	while ( x < amt )
	{
		curropt = document.AltAddr.State.options[document.AltAddr.State.selectedIndex].value;
		if ( curropt == 'NY' )
		{// Microsoft Internet Explorer
			if (document.all)
			{
				
				document.all.CountyDiv.style.visibility="visible";
				
				break;
				
			}
			// Netscape Navigator
			else
			{
				document.CountyDiv.visibility="visible";
				break;
			}
		}
		else
		{
			
			// Microsoft Internet Explorer
			if (document.all)
			{
				document.all.CountyDiv.style.visibility="hidden";
				
			}
			// Netscape Navigator
			else
			{
				document.CountyDiv.visibility="hidden";
				
			}
		}	
		x++;
				
	} 
	
}

function ShowCountyRegister()
{
	
	var pos;
	
	var amt = document.Register.State.options.length;
	var curropt;
			
	var x = 0;
	
	while ( x < amt )
	{
		curropt = document.Register.State.options[document.Register.State.selectedIndex].value;
		if ( curropt == 'NY' )
		{// Microsoft Internet Explorer
			if (document.all)
			{
				
				document.all.CountyDiv.style.visibility="visible";
				
				break;
				
			}
			// Netscape Navigator
			else
			{
				document.CountyDiv.visibility="visible";
				break;
			}
		}
		else
		{
			
			// Microsoft Internet Explorer
			if (document.all)
			{
				document.all.CountyDiv.style.visibility="hidden";
				
			}
			// Netscape Navigator
			else
			{
				document.CountyDiv.visibility="hidden";
				
			}
		}	
		x++;
				
	} 
	
}

function ShowsCountyRegister()
{
	
	var pos;
	
	var amt = document.Register.sState.options.length;
	var curropt;
			
	var x = 0;
	
	while ( x < amt )
	{
		curropt = document.Register.sState.options[document.Register.sState.selectedIndex].value;
		if ( curropt == 'NY' )
		{// Microsoft Internet Explorer
			if (document.all)
			{
				
				document.all.sCountyDiv.style.visibility="visible";
				
				break;
				
			}
			// Netscape Navigator
			else
			{
				document.sCountyDiv.visibility="visible";
				break;
			}
		}
		else
		{
			
			// Microsoft Internet Explorer
			if (document.all)
			{
				document.all.sCountyDiv.style.visibility="hidden";
				
			}
			// Netscape Navigator
			else
			{
				document.sCountyDiv.visibility="hidden";
				
			}
		}	
		x++;
				
	} 
	
}

function ShowCountyUpdate()
{
	
	var pos;
	
	var amt = document.UpdateProfile.State.options.length;
	var curropt;
			
	var x = 0;
	
	while ( x < amt )
	{
		curropt = document.UpdateProfile.State.options[document.UpdateProfile.State.selectedIndex].value;
		if ( curropt == 'NY' )
		{// Microsoft Internet Explorer
			if (document.all)
			{				
				document.all.CountyDiv.style.visibility="visible";				
				break;				
			}
			// Netscape Navigator
			else
			{
				document.CountyDiv.visibility="visible";
				break;
			}
		}
		else
		{
			
			// Microsoft Internet Explorer
			if (document.all)
			{
				document.all.CountyDiv.style.visibility="hidden";				
			}
			// Netscape Navigator
			else
			{
				document.CountyDiv.visibility="hidden";				
			}
		}	
		x++;
				
	} 
	
}

function ShowsCountyUpdate()
{
	
	var pos;
	
	var amt = document.UpdateProfile.sState.options.length;
	var curropt;
			
	var x = 0;
	
	while ( x < amt )
	{
		curropt = document.UpdateProfile.sState.options[document.UpdateProfile.sState.selectedIndex].value;
		if ( curropt == 'NY' )
		{// Microsoft Internet Explorer
			if (document.all)
			{
				
				document.all.sCountyDiv.style.visibility="visible";
				
				break;
				
			}
			// Netscape Navigator
			else
			{
				document.sCountyDiv.visibility="visible";
				break;
			}
		}
		else
		{
			
			// Microsoft Internet Explorer
			if (document.all)
			{
				document.all.sCountyDiv.style.visibility="hidden";
				
			}
			// Netscape Navigator
			else
			{
				document.sCountyDiv.visibility="hidden";				
			}
		}	
		x++;
				
	} 
	
}


function ShowCurrent()
{
	var pos = document.forms[1].LinkTypeList[0].checked;
	
	if ( pos )
	{
			// Microsoft Internet Explorer
			if (document.all)
			{
				document.all.ManualLinkDiv.style.visibility="visible";
				document.all.ProductLinkDiv.style.visibility="hidden";
			}
			// Netscape Navigator
			else
			{
				document.ManualLinkDiv.visibility="visible";
				document.ProductLinkDiv.visibility="hide";
			}
	}
	else
	{
			// Microsoft Internet Explorer
			if (document.all)
			{
				document.all.ProductLinkDiv.style.visibility="visible";
				document.all.ManualLinkDiv.style.visibility="hidden";
			}
			// Netscape Navigator
			else
			{
				document.ProductLinkDiv.visibility="visible";
				document.ManualLinkDiv.visibility="hide";				
			}
	}

}

function closeAltShip()
{

			if (document.all)
			{
				var modalWidth = '450px';
				var modalheight = '450px';
				
				var confirmed = showModalDialog('Disclaimer.aspx', modalWidth,'dialogWidth='+ modalWidth + ';dialogHeight='+ modalheight +';status=0');
				//alert(confirmed);
				
				if ( confirmed )
				{
					return true;
				}
				
			}
			// Netscape Navigator
			else
			{
				return true;
			}
			
			return false;
}

function doConfirm(controlIn){
    if (confirm("Are you sure you wish to delete this entry?")){
        eval(controlIn);
        }
    }
    
function confirmDropDelete(controlIn){
	if (confirm("Note: if you delete a drop shipping, anyone product associated with will reset to default drop zip.  Proceed?")){
		eval(controlIn);
		}
	}
	

function RemoveDepartments()
		{
			var amt = document.Form1.DepartmentList.options.length;
			var curropt;
			
			var x = 0;
			
			while ( x < amt )
			{
				curropt = document.Form1.DepartmentList.options[x];
				
				if ( curropt.selected )
				{
					document.Form1.DepartmentList.remove(x);
					amt--;
				}
					
				x++;
				
			} 
	
		}
		
		function AddDepartment()
		{
			var amt = document.Form1.DepartmentList.options.length;
			
			var i = document.Form1.DeptDropList.selectedIndex;
			
			var optxt = document.Form1.DeptDropList.options[i].text;
			var opval = document.Form1.DeptDropList.options[i].value;
			
			var newop = new Option(optxt,opval);
			
			document.Form1.DepartmentList.add(newop, amt);
	
		}
	
	
	

		function MM_findObj(n, d) 
		{ //v3.0
			var p,i,x;  
			if(!d) d=document; 
			if((p=n.indexOf("?"))>0&&parent.frames.length) 
			{
				d=parent.frames[n.substring(p+1)].document; 
				n=n.substring(0,p);
			}
			if(!(x=d[n])&&d.all) 
				x=d.all[n]; 
				
			for (i=0;!x&&i<d.forms.length;i++) 
				x=d.forms[i][n];
			
			for(i=0;!x&&d.layers&&i<d.layers.length;i++) 
				x=MM_findObj(n,d.layers[i].document); 
				
			return x;
		}
		
		function MM_swapImage() 
		{ //v3.0
			var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; 
			for(i=0;i<(a.length-2);i+=3)
				if ((x=MM_findObj(a[i]))!=null)
				{
					document.MM_sr[j++]=x; 
					if(!x.oSrc) 
						x.oSrc=x.src; x.src=a[i+2];
				}
		}
		
		function MM_swapImgRestore() 
		{ //v3.0
			var i,x,a=document.MM_sr; 
			for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) 
				x.src=x.oSrc;
		}

		function MM_preloadImages() 
		{ //v3.0
			var d=document; 
			if(d.images)
			{ 
				if(!d.MM_p) 
					d.MM_p=new Array();
				var i,j=d.MM_p.length,a=MM_preloadImages.arguments; 
				for(i=0; i<a.length; i++)
					if (a[i].indexOf("#")!=0)
					{ 
						d.MM_p[j]=new Image; 
						d.MM_p[j++].src=a[i];
					}
			}
		}
		
		
		function QuickBuy(boughtproduct)
		{
			alert(boughtproduct + ' has been added to your cart');
		}
		
		function ProdSearch(linkurl)
		{
			if ( (event.which && event.which == 13) || (event.keyCode && event.keyCode == 13) ) 
			{
				event.cancelBubble = true;
				event.returnValue = false;
				
				location.href(linkurl + document.forms[0].txtSearch.value);
				
			}
			else
			{
				return true;
			}
		}
		
		function CheckCartItems(count)
		{
			
			
			if ( count == '0' )
			{
				alert('There are no items in your cart.');
				return false;
			}
			else
			{
				return true;
			}
		
		}
		
		
		function EnterProdManage()
		{
			if ( (event.which && event.which == 13) || (event.keyCode && event.keyCode == 13) ) 
			{
				event.cancelBubble = true;
				event.returnValue = false;
				
				document.forms[0].SearchButton.click();
				
			}
			else
			{
				return true;
			}
		
		}
		
		
		function EnterKeyBranch()
		{
			if ( (event.which && event.which == 13) || (event.keyCode && event.keyCode == 13) ) 
			{
				event.cancelBubble = true;
				event.returnValue = false;
				
				document.forms[0].AddBranchButton.click();
				
			}
			else
			{
				return true;
			}
		
		}
		
		
		function AddDeptClick()
		{
			if ( (event.which && event.which == 13) || (event.keyCode && event.keyCode == 13) ) 
			{
				event.cancelBubble = true;
				event.returnValue = false;
				
				document.forms[0].AddNewDepartmentButton.click();
				
			}
			else
			{
				return true;
			}
		
		}
		
		function PerformLogin(email,pass,path)
		{
			
			if ( (email == '') || (pass == '') )
			{
				alert('Email/Password are required for login');
				
				document.forms[0].Email.value = '';
				document.forms[0].Password.value = '';
				
				document.forms[0].Email.focus();
				
				return false;
			}
		
			var fullpath = path + '?Email=' + email + '&Password=' + pass;
			
			location.href(fullpath);
			
		}
		
		
		
		// SEARCH CLICK - BANNER
		function PerformSearch(linkurl)
		{
			var redirecturl = linkurl + document.forms[0].txtSearch.value;
		
			location.href(redirecturl);
		
		}
		
	
		// ENTER KEY SEARCH - BANNER
		function EnterKeySearch(myurl)
		{
			if ( (event.which && event.which == 13) || (event.keyCode && event.keyCode == 13) ) 
			{
				event.cancelBubble = true;
				event.returnValue = false;
				
				var linkurl = myurl + document.forms[0].SearchField.value;
				
				location.href(linkurl);return false;
				
			} 
			else 
			{	
				return true;
			}
			
		}
		
		
		
		// ENTER KEY LOGIN - DYNAMIC BANNER
		function EnterKeyLogin(myurl)
		{
			if ( (event.which && event.which == 13) || (event.keyCode && event.keyCode == 13) ) 
			{
				event.cancelBubble = true;
				event.returnValue = false;
				
				PerformLogin(document.forms[0].Email.value, document.forms[0].Password.value, myurl);
				
			} 
			else
			{
				return true;
			}
			
		}
		
		// ALERT USER IF CHECKOUT IS CLICKED WITH EMPTY CART
		function checkOutError(path, cost)
		{
			if (cost != 'Shopping Cart is Empty')
			{
				window.location= path;
			}
			else 
			{
				alert('Cart is empty!');
			}
		}
		
		// COPY CONTACT DETAILS
        function copyContactDetails() 
        {
			document.CheckOut.sCompanyName.value = document.CheckOut.CompanyName.value;
            document.CheckOut.sFirstName.value = document.CheckOut.FirstName.value;
            document.CheckOut.sLastName.value = document.CheckOut.LastName.value;
            document.CheckOut.sStreet.value = document.CheckOut.Street.value;
            document.CheckOut.sStreet2.value = document.CheckOut.Street2.value;
            document.CheckOut.sCity.value = document.CheckOut.City.value;
            document.CheckOut.sCountryList.selectedIndex = document.CheckOut.CountryList.selectedIndex;
            document.CheckOut.sState.value = document.CheckOut.State.value;
            document.CheckOut.sPostalCode.value = document.CheckOut.PostalCode.value;
            document.CheckOut.sTelephone.value = document.CheckOut.Telephone.value;
            document.CheckOut.sEveTelephone.value = document.CheckOut.EveTelephone.value;
            
            if ( document.CheckOut.nyCountyList != null )
            {
				document.CheckOut.sNYCountyList.selectedIndex = document.CheckOut.nyCountyList.selectedIndex;
				document.all.sCountyDiv.style.visibility="visible";
			}
			
			/*
			if ( document.CheckOut.CountyBox != null )
			{
				document.CheckOut.sCountyBox.value = document.CheckOut.CountyBox.value;;
			}
			*/
                     
			/*
			if ( document.CheckOut.sPostalCode.value != '' )
			{
				document.CheckOut.submit();
			}
			*/
			
        }
        
        // COPY CONTACT DETAILS
        function copyContactDetails2() 
        {
            document.Register.sFirstName.value = document.Register.FirstName.value;
            document.Register.sLastName.value = document.Register.LastName.value;
            document.Register.sStreet.value = document.Register.Street.value;
            document.Register.sStreet2.value = document.Register.Street2.value;
            document.Register.sCity.value = document.Register.City.value;
            document.Register.sCountryList.selectedIndex = document.Register.CountryList.selectedIndex;
            document.Register.sState.value = document.Register.State.value;
            document.Register.sPostalCode.value = document.Register.PostalCode.value;
            document.Register.sTelephone.value = document.Register.Telephone.value;
            document.Register.sEveTelephone.value = document.Register.sTelephone.value;
            if ( document.Register.nyCountyList != null )
            {
				document.Register.sNYCountyList.selectedIndex = document.Register.nyCountyList.selectedIndex;
				if( document.Register.State.options[document.Register.State.selectedIndex].value == 'NY' )
				{ 
					document.all.sCountyDiv.style.visibility="visible";
				}
				else
				{
					document.all.sCountyDiv.style.visibility="hidden";
				}
					
			}
			
			
        }
        
          // COPY CONTACT DETAILS
        function copyContactDetails3() 
        {
            document.UpdateProfile.sFirstName.value = document.UpdateProfile.FirstName.value;
            document.UpdateProfile.sLastName.value = document.UpdateProfile.LastName.value;
            document.UpdateProfile.sStreet.value = document.UpdateProfile.Street.value;
            document.UpdateProfile.sStreet2.value = document.UpdateProfile.Street2.value;
            document.UpdateProfile.sCity.value = document.UpdateProfile.City.value;
            document.UpdateProfile.sCountryList.selectedIndex = document.UpdateProfile.CountryList.selectedIndex;
            document.UpdateProfile.sState.value = document.UpdateProfile.State.value;
            document.UpdateProfile.sPostalCode.value = document.UpdateProfile.PostalCode.value;
            document.UpdateProfile.sTelephone.value = document.UpdateProfile.Telephone.value;
            document.UpdateProfile.sEveTelephone.value = document.UpdateProfile.EveTelephone.value;
            if ( document.UpdateProfile.nyCountyList != null )
            {
				document.UpdateProfile.sNYCountyList.selectedIndex = document.UpdateProfile.nyCountyList.selectedIndex;
				if( document.UpdateProfile.State.options[document.UpdateProfile.State.selectedIndex].value == 'NY' )
				{ 
					document.all.sCountyDiv.style.visibility="visible";
				}
				else
				{
					document.all.sCountyDiv.style.visibility="hidden";
				}
				
			}
			
			
			
        }
        
        // COPY CONTACT DETAILS
        function copyAuthenticationDetails() 
        {
			document.AuthForm.sCompanyName.value = document.AuthForm.CompanyName.value;
            document.AuthForm.sFirstName.value = document.AuthForm.FirstName.value;
            document.AuthForm.sLastName.value = document.AuthForm.LastName.value;
            document.AuthForm.sStreet.value = document.AuthForm.Street.value;
            document.AuthForm.sStreet2.value = document.AuthForm.Street2.value;
            document.AuthForm.sCity.value = document.AuthForm.City.value;
            document.AuthForm.sCountryList.selectedIndex = document.AuthForm.CountryList.selectedIndex;
            document.AuthForm.sState.value = document.AuthForm.State.value;
            document.AuthForm.sPostalCode.value = document.AuthForm.PostalCode.value;
            document.AuthForm.sTelephone.value = document.AuthForm.Telephone.value;
            document.AuthForm.sEveTelephone.value = document.AuthForm.EveTelephone.value;
            
            if ( document.AuthForm.State.value == "NY" )
            {
				document.AuthForm.sNYCountyList.selectedIndex = document.AuthForm.nyCountyList.selectedIndex;
				document.all.sCountyDiv.style.visibility="visible";
			}
			else
			{
				document.all.sCountyDiv.style.visibility="hidden";
			}
			
			/*
			if ( document.CheckOut.CountyBox != null )
			{
				document.CheckOut.sCountyBox.value = document.CheckOut.CountyBox.value;;
			}
			*/
                     
			/*
			if ( document.CheckOut.sPostalCode.value != '' )
			{
				document.CheckOut.submit();
			}
			*/
			
        }
        
        // FORMAT PHONE FOR RENT
        function FormatPhoneRent()
        {
			document.rentrequestform.Phone.value = formatPhone(document.rentrequestform.Phone.value);
		}
		
		function FormatPhoneRent2()
        {
			document.Form1.Phone.value = formatPhone(document.Form1.Phone.value);
		}
      
		// FORMAT PHONE FOR 1st PHONENUM
		function FormatPhone1() 
		{
			document.CheckOut.Telephone.value= formatPhone(document.CheckOut.Telephone.value);
		}
		
		// FORMAT PHONE FOR 2nd PHONENUM
		function FormatPhone2() 
		{
			document.CheckOut.sTelephone.value= formatPhone(document.CheckOut.sTelephone.value);
		}
		
		// FORMAT PHONE FOR 3rd PHONENUM
		function FormatPhone3() 
		{
			document.Register.Telephone.value= formatPhone(document.Register.Telephone.value);
		}
		
		// FORMAT PHONE FOR 4th PHONENUM
		function FormatPhone4() 
		{
			document.Register.sTelephone.value= formatPhone(document.Register.sTelephone.value);
		}
		
		// FORMAT PHONE FOR 5th PHONENUM
		function FormatPhone5() 
		{
			document.UpdateProfile.Telephone.value= formatPhone(document.UpdateProfile.Telephone.value);
		}
		
		// FORMAT PHONE FOR 6th PHONENUM
		function FormatPhone6() 
		{
			document.UpdateProfile.sTelephone.value= formatPhone(document.UpdateProfile.sTelephone.value);
		}
		
		// FORMAT PHONE FOR 7th PHONENUM
		function FormatPhone7() 
		{
			document.AltAddr.Telephone.value= formatPhone(document.AltAddr.Telephone.value);
		}
		
		// FORMAT PHONE FOR 8th PHONENUM
		function FormatPhone8() 
		{
			document.contactus.Telephone.value= formatPhone(document.contactus.Telephone.value);
		}
		
		// FORMAT PHONE FOR 9th PHONENUM
		function FormatPhone9() 
		{
			document.contactus.AltPhone.value= formatPhone(document.contactus.AltPhone.value);
		}
		
		// FORMAT PHONE FOR 9th PHONENUM
		function FormatPhone10() 
		{
			document.AuthForm.sTelephone.value= formatPhone(document.AuthForm.sTelephone.value);
		}
		
		// FORMAT PHONE FOR 9th PHONENUM
		function FormatPhone11() 
		{
			document.AuthForm.Telephone.value= formatPhone(document.AuthForm.Telephone.value);
		}
		
		// FORMAT PHONE FOR 1st EVEPHONENUM
		function FormatEvePhone1() 
		{
			document.CheckOut.EveTelephone.value= formatPhone(document.CheckOut.EveTelephone.value);
		}
		
		// FORMAT PHONE FOR 2nd EVEPHONENUM
		function FormatEvePhone2() 
		{
			document.CheckOut.sEveTelephone.value= formatPhone(document.CheckOut.sEveTelephone.value);
		}
		
		// FORMAT PHONE FOR 3rd PHONENUM
		function FormatEvePhone3() 
		{
			document.Register.EveTelephone.value= formatPhone(document.Register.EveTelephone.value);
		}
		
		// FORMAT PHONE FOR 4th PHONENUM
		function FormatEvePhone4() 
		{
			document.Register.sEveTelephone.value= formatPhone(document.Register.sEveTelephone.value);
		}
		
		// FORMAT PHONE FOR 5th PHONENUM
		function FormatEvePhone5() 
		{
			document.UpdateProfile.EveTelephone.value= formatPhone(document.UpdateProfile.EveTelephone.value);
		}
		
		// FORMAT PHONE FOR 6th PHONENUM
		function FormatEvePhone6() 
		{
			document.UpdateProfile.sEveTelephone.value= formatPhone(document.UpdateProfile.sEveTelephone.value);
		}
		
		// FORMAT PHONE FOR 7th PHONENUM
		function FormatEvePhone7() 
		{
			document.AltAddr.EveTelephone.value= formatPhone(document.AltAddr.EveTelephone.value);
		}
		
		function FormatEvePhone8()
		{
			document.AuthForm.sEveTelephone.value= formatPhone(document.AuthForm.sEveTelephone.value);
		}
		
		function FormatEvePhone9()
		{
			document.AuthForm.EveTelephone.value= formatPhone(document.AuthForm.EveTelephone.value);
		}
		
		function formatPhone(num)
		{ 
			var _return=false;
			/*
				* 7181238748 to 1(718)123-8748
			*/ 
			
			num= replaceSubstring(num, "-", "");
			num= replaceSubstring(num, " ", "");
			
			if(num.length != 10)
			{ 
				/* 
				* if user did not enter 10 digit phone number then simply print whatever user entered 
				*/ 
				_return=_OUTPUT?num:false;
			} 
			else
			{ 
				/* formating phone number here */ 
				_return="(";
				var ini = num.substring(0,3);
				_return+=ini+") ";
				var st = num.substring(3,6);
				_return+=st+"-";
				var end = num.substring(6,10);
				_return+=end;
			}
			return _return; 
		} 
	
	// REPLACE A SUBSTRING WITHIN A STRING
	function replaceSubstring(inputString, fromString, toString) 
	{
		// Goes through the inputString and replaces every occurrence of fromString with toString
		var temp = inputString;
		if (fromString == "") 
		{
			return inputString;
		}
		if (toString.indexOf(fromString) == -1) 
		{ // If the string being replaced is not a part of the replacement string (normal situation)
			while (temp.indexOf(fromString) != -1) 
			{
				var toTheLeft = temp.substring(0, temp.indexOf(fromString));
				var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
				temp = toTheLeft + toString + toTheRight;
			}
		} 
		else 
		{ // String being replaced is part of replacement string (like "+" being replaced with "++") - prevent an infinite loop
			var midStrings = new Array("~", "`", "_", "^", "#");
			var midStringLen = 1;
			var midString = "";
			// Find a string that doesn't exist in the inputString to be used
			// as an "inbetween" string
			while (midString == "") 
			{
				for (var i=0; i < midStrings.length; i++) 
				{
					var tempMidString = "";
					for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }
					if (fromString.indexOf(tempMidString) == -1) 
					{
						midString = tempMidString;
						i = midStrings.length + 1;
					}
				}
			} // Keep on going until we build an "inbetween" string that doesn't exist
			// Now go through and do two replaces - first, replace the "fromString" with the "inbetween" string
			while (temp.indexOf(fromString) != -1) 
			{
				var toTheLeft = temp.substring(0, temp.indexOf(fromString));
				var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
				temp = toTheLeft + midString + toTheRight;
			}
			// Next, replace the "inbetween" string with the "toString"
			while (temp.indexOf(midString) != -1) 
			{
				var toTheLeft = temp.substring(0, temp.indexOf(midString));
				var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
				temp = toTheLeft + toString + toTheRight;
			}
		} // Ends the check to see if the string being replaced is part of the replacement string or not
		return temp; // Send the updated string back to the user
	
	} // Ends the "replaceSubstring" function


	