//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 signup() {
	//Setting variables
	var p1 = '' + document.getElementById('seller_phone1').value;
	var p2 = '' + document.getElementById('seller_phone2').value;
	var p3 = '' + document.getElementById('seller_phone3').value;
	var dd = document.getElementById('event_case');
	var event_case= dd.options[dd.selectedIndex].value;
	var first_name = document.getElementById('name_first').value;
	var last_name = document.getElementById('name_last').value;
	
	//Validation
	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('seller_phone1').value,document.getElementById('seller_phone2').value,document.getElementById('seller_phone3').value) < 1) {alert ('Valid phone number is required'); return 0;}
	if (emailvalidate(document.getElementById('seller_email').value) < 1) {alert ('Valid e-mail address required'); return 0;}
	if (!document.getElementById('event_name').value) {alert ('Value required for event name'); return 0;}
	if (!document.getElementById('event_date').value) {alert ('Value required for event date\(s\)'); return 0;}
	if (!document.getElementById('event_case').value) {alert ('You must choose a region near your event'); return 0;}

	//variable for passing to thank you
	var seller_name = first_name+' '+last_name;
	var seller_phone = p1+' - '+p2+' - '+p3;
	var seller_email = document.getElementById('seller_email').value;
	var event_name = document.getElementById('event_name').value;
	var event_venue = document.getElementById('event_venue').value;
	var event_date = document.getElementById('event_date').value;
	var event_region = dd.options[dd.selectedIndex].innerHTML;
	var regional_office = document.getElementById('regional_office').value;
	var to_email_address = document.getElementById('to_email_address').value;
	document.mainform.subject.value = 'LMS - ' + document.getElementById('event_name').value + ', ' + document.getElementById('event_date').value;
	
	// Evaluate the event location and assign the email address and fax number accordingly
	switch(event_case) {
		case '1':	 	
		to_email = "east.lms@stubhub.com";
		region_office = "StubHub - Boston";
		break;
		case '2':	 	
		to_email = "nyc.lms@stubhub.com";
		region_office = "StubHub - New York";
		break;
		case '3':	 	
		to_email = "south.lms@stubhub.com";
		region_office = "StubHub - Dallas";
		break;
		case '4':	 	
		to_email = "midwest.lms@stubhub.com";
		region_office = "StubHub - Chicago";
		break;
		case '5':	 	
		to_email = "west.lms@stubhub.com";
		region_office = "StubHub - Los Angeles";
		break;
		default:
		to_email = "StubHub_SF@StubHub.com";
		region_office = "StubHub";
		break;
	}	
	
	//Setting vaiables to hidden fields	values
	document.getElementById('event_region').value =  event_region
	document.getElementById('seller_name').value = seller_name;
	document.getElementById('seller_phone').value = seller_phone;
	document.getElementById('to_email_address').value = to_email;
	document.getElementById('regional_office').value = region_office;
	
var thanktext = '<table width="655" border="0" cellspacing="0" cellpadding="10" class="contentCell" style="color:#000000;"><tr><td align="left" class="mediumheader" colspan="2"><span style="font-size:18px; font-weight:bold;">Last Minute Services</span><br /><br /><span style="color:#CC2828; font-size:18px; font-weight:bold;">Wait... you\'re not done yet!  You MUST print or save this page.</span><br /><br /> A Last Minute Services (LMS) representative will contact you within 24 hours to assist you in finalizing your request.  You will be asked to sign the LMS Release form below and submit it along with your tickets.</td></tr><tr><td align="center" style="border-bottom:1px solid black;" colspan="2"><span style="font-size:18px; font-weight:bold; padding-top:5px;">Last Minute Services Release -- Please Sign</span></td></tr><tr><td width="40%" valign="top" style="padding-left:40px;"><span class="littleheader">Seller Information</span><br />Name:&nbsp;&nbsp;'+seller_name+'<br />Phone:&nbsp;&nbsp;'+seller_phone+'<br />Email:&nbsp;&nbsp;'+seller_email+'</td><td width="60%" valign="top">	<span class="littleheader">Ticket Information</span><br />Event:&nbsp;&nbsp;'+event_name+'<br />Date(s):&nbsp;&nbsp;'+event_date+'</td></tr></table><table width="655" border="0" cellspacing="15" cellpadding="0" style="color:#000000;" class="contentCell"><tr><td colspan="2">I, '+seller_name+', am tendering to LMT, Inc. my tickets as listed above for the purpose of selling with Last Minute Services.<br />	I understand and agree to the conditions set forth below.  I acknowledge and agree that these conditions are a supplement to the terms and conditions contained on the StubHub website to which I have agreed.<br /><br /><em class="medium" style="color:#000000;">Please initial each entry below</em></td></tr><tr><td width="40" align="right" valign="bottom" valign="bottom" style="border-bottom:1px solid #000000;">&nbsp;</td><td width="615">I understand that these tickets may not sell prior to the event. Neither StubHub nor LMT, Inc. make any guarantees or assurances to this effect.  If they do not sell, I will not be entitled to compensation for my tickets.</td></tr><tr><td style="border-bottom:1px solid #000000;">&nbsp;</td><td>It is my responsibility to list my tickets on StubHub.com and to set, maintain and/or change the pricing of my tickets.</td></tr><tr><td style="border-bottom:1px solid #000000;">&nbsp;</td><td>It is my sole responsibility to deactivate or delete my listing and then retrieve my tickets from LMT, Inc. prior to the event, if I choose to alternately dispose of or utilize them.</td></tr><tr><td style="border-bottom:1px solid #000000;">&nbsp;</td><td>If my tickets sell more than 3 days in advance of the event date while the possession of LMT, Inc., I will confirm the transaction within 24 hrs and forward the confirmation notice to the Last Minute Service Center in possession of my tickets. In the event I don\'t confirm my sale and notify the local office within 24 hrs, I understand that my sale may be cancelled and my tickets substituted with other tickets in order to facilitate timely confirmation of the order for the buyer.</td></tr><tr><td style="border-bottom:1px solid #000000;">&nbsp;</td><td>If my tickets sell, I will be compensated per the terms of the StubHub User Agreement and Seller Learning Center including the deduction of all applicable seller fees. </td></tr><tr><td style="border-bottom:1px solid #000000;">&nbsp;</td><td>Liability for these tickets to LMT, Inc. is limited to "face-value" only. There is no liability to StubHub for these tickets.</td></tr><tr><td style="border-bottom:1px solid #000000;">&nbsp;</td><td>Beyond the scheduled event start-time and unless otherwise arranged in advance, neither StubHub nor LMT, Inc. will be obligated to return to me tickets that have not sold. If I want my unused/unsold tickets returned to me, I will notify StubHub as soon as possible and, in any event, no later than two (2) hours prior to the scheduled event start-time.</td></tr><tr><td style="border-bottom:1px solid #000000;">&nbsp;</td><td>While in the possession of LMT, Inc., I understand that my tickets cannot be listed on any other ticketing or posting website other than StubHub.com.</td></tr><tr><td colspan="2"><table width="100%" border="0" cellspacing="20" cellpadding="0"><tr><td width="50%" style="border-bottom:1px solid #000000;">&nbsp;<br /><br /><br /></td><td width="50%" style="border-bottom:1px solid #000000;">&nbsp;</td></tr><tr><td valign="top" class="medium" style="padding-left:20px">Seller Name</td><td valign="top" class="medium" style="padding-left:20px">Date</td></tr></table></td></tr></table>';
  	
	document.getElementById('thank_you_text').value = thanktext;

	document.getElementById('mainform').action='http://www.stubhub.com/?gSec=content_form';
	document.getElementById('mainform').submit();
}