/*
	20090323 tomc
*//*
	.:: MENU NAV ROLLOVER ::.
*/
window.addEvent( 'domready', function(){

	// CHANGE THE THE BG OF THE TABLE FOR EFFECT //
	$('topMenu').setStyles({ 'background-image':'url(assets/graphics/w809/menu2-bg-over.gif)' });

	/*
		CREATE ROLL OVER FOR EACH CELL
	*/
	tds = $$('#topMenuTable td');
	tds.each(function( td, index ){
		
		var imgMar = 0;
		
		if( index > 0 )
			imgMar = '-20px';
			
		if( index == tds.length - 1 )
			imgMar = '-' + td.getPosition($('topMenu')).x + 'px';
		
		/*
			an absolute positioned image
			appears underneath the cell
		*/
		var e = new Element( 'div' );
		e.setStyles({
			position:'absolute',
			zIndex	:100,
			top		:0,
			left	:td.getPosition($('topMenu')).x + 'px',
			width	:td.getSize().x +'px',
			height	:td.getSize().y +'px',
			overflow:'hidden'
		});
		
		e.setProperty( 'html', '<img style="margin-left:'+imgMar+';" src="assets/graphics/w809/menu2-bg.gif" />' );
		e.inject( $('topMenu'), 'bottom' );
		
		
		/*
			IF THIS IS THE ACTIVE PAGE
			CHANGE MENU BG
			OR
			CREATE ROLL OVER EVENTS
		*/
		var aTag = td.getElements('a')[0];
		aTag.bgEl = e;
		if( window.location.pathname.contains( aTag.getProperty('href') ) ){
			aTag.bgEl.fade(0);
		} else {
			aTag.addEvents({
				mouseover:function(){ this.bgEl.fade(0); },
				mouseout:function(){ this.bgEl.fade(1); }
			});
		}
	});
	
	
	
	
	/*
		POSTCODE STRIP SPACES
	*/
	$('pcSearchForm').addEvent( 'submit', function(e){
		
		this.PostCodeSearch.value = String(this.PostCodeSearch.value).split(' ').join('');
		
		if( !checkPostCode( this.PostCodeSearch.value ) ){
			pcPopup( this.PostCodeSearch.value );
			return false;
		}
		
		return true;
		
	});
	
	
});

/*
	CREATE / DISPLAY POST CODE POPUP
*/
var pcFadInt = null;
var pcPopup = function( _pc ){

	$clear(pcFadInt);

	var sbEl = $('pcSearchBox');
	
	if( $('pcsearchpopup') ){
	
	} else {
		var div = new Element( 'div', {
			id:'pcsearchpopup',
			styles:{
				position:'absolute',
				zIndex:999,
				top: ( sbEl.getPosition().y - 8 ) +'px',
				left: ( sbEl.getPosition().x + 32 ) + 'px',
				opacity:0,
				padding:'8px 6px 8px 32px',
				border: '1px solid #a7a6aa',
				background:'#810020 url(grx/exclamation_diamond.png) no-repeat 10px 6px',
				color:'#ffffff'
			}
		});
		div.inject( $$('body')[0], 'top' );
	}
	
	
	var err = 'Please enter a postcode';
	if( _pc > '' )
		err = 'Please try again, &quot;' + _pc  + '&quot; is an invalid post code.<br /> You should enter your full post code. <br /> For example - ST18 5GN <br /> Thank you.';
	
	
	$('pcsearchpopup').setProperty('html',err);
	$('pcsearchpopup').fade(1);
	
	
	pcFadInt = function(){ $('pcsearchpopup').fade(0); }.delay(6000);

}















