// JavaScript Document

//MetaPlusBold
//MetaBold-Roman
//MetaNormal-Roman
//MetaOT-NormIta

Cufon.replace('h2,  .font, #mainNavigation a, .categoryheading span, .morebutton, ul.footernav li a, .roseOne span, .roseOne strong, .buttonMenu a strong, .buttonFindOut span, .bannerPaging li a, .positionsBox strong, .contactOption span, .bannerheading span,  .tags, .pictureDescription, .buttonSubmit, .buttonArticle, #breadcrumb a, .contactDetailRight ', { 
	fontFamily: 'MetaNormal-Roman', hover: true 
});

Cufon.replace('h1', { 
	fontFamily: 'MetaBold-Roman', hover: true 
});

Cufon.replace('.buttonJoin, #banner .tagrow span', { 
	fontFamily: 'MetaPlusBold', hover: true 
});

Cufon.replace('.evidenceBox li, .textContainerHeading', { 
	fontFamily: 'MetaOT-NormIta', hover: true 
});


Cufon.replace('.downloadsList a ', {
	 fontFamily: 'MetaOT-NormIta', hover: true, hoverables: { a:true }
});

$(function(){
	$("#mainNavigation li").hover(function(){
		getwidth = $(this).width();
		getrel = $(this).parents('li').attr('value');
		if(getrel == '1'){
			getUlwidth = - $(this).find("ul:first").width();
			$(this).find("ul.subnav:first").css({"left": getUlwidth, 'width':getUlwidth});	
		}else{
			$(this).find("ul.subnav:first").css("left", getwidth);	
		}
		
		$(this).find("ul:first").show().parent('li').addClass('navactive');			
	}, function(){
		$(this).find("ul:first").hide().parent('li').removeClass('navactive');	
	});
	
	$("#accountNav li.dropmenu").hover(function(){
		$(this).find("ul:first").show().parent("li").addClass("activenav");
	},function(){
		$(this).find("ul:first").hide().parent("li").removeClass("activenav");	
	});
	
	$("#accountNav li.selecttopics").hover(function(){
		$(this).find("ul:first").show().parent("li").addClass("selectNav");
	},function(){
		$(this).find("ul:first").hide().parent("li").removeClass("selectNav");
		Cufon.replace('.font ', { fontFamily: 'MetaNormal-Roman', hover: true });	
	});
	
	$(".downloadsList li").hover(function(){
		$(this).addClass('buttonActive');
	}, function(){
		$(this).removeClass('buttonActive');	
		Cufon.replace('.downloadsList a ', { fontFamily: 'MetaNormal-Roman', hover: true });
		
	});
	
	$(".buttonMenu li").hover(function(){
		$(this).addClass('hover').removeClass('nohover');
		Cufon.replace('.buttonMenu a strong ', { fontFamily: 'MetaNormal-Roman', hover: true });
	}, function(){
		$(this).removeClass('hover').addClass('nohover');
		Cufon.replace('.buttonMenu a strong ', { fontFamily: 'MetaNormal-Roman', hover: true });
		
	});
	
	$(".service_item tr").hover(function(){
		$(this).addClass("over");
	},function(){
		$(this).removeClass("over");	
	});

	
	
});

/* =Tooltips
--------------------------------------------------------------------------------------------------------*/
$(document).ready(function() {
	$('a.poplight[href^=#]').click(function() {
    var popID = $(this).attr('rel'); //Get Popup Name
    var popURL = $(this).attr('href'); //Get Popup href to define size

    //Pull Query & Variables from href URL
    var query= popURL.split('?');
    var dim= query[1].split('&');
    var popWidth = dim[0].split('=')[1]; //Gets the first query string value

    //Fade in the Popup and add close button
    $('#' + popID).show().css({ 'width': Number( popWidth ) }).prepend('<a href="#" class="close"></a>');

    //Define margin for center alignment (vertical   horizontal) - we add 80px to the height/width to accomodate for the padding  and border width defined in the css
    var popMargTop = ($('#' + popID).height() + 80) / 2;
    var popMargLeft = ($('#' + popID).width() + 80) / 2;

    //Apply Margin to Popup
    $('#' + popID).css({
        'margin-top' : -popMargTop,
        'margin-left' : -popMargLeft
    });

    //Fade in Background
    $('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag.
    $('#fade').css({'filter' : 'alpha(opacity=60)'}).fadeIn(); //Fade in the fade layer - .css({'filter' : 'alpha(opacity=80)'}) is used to fix the IE Bug on fading transparencies 

    return false;
});

//Close Popups and Fade Layer
$('a.close, #fade').live('click', function() { //When clicking on the close or fade layer...
    $('#fade , .popup_block').hide(function() {
        $('#fade, a.close').remove();  //fade them both out
    });
    return false;
});

});

/* End Tooltips
--------------------------------------------------------------------------------------------------------*/
