var RiskWidget = {

	width: 			300,
	results_height:	130,		
	IFrameObj: 		false,
	__URL: 			'http://www.riskcareers.com',
	query: 			'lawyer',
	heading: 		'Job Search',
	keyword: 		'keywords',
	results_head: 		'top jobs',

	settings: function(settings)
	{
		
		settings = settings || false;
		
		if(settings == false) return 0;
		
		this.width = settings.width || this.width;
		this.query = encodeURIComponent(settings.query) || this.query;
		this.heading = settings.heading || this.heading;
		this.keyword = settings.keyword || this.keyword;
		this.results_head = settings.results_head || this.results_head;
		this.results_height = settings.results_height || this.results_height;
	},

	display: function()
	{
		if(this.width < 150){alert('Sorry but min width is 150px'); return false;}
		
		this.css();
		this.html();
	},
	
	doRequest: function(form)
	{
		var query = document.getElementById('RiskWidget_q');
		
		if(query.value == this.keyword || query.value == '')
		{
			alert('Please provide a query');
			form.action = 'javascript:void(0)';
			form.target = '_top';
			return 0;
		}
		else
		{
			form.action = this.__URL+'/results';
			form.target = '_blank';
			return 1;
		}
	},
	
	checkKeywordFocus: function(elem)
	{
		if(elem.value == this.keyword) elem.value = '';
	},
	
	checkKeywordBlur: function(elem)
	{
		if(elem.value == '') elem.value = this.keyword;
	},
	
	handleResponse: function(json) 
	{
		document.getElementById('riskwidget_button').value = 'Search';
		alert(json);
	},
	
	html: function()
	{
		document.write(
			'<div id="riskcareerwidget">'+
			'<h2>'+
			'<span id="topleft"></span>'+
			'<span id="topright"></span>'+
				this.heading+
			'</h2>'+
			'<div id="hr_cont"><div id="hr"></div></div>'+
			'<div id="riskcareerwidget_cont">'+
				'<div id="search_box">'+
					'<form action="javascript:void(0);" method="get" onsubmit="RiskWidget.doRequest(this);"><span id="zoom"></span>'+
					'<input type="text" onblur="RiskWidget.checkKeywordBlur(this);" onfocus="RiskWidget.checkKeywordFocus(this);" value="'+this.keyword+'" name="keywords" id="RiskWidget_q" />'+
					'<input type="submit" id="riskwidget_button" value="Search" />'+
					'<div class="clear"></div></form>'+
				'</div>'+
				'<div id="risk_logo"><a href="http://www.riskcareers.com" title="Riskcareers.com logo and link to the site"><img src="'+this.__URL+'/api/images/widget_logo.gif" alt="Riskcareers.com logo and link to the site" /></a></div>'+
			'</div>'+
			'<div id="riskcareerwidget_bottom">'+
				'<span id="bottomleft"></span>'+
				'<span id="bottomright"></span>'+
			'</div>'+
		'</div>'
		);
	},
	
	css: function()
	{
		document.write(
		'<style tyupe="text/css">'+
			'#riskcareerwidget{position: relative; width: '+this.width+'px;}'+
			'#riskcareerwidget .clear{overflow: hidden; clear: both;}'+
			'#riskcareerwidget h2{font-family: Arial; font-size: 12px; color #000; padding: 7px; border-top: 1px solid #dcdcda; border-left: 1px solid #dcdcda; margin: 0; background:#efefef url('+this.__URL+'/api/images/right-border.gif) repeat-y right; font-weight: normal}'+
			'#riskcareerwidget h2 span#topleft{display: block; width: 5px; height: 4px; position: absolute; left: 0; top: 0; background: url('+this.__URL+'/api/images/topleft.gif) no-repeat;}'+
			'#riskcareerwidget h2 span#topright{display: block; width: 8px; height: 7px; position: absolute; right: 0; top: 0; background: url('+this.__URL+'/api/images/topright.gif) no-repeat;}'+
			
			'#riskcareerwidget div#hr_cont{border-left: 1px solid #dcdcda; background:#fff url('+this.__URL+'/api/images/right-border.gif) repeat-y right; padding-left: 0px; padding-right: 3px; height: 2px; overflow: hidden; margin: 0;}'+
			'#riskcareerwidget div#hr{border-top: 1px solid #8dc53e; overflow: hidden; margin: 0; padding: 0;}'+
			
			'#riskcareerwidget div#riskcareerwidget_cont{position: relative; width: '+(this.width-18)+'px; padding: 7px; padding-right: 10px; border-left: 1px solid #dcdcda; background: #fff url('+this.__URL+'/api/images/right-border.gif) repeat-y right;}'+
			'#riskcareerwidget div#riskcareerwidget_cont #search_box{overflow: hidden; display: block !important; height: 20px; padding-top: 5px; border-bottom: 1px dotted #cacaca; padding-bottom: 15px;}'+
			'#riskcareerwidget div#riskcareerwidget_cont #search_box input#RiskWidget_q{float: left; width: '+(this.width-110)+'px; margin: 0; font-size: 12px; font-family: Arial; padding: 3px; padding-left: 21px; background: #fff url('+this.__URL+'/api/images/input_bg.gif?1) no-repeat; border: 1px solid #a0a0a0; border-bottom: 1px solid #e2e2e2}'+
			'#riskcareerwidget div#riskcareerwidget_cont #search_box #riskwidget_button{width: 65px; float: left; height: 23px; margin:0; border: 0px; background: #4f4c4d; font-size: 12px; color: #fff; font-family: Arial;}'+
			
			'#riskcareerwidget div#riskcareerwidget_cont p{color: #000; font-family: Arial; font-size: 12px; margin: 7px 1px 5px 1px; font-weight: normal;}'+
			'#riskcareerwidget div#riskcareerwidget_cont ul{list-style-image: url('+this.__URL+'/api/images/list-style-image.gif); margin: 0; padding: 0; padding-left: 17px;}'+
			'#riskcareerwidget div#riskcareerwidget_cont ul li{margin: 0; padding: 0;}'+
			'#riskcareerwidget div#riskcareerwidget_cont ul li a{font-size: 12px; margin: 0; padding: 0; font-family: Arial; color: #3b7e8c; font-weight: bold; text-decoration: none;}'+
			
			'#riskcareerwidget div#riskcareerwidget_bottom{position: relative; background: #fff url('+this.__URL+'/api/images/bottom-border.gif) repeat-x top; background-position: 0 4px; overflow: hidden; height: 17px; margin: 0; padding: 0;}'+
			'#riskcareerwidget div#riskcareerwidget_bottom span#bottomleft{display: block; width: 7px; height: 7px; position: absolute; left: 0; top: 0; background: url('+this.__URL+'/api/images/bottomleft.gif) no-repeat;}'+
			'#riskcareerwidget div#riskcareerwidget_bottom span#bottomright{display: block; width: 7px; height: 7px; position: absolute; right: 0; top: 0; background: url('+this.__URL+'/api/images/bottomright.gif) no-repeat;}'+
			'#riskcareerwidget div#riskcareerwidget_cont #risk_logo{clear: both; text-align: right; padding-top: 10px;}'+
			'#riskcareerwidget div#riskcareerwidget_cont #risk_logo a{border:0;}'+
			'#riskcareerwidget div#riskcareerwidget_cont #risk_logo a img{border:0;}'+
		'</style>'
		);
	}
}