$(function() {
	$('#slideshow').before('<div id="slide-selector"><div id="number-container">').cycle({
		fx:     'fade',
		speed:  'slow',
		timeout: 5000,
		pager:  '#number-container',
		pagerAnchorBuilder: function(idx, slide) {
			var number = idx + 1;
			return '<span>' + number + '</span>';
		}
	});
});


$(document).ready(function ()
{	
	//Main Nav Functions
	$('#main-nav ul li').hover(function ()
	{
		$(this).addClass('hover');
		if ($(this).prev('li').attr('class') != 'hi')
		{
			$(this).prev().find('a').addClass('tmp-hover');
		}
		else
		{
			$(this).prev().find('a').css('background-image', 'none');
		}
		if ($(this).next('li').attr('class') == 'hi')
		{
			$(this).find('a').css('background-image', 'none');
		}
	}, function ()
	{
		$(this).removeClass('hover');
		if ($(this).attr('class') != 'hi')
		{	
			if ($(this).prev('li').attr('class') != 'hi')
			{
				$(this).prev().find('a').removeClass('tmp-hover');
			}
			else
			{
				$(this).prev().find('a').css('background-image', '');
			}
			if ($(this).next('li').attr('class') == 'hi')
			{
				$(this).find('a').css('background-image', '');
			}
		}
	});
	
	$('#main-nav ul li.hi').prev().find('a').addClass('tmp-hover');

	//Feature Box Functions
	$('#number-container span').hover(function ()
	{
		$(this).addClass('hover');
	}, function ()
	{
		$(this).removeClass('hover');
	});


	//Homepage feature box links
	$('.home #row-2 .inner a').hover(function ()
	{
		var newClass = $(this).attr('class');
		$('.home #row-2 .link a.'+newClass).addClass('hover');
		$('.home #row-2 h3 a.'+newClass).addClass('hover');
	}, function ()
	{
		var newClass = $(this).attr('class');
		$('.home #row-2 .link a.'+newClass).removeClass('hover');
		$('.home #row-2 h3 a.'+newClass).removeClass('hover');
	});

	$('#row-2 .col-2').hover(function ()
	{
		$(this).addClass('col-2-hover'); 
	}, function ()
	{
		$(this).removeClass('col-2-hover');
	});

	$('#row-2 .col-3').hover(function ()
	{
		$(this).addClass('col-3-hover'); 
	}, function ()
	{
		$(this).removeClass('col-3-hover');
	});

	/*$('#corporate-enq-home .inner').hover(function ()
	{
		$(this).addClass('hover');
	}, function ()
	{
		$(this).removeClass('hover');
	});*/

	$('.home #row-1 .col-2').hover(function ()
	{
		$(this).find('a').addClass('hover');
		$(this).css('cursor', 'pointer');
		//$(this).find('a.inner').css('background-image', 'url(/images/home_r1_c2_inner_tint.gif)');
		$(this).find('a.inner').addClass('inner-hover');
	}, function ()
	{
		$(this).find('a').removeClass('hover');
		$(this).css('cursor', 'auto');
		//$(this).find('a.inner').css('background-image', ''); 
		$(this).find('a.inner').removeClass('inner-hover');
	});

	//Content page update box and corporate enq
	$('.content .content-col-3 .update-box, #top .col-2, .content .content-col-3 .services-box1 .col-3, .content .content-col-3 .services-box2 .col-3, .content .content-col-3 .services-box3 .col-3, .services-box4 .col-3, .services-box5 .col-3').hover(function ()
	{
		$(this).find('a').addClass('hover');
		$(this).css('cursor', 'pointer');
	}, function ()
	{
		$(this).find('a').removeClass('hover');
		$(this).css('cursor', 'auto');
	});

	$('#top .col-2').hover(function ()
	{
		$(this).addClass('content-col-2-hover'); 
	}, function ()
	{
		$(this).removeClass('content-col-2-hover'); 
	});

	$('.content .content-col-3 .update-box, .content .content-col-3 .services-box1 .col-3, .content .content-col-3 .services-box2 .col-3, .content .content-col-3 .services-box3 .col-3, .services-box4 .col-3, .services-box5 .col-3').hover(function ()
	{
		$(this).find('a.inner').addClass('inner-hover'); 
	}, function ()
	{
		$(this).find('a.inner').removeClass('inner-hover'); 
	});

	//Sets default value for search box, and removes it on click
	$('input.search-box').attr('value', 'Search');
	$('input.search-box').click(function(){
		$(this).attr('value', '');
	});

	//PDF Popups
	$("a[href*=.pdf]").click(function(){
		window.open(this.href, 'pdf', 'width=800,height=600,scrollbars=yes,top=100,left=100');
		return false;
	});

	//Left Nav Drop Downs
	$('ul.nav-left ul.nav-left li.dir ul').css('display', 'none');
	$('ul.nav-left ul.nav-left li.dir ul li.hi').parent('ul').css('display', 'block');

	$('ul.nav-left li.dir').hover(function ()
	{
		if ($(this).find('ul').is(":hidden"))
		{
			$(this).find('ul').slideDown();
			$(this).find('ul').attr('title', 'hidden');
		}
	}, function ()
	{
		if($(this).find('ul').attr('title') == 'hidden')
		{
			$(this).find('ul').slideUp('fast');
		}
	});
	
	//Language Selects
	$("li.language select").change(function(){
		window.location = $(this).val();
	});
	
	// UID Into forms
	

});

