
// FORM VALIDATION

$(document).ready(function() {
	$('form#submissionform').submit(function() {
		$('form#submissionform .error').remove();
		var hasError = false;
		$('.required').each(function() {
			if(jQuery.trim($(this).val()) == '') {
				var labelText = $(this).prev('label').text().replace(':','');
				$(this).parent().append('<span class="error">Please include your '+labelText+'.</span>');
				hasError = true;
				
				$('span.required-input').hide();
				$('.required').removeClass('input-error')
				$(this).addClass('input-error')
				
			}
		});
		if(hasError) {
			return false;
		}
	});
});



// DROPDOWN

function fillCategory(){

	// this function is used to fill the cat1 list on load
	
	addOption(document.drop_list.cat1, "Overall Wireless Ecosystem/Supply Chain Solution Provider", "Best Overall Wireless Ecosystem/Supply Chain Solution Provider", "");
	addOption(document.drop_list.cat1, "4G Enabling Technology Innovations", "Best 4G Enabling Technology Innovations", "");
	addOption(document.drop_list.cat1, "Mobile Internet Capital Companies", "Best Mobile Internet Capital Companies", "");
	addOption(document.drop_list.cat1, "Mobile Chip Company", "Best Mobile Chip Company", "");
	addOption(document.drop_list.cat1, "Mobile Internet Device Company", "Best Mobile Internet Device Company", "");
	addOption(document.drop_list.cat1, "4G Infrastructure OEM", "Best 4G Infrastructure OEM", "");
	addOption(document.drop_list.cat1, "4G Infrastructure Service Company ", "Best 4G Infrastructure Service Company ", "");
	addOption(document.drop_list.cat1, "Tower Company", "Best Tower Company", "");
	addOption(document.drop_list.cat1, "Specialty Deployment ", "Best Specialty Deployment ", "");
	addOption(document.drop_list.cat1, "Global 4G Operator Deployment ", "Best Global 4G Operator Deployment ", "");
	addOption(document.drop_list.cat1, "Mobile Content Provider", "Best Mobile Content Provider", "");
	addOption(document.drop_list.cat1, "Mobile Application", "Best Mobile Application", "");
	addOption(document.drop_list.cat1, "Mobile Marketing Campaign", "Best Mobile Marketing Campaign", "");

}

function SelectSubCat(){
	
	removeAllOptions(document.drop_list.cat2);
	addOption(document.drop_list.cat2, "", "Category Submission", "");
	
	if(document.drop_list.cat1.value == 'Chips'){
	addOption(document.drop_list.cat2,"Company Overall", "Company Overall");
	addOption(document.drop_list.cat2,"Product Specific", "Product Specific");
	}
	if(document.drop_list.cat1.value == 'Devices'){
	addOption(document.drop_list.cat2,"Company Overall", "Company Overall");
	addOption(document.drop_list.cat2,"Device Specific", "Device Specific");
	addOption(document.drop_list.cat2,"Application", "Application");
	addOption(document.drop_list.cat2,"M2M communications", "M2M communications");
	}
	if(document.drop_list.cat1.value == 'Carriers'){
	addOption(document.drop_list.cat2,"Mobile carrier", "Mobile carrier");
	addOption(document.drop_list.cat2,"Cable operator", "Cable operator");
	addOption(document.drop_list.cat2,"Specialized providers: M2M, Broadband, MobileTV", "Specialized providers: M2M, Broadband, MobileTV");
	}
	if(document.drop_list.cat1.value == 'Infrastructure'){
	addOption(document.drop_list.cat2,"Towers", "Towers");
	addOption(document.drop_list.cat2,"Wireless networks", "Wireless networks");
	addOption(document.drop_list.cat2,"Cable/Satellite networks", "Cable/Satellite networks");
	addOption(document.drop_list.cat2,"Construction & Engineering", "Construction & Engineering");
	addOption(document.drop_list.cat2,"Test Equipment", "Test Equipment");
	addOption(document.drop_list.cat2,"Distribution & Logistics", "Distribution & Logistics");
	addOption(document.drop_list.cat2,"Title company/environmental/insurance company", "Title company/environmental/insurance company");
	addOption(document.drop_list.cat2,"Component company", "Component company");
	addOption(document.drop_list.cat2,"Specialty Award", "Specialty Award");
	addOption(document.drop_list.cat2,"Backhaul", "Backhaul");
	}
	if(document.drop_list.cat1.value == 'Operating Support Systems'){
	addOption(document.drop_list.cat2,"Overall company", "Overall company");
	addOption(document.drop_list.cat2,"Product specific", "Product specific");
	}
	if(document.drop_list.cat1.value == 'Costumers'){
	addOption(document.drop_list.cat2,"Government", "Government");
	addOption(document.drop_list.cat2,"Energy", "Energy");
	addOption(document.drop_list.cat2,"Healthcare", "Healthcare");
	addOption(document.drop_list.cat2,"Financial Services including Mobile Banking", "Financial Services including Mobile Banking");
	addOption(document.drop_list.cat2,"Gen-Y ; Gamers; Boomers", "Gen-Y ; Gamers; Boomers");
	addOption(document.drop_list.cat2,"Other", "Other");
	}
	if(document.drop_list.cat1.value == 'The Channel'){
	addOption(document.drop_list.cat2,"Products", "Products");
	addOption(document.drop_list.cat2,"Services", "Services");
	addOption(document.drop_list.cat2,"Retail Channel", "Retail Channel");
	}
	if(document.drop_list.cat1.value == 'Enabler Apps'){
	addOption(document.drop_list.cat2,"Enterprise Apps", "Enterprise Apps");
	addOption(document.drop_list.cat2,"Consumer Apps", "Consumer Apps");
	}
	if(document.drop_list.cat1.value == 'Content'){
	addOption(document.drop_list.cat2,"Entertainment", "Entertainment");
	addOption(document.drop_list.cat2,"Marketing", "Marketing");
	addOption(document.drop_list.cat2,"Voice", "Voice");
	addOption(document.drop_list.cat2,"LBS", "LBS");
	}
	if(document.drop_list.cat1.value == 'Facilitators'){
	addOption(document.drop_list.cat2,"Regulatory", "Regulatory");
	addOption(document.drop_list.cat2,"Consultant/Analyst", "Consultant/Analyst");
	addOption(document.drop_list.cat2,"Association", "Association");
	addOption(document.drop_list.cat2,"Financial", "Financial");
	}

}

function SelectSubSubCat(){
	
	removeAllOptions(document.drop_list.cat3);
	addOption(document.drop_list.cat3, "", "Sub Subcategory", "");
	
	if(document.drop_list.cat2.value == 'Mobile carrier'){
	addOption(document.drop_list.cat3,"EMEA", "EMEA");
	addOption(document.drop_list.cat3,"APAC", "APAC");
	addOption(document.drop_list.cat3,"LATAM", "LATAM");
	addOption(document.drop_list.cat3,"NA", "NA");
	}
	if(document.drop_list.cat2.value == 'Cable operator'){
	addOption(document.drop_list.cat3,"EMEA", "EMEA");
	addOption(document.drop_list.cat3,"APAC", "APAC");
	addOption(document.drop_list.cat3,"LATAM", "LATAM");
	addOption(document.drop_list.cat3,"NA", "NA");
	}
	if(document.drop_list.cat2.value == 'Specialized providers: M2M, Broadband, MobileTV'){
	addOption(document.drop_list.cat3,"EMEA", "EMEA");
	addOption(document.drop_list.cat3,"APAC", "APAC");
	addOption(document.drop_list.cat3,"LATAM", "LATAM");
	addOption(document.drop_list.cat3,"NA", "NA");
	}
	if(document.drop_list.cat2.value == 'Component company'){
	addOption(document.drop_list.cat3,"Over $1 billion", "Over $1 billion");
	addOption(document.drop_list.cat3,"Over $100 million", "Over $100 million");
	addOption(document.drop_list.cat3,"Under $10 million", "Under $10 million");
	}
	if(document.drop_list.cat2.value == 'Specialty Award'){
	addOption(document.drop_list.cat3,"RF Engineer", "RF Engineer");
	addOption(document.drop_list.cat3,"Tower climber of the year", "Tower climber of the year");
	addOption(document.drop_list.cat3,"Tower of the year", "Tower of the year");
	}
	if(document.drop_list.cat2.value == 'Backhaul'){
	addOption(document.drop_list.cat3,"Company", "Company");
	addOption(document.drop_list.cat3,"Product", "Product");
	}
	if(document.drop_list.cat2.value == 'Retail Channel'){
	addOption(document.drop_list.cat3,"Online", "Online");
	addOption(document.drop_list.cat3,"Storefront", "Storefront");
	}
	if(document.drop_list.cat2.value == 'Financial'){
	addOption(document.drop_list.cat3,"Venture deal of the year", "Venture deal of the year");
	addOption(document.drop_list.cat3,"Private equity deal of the year", "Private equity deal of the year");
	addOption(document.drop_list.cat3,"M&A deal of the year", "M&A deal of the year");
	addOption(document.drop_list.cat3,"Accounting Firm", "Accounting Firm");
	addOption(document.drop_list.cat3,"Lawyer or Law Firm", "Lawyer or Law Firm");
	}

}


function removeAllOptions(selectbox)
{
	var i;
	for(i=selectbox.options.length-1;i>=0;i--)
	{
		//selectbox.options.remove(i);
		selectbox.remove(i);
	}
}


function addOption(selectbox, value, text )
{
	var optn = document.createElement("OPTION");
	optn.text = text;
	optn.value = value;

	selectbox.options.add(optn);
}