

$(document).ready(function() {
	
	swfobject.embedSWF("/media/images/camco_timeline_228.swf", "swfHist", "572", "191", "9.0.0");
// ===========
// = Captcha =
// ===========
	$('li#whatIsCaptcha').hide();
	$("fieldset.question").hover(
      function(){
       $('li#whatIsCaptcha').slideDown();
      }, 
      function(){
        $('li#whatIsCaptcha').slideUp();
      });
    
// ==================
// = Download Hover =
// ==================
	$('a.download').hover(
		function(){
			$(this).children('span.downloadhover').css({display:'block'});
		},
		function(){
			$(this).children('span.downloadhover').css({display:'none'});
		});
// ==================
// = Sites Dropdown =
// ==================
	$("ul#SitesList li#headlink").hoverIntent(headlink);

// ===========
// = Tooltip =
// ===========
	/* create markup needed */
	$("div.MDescription").wrap('<div class="MDescOutWrap"></div>');
	$("div.MDescription").after("<div class='MDBottom'> </div>");
	/* override non-javascript styles */
	$("ul.TeamList li").css({width:'106px',height:'195px',minHeight:'auto',float:'left',padding:'0 6px 0 0',margin:'0 0 1px 0',clear:'none',position:'relative'});
	$("div.Member").css({width:'auto'});
	$("div.MDescription").css({background:'#e31937',width:'228px',margin:'0',color:'#FFFFFF'});
	$("div.MDescription p").css({padding:'0 12px 10px',margin:'0',fontSize:'11px',lineHeight:'17px'})

	$("ul.TeamList").each(function(){
		for(i = 0; i < $(this).children('li').length; i++) {
			if((i%5)%3 == 0 && (i%5) !=0 ) {
				$(this).children('li').eq(i).children('div.Member').addClass('last');
			}
			else if((i%5)%4 == 0 && (i%5) != 0) {
				$(this).children().eq(i).children('div.Member').addClass('last');
			}
		}
	});

		
		$("div.Member").children("div.MDescOutWrap").css({position:'absolute',top:'0',right:'-223px',width:'228px',background:'url(/media/images/bg_tooltip_top_128.png) no-repeat left top',padding:'12px 0 0 18px',zIndex:'98',display:'none'});
		$("div.Member").children("div.MDescOutWrap").addClass("png");
		$("div.Member div.MDescOutWrap").children("div.MDBottom").css({clear:'both',background:'url(/media/images/bg_tooltip_bottom_129.png) no-repeat left top',height:'12px',width:'228px'});
		$("div.Member div.MDescOutWrap").children("div.MDBottom").addClass("png");
		$("div.Member").children("div.MDetails").css({position:'absolute',top:'137px',left:'0'});
		
		$("div.last").children("div.MDescOutWrap").css({position:'absolute',top:'0',right:'112px',width:'228px',background:'url(/media/images/bg_tooltip_top_l_130.png) no-repeat right top',padding:'12px 18px 0 0px',zIndex:'98',display:'none'});
		$("div.last").children("div.MDescOutWrap").addClass("png");
		$("div.last div.MDescOutWrap").children("div.MDBottom").css({clear:'both',background:'url(/media/images/bg_tooltip_bottom_l_131.png) no-repeat left top',height:'12px',width:'228px'});
		$("div.last div.MDescOutWrap").children("div.MDBottom").addClass("png");
		$("div.last").children("div.MDetails").css({position:'absolute',top:'137px',left:'0'});
		

	
	/* activate the tooltip */
	$("ul.TeamList li div.Member").hoverIntent(tooltip);
	$("div.NonTextBody").fadeIn('fast');

// ================
// = Facts Picker =
// ================
	var li_height = $("li.quote").css("height");
	var current_quote = 0;
	var old_quote = 0;
	var quote_count = $("li.quote").size();
	var ul_height = li_height*quote_count;
	li_height = "-" + parseInt(li_height)
	$("div.RightTopBlockInner span.cover").fadeOut("fast");
	
	setInterval(function(){
		current_quote = current_quote +1;
		if(current_quote < quote_count){
			$("div.RightTopBlockInner span.cover").fadeIn("fast", function(){
				$("div.RightTopBlockInner ul").animate({top:current_quote * li_height +"px"}, "fast", function(){
					$("div.RightTopBlockInner span.cover").fadeOut("fast");
				});
			});
		}else{
			$("div.RightTopBlockInner span.cover").fadeIn("fast", function(){
				$("div.RightTopBlockInner ul").animate({top: "0px"}, "fast", function(){
					$("div.RightTopBlockInner span.cover").fadeOut("fast");
				});
			});
			current_quote = 0;
		}	
	},15000);	

// ====================
// = Home Page Widget =
// ====================
	$('div.HRContent span.cover').fadeOut('fast');
	$('#HomeRight').hoverIntent(function()
	{
		
	},
	function()
	{
		$('div.HRContent span.cover').fadeIn('fast',function(){
			$('div.subFeature').eq(0).fadeOut('1',function(){
				$('div.subFeature').eq(1).fadeOut('1',function(){
					$('div.subFeature').eq(2).fadeOut('1',function(){
						$('.default').fadeIn('1',function(){
							$('div.HRContent span.cover').fadeOut('fast');
						});
					});			
				});		
			});
		});
	});
	


	$('.subFeatureLink').each(function(i){
		$(this).hoverIntent(function(){
		$('div.HRContent span.cover').fadeIn('1',function(){
			$('div.subFeature').eq(0).fadeOut('1',function(){
				$('div.subFeature').eq(1).fadeOut('1',function(){
					$('div.subFeature').eq(2).fadeOut('1',function(){
						$('.default').fadeOut('1',function(){
							$('div.subFeature:eq('+i+')').fadeIn('1',function(){
								$('div.HRContent span.cover').fadeOut('fast');
							});
						});
					});				
				});		
			});
		});
		return false;
		
	},function(){});
	});

	var questions = $('ul.questions li').size();
	var moveheight = 0;
	var currentli = 0;
	var nextli = currentli + 1;
	var thiselement;
	var nextelement;
	var l_change = 0;
	if (navigator.appName == "Microsoft Internet Explorer") {
	 l_change = 4;
	}
	$('a.downarrow').click(function(){
		jQuery.easing.def = "easeOutExpo";
		if(currentli <= questions - 3){
			thiselement = $('ul.questions li').eq(currentli);
			nextelement = $('ul.questions li').eq(nextli);
			moveheight = parseInt($('ul.questions').css('top')) - thiselement.height() - parseInt(thiselement.css('padding-bottom')) - nextelement.height() - parseInt(nextelement.css('padding-bottom'));
			$('ul.questions').animate({top: + moveheight + "px"},1000,"swing");
			currentli = currentli + 2;
			nextli = nextli + 2;
				
			return false;
		}else{
		}	
			return false;
	});
	$('a.uparrow').click(function(){
		jQuery.easing.def = "easeOutBack";
		$('ul.questions').animate({top:"0px"},1000,"swing");
		currentli = 0;
		nextli =1;
		moveheight = 0;
		return false;
	});

// ===================
// = World Map Calls =
// ===================
//	$('div#WorldMap div').hoverIntent( worldmap );
//	$("div.Column2 div#worldoutbg").fadeIn(250);
// =====================
// = Contact Map Calls =
// =====================
	$('div#ctcWorldMap div').hoverIntent( contact );
// =======================
// = Case Studies Boxout =
// =======================
	$('div.RedBox').hover(function(){
		
	},function(){
		$('div.CSinfo').fadeOut("fast");
		$('div.CSinfo').removeClass('Open');
	});
	
	$('div.RBContent ul li a').hoverIntent(CaseStudy);
	
// ==========
// = Search =
// ==========	
	$('div.top button').click(function(){
		$('ul.advSearch').slideDown("fast");
		$(this).hide();
		return false
	})
// ==================
// = More Widget... =
// ==================
	
	$('div.moreWidget').hide();
	$('a.moreLink').css({display:'block'});
	$('a.moreLink').click(function(){
		if($(this).is('.open')){
			$('div.moreWidget').slideUp('fast',function(){
				$('a.moreLink').text('More...');
			});
			$(this).removeClass('open');
			return false
		}else{	
			$('div.moreWidget').slideDown('fast',function(){
				$('a.moreLink').text('Less...');
			});
			$(this).addClass('open');
			return false
		};
	});

}); // END OF DOC READY FUNCTION


// =======================
// = World Map Functions =
// =======================
var worldmap = {
	sensitivity: 5,
	interval: 100, 
	over: faderIn, 
	timeout: 100,
	out: faderOut};
var p_name;
function faderIn(){
	$(this).children().children("span").fadeIn(700);
	p_name = 'p#' + this.id + 'text';
	bg_name = "div.Column2 div#" + this.id + 'bg';
	$(p_name).fadeIn(700);
	$("div.Column2 div#worldoutbg").fadeOut(200,function(){$(bg_name).fadeIn(200)});
};
function faderOut(){
	$(this).children().children("span").fadeOut(500);
	$(p_name).fadeOut(500);
	$(bg_name).fadeOut(50,function(){$("div.Column2 div#worldoutbg").fadeIn(100);});
	
};
// =======================
// = Contact Map Functions =
// =======================
var contact = {
	sensitivity: 5,
	interval: 100, 
	over: ctcfaderIn, 
	timeout: 100,
	out: ctcfaderOut};
var p_name;
function ctcfaderIn(){
	p_name = 'p#' + this.id + 'text';
	$(p_name).fadeIn(700);
	$(this).children().children("span").fadeIn(700);
};
function ctcfaderOut(){
	$(p_name).fadeOut(500);
	$(this).children().children("span").fadeOut(500);
};
// =============================
// = Global Dropdown functions =
// =============================
var headlink = {
	sensitivity: 5,
	interval: 100, 
	over: headlinkdown, 
	timeout: 800,
	out: headlinkup
}
function headlinkdown(){$(this).children("ul").slideDown("fast")};
function headlinkup(){$(this).children("ul").slideUp("fast")};

// ========================
// = Case Study Functions =
// ========================
var CaseStudy = {
		sensitivity: 10,
		interval: 50, 
		over: CasestudyOver, 
		timeout: 50,
		out: CasestudyUp}
function CasestudyOver(){
	current = $(this).parent().siblings('div.CSinfo')
	if(current.is('.Open')){
		return false;
	}else{
		$('div.Open').fadeOut("fast",function(){$(this).removeClass('Open')});
		current.fadeIn("fast",function(){current.addClass('Open')});
		return false;
	};
};
function CasestudyUp(){
	
};
// ===========================
// = HoverIntent for Tooltip =
// ===========================
var tooltip = {
	sensitivity: 10,
	interval: 50, 
	over: Toolover, 
	timeout: 50,
	out: Tooloff
};
function Toolover () {
    $(this).children("div.MDescOutWrap").fadeIn('fast');
	$("ul.TeamList li").css({zIndex:'-1'});
	$(this).parent("li").css({zIndex:'98'});
  }
  function Tooloff() {
    $(this).children("div.MDescOutWrap").fadeOut('fast',function(){$("ul.TeamList li").css({zIndex:'98'});});
  }


$(document).ready(function() {$(".userform").validate();})