	var buyArray = new Array();
	buyArray.push(new Array('Please select a topic.','default','Please select a topic.'));
	buyArray.push(new Array('Help Finding/Buying Tickets','e-sales@stubhub.com','Help Finding/Buying Tickets'));
	buyArray.push(new Array('Can\'t Find an Event','e-sales@stubhub.com','Can\'t Find an Event'));
	buyArray.push(new Array('Change Shipping Address/Pickup Information','contactus@stubhub.com','Change Shipping Address/Pickup Information'));
	buyArray.push(new Array('Order Tracking','contactus@stubhub.com','Order Tracking'));
	buyArray.push(new Array('Information on a Cancelled/Postponed Event','contactus@stubhub.com','Cancelled/Postponed Event - Buyer'));
	buyArray.push(new Array('Service Feedback','e-escalations@stubhub.com','Service Feedback - Buyer'));
	buyArray.push(new Array('Report a Map Error','contactus@stubhub.com','Report a Map Error'));
	buyArray.push(new Array('Other','Contactus@stubhub.com','Other - Buyer'));

	var sellArray = new Array();
	sellArray.push(new Array('Please select a topic.','default','Please select a topic.'));
	sellArray.push(new Array('How to Sell','contactus@stubhub.com','How to Sell'));
	sellArray.push(new Array('Confirming a Sale','contactus@stubhub.com','Question about Confirming'));
	sellArray.push(new Array('Shipping Tickets','contactus@stubhub.com','Shipping Tickets'));
	sellArray.push(new Array('Payment Status','contactus@stubhub.com','Payment Status'));
	sellArray.push(new Array('Changing Payment Information','contactus@stubhub.com','Changing Payment Information'));
	sellArray.push(new Array('Request an Event','eventrequests@stubhub.com','Request an Event'));
	sellArray.push(new Array('Service Feedback','e-escalations@stubhub.com','Service Feedback - Seller'));
	sellArray.push(new Array('Change Shipping Date','returntoship@stubhub.com','Change Shipping Date'));
	sellArray.push(new Array('Report a Map Error','contactus@stubhub.com','Report a Map Error'));
	sellArray.push(new Array('Other','contactus@stubhub.com','Other - Seller'));
	

	
	var otherArray = new Array();
	otherArray.push(new Array('Please select a topic.','default','Please select a topic.'));
	otherArray.push(new Array('Report an Error Received on the Website','contactus@stubhub.com','Report an Error Received on the Website'));
	otherArray.push(new Array('Unsubscribe From StubHub Ticket Update','contactus@stubhub.com','Unsubscribe From StubHub Ticket Update'));
	otherArray.push(new Array('Question About Advertising','e-marketing@stubhub.com', 'Question About Advertising'));
	otherArray.push(new Array('Report a Map Error','contactus@stubhub.com','Report a Map Error'));


function detectChecked() {
	var radioArray = document.getElementsByName('emailRadio');
	for (var i=0; i<radioArray.length; i++) {
		if (radioArray[i].checked) {
			buildDropDown(radioArray[i].value);
		}
	}
}

function detectCheckedValidate() { 
       var radioArray = document.getElementsByName('emailRadio'); 
       for (var i=0; i<radioArray.length; i++) { 
            if (radioArray[i].checked) { 
                 return 1; 
            } 
      } 
return 0;
  }

function buildDropDown(value) {
	var emailSelect = document.getElementById('emailSelect');
	if (value == 'buy') {
		var theArray = buyArray;
	}
	else if (value == 'sell') {
		var theArray = sellArray;
	}
	else {
		var theArray = otherArray;
	}
	clearElement(emailSelect); // removes existing options
	for (var i=0; i<theArray.length; i++) {
		var newOption = document.createElement('option');
		var newText = theArray[i][0]; // the first element -- the question
		newOption.appendChild(document.createTextNode(newText)); // append this text to the option
		newOption.value = theArray[i][1]; // set the option value to the second element, the email address
		newOption.id = value+'_'+i;
		emailSelect.appendChild(newOption); // append the option to the <select>, by ID.
	}
}

function getArrayInfo (id) {
	arrayType = id.split('_')[0];
	arrayNumber = id.split('_')[1];
	if (arrayType == 'buy') {theArray = buyArray;}
	else if (arrayType == 'sell') {theArray = sellArray;}
	else {theArray = otherArray;}
	arrayDetails = theArray[arrayNumber];
	return (arrayDetails);
}

function clearElement(element) {
	if (element.hasChildNodes()) {
		element.removeChild(element.childNodes[0]);
		clearElement(element);
	}
	return;
}

function init() {
	var radioArray = document.getElementsByName('emailRadio');
	for (var i=0; i<radioArray.length; i++) {
		radioArray[i].checked = false;
	}
}
//Email validation script
function emailvalidate (string) { 
	var valregex = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; 
	if (valregex.test(string)) {return 1;} 
	      else {return 0;} 
}
//Phone validation script
function phonevalidate (p1,p2,p3) {
	var p1test = /^([0-9]{3})/;
	var p2test = /^([0-9]{3})/;
	var p3test = /^([0-9]{4})/;
	if ((p1test.test(p1)) && (p2test.test(p2)) && (p3test.test(p3))) {return 1;}
	else {return 0;}
}

function contactus() {
	//Setting variables
	var p1 = '' + document.getElementById('cu_phone1').value;
	var p2 = '' + document.getElementById('cu_phone2').value;
	var p3 = '' + document.getElementById('cu_phone3').value;
	var first_name = document.getElementById('name_first').value;
	var last_name = document.getElementById('name_last').value;
	
	if (detectCheckedValidate() == 0) {alert ('Please select a topic by choosing a radio button.'); return 0;}	
	
	var dropDown = document.getElementById('emailSelect');
	var id = dropDown.options[dropDown.selectedIndex].id;
	var selectedSubject = dropDown.options[dropDown.selectedIndex].id;
	var details = getArrayInfo(selectedSubject);	
	var emailAddress = details[1];
	var emailSubject = details[2];
	var cu_name = first_name+' '+last_name;
	var cu_phone = p1+' - '+p2+' - '+p3;
	var userEmail = document.getElementById('cu_email').value;
	var eventName = document.getElementById('cu_event_name').value;
	var eventDate = document.getElementById('cu_event_date').value;
	var message = document.getElementById('cu_message').value;
	
	if (id == 'sell_6') {emailSubject = 'Events - '+ eventName + ' - ' +  eventDate; }	//subject for events
	
	//Validation

	if (emailSubject=='Please select a topic.') {alert ('Please select a topic from the pulldown.'); return 0;}
	if (!document.getElementById('name_first').value) {alert ('Value required for first name'); return 0;}
	if (!document.getElementById('name_last').value) {alert ('Value required for last name'); return 0;}
	if (phonevalidate(document.getElementById('cu_phone1').value,document.getElementById('cu_phone2').value,document.getElementById('cu_phone3').value) < 1) {alert ('Valid phone number is required'); return 0;}
	if (emailvalidate(document.getElementById('cu_email').value) < 1) {alert ('Valid e-mail address required'); return 0;}
	if (!document.getElementById('cu_message').value) {alert ('Please enter a message.'); return 0;}

	//settings for passing to body text
	
	document.getElementById('subject').value = emailSubject;
	document.getElementById('user_phone').value = cu_phone;
	document.getElementById('to_email_address').value = emailAddress;
	document.getElementById('from_email_address').value = userEmail;

	var bodytext = '<p>The following information was submitted via the Contact Us form.</p><p>SUBJECT:&nbsp;&nbsp;'+emailSubject+' </p><p>FROM (Customer Email Address):&nbsp;&nbsp;'+userEmail+'</p><p>NAME:&nbsp;&nbsp;'+cu_name+'</p><p>PHONE NUMBER:&nbsp;&nbsp;'+cu_phone+'</p><p>EVENT NAME:&nbsp;&nbsp;'+eventName+'</p><p>EVENT DATE:&nbsp;&nbsp;'+eventDate+'</p><p>CUSTOMER MESSAGE:<br />'+message+'</p>';
	
	document.getElementById('body').value = bodytext;
		
	document.getElementById('mainform').action='/?gSec=content_form';
	document.getElementById('mainform').submit();
}
