var $j = jQuery.noConflict();

if (!TL) { var TL = {}; }
if (!TL.components) { TL.components = {}; }

TL.components.Search = function() {
    return {
            submit: function() {
                var tzOffset = -new Date().getTimezoneOffset();
                var searchString = $j.trim(document.getElementById('ctl02_ctl01_TXTQuery').value);
                
                if (searchString == '')
                {
                    alert('Search string is empty');
                }
                else
                {
                    location.href = '/site-info/search-results.aspx?&amp;lcid=9&amp;q=' + encodeURIComponent(searchString) + '&amp;t=' + tzOffset;
                }
            }
        }
}();

TL.components.YAF = function() {
	_IMGPATH = '/forum/themes/Gray/' ;
	return {
		init:function() {
			this.addCorners();
			this.addImageCorners();
		},
		
		addImageCorners:function() {
			$j('.yafnet #yafheader td:first').css('background','#FFF url('+_IMGPATH+'yafheader-left.gif) no-repeat left') ;
			$j('.yafnet #yafheader td:last').css('background','#FFF url('+_IMGPATH+'yafheader-right.gif) no-repeat right') ;
			$j('.yafnet .wrap-white').css('background','#FFF url('+_IMGPATH+'wrap-white-bottom.gif) no-repeat bottom left') ;
			$j('.yafnet .wrap-grey').css('background','#EDEDED url('+_IMGPATH+'wrap-grey-bottom.gif) no-repeat bottom left') ;
		},
		
		addCorners:function() {
			$j('.yafnet #topbar').cornerz({ radius: 12, background: '#F7F8F8' });
			$j('.yafnet .yafPageLink').each(function(){
				var color = '#F7F8F8';
				if ($j(this).parent().hasClass('wrap-grey')) {
					color = '#EDEDED';	
				}
				$j(this).cornerz({ radius: 10, background: color });										 
			});
			$j('.yafnet .wrap-white').cornerz({ radius: 12, background: '#EDEDED', corners:'tl tr' });
			$j('.yafnet .wrap-grey').cornerz({ radius: 12, background: '#F7F8F8', corners: 'tl tr' });
			
			
		}
	}
}();



$j(document).ready(function() {
	TL.components.YAF.init() ;
	
	
	$j.preload('.rollover', { find: '-off.', replace: '-over.' });
	$j('.rollover').hover(function() { this.src = this.src.replace('-off.', '-over.'); }, function() { this.src = this.src.replace('-over.', '-off.'); });
	
	$j('ul.sf-menu').superfish({autoArrows: false,dropShadows: false});
	
	// Add cornerz for Forum template
	$j('#login-search-box li.bg').cornerz({radius:3, background: '#FFFFFF' }) ;
	$j('.related-docs h2.bg').cornerz({radius:7, background: '#F7F8F8', corners:"tr tl"}) ;
	$j('.small-promo h2.bg, .popularTopics h2.bg, .related-items h2.bg, .external-links-small h2.bg').cornerz({radius:7, background: '#F7F8F8'}) ;
	$j('#content .page').cornerz({ radius: 15, background: '#F7F8F8' });
	
	
});
