function redirecttimer(){
    window.location = "http://microwaveamps.co.uk";
}

$(function(){
	$('#main_navmenu ul li a').unbind('mouseover');
	$('body').unbind('mousemove');
	$('#main_navmenu ul li a').bind('mouseover',function(){
	
	hiddenmenu1 = $('#hiddensubmenu_type');
	hiddenmenu2 = $('#hiddensubmenu_apps');

	var ref=this.rel;
	if((ref!=undefined) && (ref!="")){
	var width=$('#'+ref).innerWidth();
	var height=$('#'+ref).innerHeight();
	var pad=((($('#'+ref).innerWidth())-($('#'+ref).width()))/(2));
	var offset=$('#'+ref).offset();
	var left=offset.left;
	var top=offset.top;
	
	$('#dropdown_menu').hide();
	$('#dropdown_menu').css({'width':(width-2)+'px','left':left+'px','top':(top+height)+'px'});
	$('.dropdown_menuitem').css({'padding-left': (pad-3)+'px'});
	$('#dropdown_menu').html($('#'+ref+'_drop').html());
	$('#dropdown_menu').show();
	var dropheight=$('#dropdown_menu').height();
	}else{
		return true;
	}
	var dropright=(left+width);
	var dropbottom=((top)+(dropheight)+(height))+12; // give it a bit extra on the end.
	
	$('body').bind('mousemove',function(e){
		if(e.pageX<left || e.pageX>dropright || e.pageY<top || e.pageY>dropbottom) {
			$('#dropdown_menu').hide();
			$('body').unbind('mousemove');
		}
	});
		return false;
	});
	
	
	$('form#contact_form').keypress( function(){
		$('#contactwarning').hide();
		$('#contact_form input').removeClass("highlighted");
		$('#contact_form textarea').removeClass("highlighted");
	});
	
	$('form#contact_form').unbind('submit');
	
	
$('form#contact_form').bind('submit',function(){
	
		if($('#contactname').val()==""){
			$('#contactwarning').text("You must provide your name.");
			$('#contactname').addClass("highlighted");
			$('#contactwarning').show();
			$('#contactname').focus();
			return false;
		}
		if(($('#contactemail').val()=="") && ($('#contactphone').val()=="")){
			$('#contactwarning').text("You must provide either an email or a phone number.");
			$('#contactemail').addClass("highlighted");
			$('#contactphone').addClass("highlighted");
			$('#contactwarning').show();
			$('#contactemail').focus();
			return false;
		}
		if($('#contactmsg').val()==""){
			$('#contactwarning').text("You have not written a message.");
			$('#contactmsg').addClass("highlighted");
			$('#contactwarning').show();
			$('#contactmsg').focus();
			return false;
		}
		$('#contactwarning').hide();
		return true;
	});
	
	/*
$('#smallmapdiv').click( function(){
		$('#bigmapdiv').fadeIn('slow');
		$('#fadewrap').fadeIn('slow');
	});
	
	$('#bigmapdiv').click( function(){
		$('#bigmapdiv').fadeOut('fast');
		$('#fadewrap').fadeOut('fast');
	});
*/

	$('#homepagecolumns ul li:last-child').css('border','none');
	
	$('#printbutton').unbind('click');
	$('#printbutton').unbind('mouseenter');
	$('#printbutton').unbind('mouseleave');
	
	$('#printbutton').bind('mouseenter', function(){
		$('#printbutton').removeClass('buttonup');
		$('#printbutton').addClass('buttonover');
	});
	$('#printbutton').bind('mouseleave', function(){
		$('#printbutton').removeClass('buttonover');
		$('#printbutton').addClass('buttonup');
	});
	
	$('#printbutton').bind('click', function(){
		window.print();	
	});
	
	$('#downloadbutton').unbind('mouseenter');
	$('#downloadbutton').unbind('mouseleave');
	
	$('#downloadbutton').bind('mouseenter', function(){
		$('#downloadbutton').removeClass('buttonup');
		$('#downloadbutton').addClass('buttonover');
	});
	$('#downloadbutton').bind('mouseleave', function(){
		$('#downloadbutton').removeClass('buttonover');
		$('#downloadbutton').addClass('buttonup');
	});
	
		$('#productsbutton').unbind('mouseenter');
	$('#productsbutton').unbind('mouseleave');
	
	$('#productsbutton').bind('mouseenter', function(){
		$('#productsbutton').removeClass('buttonup');
		$('#productsbutton').addClass('buttonover');
	});
	$('#productsbutton').bind('mouseleave', function(){
		$('#productsbutton').removeClass('buttonover');
		$('#productsbutton').addClass('buttonup');
	});
	
	//image stuff
	
	$('#contentholder img').removeAttr('width');
	$('#contentholder img').removeAttr('height');

	
});
