// Clear/Fill Search Box
function clearInput(formfield)
{
  if (formfield.defaultValue==formfield.value)
   	formfield.value = ""
}
function fillInput(formfield)
{
  if (formfield.value== "")
   	formfield.value = "Search using Keywords"
 }
///////////////////////////////////////////////////////////////////////////////////////

$(document).ready(function() {

$(".what-they-say").click(function(event) {
	event.preventDefault();
});
$(".in-safe-hands").click(function(event) {
	event.preventDefault();
});
$(".topNavRow .whiteBg .topLevelLink").click(function(event) {
	event.preventDefault();
});

$(".baImages").children('.images').hide();
$(".baImages").children('.images:first').addClass('active').show();



setInterval(function(){
	if ($(".baImages").children('.active').next().size() > 0)
		{
			$(".baImages").children('.active').removeClass('active').fadeOut('slow').next().addClass('active').fadeIn('slow');
		}
	else
		{
			if (($(".baImages").children('.images').size()) == 1){
		
			} else {
				$(".baImages").children('.active').removeClass('active').fadeOut('slow');
				$(".baImages").children('.images:first').addClass('active').fadeIn('slow');
			}
		}
	}, 5000);

$(".hookCont").children('.hook').hide();
$(".hookCont").children('.hook:first').addClass('active').show();

setInterval(function(){
	if ($(".hookCont").children('.active').next().size() > 0)
		{
			$(".hookCont").children('.active').removeClass('active').fadeOut('slow').next().addClass('active').fadeIn('slow');
		}
	else
		{
			$(".hookCont").children('.active').removeClass('active').fadeOut('slow');
			$(".hookCont").children('.hook:first').addClass('active').fadeIn('slow');
		}
	}, 5000);



// PRELOAD ROLLOVER STATES //////////////////////
var loadHover1 = $('<img />').attr('src', site_uri + 'images/system/global_Recommend_hover.jpg');
var loadHover2 = $('<img />').attr('src', site_uri + 'images/system/global_SpecOff_hover.jpg');
var loadHover3 = $('<img />').attr('src', site_uri + 'images/system/hook_Recommend_hover.jpg');
var loadHover4 = $('<img />').attr('src', site_uri + 'images/system/hook_SpecOff_hover.jpg');
var loadHover5 = $('<img />').attr('src', site_uri + 'images/system/logo_facebook_hover.jpg');
var loadHover6 = $('<img />').attr('src', site_uri + 'images/system/logo_newsletter_hover.jpg');
var loadHover7 = $('<img />').attr('src', site_uri + 'images/system/logo_arrange_hover.jpg');
var loadHover8 = $('<img />').attr('src', site_uri + 'images/system/logo_book_hover.jpg');
var loadHover9 = $('<img />').attr('src', site_uri + 'images/system/logo_view_hover.jpg');
var loadHover10 = $('<img />').attr('src', site_uri + 'images/system/logo_tel_hover.jpg');


// DATE BOX //////////////////////
$.date_input.initialize();

// LIGHT BOX //////////////////////
$(".lightBox-Brochure").colorbox({iframe:true, innerWidth:600, innerHeight:480, opacity:0.75, scrolling:false});
$(".lightBox-Book").colorbox({iframe:true, innerWidth:600, innerHeight:655, opacity:0.75, scrolling:false});
$(".lightBox-Callback").colorbox({iframe:true, innerWidth:600, innerHeight:430, opacity:0.75, scrolling:false});
$(".lightBox-Newsletter").colorbox({iframe:true, innerWidth:600, innerHeight:350, opacity:0.75, scrolling:false});
$(".lightBox-recommend").colorbox({iframe:true, innerWidth:600, innerHeight:250, opacity:0.75, scrolling:false});

$(".recommend").colorbox({iframe:true, innerWidth:600, innerHeight:650, opacity:0.75, scrolling:false});
$(".globalRecommend").colorbox({iframe:true, innerWidth:600, innerHeight:150, opacity:0.75, scrolling:false});


//SEO Tabs Rounded Corners
//Tabs
$("#seo #tabs ul.tabs li a").corner("round top 5px").parent().css('padding', '1px 1px 0px 1px').corner("round top 5px");
//Content
$("#seo #tabs .tabContent").corner("bottom 5px").corner("tr 5px").parent().css('padding', '1px').corner("bottom 5px").corner("tr 5px");
//Global Content
$("#contentCont .bottomRow .bottomGlobal .hook .padd").corner("10px").parent().css('padding', '1px').corner("10px");
$("#contentCont .topRow .rightCol .rightGlobal .hook .padd").corner("10px").parent().css('padding', '1px').corner("10px");
$("#contentCont .midRow .hookCont .bg").corner("10px").parent().css('padding', '1px').corner("10px");

// SET RIGHT COLUN HEIGHT /////////////////////////////////////////////////////////////////////////////////////////
	var column1Height = $(".topRow").height();
	var column2Height = $(".rightCol").height();

    if (column1Height > column2Height)
		{
			var newHeight = (column1Height);
			
			$(".rightCol").height(newHeight);
		}

//	SEO TABS /////////////////////////////////////////////////////////////////////////////////////////
	
	$(".tab_content").hide(); 

	$("#tabs ul.tabs a:first").addClass("active").show(); 
	$(".tab_content:first").show(); 

	
	$("#tabs ul.tabs a").click(function() {
	
		$("#tabs ul.tabs a").removeClass("active"); 
		
		$(this).addClass("active"); 
		
		$(".tab_content").hide();
		
		//var activeTab = $(this).attr("href"); //Find the href attribute value to identify the active tab + content
		var activeTab = '#'+$(this).attr("title");
	
		
		$(activeTab).css('display','block'); 
		

		return false;
	});

	// Homepage Slider
  	var slides = $('.slides .text');
	var numberOfSlides = slides.length;
	var slideWidth = 485;
	var limit = numberOfSlides * slideWidth;
	$(".slides").css('width',slideWidth+'px');
	setInterval(function(i) {
		var leftValTimer = parseInt($(".slides").css("left"));
		//alert(leftValTimer + ' '+    ((limit - slideWidth) * -1));
	
			if ($(".headerGraphicHero .active").next().size() > 0)
			{
				$(".headerGraphicHero .active").removeClass('active').fadeOut(800).next().fadeIn(800).addClass('active');
				$(".slideWrapper .active").removeClass('active').fadeOut(800).next().fadeIn(800).addClass('active');
			} else {
			// alert('test ahh');
			//$('.slideWrapper').find('.active').css("display", "none").removeClass("active").prevAll('.first').fadeIn(800).addClass("active");	
			//$('.headerGraphicHero').find('.active').css("display", "none").fadeOut(800).removeClass("active").prevAll('.first').fadeIn(800).addClass("active");		
			
			$('.slideWrapper  .active').fadeOut(800).removeClass('active').prevAll('.first').fadeIn(800).addClass("active");
		//	$('.slideWrapper div:first').fadeOut(800).removeClass('active');
			$('.headerGraphicHero .active').fadeOut(800).removeClass('active').prevAll('.first').fadeIn(800).addClass("active");
		//	$('.headerGraphicHero img:first').fadeOut(800).removeClass('active');
			}
			
			
		
			
			
	
	},6000);
});
