﻿// JScript File

function getPriceOptions()
{  
        try
        {
            obj1=new XMLHttpRequest();
        }
        catch(e)
	    {       
		    try
		    {
			    obj1 = new ActiveXObject("Microsoft.XMLHTTP");			
		    }
		    catch(e1)
		    {
			    obj1 = null;
		    }
	    }	
	    if(obj1!=null)
	    {
		    obj1.onreadystatechange = ProcessOptionResult;
		    obj1.open("GET", "get-size-options.asp?idProduct=813&sColor=WHITE&qty=S|12|M||L||XL||2XL||3XL||4XL|&wt=Screen&loc=1|0|0|0",  true);
		    obj1.send(null);         
	    }
	    return false;
}

function ProcessOptionResult()
{
	if(obj1.readyState == 4)
	{	
		if(obj1.status == 200)
		{
			if (obj1.responseText != "")
			{
			    var sizeOptionSection = document.getElementById('sizeOptionSection');
				try
				{			
					sizeOptionSection.innerHTML =  obj1.responseText;
				}
				catch(e)
				{
				}
			}
			else
			{
				sizeOptionSection.innerHtml = '';
			}
		}
	}
}

function sendEventRequest()
{
  if (validate)
  {
    var form = document.getElementById('form1');
    form.submit();
  }
}

function validate()
{
    var validationSummary = '';
    
    var firstName = document.getElementById('txtFirstName');
    var lastName = document.getElementById('txtLastName');
    var organization = document.getElementById('txtOrganization');
    var email = document.getElementById('txtEmail');
    var phone = document.getElementById('txtPhone');
    var state = document.getElementById('ddlState');
    var designColor = document.getElementById('txtDesignColor');
    var quantity = document.getElementById('txtQuantity');
    
    if(firstName.value == '')
    {
        validationSummary += ' - Please enter a first name.\r\n';
    }
    if(lastName.value == '')
    {
        validationSummary += ' - Please enter a last name.\r\n';
    }
    if(organization.value == '')
    {
        validationSummary += ' - Please enter an organization.\r\n';
    }
    if(email.value == '')
    {
        validationSummary += ' - Please enter an email address.\r\n';
    }
    if(phone.value == '')
    {
        validationSummary += ' - Please enter a phone number.\r\n';
    }
    if(state.value == '')
    {
        validationSummary += ' - Please select a state.\r\n';
    }
    if(designColor.value == '')
    {
        validationSummary += ' - Please enter the design colors.\r\n';
    }
    if(quantity.value == '')
    {
        validationSummary += ' - Please enter a quantity.\r\n';
    }
    else
    {
        if (parseInt(quantity.value) < 12) {
            validationSummary += ' - A minimum of 12 items is required.\r\n';
        }
    }
    
    if(validationSummary.length != 0)
    {
        alert(validationSummary);
        return false;
    }
    else
    {
         return true;
    }
}