var siteAddr = location.protocol + '//' + location.host + '/';

/* Pre loaded images */
var imgPath = siteAddr + '_img/front_end/'; 
var preImgs = [
	imgPath + 'icons/plus_white.gif',
	imgPath + 'icons/minus_white.gif'
];
var preImgLoads = new Asset.images(preImgs);

/* vars for timer */
var i         = 0;
var timeLimit = 1;
var timer;
var hoverEle;
var eGlob;
/* vars */


window.addEvent('domready', function(){
	//Call to function to clear input areas with a class of textarea
	if($$('.textarea')){
		$$('.textarea').addEvent('focus', function(){inputClear(this.id);});
	}
	
	var scrollCount = $$('.smoothAnchor').length;
	if(scrollCount > 0){
		var mySmoothScroll = new Fx.SmoothScroll({duration:1000, links: '.smoothAnchor', wheelStops: false});
	}
	
	if(Browser.Engine.trident4 && $('seoblock')){
		$('seoblock').setStyle('bottom', '0px');
	}
	if($('seoblock')){
		var seoSize = $('seoblock').getSize();
		$('container').setStyle('padding-bottom', parseInt(seoSize.y));
		$('seoblock').setStyle('left', '0');
	}

	
	
	if($('tabblocks')){
		var tabTotal = $$('.specialLink').length;
		var tabcount = 1;
		var pauseTab = 1;
		var theTimer = 5000;
		
		var tabLoop = function(){
			showNextTabBlock('special_' + tabcount);
			//move the counter for the tabs up by one to ensure it moves to the next block
			tabcount++;
			if(tabcount > tabTotal){
				tabcount = 1;
			}	
		}
			
		var periodicalTab = tabLoop.periodical(theTimer, this);
		
		$$('.specialLink').addEvent('click', function(e){
			showTabBlock(this, e);
			$clear(tabcount);
			tabcount = this.id.replace('special_', '');
			$clear(periodicalTab);
			periodicalTab = tabLoop.periodical(theTimer);
		});
		
	}
	var noClickCount = $$('.noClick').length;
	if(noClickCount > 0){
		$$('.noClick').addEvent('click', function(e){e.stop();});
	}

	
});

// function for clearing text boxes
function inputClear(id){
	// Get the value and title
	var inputValue = $(id).value;
	var inputTitle = $(id).title;
	if(inputValue == inputTitle){
		//Remove the default text and highlight the entry
		$(id).set('value', '');
		$(id).addClass('highon');
		// Check to see something has been entered
		$(id).addEvent('blur', function(){
			if($(id).value == ''){
				// Give the input its old value
				$(id).set('value', inputValue);
				// Remove the hihglight class if the title and value stays the same
				$(id).removeClass('highon');
			}
		});
	}
}

//function to set the visible block
function showTabBlock(ele, e){
	e.stop(); // stop the a tag
	var linkID =ele.id; // get the links id
	var cleanLink = linkID + '_block'; // get the name of the ID to be revealed
	$$('.specialtabBlock').addClass('hide'); // apply a hide class to all the generic informational divs
	$(cleanLink).removeClass('hide'); // remove the hide class from the relevant div
	setSpecialTab(linkID)
}
function showNextTabBlock(relBlock){
	var relBlockName = relBlock + '_block';
	$$('.specialtabBlock').addClass('hide'); // apply a hide class to all the generic informational divs
	$(relBlockName).removeClass('hide'); // remove the hide class from the relevant div
	setSpecialTab(relBlock);
}

// function for colouring tabs up correctly
function setSpecialTab(linkID){
	$$('.specialnav a').removeClass('curtab');
	$(linkID).addClass('curtab');
}


// General Timer
//timer function to increment seconds and trigger after timeLimit seconds
function delTimer(e, ele){
    hoverEle = ele;
    eGlob = e;
    i=i+1
    if(i > timeLimit){
        showDelInfo(e, hoverEle)
        stopTimer()
    }else{
        timer=setTimeout("delTimer(eGlob, hoverEle)",500);
    }
}
//cancel the timer
function stopTimer(){
    clearTimeout(timer);
}



