// JavaScript Document

// USCOURTS.GOV specific javascript functions
// by Jack Okorn and Kate Suttapakti - Nov 2009

//---------------------------------------------------------------------------------------------------------------------------------//
// open windows for  sharing

function openEmailWindow() {
	//alert('hi');
	var shareURL;
	var thisURL = document.URL;
	shareURL = "/emailShare.aspx?subject=" + thisURL;	
	//alert(shareURL);
	myWindow=window.open(shareURL,"_blank","height=450,width=500,location=no,menubar=no,resizable=no,scrollbars=no,status=yes,titlebar=no,toolbar=no,top=200,left=300",replace="true");
	myWindow.focus()
	
	}



function openFacebookWindow() {
	//alert('hi');
	var	shareURL;
	var thisURL = document.URL;
	var thisTitle = document.title;
	shareURL = "http://www.facebook.com/sharer.php?u=" + encodeURIComponent(thisURL) + "&t=" + encodeURIComponent(thisTitle);
	//alert(shareURL);
	myWindow=window.open(shareURL,"_blank","height=360,width=650,location=no,menubar=no,resizable=no,scrollbars=no,status=yes,titlebar=no,toolbar=no,top=200,left=300",replace="true");
	myWindow.focus()
	
	}
	
	
	


//--------------------------------------------------------------------------------------------------------------------------------//


// SPRY collapsible panels 
/*
		[[THIS COMMENT ENTERED HERE ONLY AS BACKGROUND INFORMATION.  THIS FUNCTION IS ACTUALLY LOCATED ON THE HTML PAGE.]]
		The below "runPanel()" function is used on the HTML page by Spry to establish collapsible panels.  
		It must be called from the bottom of the page.  If this is called at the top of the page, the panels will not work.
		In this example, we are using 5 as the number of panels.  Edit the number of panels to suit your need.  
				<!-- Panel Initiation Call, made from the bottom of the HTML page -->
				<script type="text/javascript">
					runPanel(5)
				</script>
*/

        //------------------------------------------------------------------------------------------------------------------------//

/*				
		Below is the runPanel() function.  It will remember the panel's open/closed state and set the panel open or closed accordingly.  
		When a user opens the page for the first time, all the panels are initially closed.
		When a user expands a panel, a session cookie is set (upon clicking the panel lable) to record the open state.
		The next time the user visits the page (in the same session), the open panel will automatically re-open.
*/
function runPanel(count){
for (y=1;y<=count;y++)
	{
		var str = "CollapsiblePanel" + y ; 
		var strpanel = "panel" + y;		
		if (getCookie(strpanel))
			{	var str = new Spry.Widget.CollapsiblePanel(str, { contentIsOpen: true }); }
		else 	
			{	var str = new Spry.Widget.CollapsiblePanel(str, { contentIsOpen: false }); }
	}
}

//--------------------------------------------------------------------------------------------------------------------------------//

function expandAll(count){
for (y=1;y<=count;y++)
	{
		var str = "CollapsiblePanel" + y ; 
		var strpanel = "panel" + y;		
		document.cookie = strpanel + "=" + "open" ;
		var str = new Spry.Widget.CollapsiblePanel(str, { contentIsOpen: true });
	}
	document.getElementById('expandAllButton').style.display = "none";
	document.getElementById('collapseAllButton').style.display = "inline";
	//window.location.reload();
}

function collapseAll(count){
for (y=1;y<=count;y++)
	{	
		var str = "CollapsiblePanel" + y ; 
		var strpanel = "panel" + y;		
		document.cookie = strpanel + "=" + "open" + ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
	}
	document.getElementById('expandAllButton').style.display = "inline";
	document.getElementById('collapseAllButton').style.display = "none";
	window.location.reload();
}
//--------------------------------------------------------------------------------------------------------------------------------//

/*
		toggle switch for setting up session-only cookies to store the open/closed status of the collapsible panels.  
		(We want to record the open/close state so when the user refreshes the page, the same panels are opened/closed.)
		This function toggles the existence of the cookie.  
		    If the cookie exists, the panel WAS open and IS being closed.
		    If the cookie does not exist, the panel WAS closed and IS being opened.
		This function does not affect the existing state of panels on page refresh, it is only called when a user clicks 
		a panel to open/close- and thus toggles that panel's cookie.  The page refresh function is runPanel(#).
*/

function setToggleCookie(panelID,state){  
	//if the cookie already exists, then the panel is already open and needs to be closed, so remove the cookie.
	if (getCookie(panelID)) {
		document.cookie = panelID + "=" + state + ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
	} 
	//if the cookie does not exist, then the panel is still closed and needs to be opened, so add the cookie.
	else{
		document.cookie = panelID + "=" + state;
	}
}

//--------------------------------------------------------------------------------------------------------------------------------//

//	Used in the multimedia Videos page for the english/spanish tabs.
function setTabCookie(panelID, state) {
    document.cookie = panelID + "=" + state;
}

//--------------------------------------------------------------------------------------------------------------------------------//

//	Used in the multimedia Videos page for the english/spanish tabs.
function deleteTabCookie(panelID, state) {
    document.cookie = panelID + "=" + state + ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

//--------------------------------------------------------------------------------------------------------------------------------//

function setCookie(name,value){  
		document.cookie = name + "=" + value ;
}


// used for text sizing
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
		
function eraseCookie(name) {
	createCookie(name,"",-1);
}		

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

// used for text sizing
function createJackCookie(name,value) {

	document.cookie = name+"="+value+"; path=/";
}


//--------------------------------------------------------------------------------------------------------------------------------//

//	get existing cookies, used in the setCookie() and runPanel() functions.
function getCookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f
	for ( i = 0; i < a_all_cookies.length; i++ )
	{	// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );
		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{	b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
				{ cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') ); }
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{	return null; }
}	
	
	
//--------------------------------------------------------------------------------------------------------------------------------//

	
//---------------------------------------------------------------------------------------------------------------------------------//

//	this function is called when the user clicks the - or + for text sizing (located in the _Common.master template)
//  the check at every page load (see bottom of page template for the function that calls getAndSetFontSize is 
//  necessary so the changed font size stays in effect for the rest of the user's session, when switching pages, etc.

function changeFontSize(amt){ 
	fCookie = readCookie('fSize');
//	alert("2) " + fCookie + " " +amt );
	nCookie = (parseFloat(fCookie) + parseFloat(amt));
	setFontSize(nCookie);
}  

function getAndSetFontSize(){
	if (readCookie('fSize')){
			fCookie = readCookie('fSize');
	}
	else {
			fCookie = 12;
	}
	setFontSize(fCookie);
}

function setFontSize(nCookie){
//	alert("found cookie, setting size to: " + nCookie);
	createCookie('fSize',nCookie,1);
//	alert("3) " + nCookie);
	var nCookieString = nCookie+'px';
// 	alert("4) " + nCookieString);
	// set all text styles for resizing here.
	// '$' represents jQuery parameter
	$('.maincontent li').css('font-size',nCookieString);
	$('.maincontent p').css('font-size',nCookieString);
	$('.maincontent td').css('font-size',nCookieString);
	$('.maincontent dd').css('font-size',nCookieString);
	$('.maincontent dt').css('font-size',nCookieString);
}

//  ---  Added script to set up text size for usaSearch template- since it is in a different domain, search.uscourts.gov
function searchchangeFontSize(amt){ 
	fCookie = readCookie('sfSize');
//	alert("2) " + fCookie + " " +amt );
	nCookie = (parseFloat(fCookie) + parseFloat(amt));
	searchsetFontSize(nCookie);
}  

function searchgetAndSetFontSize(){
	if (readCookie('sfSize')){
			fCookie = readCookie('sfSize');
	}
	else {
			fCookie = 12;
	}
	searchsetFontSize(fCookie);
}

function searchsetFontSize(fCookie){
	nCookie = parseFloat(fCookie);
	//alert("found cookie, setting size to: " + nCookie);
	createCookie('sfSize',nCookie,1);
//	alert("3) " + nCookie);
	var nCookieString = nCookie+'px';
// 	alert("4) " + nCookieString);
	// set all text styles for resizing here.
	// '$' represents jQuery parameter
	$('.searchresult h2').css('font-size',nCookieString);
	$('.searchresult h3').css('font-size',nCookieString);
}





//--------------------------------------------------------------------------------------------------------------------------------//

/*	function to grab any parameter from a url.  For example if you have the following url:
				http://www.foo.com/index.html?bob=123&frank=321&tom=213#top
		You want to get the value from the 'frank' parameter so you call the javascript function as follows: 
				var frankValue = gup('frank')
		You will be returned '321'
*/

function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}


//--------------------------------------------------------------------------------------------------------------------------------//


// function to toggle hide or unhide any display item that is hidden
function hideUnhide(id){
	if (	document.getElementById(id).style.display=='none') 
				document.getElementById(id).style.display='';
	else(	document.getElementById(id).style.display='none');
}


//---------------------------------------------------------------------------------------------------------------------------------//



//function to allow user to view pdfs and other documents in an iframe
function documentViewer(){
		var pageNumber = gup('page');  //if opening the pdf to a certain page, grab the '&page=' parameter value from the url
		if (pageNumber ==''){
					var pageText = ''}
		else {var pageText = "#page=" + pageNumber}
    var issueValue = gup('doc');	//grab the '?doc=' parameter value from the url.  This should be the full url to the document, from the root of the web server.  i.e. '/uscourts/... '
    if (issueValue !='' ){
        var pathValue =  issueValue + pageText;}
    else{var pathValue = "about:blank"}		//if this function is called on a blank page, display BLANK so users do not see a 404 error.

	//the 'viewFullScreenTag' div tag is already built into the 1ColumnNoNav template. All we have to do is add the link
	//the positioning of the view full screen link is contained in the style sheet under the .viewFullScreen class
	addFullScreenTag();

	//write out the iframe	
	document.write('<iframe height="1100px" frameborder="0" width="100%" class="htmlPage" id="htmlPage" style="margin: auto;" marginheight="0" marginwidth="0" src="' + pathValue + '"></iframe>');


}

//---------------------------------------------------------------------------------------------------------------------------------//

//function to add the "full screen view" to the page.
//the 'viewFullScreenTag' div tag is already built into the 1ColumnNoNav template. All we have to do is add the link
//the positioning of the view full screen link is contained in the style sheet under the .viewFullScreen class
function addFullScreenTag(){
	document.getElementById('viewFullScreenTag').innerHTML = '<a href="javascript:grabCurrentSrc();">view full screen or print</a>';
}

//function to open the EXISTING page of the iframe into the "full screen view".
//this is not possible with simply calling iframe.src as the original iframe source does not change accordingly if the user is clicking around 'inside' the iframe.
//thus we have to add another function to grab the url at the moment it is needed.  

function grabCurrentSrc() {
    window.location = document.getElementById('htmlPage').contentWindow.location.href;
}

function grabCurrentSrc2() {
	alert('this is the url: ' + document.getElementById('htmlPage').src);
	alert('this is the height: ' + document.getElementById('htmlPage').height);
	alert('this is the width: ' + document.getElementById('htmlPage').width);
    window.location = document.getElementById('htmlPage').contentWindow.location.href;
}



//---------------------------------------------------------------------------------------------------------------------------------//



//Highslide script for opening graphics and movies in a modal window.
	// remove the registerOverlay call to disable the controlbar
	hs.registerOverlay(
    {
    		thumbnailId: null,
    		overlayId: 'controlbar',
    		position: 'top right',
    		hideOnMouseOut: true
		}
	);
  hs.graphicsDir = '/Scripts/High_Slide_Javascript/highslide/graphics/';
  hs.outlineType = 'rounded-white';
  // Tell Highslide to use the thumbnail's title for captions
  hs.captionEval = 'this.thumb.title';
	hs.outlineWhileAnimating = true;
	

//---------------------------------------------------------------------------------------------------------------------------------//

//Print script for printing the content of a div.

function printSelection(node){

  var content=node.innerHTML
  var pwin=window.open('','print_content','width=500,height=500');

  pwin.document.open();
  pwin.document.write('<html><body onload="window.print()">'+content+'</body></html>');
  pwin.document.close();
 
  setTimeout(function(){pwin.close();},1000);

}

//---------------------------------------------------------------------------------------------------------------------------------//


// function to print the URL of the current page.
function showURL() {
    document.write(window.location)
}


//---------------------------------------------------------------------------------------------------------------------------------//


// function to display Multimedia (video) player from Kate Suttapakti's player
function loadPlayer() {
    var videoID;
    var videoURL;
    var videoImage;
    if (gup('video_id') != '')  { videoID = gup('video_id'); }
    else                        { videoID = document.getElementById('videoFeaturedID').innerHTML; }
    if (gup('video_url') != '') { videoURL = gup('video_url'); }
    else                        { videoURL = document.getElementById('videoFeaturedItem').innerHTML; }
    if (gup('video_image') != '')   { videoImage = gup('video_image'); }
    else                            { videoImage = document.getElementById('videoFeaturedImage').innerHTML; }

    flashObj = ('<object height="342" width="560" align="middle" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" id="soundslider">');
    flashObj = flashObj + ('<param name="allowScriptAccess" value="always">');
    flashObj = flashObj + ('<param name="movie" value="/uscourts/video/videoplayer/videoPlayer.swf">');
    flashObj = flashObj + ('<param name="FlashVars" value="video_url=' + videoURL + '&amp;video_image=' + videoImage + '">');
    flashObj = flashObj + ('<param name="quality" value="high">');
    flashObj = flashObj + ('<param name="allowFullScreen" value="true">');
    flashObj = flashObj + ('<param name="menu" value="false">');
    flashObj = flashObj + ('<param name="bgcolor" value="#000000">');
    flashObj = flashObj + ('<param name="AutoPlay" value="true">');
    flashObj = flashObj + ('<embed style="vertical-align: middle;" src="http://www.uscourts.gov/video/source/Player.swf" quality="high" bgcolor="#000000" name="preview" allowscriptaccess="sameDomain" allowfullscreen="true" flashvars="video_url=' + videoURL + '&amp;video_image=' + videoImage + '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" width="560" height="342" autoplay="true">');
    flashObj = flashObj + ('</object>');

    document.getElementById('videoPlayer').innerHTML = flashObj;
    document.getElementById('videoHeader').innerHTML = document.getElementById(videoID + 'Header').innerHTML;
    document.getElementById('videoSubHeader').innerHTML = document.getElementById(videoID + 'SubHeader').innerHTML;
    document.getElementById('videoDescription').innerHTML = document.getElementById(videoID + 'Description').innerHTML;
}
//---------------------------------------------------------------------------------------------------------------------------------//


// function to display SoundSlides slideshow player
function loadSlideshow() {
    var slideshowURL;
    var featured = document.getElementById('photoFeaturedItem').innerHTML;
    if (gup('URL') != '')   { slideshowURL = gup('URL'); }
    else                    { slideshowURL = featured; }
    slideshowObj = ('<object height="463" width="800" align="middle" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" id="soundslider">');
    slideshowObj = slideshowObj + ('<param name="allowScriptAccess" value="always">');
    slideshowObj = slideshowObj + ('<param name="movie" value="' + slideshowURL + '">');
    slideshowObj = slideshowObj + ('<param name="quality" value="high">');
    slideshowObj = slideshowObj + ('<param name="allowFullScreen" value="true">');
    slideshowObj = slideshowObj + ('<param name="menu" value="false">');
    slideshowObj = slideshowObj + ('<param name="bgcolor" value="#ffffff">');
    slideshowObj = slideshowObj + ('<embed src="' + slideshowURL + '" quality="high" bgcolor="#ffffff" width="800" height="463" name="soundslider" align="middle" menu="false" allowScriptAccess="always" type="application/x-shockwave-flash" allowFullScreen="true" pluginspage="http://www.macromedia.com/go/getflashplayer" />')
    slideshowObj = slideshowObj + ('</object>');
    document.getElementById('photoMainPlayer').innerHTML = slideshowObj;

}
//---------------------------------------------------------------------------------------------------------------------------------//

// function to display correct tab (English/Spanish) upon loading or refreshing the Multimedia Videos page.

function runTabs() {
    /* grab the TabCount variable from the bottom of the .aspx page */
    var count = TabCount;
    for (y = 1; y <= count; y++) {
        var strTab = "tab" + y;
        var strPanel = "panel" + y;
        /* run through all the tabs on the page and check if a cookie exists for any.
           if a cookie exists, then show that tab and panel, and then exit the function */
        if (getCookie(strPanel)) {
            showTabAndPanel(strTab, strPanel);
            return false;
        }
    }
}
//---------------------------------------------------------------------------------------------------------------------------------//

// function to display correct tab (English/Spanish) upon clicking the tab on the Multimedia Videos page.

function showTabAndPanel(tab, panel) {
    /* grab the TabCount variable from the bottom of the .aspx page */
    var countX = TabCount;
    var i = 1;
    while (i <= countX) {
        arrayTab = "tab" + i;
        arrayPanel = "panel" + i;
        if (arrayPanel == panel) {
            setTabCookie(panel, 'somevalue');
            document.getElementById(panel).style.display = 'block';
            document.getElementById(tab).className = 'tab mmTab_Selected';
        }
        if (arrayPanel != panel) {
            deleteTabCookie(arrayPanel, 'somevalue');
            document.getElementById(arrayPanel).style.display = 'none';
            document.getElementById(arrayTab).className = 'tab mmTab';
        }
        i++;
    }
    return false;
}
//---------------------------------------------------------------------------------------------------------------------------------//


    function clearForm(oForm) {
//alert ('hi');

   var elements = oForm.elements;

        oForm.reset();

        for (i = 0; i < elements.length; i++) {

            field_type = elements[i].type.toLowerCase();

            switch (field_type) {

                case "text":
                case "password":
                case "textarea":
                case "hidden":

                    elements[i].value = "";
                    break;

                case "radio":
                case "checkbox":
                    if (elements[i].checked) {
                        elements[i].checked = false;
                    }
                    break;

                case "select-one":
                case "select-multi":
                    elements[i].selectedIndex = -1;
                    break;

                default:
                    break;
            }
        }


    }
//---------------------------------------------------------------------------------------------------------------------------------//


//redirect function
function redirect(path){
	var r=confirm("You are about to be redirected to: \n\n     " + path + "\n\nSelect OK to continue or Cancel to cancel.\n\n");
	if (r == true)
		{
			window.open(path)
		}
}

//---------------------------------------------------------------------------------------------------------------------------------//


// function to redirect users to external pages.

function runRedirect(){
    var issueValue = gup('URL');	//NOTE**** 'URL' is case sensitive (javascript), so make sure it is 'URL', not 'url" or 'Url'.

		var pathS = window.location.href;
		//alert (pathS.length);
		var pathLength = pathS.length;
		//alert('hi');
		var startURL = pathS.indexOf('URL=');
		//alert('hi2');
		//alert (startURL);
		var newPathS = pathS.substring(startURL+4,pathLength);
		//alert (newPathS);
		
		var pathValue = newPathS;

    if (issueValue =='' ){
        pathValue = "about:blank"
    }
    else if (issueValue.indexOf('http://') == -1){
        pathValue = "http://" + pathValue
    }
    

  document.getElementById('redirectPath').innerHTML="<a href='" + pathValue + "'>" + pathValue + "</a>" ;
  document.getElementById('goNew').innerHTML='<input style="float:left; font-size:12px; font-weight:bold;" type="button" onclick="javascript:window.location=\'' + pathValue + '\'" value="Continue" />'; 
  document.getElementById('noThanks').innerHTML='<input style="float:left; font-size:12px; font-weight:bold;" type="button" onclick="javascript:window.history.back()" value="No thanks" />'; 
  window.setTimeout("window.location='" + pathValue + "'" , 8000);

}



//---------------------------------------------------------------------------------------------------------------------------------//


function checkForField(fieldName){

	var thisVal = document.getElementById(fieldName).value;
	
	alert(thisVal);
	

}


//---------------------------------------------------------------------------------------------------------------------------------//
// functions used in Appointment of Counsel's, The Guide: Volume 7 page to display a pop-up warning box to users prior to opening any page or pdf, etc.

function notice(url){
	if (getCookie('vol7Alert')){
		this.document.location = url;
	}
	else{
		this.document.getElementById("notice").style.display = 'block';		
		this.document.getElementById("gotoUrl").value = url;
		this.document.getElementById("hide").checked = false;
	}
} 

function OK(){
	if (this.document.getElementById("hide").checked == true )
		{			createCookie('vol7Alert','true');		}
		else if (this.document.getElementById("hide").checked == false)
		{			eraseCookie('vol7Alert');		}
		this.document.getElementById("notice").style.display = 'none';		
		this.document.location = this.document.getElementById("gotoUrl").value;
}



//---------------------------------------------------------------------------------------------------------------------------------//

//Homepage Feature Story
//START

window.onerror=function(desc,page,line,chr){
/* alert('JavaScript error occurred! \n'
  +'\nError description: \t'+desc
  +'\nPage address:      \t'+page
  +'\nLine number:       \t'+line
 );*/
}

$(function(){
 $('a').focus(function(){this.blur();});
 SI.Files.stylizeAll();
 slider.init();

 $('input.text-default').each(function(){
  $(this).attr('default',$(this).val());
 }).focus(function(){
  if($(this).val()==$(this).attr('default'))
   $(this).val('');
 }).blur(function(){
  if($(this).val()=='')
   $(this).val($(this).attr('default'));
 });

 $('input.text,textarea.text').focus(function(){
  $(this).addClass('textfocus');
 }).blur(function(){
  $(this).removeClass('textfocus');
 });

 var popopenobj=0,popopenaobj=null;
 $('a.popup').click(function(){
  var pid=$(this).attr('rel').split('|')[0],_os=parseInt($(this).attr('rel').split('|')[1]);
  var pobj=$('#'+pid);
  if(!pobj.length)
   return false;
  if(typeof popopenobj=='object' && popopenobj.attr('id')!=pid){
   popopenobj.hide(50);
   $(popopenaobj).parent().removeClass(popopenobj.attr('id').split('-')[1]+'-open');
   popopenobj=null;
  }
  return false;
 });
 $('p.images img').click(function(){
  var newbg=$(this).attr('src').split('bg/bg')[1].split('-thumb')[0];
  $(document.body).css('backgroundImage','url('+_siteRoot+'images/bg/bg'+newbg+'.jpg)');
 
  $(this).parent().find('img').removeClass('on');
  $(this).addClass('on');
  return false;
 });
 $(window).load(function(){
	var css_ims=this;
   $.each(css_ims,function(){(new Image()).src=_siteRoot+'css/images/'+this;});
	var css_cims=this;
   $.each(css_cims,function(){
  var css_im=this;
   $.each(['blue','purple','pink','red','grey','green','yellow','orange'],function(){
    (new Image()).src=_siteRoot+'css/'+this+'/'+css_im;
   });
  });
 }); 
 $('div.sc-large div.img:has(div.tml)').each(function(){
  $('div.tml',this).hide();
  $(this).append('<a href="#" class="tml_open">&nbsp;</a>').find('a').css({
   left:parseInt($(this).offset().left)+864,top:parseInt($(this).offset().top)+1
  }).click(function(){
   $(this).siblings('div.tml').slideToggle();
   return false;
  }).focus(function(){this.blur();}); 
 });
});
var slider={
 num:-1,
 cur:0,
 cr:[],
 al:null,
 at:8*800,
 //set slide lotator speed
 ar:true,
 init:function(){
  if(!slider.data || !slider.data.length)
   return false;

  var d=slider.data;
  slider.num=d.length;
  var pos=Math.floor(Math.random()*1);//slider.num);
  for(var i=0;i<slider.num;i++){
   $('#'+d[i].id).css({left:((i-pos)*800)});
   $('#slide-nav').append('<a id="slide-link-'+i+'" href="#" onclick="slider.slide('+i+');return false;" onfocus="this.blur();">'+(i+1)+'</a>');
  }

  $('img,div#slide-controls',$('div#slide-holder')).fadeIn();
  slider.text(d[pos]);
  slider.on(pos);
  slider.cur=pos;
  window.setTimeout('slider.auto();',slider.at);
 },
 auto:function(){
  if(!slider.ar)
   return false;

  var next=slider.cur+1;
  if(next>=slider.num) next=0;
  slider.slide(next);
 },
 slide:function(pos){
  if(pos<0 || pos>=slider.num || pos==slider.cur)
   return;

  window.clearTimeout(slider.al);
  slider.al=window.setTimeout('slider.auto();',slider.at);

  var d=slider.data;
  for(var i=0;i<slider.num;i++)
      $('#'+d[i].id).stop().animate({left:((i-pos)*535)},535,'swing');
  
  slider.on(pos);
  slider.text(d[pos]);
  slider.cur=pos;
 },
 on:function(pos){
  $('#slide-nav a').removeClass('on');
  $('#slide-nav a#slide-link-'+pos).addClass('on');
 },
 text:function(di){
  slider.cr['a']=di.client;
  slider.cr['b']=di.desc;
  slider.ticker('#slide-client span',di.client,0,'a');
  slider.ticker('#slide-desc',di.desc,0,'b');
 },
 ticker:function(el,text,pos,unique){
  if(slider.cr[unique]!=text)
   return false;

  ctext=text.substring('show');
  $(el).html(ctext);

  if(pos==text.length)
   $(el).html(text);
  else
   window.setTimeout('slider.ticker("'+el+'","'+text+'",'+(pos+1)+',"'+unique+'");','show');
 }
};

if(!window.SI){var SI={};};
SI.Files={
 htmlClass:'SI-FILES-STYLIZED',
 fileClass:'file',
 wrapClass:'cabinet',
 
 fini:false,
 able:false,
 init:function(){
  this.fini=true;
 },
 stylize:function(elem){
  if(!this.fini){this.init();};
  if(!this.able){return;};
  
  elem.parentNode.file=elem;
  elem.parentNode.onmousemove=function(e){
   if(typeof e=='undefined') e=window.event;
   if(typeof e.pageY=='undefined' &&  typeof e.clientX=='number' && document.documentElement){
    e.pageX=e.clientX+document.documentElement.scrollLeft;
    e.pageY=e.clientY+document.documentElement.scrollTop;
   };
   var ox=oy=0;
   var elem=this;
   if(elem.offsetParent){
    ox=elem.offsetLeft;
    oy=elem.offsetTop;
    while(elem=elem.offsetParent){
     ox+=elem.offsetLeft;
     oy+=elem.offsetTop;
    };
   };
  };
 },
 stylizeAll:function(){
  if(!this.fini){this.init();};
  if(!this.able){return;};
 }
};


//Homepage Feature Story
//END
//---------------------------------------------------------------------------------------------------------------------------------//

//Redbar Navigation Tab
//Change the background to dark-red same like on hover.

$(document).ready(function() {
            var url = location.pathname;

            var tabClass = new Array("li.nav_fed", "li.nav_rule", "li.nav_jud", "li.nav_stat", "li.nav_form", "li.nav_court", "li.nav_edu", "li.nav_news");
            var pathUrl = new Array("/FederalCourts", "/RulesAndPolicies", "/JudgesAndJudgeships", "/Statistics", "/FormsAndFees", "/CourtRecords", "/EducationalResources", "/News");

            if (url.indexOf(pathUrl[0]) > -1) {
                $(tabClass[0]).addClass("navigationSelectedTab");
            }
            else if (url.indexOf(pathUrl[1]) > -1) {
                $(tabClass[1]).addClass("navigationSelectedTab");
            }
            else if (url.indexOf(pathUrl[2]) > -1) {
                $(tabClass[2]).addClass("navigationSelectedTab");
            }
            else if (url.indexOf(pathUrl[3]) > -1) {
                $(tabClass[3]).addClass("navigationSelectedTab");
            }
            else if (url.indexOf(pathUrl[4]) > -1) {
                $(tabClass[4]).addClass("navigationSelectedTab");
            }
            else if (url.indexOf(pathUrl[5]) > -1) {
                $(tabClass[5]).addClass("navigationSelectedTab");
            }
            else if (url.indexOf(pathUrl[6]) > -1) {
                $(tabClass[6]).addClass("navigationSelectedTab");
            }
            else if (url.indexOf(pathUrl[7]) > -1) {
                $(tabClass[7]).addClass("navigationSelectedTab");
            }
        });
        

