/*-------------------------------------------------------------------------
CONTROLLER FUNCTION - ONLOAD
-------------------------------------------------------------------------*/
function init() {
	var preloaded = new Array();
	function preload_images() {
		for (var i = 0; i < arguments.length; i++){
			preloaded[i] = document.createElement('img');
			preloaded[i].setAttribute('src',arguments[i]);
		};
	};
	preload_images(
		'/favicon.ico'
	);
	
	externalLinks();

	//-- for IE6 but not IE7, Moz, Safari, Opera...
	if (typeof document.body.style.maxHeight == "undefined") {
		try {
		  document.execCommand('BackgroundImageCache', false, true);
		} catch(e) { /* unless it's not IE6... */ }
	} // if

	$$('.bvFadeLink').each(
		function(el) {
			el.fl = new Fx.FadeHoverLink(el,{duration:500});
		}
	);
	styleSearchForm();
}
window.onDomReady(init);
/*-------------------------------------------------------------------------
 Add hover to search form
-------------------------------------------------------------------------*/
function styleSearchForm() {
	if($$(".submit").length>0) {
		var s = $$(".submit");
		for(var i=0;i<s.length;i++){
			s[i].addEvent('mouseover', function(){this.src='/img/submit-over.gif';})	
			s[i].addEvent('mouseout', function(){this.src='/img/submit.gif';})	
		}
	}
}
/*-------------------------------------------------------------------------
 Externalise links
-------------------------------------------------------------------------*/
function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}
/*-------------------------------------------------------------------------
 Spam proof email script
-------------------------------------------------------------------------*/
function generateEmailLink(n,d) {
	var username = n;
	var hostname = d;
	var linktext = n+"@"+d;
	document.write("<a hr"+"ef=" + "mai"+"l" + "to:" + username +
	"@" + hostname + ">" + linktext + "</"+"a>")
}
/*-------------------------------------------------------------------------*/
/* Fade Hover script
/*-------------------------------------------------------------------------*/
Fx.FadeHoverLink = Fx.Style.extend({
    initialize: function(el, options) {
		options.wait = false;
        this.parent(el, 'opacity', options);
        this.set(0.01);
        this.element.addEvent('mouseenter', function() {
			if(!this.element.hasClass('on'))
			this.custom(0.01,1);
			}.bind(this) );
        this.element.addEvent('mouseleave', function() { 
		   if(!this.element.hasClass('on'))
		   this.custom(1,0.01); 
		   }.bind(this) );
    }
});
/*-------------------------------------------------------------------------*/
/* Fix Input Hover script
/*-------------------------------------------------------------------------*/
var ieHover = {
	start: function(){
		ieHover.doIt();
	},
	doIt: function(){
		inputList = $$('.input_text');
		inputList.each( function(i){
			i.addEvent('mouseover', function(){ i.addClass('ie_hover'); });
			i.addEvent('mouseout', function(){ i.removeClass('ie_hover'); });
			i.addEvent('focus', function(){ i.addClass('ie_focus'); });
			i.addEvent('blur', function(){ i.removeClass('ie_focus'); });
			}
		);
	}
};
window.addEvent('domready', ieHover.start);
/*-------------------------------------------------------------------------
 sIFR
-------------------------------------------------------------------------*/
var ag_book = {src: '/inc/flash/agbook_stencil.swf'};
sIFR.activate(ag_book);
sIFR.replace({ 
			 selector: '#left-home-content h1'
			 ,src: '/inc/flash/agbook_stencil.swf'
			,css: [
				  '.sIFR-root { color: #000000; text-transform: capitalize; }'
				  ,'em { font-style: normal; color: #F5CA00; }'
				]			 			 
			 });
sIFR.replace({ selector: '#right-home-content .home-box h2',src: '/inc/flash/agbook_stencil.swf',css: {'.sIFR-root': { 'color': '#000000', 'letter-spacing': 0, 'text-transform': 'capitalize' }},wmode: 'transparent'});

sIFR.replace({ selector: '#left-content h2',src: '/inc/flash/agbook_stencil.swf',css: {'.sIFR-root': { 'color': '#000000', 'letter-spacing': 0, 'text-transform': 'capitalize' }}
	,wmode: 'transparent'
    ,filters: {
      DropShadow: {
        knockout: false
        ,distance: 1
        ,color: '#CBCBCB'
        ,strength: 2
      }}});


sIFR.replace({ selector: '#right-content h1',src: '/inc/flash/agbook_stencil.swf',css: {'.sIFR-root': { 'color': '#000000', 'letter-spacing': 0, 'text-transform': 'capitalize' }},wmode: 'transparent'});
sIFR.replace({ selector: '#full-content h1',src: '/inc/flash/agbook_stencil.swf',css: {'.sIFR-root': { 'color': '#000000', 'letter-spacing': 0, 'text-transform': 'capitalize' }},wmode: 'transparent'});
