function WinOpen(theURL, szWidth, szHeight) 
{
	var remoteWin = null;
	var params;
	params = 'toolbar=0,location=0,directories=0,status=0,scrollbars=1,scrolling=1,resizable=1,menubar=0,width='+szWidth+',height='+szHeight;
	remoteWin = window.open("","",params);
	remoteWin.location.href = theURL;
	remoteWin.focus();
};

function checkEmailAddress(field) 
{
	field = document.getElementById('txtEmail');
	var goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);

if (goodEmail)
{
   return true;
} else {
   alert('Please enter a valid e-mail address.')
   field.focus()
   field.select()
   return false;
   }
}

function verifyNewAccount() {

if (document.frmNewAccount.firstname.value == '')
	{
    	alert('Please enter your first name.');
        document.frmNewAccount.firstname.focus();
        return false;
    }
else if (document.frmNewAccount.lastname.value == '')
	{
    	alert('Please enter your last name.');
        document.frmNewAccount.lastname.focus();
        return false;
    }
else if (document.frmNewAccount.email.value == '')
	{
    	alert('Please enter your email address.');
        document.frmNewAccount.email.focus();
        return false;
    }
else if (document.frmNewAccount.username.value == '')
	{
    	alert('Please choose a unique user name for this account.');
        document.frmNewAccount.username.focus();
        return false;
    }
else if (document.frmNewAccount.password.value == '')
	{
    	alert('Please choose a password.');
        document.frmNewAccount.password.focus();
        return false;
    }
else if (document.frmNewAccount.passwordv.value == '')
	{
    	alert('Please verify the password you have entered.');
        document.frmNewAccount.passwordv.focus();
        return false;
    }
else if (document.frmNewAccount.password.value != document.frmNewAccount.passwordv.value)
	{
    	alert('The passwords you have entered do not match!  Please try again.');
        document.frmNewAccount.password.focus();
        return false;
    }
else
	{
	return true;
    }

}

function action(category_ID)
                {
                                if (document.getElementById('li'+category_ID).className == 'liClosed')
                                {
                                        var subLists = false;
                                        for (var sitemi=0;sitemi<document.getElementById('li'+category_ID).childNodes.length;sitemi++)
                                         {
                                                var sitem = document.getElementById('li'+category_ID).childNodes[sitemi];
                                                if (sitem.nodeName=="UL")
                                                {
                                                        subLists = true;
                                                }
                                        }
                                        if (!subLists)
                                        {
                                        var url="subcategories.php?category_ID=" + category_ID;
                                        xmlHttp=GetXmlHttpObject(stateChanged)
                                        xmlHttp.open("GET", url , true)
                                        xmlHttp.send(null)
                                        }
                                        else
                                        {
                                        document.getElementById('li'+category_ID).className = 'liOpen';
                                        }
                                }
                                else
                                {
                                document.getElementById('li'+category_ID).className = 'liClosed';
                                }

                                function stateChanged()
                                {
                                        if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
                                                {
                                                        try{

                                                        eval(xmlHttp.responseText);
                                                        }
                                                        catch(e)
                                                        {
                                                        alert(e);
                                                        alert(xmlHttp.responseText);
                                                        }

                                                }
                                }
                }

function GetXmlHttpObject(handler)
                        {
                        var objXmlHttp=null
                        if (navigator.userAgent.indexOf("Opera") >= 0)
                        {
                            objXmlHttp = new XMLHttpRequest();
							objXmlHttp.onload = handler;
							objXmlHttp.onerror = handler;
							return objXmlHttp;
                        }
                        if (navigator.userAgent.indexOf("MSIE")>=0)
                        {
                                var strName="Msxml2.XMLHTTP"
                                if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
                                {
                                strName="Microsoft.XMLHTTP"
                                }
                                try
                                {
                                objXmlHttp=new ActiveXObject(strName)
                                objXmlHttp.onreadystatechange=handler
                                return objXmlHttp
                                }
                                catch(e)
                                {
                                alert("Error. Scripting for ActiveX might be disabled")
                                return
                                }
                        }
                        if (navigator.userAgent.indexOf("Mozilla")>=0)
                        {
                        objXmlHttp=new XMLHttpRequest()
                        objXmlHttp.onload=handler
                        objXmlHttp.onerror=handler
                        return objXmlHttp
                        }
                }

function sameasbilling()
{
document.personal_info.txtShiptoFirstName.value = document.personal_info.txtFirstName.value;
document.personal_info.txtShiptoLastName.value = document.personal_info.txtLastName.value;
document.personal_info.txtShiptoCompany.value = document.personal_info.txtCompany.value;
document.personal_info.txtShiptoAddress1.value = document.personal_info.txtAddress1.value;
document.personal_info.txtShiptoAddress2.value = document.personal_info.txtAddress2.value;
document.personal_info.txtShiptoCity.value = document.personal_info.txtCity.value;
document.personal_info.selShiptoState.value = document.personal_info.selState.value;
document.personal_info.txtShiptoZip.value = document.personal_info.txtZip.value;
}

function validate_form()
{
if (document.personal_info.cust_firstname.value=='')
        {
        alert('Please enter your first name.');
        document.personal_info.cust_firstname.focus();
        return false;
        }
if (document.personal_info.cust_lastname.value=='')
        {
        alert('Please enter your last name.');
        document.personal_info.cust_lastname.focus();
        return false;
        }
if (document.personal_info.email.value=='')
        {
        alert('Please enter your email address.');
        document.personal_info.email.focus();
        return false;
        }
if (document.personal_info.dayphone.value=='')
        {
        alert('Please enter your phone number.');
        document.personal_info.dayphone.focus();
        return false;
        }
if (document.personal_info.txtFirstName.value=='')
        {
        alert('Please enter the first name for Billing.');
        document.personal_info.txtFirstName.focus();
        return false;
        }
else if (document.personal_info.txtLastName.value=='')
        {
        alert('Please enter the last name for Billing.');
        document.personal_info.txtLastName.focus();
        return false;
        }
else if (document.personal_info.txtAddress1.value=='')
        {
        alert('Please enter your billing address.');
        document.personal_info.txtAddress1.focus();
        return false;
        }
else if (document.personal_info.txtCity.value=='')
        {
        alert('Please enter your city.');
        document.personal_info.txtCity.focus();
        return false;
        }
else if (document.personal_info.selState.value=='')
        {
        alert('Please select your state.');
        document.personal_info.selState.focus();
        return false;
        }
else if (document.personal_info.txtZip.value=='')
        {
        alert('Please select your zip code.');
        document.personal_info.txtZip.focus();
        return false;
        }
else
        {
        return true;
        }
}