//function to fade in or out the basket on
//had to use an element not actually in the top nav as it threw out IE
//value for left by the margin size..???
function mytogglebasket(obj){					  
	myFx = new Fx.Style(obj, 'opacity', {duration: 300});
	if (obj.getStyle('display') == 'none'){
		obj.style.display = '';
		obj.style.top = ($('button_basket').getTop() ) + "px";
		obj.style.left = ($('topmenu_container').getLeft() + 700) + "px";
		myFx.options.duration = 250
		myFx.start(0,1);
	}
	else if (obj.getStyle('opacity') == '0') {
		obj.style.left = $('topmenu_container').getLeft() + 700 + "px";
		myFx.options.duration = 250
		myFx.start(0,1);
		return false
		//myFader = new Fx.Style(obj, 'opacity', {duration: 300}).start(0,1);
	} else {
		myFx.options.duration = 1000
		myFx.start(1,0);
		//myFader = new Fx.Style(obj, 'opacity', {duration: 1000}).start(1,0);
		return false
	}
					  
}

var fixedfooterscroll //defined here so it can be set up in the domready function but still be available


window.addEvent('domready', function(){


	fixedfooterscroll = new Fx.Style('openbasket', 'bottom', {duration:500, transition: Fx.Transitions.Quad.easeOut});


	$$('.toggling').addEvent('click', function(e) {
	
	/*this function will act on the click event of any element
	with the class name of 'toggling'
	ensure the element to be toggled has the same ID
	as the clicked element prefixed with 'open_'  
	
	If unique IDs are required for two or more clickable elements
	to act on ONE action element then suffix the clicked ID with ':whatever'
	the suffix will be removed
	
	If you wish to control the behaviour of the toggle add
	|hide |show to the end and it will hide or show or default to toggle if nothing is there
	
	If you wish to define that it is a visibility rather than a display then put |visibility
	otherwise it will default to block
	*/
	
	//e = new Event(e).stop();
	
	//create the text string for the clicked element
	//IE doesnt have target Mozilla doesnt have srcElement
	
	var tgt = e.target || e.srcElement; // IE doesn't use .target
	var elClickedstr = tgt.id;
	
	//this will find any | so we can chop it off to get the actioned element part of the string
	pos = elClickedstr.indexOf(':');
	
	//capture that ID as an object
	if (pos !=-1){el=$("open_" + elClickedstr.substring(0,pos));}
	
	else {el=$("open_" + elClickedstr);}
	
	//also want to add in a switch to say if it should hide|show|toggle
	if (elClickedstr.indexOf('visibility') != -1) {
							 
		if (elClickedstr.indexOf('hide') != -1) {el.style.visibility = 'hidden';}
		else if (elClickedstr.indexOf('show') != -1) {el.style.visibility = 'visible';}
		else {el.style.visibility = (el.style.visibility == 'hidden') ? 'visible' : 'hidden';}//just toggle it 
	}
	else {

		if (elClickedstr.indexOf('hide') != -1) {el.style.display = 'none';}
		else if (elClickedstr.indexOf('show') != -1) {el.style.display = 'block';}
		else {el.style.display = (el.style.display == 'none') ? 'block' : 'none'; }//just toggle it 
	};

	
							


	});



//now need to add an event for all class toggle baskets

$each($$('.togglebasket'), function(el){
	 //so if there is an rel= in the link AND (&&) el.rel.test(regular expression check)
		el.onclick = mytogglebasket.pass($('basketcontent')); //sets up an event so that if there is an onclick it runs this function
	
});


//order details rollover

$each($$('.orderdetails'), function(el){
	 //so if there is an rel= in the link AND (&&) el.rel.test(regular expression check)
		el.addEvent('click', fncOrderDetails.pass([el.id,1]));
		//el.addEvent('mouseleave', fncOrderDetailsHide.pass(el.id,0));
});


//adds a visual clue to focusing
$each($$('input[type=text]'), function(el){
							
el.addEvent('focus', function(e) {
	el.setStyle('background-color','#ffffdd');
							  });

el.addEvent('blur', function(e) {
	el.setStyle('background-color','');
							  });


});

//adds a visual clue to psuedo js links
$each($$('.psuedolink'), function(el){
	
	el.addEvent('mouseenter', function(e) {
		el.setStyle('color','#900');
	
	});
	el.addEvent('mouseleave', function(e) {
		el.setStyle('color','');
	});

});



// sets up the top menu movement

var szNormal = 66, szSmall  = 66, szFull   = 120;
 
var kwicks = $$("#topmenu .topmenulinks");
var fx = new Fx.Elements(kwicks, {wait: false, duration: 300, transition: Fx.Transitions.Back.easeOut});
kwicks.each(function(kwick, i) {
	kwick.addEvent("mouseenter", function(event) {
		var o = {};
		o[i] = {width: [kwick.getStyle("width").toInt(), szFull]}
		kwicks.each(function(other, j) {
			if(i != j) {
				var w = other.getStyle("width").toInt();
				if(w != szSmall) o[j] = {width: [w, szSmall]};
			}
		});
		fx.start(o);
	});
});
 
$("topmenu").addEvent("mouseleave", function(event) {
	var o = {};
	kwicks.each(function(kwick, i) {
		o[i] = {width: [kwick.getStyle("width").toInt(), szNormal]}
	});
	fx.start(o);
})

//end top menu




function myextrainfo(obj){
	obj.style.display = '';
}


}); //end of dom ready function


//URCHIN ANALYTICS
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

try {
var pageTracker = _gat._getTracker("UA-8824014-1");
pageTracker._trackPageview();
} catch(err) {}


