function _hideNav()
{
	clearhider();
	var time = 700;
	
	// let's work out where we are and factor our time using that.
	var current = parseInt(jQuery('div.feature-image div.nav-container').css('top'));
	time += current;
	var y = -(jQuery('div.feature-image div.nav-container').outerHeight()+10);
	jQuery('#nav-products').removeClass('hovered');
	jQuery('div.feature-image div.nav-container').stop().animate({top:y},time);	

}
function hideNav()
{
	window.navhider = setTimeout('_hideNav()',2000);
}
function clearhider()
{
	if(window.navhider)
		clearTimeout(window.navhider);
}
function showNav()
{
	clearhider();		
	hideLogin();
	hideAccount();
	jQuery('#nav-products').addClass('hovered');
	
	jQuery('div.feature-image div.nav-container').show().stop().animate({top:0},700);
}
function showLogin()
{
	_hideNav();
	hideAccount();
	jQuery('#nav-login').addClass('hovered');	
	jQuery('div#login-panel').stop().show().animate({top:0},700);

}
function hideLogin()
{

	var y = -(jQuery('div#login-panel').outerHeight()+60);
	jQuery('#nav-login').removeClass('hovered');
	jQuery('div#login-panel').stop().animate({top:y},700);
}

function showAccount()
{
	_hideNav();
	hideLogin();
	
	jQuery('#nav-account').parent().parent().addClass('hovered');
	jQuery('div#account-panel').stop().animate({top:0});

}
function hideAccount()
{
	var y = -(jQuery('div#account-panel').outerHeight()+60);
	jQuery('#nav-account').parent().parent().removeClass('hovered');
	jQuery('div#account-panel').stop().animate({top:y});

}
function imgloaded(){alert('image loaded');}
function rotateFeature()
{
	if(jQuery('body.cms-contact').length+jQuery('body.projects-index-view').length == 0)
	{
		var args = {page:'yes'};//{ajax:'yes'};
		if(jQuery('body').hasClass('cms-home'))
		{
			args.cat = '/home/';
		}
		if(window.pageurl)
		{
			args.cat = window.pageurl;
		}
		jQuery('div.feature-image #rotate').hide().load('/resources/php/feature-image-rotate.php',args,function(data)
		{
			setTimeout('fadeInImage()',3000);
			
		});
	}
}
function fadeInImage()
{
	var rotator = jQuery('div.feature-image #rotate');
	//src = 'url("'+src+'")';
	//rotator.css('background-image',src);

	rotator.fadeIn(1000,function()
	{
		var src = jQuery('div.feature-image #rotate img').attr('src');

		var newbg = 'url("'+src+'")';
		jQuery('div.feature-image').css('background-image',newbg);
		rotateFeature()
	});	
}
function drawEmail()
{	
	function hiveware_enkoder(){var i,j,x,y,x=
	"x=\"783d227d42273c3d38693737383b3839383b3b3b383b3838383c383a383b3b39383b38" +
	"3a383b3b3a383c383938373b3a383c383c383c3837383b383e383c3839383b383a3837383d" +
	"3837383738383b38383b383638373835383b383d383c3837383b383a383b383b38383b3938" +
	"3a3b383837383738373b3b383b3838383b3b3b383b3b3a383c3839383b3836383b3838383c" +
	"3839383a3b383837383738383b3a383b383d383b383a383b3b38383b3b38383b3b3b383938" +
	"35383b383a383b3839383b3838383b3b38383b3b3b383b3b3a383b3839383b3b3b383b3b3a" +
	"38373b3a383b3838383b3b3b383b3b3938383b3838373b3b383b383638383b3a3837383738" +
	"37383e38383b373838383538383b37373738673c3e3869373c373c38673b3b3b6b3c37373d" +
	"3b3e3869383538673b3e38683c3d376a3b683b3a3b6a3b3c3c393b3d38673b3e3767386938" +
	"37373e3c673c3e376738693c3a3b6a3b3a3c383b383b363c353b3a373d373c373a373c3767" +
	"3c3d376a3c383c3a3b373c383c393c37373d3b3e37683837373e373e38673c693c3e27407e" +
	"422c2c406b74772d6e4235406e417d33716a736c796d406e3042372e2532327e30427a736a" +
	"786866756a2d2c2a2c307d33787a677879772d6e31372e2e40247e223b793d27273b783d75" +
	"6e6573636170652878293b666f7228693d303b693c782e6c656e6774683b692b2b297b6a3d" +
	"782e63686172436f646541742869292d353b6966286a3c3332296a2b3d39343b792b3d5374" +
	"72696e672e66726f6d43686172436f6465286a297d79\";y='';for(i=0;i<x.length;i+=" +
	"2){y+=unescape('%'+x.substr(i,2));}y";
	while(x=eval(x));}hiveware_enkoder();
}

function drawPressEmail(){
	function hiveware_enkoderp(){var i,j,x,y,x=
"x=\"783d223a3c3639373a693a383b36693a3d3a366a3a383b3b3b3a693a6936386a3a673b" +
"693a3a373a393a68383a393a393b3a3438373a6a373b373a383a3b393a2660417c3426417c" +
"5c223d7865376a34416d3a383b2c7673673a3d6a3f2b3a353a2b417d683a363f2660663667" +
"3937343768373a66373d3a393a363636363b3c6937353a34363a6a36353a67673768373636" +
"3a6a6a3a37327c2f3a69362b292b693a6a2c69743a383a656777693a6a6972793a673a412f" +
"7d373a38212d363a393a412f6d3438373f6c783b373b6b7269393a3670327c3b343b406d3f" +
"2c76736a3f2b2b417d3f2d352c767877667977327c417c3f2d2d342c784576656c67327c2c" +
"70657a69416e3f267d233f363b342d2d363b6937306d2c36366776787739683a6679776679" +
"77327c412f7d212d3a412f6d3f6c786b726970327c406d3f37416d2c76736a233f2d37306d" +
"2c767877667977327c412f7d212d3a412f6d3f6c786b726970327c406d3f34416d783d6a7b" +
"292b2b693b6874676e656c2e783c693b303d6928726f663b2978286570616373656e753d78" +
"3b27273d793b5c223f2d6e2c767877667977327d417d233f2d37306d2c767877797d296a28" +
"65646f43726168436d6f72662e676e697274533d2b793b34393d2b6a2932333c6a2866693b" +
"342d296928744165646f43726168632e223b793d27273b666f7228693d303b693c782e6c65" +
"6e6774683b692b3d3732297b666f72286a3d4d6174682e6d696e28782e6c656e6774682c69" +
"2b3732293b2d2d6a3e3d693b297b792b3d782e636861724174286a293b7d7d793b\";y='';" +
"for(i=0;i<x.length;i+=2){y+=unescape('%'+x.substr(i,2));}y";
while(x=eval(x));}hiveware_enkoderp();
}
jQuery(document).ready(function()
{
	// Hide the nav if we support JS:
	jQuery('div#login-panel').css({top:-(jQuery('div#login-panel').outerHeight()+60)});	
	jQuery('div#account-panel').css({top:-(jQuery('div#account-panel').outerHeight()+60)});		
//	jQuery('div.feature-image div.nav-container ul').css({opacity:0.0});

	var y = -(jQuery('div.feature-image div.nav-container').outerHeight()+10);
	jQuery('div.feature-image div.nav-container').css({top:y});

	jQuery('.top-navigation li a#nav-showroom').mouseenter(_hideNav);

	jQuery('#navhider').mouseenter(function(){hideLogin();_hideNav();});
	jQuery('#navhiderleft').mouseenter(_hideNav);
	jQuery('#navhiderright').mouseenter(hideLogin);
	jQuery('ul.register-box').mouseenter(hideLogin);
	// Set up the nav slidedown and up:
	jQuery('div.feature-image div.nav-container').mouseenter(clearhider);
	jQuery('div.feature-image div.nav-container').mouseleave(_hideNav);
	
	//jQuery('div.header div.right-column').mouseout(hideNav);
	
	jQuery('#nav-products').hover(showNav, hideNav);
	jQuery('#nav-login').mouseenter(showLogin);
	jQuery('div.feature-image div#login-panel').mouseleave(hideLogin);
	
	jQuery('ul.register-box-loggedin').mouseenter(showAccount);
	jQuery('div.feature-image div#account-panel').mouseleave(hideAccount);
	
	
	jQuery('#login-panel .input-text').focus(function()
	{
			jQuery('label',jQuery(this).parent().parent()).fadeOut(100);
	});
	
	jQuery('#login-panel .input-text').blur(function()
	{
		if(jQuery(this).val() == '')
		  	jQuery('label',jQuery(this).parent().parent()).fadeIn('fast');
	});
	jQuery('a.top').click(function()
	{
		jQuery.scrollTo(0,300);
		return(false);
	});
	jQuery('.messages li').fadeIn('slow');
	jQuery('.messages > li').live('click',function()
	{	
		if(!jQuery('body').hasClass('wishlist-index-index'))
			jQuery(this).fadeOut();
	});
	
	setTimeout('fademessages()',5000);
	// feature rotator:
	setTimeout('rotateFeature()',1000);	
	
	jQuery(' a.product-image img').hover(
	function()
	{
		jQuery(this).stop().animate({opacity:0.7},'fast');
	},
	function()
	{
		jQuery(this).stop().animate({opacity:1.0});
	});
	
}); 
jQuery(window).load(function()
{
	setTimeout('blurAllInputs()',500);
});
function blurAllInputs()
{
	jQuery('input:not([class=qty],[type=hidden],[name=wishlistname])').focus();
	jQuery('input:not([class=qty],[type=hidden],[name=wishlistname])').blur();
}

function blurAllInputsAndFocus(elem)
{
	jQuery('input').focus();
	jQuery('input').blur();
	
	jQuery(elem).focus();
}
function fademessages() 
{ 
	if(!jQuery('body').hasClass('wishlist-index-index'))
		jQuery('.messages > li').fadeOut(); 
	
}
