function SmoothScroll() {
	$('.scroll').click(function() {
	  if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
	  && location.hostname == this.hostname) {
		var $target = $(this.hash);
		$target = $target.length && $target
		|| $('[name=' + this.hash.slice(1) +']');
		if ($target.length) {
		  var targetOffset = $target.offset().top;
		  $('html,body')
		  .animate({scrollTop: targetOffset}, 1000);
		 return false;
		}
	  }
	});
}

function Accordian() {
	var togglers = $('#faqlist li h2');
	var elements = "div";
	$(elements).hide();
	togglers.click(
	function() {
		var checkElement = $(this).next();
			if((checkElement.is(elements)) && (checkElement.is(':visible'))) {
			checkElement.slideUp(500);
			return false;
		}
		if((checkElement.is(elements)) && (!checkElement.is(':visible'))) {
			$(elements + ':visible').slideUp(500);
			checkElement.slideDown(500);
			return false;
		}
	});
}



$(document).ready(function(){
	
	SmoothScroll();
	$(document).pngFix();
	$("a[rel*='external']").attr({ target: "_blank" });
	
	var volatile = $("input[type=text], textarea")
	volatile.focus(function(event){
        if ($(this).val() == $(this).attr("title") ){        
            $(this).val("");
        }}, volatile.blur(function(event){
            if ($(this).val() == "" ){        
                $(this).val($(this).attr("title"));
            }
        }
    ));
	
	selectTabs(0);
	$('ul#servicesTabs li').click(function(){
		selectTabs($(this).index());
		return false;
	});	

		$("#latestNews ul").list_ticker({
			speed:9000,
			effect:'fade',
			run_once:false,
			random:false
		});	
		
		$("ul.ticker").list_ticker({
			speed:5750,
			fxDuration: 2000,
			effect:'crossfade',
			run_once:false,
			random:false
		});	
		
		
		
		
		var fontSize = $.cookie('fontSize');		
		if(fontSize){
			$('body').css({'font-size': fontSize+'px'});
		} else {
			$('body').css({'font-size': '12px'});
			$.cookie('fontSize', 12, { path: '/' });
		}

		$("#fontSmall").bind("click", function(e){
			$('body').animate({'font-size': '12px'},1000);
			$.cookie('fontSize', 12, { path: '/' });
			return false;
		});
		
		$("#fontMedium").bind("click", function(e){
			$('body').animate({'font-size': '14px'},1000);
			$.cookie('fontSize', 14, { path: '/' });
			return false;
		});

		$("#fontLarge").bind("click", function(e){
			$('body').animate({'font-size': '18px'},1000);
			$.cookie('fontSize', 18, { path: '/' });
			//Cookie.set("fontSize", 18, { "path": "/" });
			return false;
		});

	
	
	
});

function selectTabs(i){
	$('ul#servicesTabs li').each(function(index) {
       	if (i == index){
			$(this).addClass('selected');
		} else {
			$(this).removeClass('selected');	
		}
    });
	
	$('#serviesContainer .servicesContent').each(function(tab) {
       	if (i == tab){
			$(this).show();
		} else {
			$(this).hide();	
		}
    });
}

