$(document).ready(function(){
	
	$('ul.sf-menu').superfish({
		animation: {opacity:'show'},
		speed: 'fast',
		dropShadows: false
	});
	
	if ($("#masthead").length > 0){
		$('#masthead').flash({
			src: '/flash/Home-Flash-Paint-Viral-ended.swf',
			width: 990,
			height: 250,
			wmode: "opaque"
		});
	}
	
	Cufon.replace('h1:not(.nocufon), h2:not(.nocufon), h3, h4, #description, #telephone, .gothamRounded, .emergencyContacts td.region', { 
		fontFamily: 'GothamRounded',
		hover: true
	});
	
	$('#flexLogin').hide();
	
	$('#userLogin a').click(function() {
		$('#flexLogin').slideToggle();
	});
	
	// tabs click code....
	$('#tabs > ul > li > a').click(function(){
		var clicked_element = this;
		var id = $(clicked_element).attr('href'); // find id of new active tab
		var old_id = $('#tabs > ul > li.active > a').attr('href'); // find id of old active tab
		$('#tabs > ul > li').removeClass('active'); // remove active class from old tab
		$(clicked_element).parent().addClass('active'); // add active class to clicked tab
		$(old_id).hide(); // hide current tab
		$(id).show(); // show new tab
		delete clicked_element;
		delete id;
		delete old_id;
		return false;			
	});
	
	//set selected tab from URL param (if exists?!?!)
	if (typeof document.location.hash != 'undefined' &&
		document.location.hash.toString().length > 1 &&
		$(document.location.hash).length > 0) { //check tab/hash ref is valid and exists
			var old_id = $('#tabs > ul > li.active > a').attr('href');// find id of old active tab
			$('#tabs > ul > li').removeClass('active');// remove active class from old tab
			$('#tabs > ul > li > a').each(function(index) {
			if ($(this).attr('href') == document.location.hash) { //check for a matching href string
				$(this).parent().addClass('active'); // add active class to requested tab
				return false; //break
			}
		});
		$(old_id).hide(); // hide current tab
		$(document.location.hash).show(); // show new tab
		delete old_id;
	}
	
	// search box in nav bar
	$('#search').click(function() {
		$('#searchL').fadeOut('slow');
	});
	$('#search').click(function() {
		$('#searchL').fadeOut('slow');
	});
	
	// contact form on contact page
	$('#name').click(function() {
		$('#nameL').fadeOut('slow');
	});
	$('#company').click(function() {
		$('#companyL').fadeOut('slow');
	});
	$('#phone').click(function() {
		$('#phoneL').fadeOut('slow');
	});
	$('#email').click(function() {
		$('#emailL').fadeOut('slow');
	});
	$('#website').click(function() {
		$('#websiteL').fadeOut('slow');
	});
	
	// question form on FAQ's page
	$('#question').click(function() {
		$('#questionL').fadeOut('slow');
	});	
	
	// footer quick links slide up and down
    $("#quickLinks").hide();
    $('a#quickLinksShow').click(function() {
        if ($('#quickLinks').is(':visible')) {
            $('#quickLinks').slideUp();
            $('div.pageShadow h3 span').css("background-image", "url(/images/quick-links-down.png)")
        } else {
            $('#quickLinks').slideDown();
            $('div.pageShadow h3 span').css("background-image", "url(/images/quick-links-up.png)")
        }
        return false;
    });

});

$(function(){$(document).pngFix();});
