﻿// SEARCH
function ftn_Search()
{
	window.location = "/SearchCenter/Pages/results.aspx?s=www.cngnow.com&k=" + document.getElementById('searchTextbox').value;
}

// LOAD EVENT
function addLoadEvent(func) {
	var oldonload = window.onload;
	
	if (typeof window.onload != 'function') 
	{
		window.onload = func;
	} 
	else 
	{
		window.onload = function() 
		{
		  	if (oldonload){oldonload();}
		  	func();
		}
	}
}

if (typeof(_spBodyOnLoadWrapper) != 'undefined') addLoadEvent(_spBodyOnLoadWrapper);	


$(document).ready(function() {
	$(".rmText ~ .rmSlide").siblings().addClass("jqParent");
	$("a[rel^='prettyPhoto']").prettyPhoto();
	$(".homepage #video .videoItem a").click(function(){
		$(".pp_content").append('<a class="altVideoLink" href="/EN-US/Media/Video/EducationalSeries/"></a>');
		window.setTimeout('$("#pp_full_res").css("background-image","url(/Style%20Library/Images/now-video-unavailable-401x278.jpg)");',2400);
	});
	$("span[fragmentId='/ReusableContent/7_.000']").addClass("videoPlaylist");
	$(".videoPlaylist").append('<a class="altVideoLink" href="/EN-US/Media/Video/"></a>');
	window.setTimeout('$(".videoPlaylist").css("background-image","url(/Style%20Library/Images/now-video-unavailable-401x278.jpg)");',2400);
	$(".highlightSidebar li a.titleLink").each(function(){
		if ($(this).height() > 30) $(this).truncate( 55 );
	});
	$("#ctl00_PlaceHolderMain_breadpath span").eq(1).html('');
	$("#ctl00_PlaceHolderMain_breadpath span").eq(2).html('');
	$("#content #bread").fadeIn();
	if (window.location.href.toLowerCase().indexOf('/EN-US/NewsAndEvents/Legislation/Pages'.toLowerCase())!=-1) {
		$("#newsarticle-header h1").html('<a href="/EN-US/NewsAndEvents/Legislation">Legislation News</a>');
	}
	
	
	
	
	//band up the silverpop form
	
	var popform = $('#arm-right fieldset'); 
	popform.parent().parent().parent().addClass('silverpop'); 
	popform.parent().parent().addClass('top'); 
	popform.parent().addClass('bottom'); 
	popform.addClass('back');
	
	$('#arm-right fieldset .buttonRow input').addClass('signupButton'); 
	var items = $('#arm-right fieldset ul li'); 
	for ( i = 0; i <= items.size(); i++){ 
		switch(i){ 
			case 0: items.eq(i).addClass('first'); break; 
			case 1: items.eq(i).addClass('second'); break; 
			case 2: items.eq(i).addClass('third'); break; 
			case 3: items.eq(i).addClass('fourth'); break; 
			case 4: items.eq(i).addClass('fifth'); break; 
			case 5: items.eq(i).addClass('sixth'); break; 
			case 6: items.eq(i).addClass('seventh'); break; 
			case 7: items.eq(i).addClass('eighth'); break; 
			case 8: items.eq(i).addClass('ninth'); break; 
			case 9: items.eq(i).addClass('tenth'); break; 
		} 
	} 
	if( $('#arm-right span.success').length != 0 ) 
		$('#arm-right fieldset input.textbox').val(''); 
	
	$('#arm-right fieldset').siblings('span.success').fadeTo(600,1,function(){ 
		$(this).animate({top:"0"},900).fadeTo(2200,1,function(){ 
			$(this).animate({top:"-40px" },600);
		}).click(function(){ 
			$(this).stop().animate({top:"-40px"},100); 
		}); 
	}); 
	
	$('#arm-right fieldset').siblings('span.failed').fadeTo(600,1,function(){ 
		$(this).animate({top:"0"},900).fadeTo(2200,1,function(){ 
			$(this).animate({top:"-72px" },600); 
		}).click(function(){ 
			$(this).stop().animate({top:"-72px"},100); 
		}); 
	}); 
	
	$('#arm-right fieldset input.textbox').siblings('span.validationLabel').siblings('input.textbox').blur(function(){ 
		if( $(this).val() == '' ) $(this).siblings('span.validationLabel').fadeIn().fadeTo(1500,1,function(){ 
			$(this).fadeOut(); 
		}) 
		$(this).siblings('span.validationLabel').click(function(){ 
			$(this).stop().fadeOut(100); 
		}); 
	}); 
	
	$('#arm-right .silverpop .bottom').css('visibility', 'visible');

	
	
});
