$(document).ready(function() {	
	// search-site-input
	inputBoxNotifier($("#search-site-input"),"#000000","#cccccc");
	
	// overstate
	home_overstate();
	
	// on/off state for all button class images
	$("img.btn")
	.mouseenter(function()
	{
		src = $(this).attr('alt');
		src = cftcJsFragmentsRoot +"web_header/img/" + src + "-over.png";
		$(this).attr('src',src);
	})
	.mouseleave(function()
	{
		src = $(this).attr('alt');
		src = cftcJsFragmentsRoot +"web_header/img/" + src + ".png";
		$(this).attr('src',src);
	});
	
	// on/off state for nav-sub
	$('.extend').mouseover(function(){
			$(this).find('img').attr("src",cftcJsFragmentsRoot +"web_header/img/side-nav-arrow-white.gif");
	}).mouseout(function(){
			$(this).find('img').attr("src",cftcJsFragmentsRoot +"web_header/img/side-nav-arrow-orange.gif");
	});	
		
	
	// calls the font size change function
	$('.page-controls .large').click(function(){ changeFontSize(14); return false; });
	$('.page-controls .regular').click(function(){ changeFontSize(12); return false; });
	$('.page-controls .small').click(function(){ changeFontSize(11); return false; });
	
});


// switches the notifier and colors for input boxes
function inputBoxNotifier( obj , color_on , color_off )
{
	// triggered on initial load when document is ready
	if (obj.val() == "" || obj.val() != obj.attr("title")) // check if obj is empty or not equal to title, if so...
	{
		obj
		.val( obj.attr("title") )						// set the input box value the same as the title's attirbute 
		.css( "color" , color_off );					// switches to off state color
	}
	
	obj
	.focus(function()									// using jquery on focus event
	{
		if ( $(this).val() == $(this).attr("title") ) 	// check if the input box value matches the title attribute, if so...
		{
			$(this)
			.val("")									// empty the input box value to allow for user input
			.css( "color" , color_on );					// switches to on state color
		}
	})
	.blur(function()									// using jquery on blur event
	{
		if ($(this).val() == "")						// check if the input box value is empty, if so...
		{
			$(this)
			.val( $(this).attr("title") )				// set the input box value the same as the title's attirbute
			.css( "color" , color_off );				// switches to off state color
		}
	});
}

// overstate for the featured menus on the homepage
function home_overstate() {
	
	// sets the overstate for the first link on page load
		//$(".featured-menu ul li:first-child a").css({"color": "#ffffff", "background": "transparent url("+ cftcJsFragmentsRoot +"web_header/img/bg-box-menu.gif) repeat scroll 0 0"});
	
	// set overstate if deep linked
		//$(".featured-menu li a[href=" + window.location.hash + "]")
			//.css({"color": "#ffffff", "background": "transparent url("+ cftcJsFragmentsRoot +"web_header/img/bg-box-menu.gif) repeat scroll 0 0"});
			
	// for press room menu
	$("#box-press_room .featured-menu li a").click(function() {
		
		// set everything else back to normal
		//$("#box-press_room .featured-menu li a").css({"color": "", "background": ""})
		$("#box-press_room .featured-menu li a").removeClass("on");
		
		// set the one clicked to overstate
		//$(this).css({"color": "#ffffff", "background": "transparent url("+ cftcJsFragmentsRoot +"web_header/img/bg-box-menu.gif) repeat scroll 0 0"});
		$(this).addClass("on");
	});
	
	// for law and regulation menu
	$("#box-law_regulation .featured-menu li a").click(function() {
		
		// set everything else back to normal
		//$("#box-law_regulation .featured-menu li a").css({"color": "", "background": ""})
		$("#box-law_regulation .featured-menu li a").removeClass("on");
		// set the one clicked to overstate
		//$(this).css({"color": "#ffffff", "background": "transparent url("+ cftcJsFragmentsRoot +"web_header/img/bg-box-menu.gif) repeat scroll 0 0"});
		$(this).addClass("on");
	});
}

// changes the font size
function changeFontSize( size ) {
	$('#wrap-body-main .body li').css( {'font-size': size} );
	$('#wrap-body-main').css( {'font-size': size} );
}

function setBookmark(url,title) {
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
  window.external.AddFavorite(url,title);
  } else if (navigator.appName == "Netscape") {
    window.sidebar.addPanel(title,url,"");
  } else {
    alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
  }
}

$(document).ready(function(){
	$("table tr:even").addClass("even");
	//$("table tr:first").addClass("first");
        // replace above line with below three lines	
 
	$("table").each(function(i){
	    $("table:eq("+i+") tr:first").addClass("first");
	});
 
 
$("table tr:first").addClass("first");


	//$("table tr:first td:first").addClass("firsttd");
	//$("tr td:has('b')").addClass("firsttd");
	$('a[name!=""]').addClass("anchorclass");
	
	$('a[href*="youtube.com/v/"]').addClass("videopop");
	
   $("a[href^='http://www.c-spanvideo.org/']")
   .each(function()
   { 
	//if is an exit cftc url then do not open in lightbox
     if (this.href.indexOf("exit") == -1) {
		this.href = cftcVideoNode + "?videoid=" + this.href.substring(this.href.lastIndexOf("/")+1);
	
	  }
   });
    $("a[href^='http://www.c-spanarchives.org/']")
   .each(function()
   { 
	//if is an exit cftc url then do not open in lightbox
     if (this.href.indexOf("exit") == -1) {
		this.href = cftcVideoNode + "?videoid=" + this.href.substring(this.href.lastIndexOf("/")+1);
		
	  }
   });
   $('a[href*="/Tools/Video/"]').addClass("videopop-cspan");

	
});


