/**
 * Remote_Search javascript class
 */

/**
 * Create a Syn.Remote_Search component instance
 * @constructor
 */
Syn.Remote_Search = Syn.Component.extend (
{
	/**
	 * Initialize the component class. This is called automatically by the default constructor.
	 * @member Syn.Remote_Search
	 *
	 * @param {Object} config The configuration data structure
	 */
	init: function(config)
	{
		this._super(config);
		// Bind mouseover event to sponsored links "li" element.
		$('.serp_sponsored ol li').bind('mouseover', function(e){
			$(this).attr('class', 'on');
		});

		// Bind mouseout event to sponsored links "li" element.
		$('.serp_sponsored ol li').bind('mouseout', function(e){
			$(this).attr('class', 'off');
		});

		for (var i=1; $('#ad'+i).length; i++)
		{
			$('#ad'+i).connect('click',this,'launchURL');
		}

		// If there are no sponsored results, hide the sponsored div.
		if ($('#ad1').length == 0)
		{
			$('.serp_sponsored').css('display', 'none');
		}

	},

	/**
	 * Event Handler when page number is clicked
	 * @member Syn.Remote_Search
	 */
	launchURL: function(elmt,ev)
	{
		if ($(elmt).find('a').attr('target') == "_blank")
		{
			window.open($(elmt).find('a').attr('href'));
		}
		else
		{
			window.location = $(elmt).find('a').attr('href');
		}
	}
});