﻿

	
CB.iQSB = function(){

			var ddlCities;
			var ddlCountries;
			return{

				//Attributes 
				topC1Cities: new Array(),
				topC2Cities: new Array(),
				topC3Cities: new Array(),
				topC1Code:'',
				topC2Code:'',
				topC3Code:'',
				countryDropDownlistID :'',
				cityDropDownlistID :'',
				txtcity :'',
				txtKeywords : '',

//eventHandlers 

				addOnChangeEvent:function(handler){
						this.addEventListener(window,'load',handler);
				},



//Functions     
                
				setContent:function() {

			       var _CountryCID = CB.e(CB.iQSB.countryDropDownlistID);
			       if(_CountryCID !=null){
				        CB.iQSB.populateTopCities(CB.e(CB.iQSB.countryDropDownlistID).value);}

				},

				setSuggestionContent: function () {
				    CB.e(CB.iQSB.txtKeywords).disabled = true;
				    CB.SuggestionTextbox.setupTextbox(CB.e(CB.iQSB.txtKeywords), CB.e('iQSBlabelKeywords').innerHTML, CB.e('sbmt'));
				    CB.e(CB.iQSB.txtKeywords).disabled = false;
				    
                    CB.e(CB.iQSB.txtcity).disabled = true;
					CB.SuggestionTextbox.setupTextbox(CB.e(CB.iQSB.txtcity), CB.e('iQSBlabelLocation').innerHTML, CB.e('sbmt'));
					CB.e(CB.iQSB.txtcity).disabled = false;
                },

				populateTopCities:function(selectedCountry)
				{       
					ddlCities = CB.e(CB.iQSB.cityDropDownlistID + 'ddlTopCities');
					if(selectedCountry.length>0){
					    if (selectedCountry == "BE"){
					        CB.iQSB.hideLocationTxt();
					        CB.iQSB.showLocationState();
					        CB.e(CB.iQSB.txtcity).value ='';
					    }
					    else if (selectedCountry == "DE"){
					        CB.iQSB.hideTopCitiesDD();
					        CB.iQSB.showLocationTxt();
					        CB.iQSB.hideLocationState();
					        if(document.getElementById('cblocexDE')) {
										document.getElementById('cblocexDE').style.display = "block";
					        }
					        if(document.getElementById('cblocexNL')) {
						        document.getElementById('cblocexNL').style.display = "none";
					        }
					        if(document.getElementById('cblocexFR')) {
						        document.getElementById('cblocexFR').style.display = "none";
					        }
					        if(document.getElementById('cblocexOther')) {
					       		document.getElementById('cblocexOther').style.display = "none";
					        }
					        if(document.getElementById('ctrlSearch_MXJobSrchCriteria_States')) {
					        	document.getElementById('ctrlSearch_MXJobSrchCriteria_States').value = '';
					        }
					        if(document.getElementById(CB.iQSB.txtcity)) {
					        	document.getElementById(CB.iQSB.txtcity).value ='';
									}
					    }
					    else if (selectedCountry == "NL"){
					        CB.iQSB.showLocationTxt();
					        CB.iQSB.hideLocationState();
					        if(document.getElementById('cblocexDE')) {
						        document.getElementById('cblocexDE').style.display = "none";
									}
					        if(document.getElementById('cblocexNL')) {
						        document.getElementById('cblocexNL').style.display = "block";
									}
					        if(document.getElementById('cblocexFR')) {
						        document.getElementById('cblocexFR').style.display = "none";
									}
					        if(document.getElementById('cblocexOther')) {
						        document.getElementById('cblocexOther').style.display = "none";
									}
					        if(document.getElementById('ctrlSearch_MXJobSrchCriteria_States')) {
						        document.getElementById('ctrlSearch_MXJobSrchCriteria_States').value = '';
									}
					        if(document.getElementById(CB.iQSB.txtcity)) {
						        document.getElementById(CB.iQSB.txtcity).value ='';
									}
					    }
					    else if (selectedCountry == "FR"){
					        CB.iQSB.showLocationTxt();
					        CB.iQSB.hideLocationState();
					        if(document.getElementById('cblocexDE')) {
										document.getElementById('cblocexDE').style.display = "none";
									}
					        if(document.getElementById('cblocexNL')) {
						        document.getElementById('cblocexNL').style.display = "none";
									}
					        if(document.getElementById('cblocexFR')) {
						        document.getElementById('cblocexFR').style.display = "block";
									}
					        if(document.getElementById('cblocexOther')) {
						        document.getElementById('cblocexOther').style.display = "none";
									}
					        if(document.getElementById('ctrlSearch_MXJobSrchCriteria_States')) {
						        document.getElementById('ctrlSearch_MXJobSrchCriteria_States').value = '';
									}
					        if(document.getElementById(CB.iQSB.txtcity)) {
						        document.getElementById(CB.iQSB.txtcity).value ='';
									}
					    }
						else if (selectedCountry == CB.iQSB.topC1Code && CB.iQSB.topC1Cities.length >0){
							CB.iQSB.hideLocationTxt(); 
							CB.iQSB.showTopCitiesDD(CB.iQSB.topC1Cities); 
						}
						else if (selectedCountry == CB.iQSB.topC2Code && CB.iQSB.topC2Cities.length > 0){
						    CB.iQSB.hideLocationTxt(); 
						    CB.iQSB.showTopCitiesDD(CB.iQSB.topC2Cities);						     
						}
						else if (selectedCountry == CB.iQSB.topC3Code && CB.iQSB.topC3Cities.length > 0 ){
						    CB.iQSB.hideLocationTxt(); 
						    CB.iQSB.showTopCitiesDD(CB.iQSB.topC3Cities); 
						}
						else {
	                        CB.iQSB.hideTopCitiesDD();
	                        CB.iQSB.showLocationTxt(); 
						}
					}

				},

                hideTopCitiesDD: function() { 
                    CB.e(CB.iQSB.txtcity).value ='';
					CB.e(CB.iQSB.cityDropDownlistID + 'ddlTopCities').options.length= 0 ;
					CB.e('divCityDDL').style.display='none'; 
					
                },
                
                showTopCitiesDD: function(topCities){
                    ddlCities.options.length = 0
					for(var i = 0 ;i < topCities.length ;i++)	{
						ddlCities[i]= new Option(topCities[i],topCities[i]);
					} 
					CB.e('divCityDDL').style.display=''; 
					CB.iQSB.populateCity(ddlCities[0].value);
                },
                
                showLocationTxt: function() { 
                    CB.e('divTxtLocation').style.display='block'; 
                },
                
                hideLocationTxt: function() { 
                 CB.e('divTxtLocation').style.display='none';
                }, 
             
				populateCity: function(city)
				{
					CB.e(CB.iQSB.txtcity).value ='';
					CB.e(CB.iQSB.txtcity).value = city; 
				},
				
				showLocationState: function() { 
                    CB.e('divDdlLocation').style.display='block'; 
                },
                
                hideLocationState: function() { 
                    CB.e('divDdlLocation').style.display='none'; 
                }


		};

}();

