(function(){
	var __constructor = function(params){
		var privateVars = {
			container : null,
			formClassName : null,
			comboBoxClassName : null,
			searchButtonClassName : null
		}
		
		var elements = {
			'countryComboBox' : null,
			'degreeComboBox' : null,
			'termComboBox' : null
		}
		
		for(var prop in params){
			if(typeof privateVars[prop] == 'undefined'){
				alert('Error! Undefined property [' + prop + '] for GASearchWidget!');
				return;
			}
			privateVars[prop] = params[prop];
		}
		
		this.render = function(){
			var cont = document.getElementById(privateVars['container']);
			
			var countryComboBox = document.createElement('select');
			countryComboBox.name = 'countryID';
			if(privateVars['comboBoxClassName'] != null){
				countryComboBox.className = privateVars['comboBoxClassName'];
			}			
			var countrySelections = GASearchWidget.getSelection('countries');
			countryComboBox.options[countryComboBox.options.length] = new Option('-- Select Country --',0);
			for(var key in countrySelections){
				countryComboBox.options[countryComboBox.options.length] = new Option(countrySelections[key],key);
			}
			cont.appendChild(countryComboBox);
			
			elements['countryComboBox'] = countryComboBox;
			
			//degree
			var degreeComboBox = document.createElement('select');
			degreeComboBox.name = 'degprogID';
			if(privateVars['comboBoxClassName'] != null){
				degreeComboBox.className = privateVars['comboBoxClassName'];
			}
			var degreeSelections = GASearchWidget.getSelection('degrees');
			degreeComboBox.options[degreeComboBox.options.length] = new Option('-- Select Degree Programs --',0);
			for(var key in degreeSelections){
				degreeComboBox.options[degreeComboBox.options.length] = new Option(degreeSelections[key],key);
			}
			cont.appendChild(degreeComboBox);
			
			elements['degreeComboBox'] = degreeComboBox;
			
			//term
			var termComboBox = document.createElement('select');
			termComboBox.name = 'termID';
			if(privateVars['comboBoxClassName'] != null){
				termComboBox.className = privateVars['comboBoxClassName'];
			}
			var termSelections = GASearchWidget.getSelection('terms');
			termComboBox.options[termComboBox.options.length] = new Option('-- Select Terms --',0);
			for(var key in termSelections){
				termComboBox.options[termComboBox.options.length] = new Option(termSelections[key],key);
			}
			cont.appendChild(termComboBox);	
			
			elements['termComboBox'] = termComboBox;
			
			//create the search button
			var submitButton = document.createElement('input');
			submitButton.type = 'submit';
			submitButton.value = 'Search';
			
			if(privateVars['searchButtonClassName'] != null){
				submitButton.className = privateVars['searchButtonClassName'];
			}
			
			submitButton.onclick = function(){
				//var domainName = 'diversity-dev.studyabroaddirectory.com';
				var domainName = 'studyabroad.diversityabroad.com';
				var countryIDParam =  elements['countryComboBox'].options.selectedIndex != 0 ? '/countryID/'+elements['countryComboBox'].options[elements['countryComboBox'].options.selectedIndex].value : '';
				var degreeIDParam = elements['degreeComboBox'].options.selectedIndex != 0 ? '/degprogID/'+elements['degreeComboBox'].options[elements['degreeComboBox'].options.selectedIndex].value : '';
				var termIDParam = elements['termComboBox'].options.selectedIndex != 0 ? '/termID/'+elements['termComboBox'].options[elements['termComboBox'].options.selectedIndex].value : '';
				var fullUrl ='http://'+domainName+'/da-listings.cfm'+ countryIDParam + degreeIDParam + termIDParam;
				window.location = fullUrl;
			}
			cont.appendChild(submitButton);			
		}
	}
	
	var GASearchWidget = window.GASearchWidget = new function(){
		var constVars = {
			'requestHandler' : 'http://studyabroad.diversityabroad.com'
		};
		var initVars = {'apiKey' : null, 'stage':'dev'};
		var selections = {
			'countries'	: {"104":"- Multi-Country","115":"Antigua & Barbuda","3":"Argentina","4":"Australia","5":"Austria","117":"Bahamas","118":"Barbados","7":"Belgium","8":"Belize","9":"Bermuda","10":"Bolivia","124":"Botswana","11":"Brazil","243":"British Virgin Islands","12":"Bulgaria","128":"Cambodia","129":"Cameroon","13":"Canada","14":"Caribbean","15":"Chile","16":"China","17":"Costa Rica","98":"Croatia","20":"Czech Republic","21":"Denmark","136":"Dominica","22":"Dominican Republic","23":"Ecuador","24":"Egypt","25":"El Salvador","27":"England","140":"Fiji","29":"Finland","31":"France","32":"Germany","33":"Ghana","34":"Greece","144":"Grenada","35":"Guatemala","219":"Hawaii (USA)","109":"Honduras","37":"Hungary","38":"Iceland","39":"India","40":"Indonesia","41":"Ireland","42":"Israel","43":"Italy","45":"Jamaica","46":"Japan","47":"Jordan","48":"Kenya","152":"Kiribati","154":"Laos","53":"Luxembourg","160":"Macedonia","161":"Madagascar","54":"Malaysia","164":"Mali","55":"Malta","57":"Mexico","171":"Mongolia","1119":"Montserrat","58":"Morocco","59":"Namibia","60":"Nepal","61":"Netherlands","62":"New Zealand","63":"Nicaragua","64":"Niger","65":"Northern Ireland","66":"Norway","177":"Oman","67":"Panama","68":"Peru","70":"Poland","71":"Polynesia","72":"Portugal","75":"Russia","183":"Rwanda","211":"Samoa","77":"Scotland","78":"Senegal","1510":"Serbia","79":"Singapore","80":"South Africa","49":"South Korea","82":"Spain","186":"St. Vincent & Grenadines","83":"Sweden","84":"Switzerland","85":"Syria","218":"Tahiti","86":"Taiwan","108":"Tanzania","87":"Thailand","202":"Trinidad & Tobago","203":"Tunisia","89":"Turkey","206":"Uganda","91":"United States","242":"US Virgin Islands","93":"Venezuela","94":"Vietnam","95":"Wales"},
			'terms' : {"6":"Academic Year","1":"Fall","10":"May Term","2":"Spring","3":"Summer","7":"Throughout the year","5":"Trimester","4":"Winter"},
			'degrees' : {"2":"Accounting","443":"Acting","3":"Admin (Health Services)","4":"Admin (Hospitality, Sports)","5":"Admin (Recreation, Parks)","6":"African Studies","145":"African-American Studies","7":"Agricultural Economics","8":"Agricultural Sciences","161":"Agriculture","135":"Agronomy","415":"Air Quality","183":"American Studies","241":"Animal Science","9":"Anthropology","163":"Applied Science","109":"Arabic","10":"Archaeology","11":"Architecture","165":"Area\/Ethnic Studies","13":"Art History","12":"Art\/Fine Arts","146":"Arts","167":"Asian and Asian American Studies","14":"Asian Studies","15":"Astronomy\/Astrophysics","417":"Atmospheric Chemistry","364":"Australian Studies","169":"Aviation\/Aerospace","16":"Biochemistry","253":"Bioengineering","17":"Biology (General)","18":"Biomedical Sciences","267":"Biotechnology","19":"Botany","419":"Business","20":"Business Admin. & Mngmt.","171":"Business Management","129":"Business Studies Grad Level","261":"Chemical & Process Engineering","21":"Chemistry","104":"Chicano Studies","22":"Chinese Language","367":"City and Regional Planning","173":"Classical Civilization","125":"Classical Studies","90":"Comm. (Radio, TV, & Film)","23":"Comm. Science & Disorders","24":"Communications","257":"Community Service","25":"Comparative Literature","381":"Comparative Public Administration","177":"Computer Electronics","179":"Computer Information Systems","181":"Computer Programming","26":"Computer Science \/ IT","27":"Conflict Studies","185":"Conservation and Preservation","133":"Continuing Education","28":"Counseling","29":"Creative Writing","30":"Criminal Justice \/ Corrections","383":"Criminology","112":"Culinary Arts","121":"Culture","136":"Dairy Science","385":"Dance","187":"Dentistry","115":"Design","119":"Development Studies","401":"Diplomatic Outreach","403":"Domestic and Legal Policy","421":"Drawing","369":"Earth Sciences","191":"East Asian Studies","31":"Ecology","32":"Economics","33":"Education","435":"Electronics","371":"Engineering","35":"Engineering (Chemical)","140":"Engineering (Civil)","123":"Engineering (Computer)","122":"Engineering (Electrical)","34":"Engineering (Mechanical)","124":"English","36":"English as a Second Language","107":"English Literature","37":"Entomology","38":"Environmental Management","423":"Environmental Management Systems \/ Policy","425":"Environmental Risk","40":"Environmental Sci. (Atmosph.)","42":"Environmental Studies","189":"Ethnic Studies","373":"European Studies (includes Politics)","43":"Family & Home Studies","116":"Fashion Design","193":"Feminist, Gender, and Sexuality Studies","144":"Field-Study","427":"Film","138":"Filmmaking","44":"Finance","45":"Food Science and Nutrition","195":"Foreign Language","46":"Forestry","47":"Fourth World Studies","48":"French","118":"Furniture Design","105":"Geography","50":"Geology","49":"German","405":"Global Jewish Policy","197":"Government","51":"Graphic Design","199":"Health Administration","52":"Health Sciences","134":"High School Program","53":"History","54":"Horticulture \/ Floriculture","151":"Hospitality","55":"Human Res. Management","407":"Human Rights Advocacy","56":"Humanities","205":"Iberian Studies","137":"Illustration\/Animation","442":"Independent Study","152":"Industrial Design","265":"Information Studies","57":"Information Systems","120":"Intensive Language","58":"Interdisciplinary","117":"Interior Design","153":"International Business","409":"International Policy and Diplomacy","59":"International Relations","60":"Internship Programs","411":"Interreligious \/ Interethnic Relations","126":"Irish Studies","61":"Italian","113":"Japanese","444":"Jewelry Design","62":"Jewish Studies","111":"Journalism \/ Broadcasting","63":"Kinesiology\/Exercise Science","64":"Labor & Industrial Relations","65":"Landscape Architecture","69":"Languages \/ Linguistics","106":"Latin American Studies","155":"Law","387":"Law Enforcement","365":"Leadership","389":"Lecturing \/ Research","66":"Legal Studies","150":"Leisure Study","67":"Liberal Arts","68":"Library & Information Science","207":"Library Sciences","114":"Literature","245":"Management","243":"Management Information Systems","209":"Marine Biology","70":"Marine Science","71":"Marketing, Ad., & PR","72":"Mathematics","375":"Media and Cultural Studies","413":"Media Relations","110":"Medicine","211":"Medieval Studies","41":"Meteorology","108":"Middle Eastern Studies","213":"Molecular Biology","73":"Museum Studies","74":"Music","131":"Music - Vocal Performance","215":"Musical Theater","217":"Natural Resources","219":"Natural Sciences","247":"Network Administration","221":"Neuroscience and Behavior","75":"Nursing","399":"Nutrition","76":"Occupational, Environ. Health","132":"Opera","377":"Optometry and Vision Sciences","446":"Organizational Behavior","130":"Oriental Medicine","429":"Painting","128":"Peace Studies","77":"Performance Design","78":"Pharmaceuticals","79":"Philippine Studies","80":"Philosophy","81":"Photography","82":"Physical Therapy","83":"Physics","225":"Plant Sciences","450":"Playwriting","84":"Political Science\/Politics","85":"Portuguese","86":"Pre-Law","87":"Pre-Med","88":"Psychology","227":"Public \/ Community Service Sciences","89":"Public Admin, Public Policy, Govt","249":"Public Health","391":"Public Management","263":"Pure Science","451":"Recorded Music","141":"Refugee Studies","91":"Religious Studies","437":"Research Study","445":"Restoration\/Conservation","229":"Romance Studies","92":"Russian & Slavic Studies","231":"Russian and East European Studies","233":"Russian Language and Literature","251":"Science","452":"Screenwriting","431":"Sculpture","393":"Social Policy","93":"Social Sciences","94":"Social Work","95":"Sociology","96":"Spanish","235":"Spanish Literature","447":"Sports","448":"Sports Economics\/Management","127":"Sports Science","97":"Statistics","143":"Student Trips (non-credit)","255":"Studio Arts","158":"Sustainable Development","142":"Swahili","98":"Technology","439":"Telecommunications","147":"TESOL","148":"Theater","99":"Theater, Drama, Dance","100":"Theology","237":"Town and Country Planning","149":"Travel \/ Tourism","433":"Tropical Biology","397":"TV and Media Production","395":"U.S. Studies ","223":"Unrestricted \/ Other","101":"Urban & Regional Planning","154":"Veterinary Medicine\/Science","139":"Visual Arts","156":"Web Design","102":"Women's Studies","103":"Zoology & Wildlife Sciences"}		};
		this.init = function(params){
			for(var prop in params){
				if(typeof initVars[prop] == 'undefined'){
					alert('Error! Undefined initialization variable [' + prop + '] for GASearchWidget!');
					return 0;
				}
				initVars[prop] = params[prop];
			}
		}
		this.create = function(params){
			return new __constructor(params);
		}		
		this.getSelection = function(selectionType){
			return selections[selectionType];
		}
	}
})();