var tjsMap = {
		
	__API_URL: 'http://www.twitjobsearch.com/api/job-map',
	__IMAGES_URL: 'http://www.twitjobsearch.com/widgets/images',
	__URL:	'http://www.twitjobsearch.com',
	__KEYWORD: 'What do you want to do?',
	__LOGO: 'tjsMap-logo.gif',
	
	height: (578-125),
	width: 288,
	location: 'United Kingdom',
	zoom: 2,
	
	settings: function(settings)
	{
		settings = settings || false;
		if(settings == false) return 0;
		
		this.width 	= settings.width-2 || this.width;
		this.height = settings.height-127 || this.height;
		this.location = settings.location || this.location;
		this.zoom = settings.zoom || this.zoom;
	},
	
	checkKeywordFocus: function(elem)
	{
		if(elem.value == this.__KEYWORD) elem.value = '';
	},
	
	checkKeywordBlur: function(elem)
	{
		if(elem.value == '') elem.value = this.__KEYWORD;
	},
	
	doRequest: function(form)
	{
		var query = document.getElementById('tjsMap_q');
		
		if(query.value == this.__KEYWORD || query.value == '')
		{
			alert('Please enter a job search.');
			form.action = 'javascript:void(0)';
			form.target = '_top';
			return 0;
		}
		else
		{
			form.action = this.__URL+'/search';
			form.target = '_blank';
			return 1;
		}
	},
		
	display: function()
	{		
		
		if(this.width < 290 && this.width > 182)
		{
			this.__LOGO = 'tjsMap-logo-small.gif'
		}
		else if(this.width < 183)
		{
			alert('Sorry but minimum supported width is 185');
			return 0;
		}
		
		if(this.zoom < 1 || this.zoom > 17)
		{
			alert('Sorry but zoom range can be between 1 and 17 only');
			return 0;
		}
		
		this.html();
	},
	
	html: function()
	{
		this.location = this.location.replace(/ /g,'---');
		this.location = encodeURIComponent(this.location);
		this.location = this.location.replace(/---/g,'+');
		
		document.write(
		'<div style="background: #999999; height: '+(this.height+125)+'px; width: '+this.width+'px; border: 1px solid #333333;">'+
			'<div style="text-align: center; border-bottom: 1px solid #333333; height: 55px; background: #999999;"><a title="TwitteJobSearch - A Job Search Engine for Twitter." href="http://www.twitterjobsearch.com/" target="_blank"><img src="'+this.__IMAGES_URL+'/'+this.__LOGO+'" alt="TwitterJobSearch" style="border: 0;" /></a></div>'+
			'<iframe scrolling="no" src="'+this.__API_URL+'?domain='+location.host+'&width='+this.width+'&height='+this.height+'&location='+this.location+'&zoom='+this.zoom+'" frameBorder="0"'+
			'style="overflow: hidden; height: '+this.height+'px; width: '+this.width+'px; border: 0px; padding: 0; margin: 0;"></iframe>'+
			'<div style="text-align: center; padding: 5px; height: 58px; background: #999; border-top: 1px solid #333333;">'+
				'<form onsubmit="tjsMap.doRequest(this)" target="_blank" style="border: 0; margin:0; padding: 0;" action="javascript:void(0)" method="get"><input id="tjsMap_q" type="text" name="q" value="'+this.__KEYWORD+'" onclick="tjsMap.checkKeywordFocus(this)" onblur="tjsMap.checkKeywordBlur(this)" style="width: '+(this.width-20)+'px; position: static; border: 1px solid #333; padding: 3px; font-size: 14px; font-weight: bold;" />'+
				'<input type="submit" value="Search" style="position: static; padding: 0; margin: 0; background: #33ccff url('+this.__URL+'/images/button_bg1.gif) top repeat-x; border: 0px; font-family: Arial;'+
				'font-weight: normal; font-size: 14px; font-weight: bold; color: #fff; cursor: pointer; padding: 4px; margin: 0;'+
				'color: #fff; border: 0px solid #33ccff; border-left: 0px; margin-top: 3px;" /></form>'+
			'</div>'+
		'</div>'
		);
	}
			
}