RUN4IT=(typeof RUN4IT=='undefined'?{}:RUN4IT);
RUN4IT.classes=(typeof RUN4IT.classes=='undefined'?{}:RUN4IT.classes);
RUN4IT.classes.Contact = function()
{
	if(!(this.contactLink = $('#contact-sub-nav')).length || !(this.miniContact = $('#mini-contact')).length) return;
	var _this = this;
	
	$(this.miniContact).append('<span class="arrow" />');
	this.miniContactClose = $('<span class="close" title="Close" />').bind('click', function() { $(_this.miniContact).toggle(false); });
	$(this.contactLink).hover(function() { $(_this.miniContact).toggle(true); });
	$(this.miniContact).toggle(false);
	$(this.miniContact).addClass('js');
	
	// Close the popup when clicking the close button
	$(this.miniContact).append(this.miniContactClose);
	// Close the popup onmouseout
	$(this.miniContact).mouseenter(function()
	{
		$(this).mouseleave(function(event)
		{
			if(!$(event.target).is('span.arrow'))
			{
				$(this).toggle(false);
			}
		});
	});
	// Close the popup when click on the background of the page (if onmouseout event didn't trigger)
	$('body').bind('click', function(event)
	{
		if(!$(event.target).parents('div#mini-contact').length && !$(event.target).is('div#mini-contact'))
		{
			$(_this.miniContact).toggle(false);
		}
	});
	
	if(Shine.browser.isIE && Shine.browser.ieVersion < 7) return;
	var test = document.body;
	if(!(typeof test.style.MozBorderRadius == 'undefined' && typeof test.style.WebkitBorderRadius == 'undefined' && typeof test.style.borderRadius == 'undefined')) return;
	
	$(this.miniContact).css({'padding-top': 0, 'width': '299px', 'border-style': 'none solid'});
	$(this.miniContact).css({'top': (parseInt($(this.miniContact).css('top')) + 18) + 'px'});
	$(this.miniContact).find('span.arrow').css({'top': '-22px'});
	$(this.miniContact).find('p').last().css({'margin': '0'});
	var corners = $('<span />').css({
		'position': 'absolute',
		'left': '-4px',
		'width': '331px',
		'height': '12px',
		'background': 'url(/templates/r4i-shop/images/global/mini-contact/corners.png) no-repeat'
	});
	var cornerTop = $(corners).clone(false).css({'top': '-12px', 'background-position': 'left top'});
	var cornerBottom = $(corners).clone(false).css({'bottom': '-12px', 'background-position': 'left bottom'});
	$(this.miniContact).append(cornerTop);
	$(this.miniContact).append(cornerBottom);
}
document.loadHooks=(typeof document.loadHooks=='undefined'?[]:document.loadHooks);
document.loadHooks.push(function(){new RUN4IT.classes.Contact();});
