(function () {
	
jQuery.noConflict();

var $ = jQuery;
var modalInserted = false;
var closeBtn = $( '<a />' ).attr( {
		'class': 'modal-close-btn'
	}).html( '&times;' );
var modal;




var IE = ( !!window.ActiveXObject && +( /msie\s(\d+)/i.exec( navigator.userAgent )[1] ) ) || NaN;


if ( IE < 8 ) {
	$( '.regional-buybtn' ).hover(
		function () {
			$( '.regional-buybtn-retailers', this ).addClass( 'hover' );
		},
		function () {
			$( '.regional-buybtn-retailers', this ).removeClass( 'hover' );
		}
	);
} 

$( '.regional-buybtn-retailers a' ).click(function ( e ) { 
	e.preventDefault();
	if ( modalInserted ) {
		return false;
	}	
	$.get( this.href, function ( data ) {
		var container = document.createElement( 'div' );
		container.innerHTML = $.trim( data );
		modal = container.firstChild;
		var inner = $( '.retailers-modal', modal ).get(0);
		inner.appendChild( closeBtn.get(0) );
		modal.style.top = $( window ).scrollTop() + 80 + 'px';
		document.body.appendChild( modal );
		modalInserted = true;
	});
});

$( '.modal-close-btn' ).live( 'click', function ( e ) {
	$( modal ).remove();
	if ( IE < 8 ) {
		$( '.regional-buybtn .regional-buybtn-retailers' ).removeClass( 'hover' );
	}
	modalInserted = false;
});

})()
