// JavaScript Document

/* Double click variables */
var axel = Math.random() + "";
var ord = axel * 1000000000000000000;
var adRotation = 240000; /* 1000 miliseconds per second */
var intervalObj = "";
var adsToRefresh = "";
/* Double click variables */

var featuredTabIdx = 1;
var totalFeaturedTabs = 1;
var featuredTimer;
var currPage = 1;

//function expandTopAdZone() {
// document.getElementById('topAdContainer').style.height='230px';
//}

/*function collapseTopAdZone(e) {
 if(e) {
  var tag = getEventSource(e).tagName;
 
  if(tag != 'EMBED' && tag!= 'OBJECT' && tag != 'TD') {
   document.getElementById('topAdContainer').style.height='90px';	
  }
 }
 else {  
  document.getElementById('topAdContainer').style.height='90px';	
 }
}

function expandSideAdZone() {
 document.getElementById('sideAdContainer').style.width='550px';
 document.getElementById('sideAdContainer').style.left='-250px';
}

function collapseSideAdZone() {
 document.getElementById('sideAdContainer').style.width='300px';
 document.getElementById('sideAdContainer').style.left='0px';	 
}*/

$(document).ready(function(){
						   
		intervalObj = setInterval("refreshAds()", adRotation); 
		adsToRefresh = document.getElementsByName("advertisement");				   
						   
	  /*$(".paginationLnk, .paginationLnkSelected").click(function(){															
		$('a').removeClass("paginationLnkSelected");
		$(this).addClass("paginationLnkSelected");
		$("#page"+currPage).hide();
		currPage = $(this).text();
		$("#page"+currPage).show();		
		//window.scroll(0,0);		
		//refreshAdZones();
	  });	*/
	  
	 /* $("#nextPageLnk").click(function(){	
	    var temp = currPage*1+1;		
		if(document.getElementById('page'+temp)) {
		 $('$paginationLnk'+currPage).removeClass("paginationLnkSelected");	
		 $("#page"+currPage).hide();	
		 currPage = currPage*1+1;				 
		 $("#paginationLnk"+currPage).addClass("paginationLnkSelected");
		 $("#page"+currPage).show();
		 //window.scroll(0,0);
		 //refreshAdZones();		 		 
		}
	  });	*/
	  
	  
						   	
	  //if(document.getElementById('topAdContainer')) {
	//	document.getElementById('topAdContainer').onmouseover=expandTopAdZone; 
	//	document.getElementById('topAdContainer').onmouseout=collapseTopAdZone; 
	 // }
	  
	
	//Most Popular Tabs	
	/*$("div.mostpopular ul.selector li a").click(function(){
													
		$("div.mostpopular ul.selector li a").removeClass("selected");
		$(this).addClass("selected");
		$("div.mostpopular div").css("display","none");

		switch ($(this).attr("id")) {
			case "viewed": 	
				$("div#viewedlinks").css("display","block");
				break
			case "emailed": 	
				$("div#emailedlinks").css("display","block");
				break
		}
		return false;
	});	*/  
	
	
	if(document.getElementById('commentLink')) {
	  $("#commentLink").toggle(function(){
	   showCommentForm();
	  },function(){
	   hideCommentForm();
	 });		 			
	}
	
	
	
	// 404 Redirect					   
	if (document.getElementById('404Container')) {
	 setTimeout("window.location='/'",5000);
	}
	//Rating Chart - Changed 10/23/07
	if ($("#nofavorite")) {
		
		dleans = $("#leansdemocrat").height();
		rleans = $("#leansrepublican").height();
		totalleans = Math.abs(rleans-dleans) + 5;
			
		if (rleans < dleans) $("#leansrepublican table td").css("padding-bottom",totalleans+'px');
		else  $("#leansdemocrat table td").css("padding-bottom",totalleans+'px');

		rfavored = $("#republicanfavored").height();
		dfavored = $("#democratfavored").height();
		totalfavored = Math.abs(rfavored-dfavored) + 5;
			
		if (rfavored < dfavored) $("#republicanfavored table td").css("padding-bottom",totalfavored+'px');
		else  $("#democratfavored table td").css("padding-bottom",totalfavored+'px');

		rsafe = $("#saferepublican").height();
		dsafe = $("#safedemocrat").height();
		totalsafe = Math.abs(rsafe-dsafe) + 5;
			
		if (rsafe < dsafe) $("#saferepublican table td").css("padding-bottom",totalsafe+'px');
		else  $("#safedemocrat table td").css("padding-bottom",totalsafe+'px');
	};					   	 
	
	
	
	if ($(".bylinelnk")) {			   		
		$(".bylinelnk").click(function(){			
		 window.location='/wmspage.cfm?parm1='+$('#primarySectionID').text()+'&byline='+$(this).text();			 		 
		});
	};
	
	if ($(".publicationlnk")) {		
		$(".publicationlnk").click(function(){			
		 window.location='/wmspage.cfm?parm1='+getURLArg('parm1')+'&publication='+$(this).attr('id');			 		 		 
		});
	};
	
	//if ($("#adContainer")) {		
		
	//	setInterval("refreshAds()",adRefreshRate);
		
	//};
	
	
	//Landing Page Functions
	if ($("div.landing")) {	
	    if(document.getElementById('rotateContentControl')) {
		 $("#rotateContentControl").click(function(){				
				if(featuredTimer) {					 
				 stopFeaturedRotation();	
				}
				else {
				 startFeaturedRotation();	
				}
				return false;
			});			
		}
	
	    // if the featured load container exists setup auto rotation timer
	    if(document.getElementById('featuredContentLoadContainer')) {			
		 totalFeaturedTabs = $("ul.featureditems li a").size();
		 //featuredTimer=setInterval("rotateFeaturedItems()",10000);		
		}
		$("ul.featureditems li a").click(function(){			
			$("ul.featureditems li a").removeClass("selected");
			$(this).addClass("selected");			
			var tabArray = $(this).attr('id').split("_");
			var idx = tabArray[1];	
			featuredTabIdx = idx;
			section = $('#primarySection').text();			
			getMarkup('/actions/getFeaturedContent.cfm?featuredContentIdx='+idx+'&section='+section,'displayFeaturedContent');					
			return false;
		});	

		$("div.congresseye ul.selector li a").click(function(){
			$("div.congresseye ul.selector li a").removeClass("selected");
			$(this).addClass("selected");
			$("div.congresseye div").css("display","none");

			switch ($(this).attr("id")) {
				case "snapshots": 	
				    $("div.snapshots").fadeIn(1000); 	
					//$("div.snapshots").css("display","block");
					break
				case "votes": 
				    $("div.votes").fadeIn(1000); 	
					//$("div.votes").css("display","block");
					break
				case "billwatch": 
				    $("div.billwatch").fadeIn(1000); 	
					//$("div.billwatch").css("display","block");
					break
			}
			return false;
		});	
		
	}
	
	//Votes Detail Page - Added 10/12/07
	if ($("#republican_yeas")) {
		
		ryeas = $("#republican_yeas").height();
		dyeas = $("#democrat_yeas").height();
		totalyeas = Math.abs(ryeas-dyeas) + 7;
		//alert("R="+ryeas+", D="+dyeas+", Total="+total);
			
		if (ryeas < dyeas) $("#republican_yeas p.backtotop").css("margin-top",totalyeas+'px');
		else  $("#democrat_yeas p.backtotop").css("margin-top",totalyeas+'px');

		rnays = $("#republican_nays").height();
		dnays = $("#democrat_nays").height();
		totalnays = Math.abs(rnays-dnays) + 7;
		//alert("R="+ryeas+", D="+dyeas+", Total="+total);
			
		if (rnays < dnays) $("#republican_nays p.backtotop").css("margin-top",totalnays+'px');
		else  $("#democrat_nays p.backtotop").css("margin-top",totalnays+'px');

		rnovote = $("#republican_novote").height();
		dnovote = $("#democrat_novote").height();
		totalnovote = Math.abs(rnovote-dnovote) + 7;
		//alert("R="+ryeas+", D="+dyeas+", Total="+total);
			
		if (rnovote < dnovote) $("#republican_novote p.backtotop").css("margin-top",totalnovote+'px');
		else  $("#democrat_novote p.backtotop").css("margin-top",totalnovote+'px');
	};

	//General Functions

	
	
	//$("#emailed").click(function(){
							//	 $("div#viewedlinks").css("display","none");
							//	 $("div#emailedlinks").css("display","block");
													
		//$("div.mostpopular ul.selector li a").removeClass("selected");
		//$(this).addClass("selected");
		//$("div.mostpopular div").css("display","none");

		//switch ($(this).attr("id")) {
		//	case "viewed": 	
		//		$("div#viewedlinks").css("display","block");
		//		break
		//	case "emailed": 	
		//		$("div#emailedlinks").css("display","block");
		//		break
		//}
		//return false;
	//});	
	
	
	
	
	// Search button rollover
	$("input.searchbutton").hover(		
		function() {			
			off_img = $(this).attr('src');					
			over_img = off_img.replace('off/','on/');																			
			$(this).attr('src', over_img);	
			return false;
		},		
		function() {		
			$(this).attr('src', off_img);
			return false;		
		}		
	);
	
	if ($("#quickSearchForm")) {		
		$("#quickSearchForm").submit(function(){		
		 document.getElementById('searchArgQuick').style.borderColor='#D3D2C6';		  
		 if(isBlank(document.getElementById('searchArgQuick'))) {
		   document.getElementById('searchArgQuick').style.border='2px solid red';
		 }
		 else {
		  var oInput = document.createElement("input");
		  oInput.setAttribute("name","newsearch");
		  oInput.setAttribute("id","newsearch");
		  oInput.setAttribute("type","hidden");
		  oInput.value = true;
		  document.getElementById('quickSearchForm').appendChild(oInput);	  
		  document.getElementById('quickSearchForm').submit();		  
		 }		
		 return false;
		});	
	};
	
	if ($("#siteSearchForm")) {		
		$("#siteSearchForm").submit(function(){								
		 clearErrors();		
		 if(isBlank(document.getElementById('searchArg'))) {
		   setError('searchArg','Keyword(s) is a required field.'); 
		   displayErrorMessages();		   
		 }
		 else {		
		  var oInput = document.createElement("input");
		  oInput.setAttribute("name","newsearch");
		  oInput.setAttribute("id","newsearch");
		  oInput.setAttribute("type","hidden");
		  oInput.value = true;
		  document.getElementById('ss_resultsPage').value=1;
		  document.getElementById('siteSearchForm').appendChild(oInput);		  
		  document.getElementById('siteSearchForm').submit();  
		 }	
		 return false;		 
		});	
	};
	
	
	if ($("#searchOperatorsLink")) {		
		$("#searchOperatorsLink").toggle(function(){
				$(document.getElementById('searchHelpContainer')).css("display", "block");
				
			 },function(){
				$(document.getElementById('searchHelpContainer')).css("display", "none");
			});		
	};
	
	
	
	
	

	//For Content Page
	var test = $("#col_b").css("border-left-style");	
	var height_a = $("#col_a").css("height");
	var height_b = $("#col_b").css("height");
	if ((test=="solid") && (parseInt(height_a) > parseInt(height_b))) $("#col_b").css("height", height_a);	
	
	//Rating Chart
	if ($("ul.charttop")) {

		$("a#democrat_tab").click(function(){
			tab_off = $(this).css("background-image");
			if (tab_off.search('_off') > -1) tab_on = tab_off.replace('_off','_on');

			test = $("a#republican_tab").css("background-image");
			if (test.search('_on') > -1) $("a#republican_tab").css("background-image",tab_off);
			$("a#democrat_tab").css("background-image",tab_on);
			$("#republican_chart").css("display","none");
			$("#democrat_chart").css("display","block");
			return false;
		});	

		$("a#republican_tab").click(function(){
			tab_off = $(this).css("background-image");
			if (tab_off.search('_off') > -1) tab_on = tab_off.replace('_off','_on');
			
			test = $("a#democrat_tab").css("background-image");
			if (test.search('_on') > -1) $("a#democrat_tab").css("background-image",tab_off);
			$("a#republican_tab").css("background-image",tab_on);
			$("#republican_chart").css("display","block");
			$("#democrat_chart").css("display","none");
			return false;
		});
	};

	//Senate/House Landing
	if ($(".subnav")) {
		var t;			
		$('#nav ul li a').mouseover(function(){
		 var id = $(this).attr('id');
		 if(id) {
		  if(id.indexOf("nav_") == 0) {
		   $('table.subnavtable').css('display','none');
		  }		 	 
		 }	 
		 
		 $('#sub'+id).css('display','block');
		 clearTimeout(t);
		});	
		
		$("#nav ul li a").mouseout(function(){		    
			var id = $(this).parent().parent().parent().parent().attr("id");						
			if(id == 'header') {
			  t = setTimeout("$('#subnav_74').css('display','none')",150);
			}
			if(id.indexOf("subnav_") != -1) {
			 t = setTimeout("$('#"+id+"').css('display','none')",150);				 
			}
			else {
			 id = 'sub'+$(this).attr("id");			 						
			}		
		});	
		
		

	};

	//Race Details Page - Added 10/09/07
	if ($("a#opendistrict")) {

		$("a#opendistrict").toggle(
		  function(){
			$("#districtprofile").css("display","block");
			$("a#opendistrict").css("padding-left", "17px");
			$("a#opendistrict").css("background", "transparent url(images/backgrounds/marker.gif) no-repeat 0px 2px");
		  },
		  function(){
			$("#districtprofile").css("display","none");
			$("a#opendistrict").css("padding-left", "0px");
			$("a#opendistrict").css("background-image", "none");
		  }
		);
	};

	//Flash Box open - Added 10/09/07
	if ($("#flashbox")) {

		$("#electionflash").click(function(){
			$("#flashbox").css("display","block");
			href = $("#electionflash").attr("href");
			$("#flash").load(href);
			return false;
		});	

	};
	
	
	//Presidential Candidate Select Box	
	if ($("#presidentialCandidateForm")) {
		$("#candidates").change(function(){										 
		 if($(this).attr("value")) {	
		    if(document.location.search.indexOf("docID") == -1) {
		 	window.location = '/wmspage.cfm'+document.location.search+'&docID=profile-'+$(this).attr("value");		
			}
			else {
			 window.location = '/wmspage.cfm?parm1=6&docID=profile-'+$(this).attr("value");	
			}
		 }
		});	
	};
	
	
	// reprint function
	if ($("#reprintLink")) {
	  $("#reprintLink").click(function(){
	    window.open('http://corporate.cq.com/wmspage.cfm?parm1=265');
	  });
	}
	
	// print function
	if ($("#printLink")) {
	  $("#printLink").click(function(){
			 width=740;
 height=500;
 print_win=window.open('/frame-templates/print_template.html','PrintWMSPage','width='+width+',height='+height+', top='+((screen.availHeight/2)-(height/2))+',left='+((screen.availWidth/2)-(width/2))+',toolbar=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no');
 print_win.focus();  	
	  });
	}
	
	// email function
	if ($("#emailLink")) {
	  $("#emailLink").click(function(){
			 width=461;
 height=490;

 
 email_win=window.open('/frame-templates/email_template.cfm?email_url='+encodeURIComponent(location.href)+'&emailDocID='+getURLArg('docID'),'EmailWMSPage','width='+width+',height='+height+', top='+((screen.availHeight/2)-(height/2))+',left='+((screen.availWidth/2)-(width/2))+',toolbar=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no');
 email_win.focus();  	
	  });
	}
	
	if ($("#printLinkBtm")) {
	  $("#printLinkBtm").click(function(){
			 width=740;
 height=500;
 print_win=window.open('/frame-templates/print_template.html','PrintWMSPage','width='+width+',height='+height+', top='+((screen.availHeight/2)-(height/2))+',left='+((screen.availWidth/2)-(width/2))+',toolbar=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no');
 print_win.focus();  	
	  });
	}
	
	// email function
	if ($("#emailLinkBtm")) {
	  $("#emailLinkBtm").click(function(){
			 width=461;
 height=490;

 
 email_win=window.open('/frame-templates/email_template.cfm?email_url='+encodeURIComponent(location.href)+'&emailDocID='+getURLArg('docID'),'EmailWMSPage','width='+width+',height='+height+', top='+((screen.availHeight/2)-(height/2))+',left='+((screen.availWidth/2)-(width/2))+',toolbar=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no');
 email_win.focus();  	
	  });
	}
	
	
	if ($("#lawmakersform")) {
		$("#lawmakersform").submit(function(){			 
		 return false;
		 });	
	};
	
	if ($("#senaterepsBtn")) {
		$("#senaterepsBtn").click(function(){
		  if(document.getElementById('senatereps').selectedIndex > 0) {		 
		   window.location = '/wmspage.cfm?docID='+document.getElementById('senatereps').value;
		  }
		 });			
	};
	
	if ($("#houserepsBtn")) {
		$("#houserepsBtn").click(function(){
		  if(document.getElementById('housereps').selectedIndex > 0) {		 
		   window.location = '/wmspage.cfm?docID='+document.getElementById('housereps').value;
		  }
		 });			
	};
	
	if ($("#newsenaterepsBtn")) {
		$("#newsenaterepsBtn").click(function(){
		  if(document.getElementById('newsenatereps').selectedIndex > 0) {		 
		   window.location = '/wmspage.cfm?docID='+document.getElementById('newsenatereps').value;
		  }
		 });			
	};
	
	
	
	
	
	
	
	
	
	
	

});

function displayFeaturedContent(httpResponse) {	
 //$(document.getElementById('featuredContentLoadContainer')).hide();     
 //alert('test');
 document.getElementById('featuredContentLoadContainer').innerHTML=httpResponse;
 //$(document.getElementById('featuredContentLoadContainer')).fadeIn(1000); 	
}

function commentIsValid() {
 if(isBlank(document.getElementById('captchaVerification'))) {
  setError('captchaVerification','Verification is a required field.');	 
 }
 if(isBlank(document.getElementById('name'))) {
  setError('name','Name is a required field.');	 
 }
 if(!isValidEmail(document.getElementById('email'))) {
  setError('email','Email address is a required field.');	 
 }
 if(isBlank(document.getElementById('comments'))) {
  setError('comments','Comment is a required field.');	 
 }
 if(formHasErrors()) {
  return false;
 }
 return true;	
}

function completeCommentPost(str) {
 if(str.indexOf('Failed: captcha') != -1) {
  setError('captchaVerification','Verification does not match the image displayed.');	 				
  displayErrorMessages();
 }
 else if(str.indexOf('success') != -1) { 
  alert("comment submitted");
  hideCommentForm(); 
  
  	
 }
}

function emailPageFormIsValid() {
 if(isBlank(document.getElementById('to_name'))) {
  setError('to_name','');	 
 }
 if(!isValidEmail(document.getElementById('to_email'))) {
  setError('to_email','');	 
 }
 if(isBlank(document.getElementById('from_name'))) {
  setError('from_name','');	 
 }
 if(!isValidEmail(document.getElementById('from_email'))) {
  setError('from_email','');	 
 } 
 if(formHasErrors()) {
  return false;
 }
 return true;	
}

function emailPageLink() { 
 clearErrors(); 									   
 if(emailPageFormIsValid()) {
  document.getElementById('emailPageForm').action='/wmsemail.cfm';
  document.getElementById('emailPageForm').submit();  
  return false;
 }
 else {
  displayErrorMessages();		
 }	
}

function completeEmailPagePost(str) {
 if(str.indexOf("success") != -1) {
	self.parent.tb_remove();
	alert("Email has been sent.");
	 
 }
 else {
  self.parent.tb_remove();	 
 }
}


function getResultsPage(resultsPage) { 
 document.getElementById('siteSearchForm').reset();
 document.getElementById('ss_resultsPage').value=resultsPage;
 document.getElementById('siteSearchForm').submit(); 
}

// this function gets the cookie, if it exists
function Get_Cookie( name ) {	
 var start = document.cookie.indexOf( name + "=" );
 var len = start + name.length + 1;
 if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
  return null;
 }
 if ( start == -1 ) return null;
 var end = document.cookie.indexOf( ";", len );
 if ( end == -1 ) end = document.cookie.length;
 return unescape( document.cookie.substring( len, end ) );
}

/*
 only the first 2 parameters are required, the cookie name, the cookie
 value. Cookie time is in milliseconds, so the below expires will make the 
 number you pass in the Set_Cookie function call the number of days the cookie
 lasts, if you want it to be hours or minutes, just get rid of 24 and 60.

 Generally you don't need to worry about domain, path or secure for most applications
 so unless you need that, leave those parameters blank in the function call.
*/
function Set_Cookie( name, value, expires, path, domain, secure ) {
 // set time, it's in milliseconds
 var today = new Date();
 today.setTime( today.getTime() );
 // if the expires variable is set, make the correct expires time, the
 // current script below will set it for x number of days, to make it
 // for hours, delete * 24, for minutes, delete * 60 * 24
 if ( expires ) {
  expires = expires * 1000 * 60 * 60 * 24;
 }
 //alert( 'today ' + today.toGMTString() );// this is for testing purpose only
 var expires_date = new Date( today.getTime() + (expires) );
 //alert('expires ' + expires_date.toGMTString());// this is for testing purposes only
 document.cookie = name + "=" +escape( value ) +
  ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + //expires.toGMTString()
  ( ( path ) ? ";path=" + path : "" ) + 
  ( ( domain ) ? ";domain=" + domain : "" ) +
  ( ( secure ) ? ";secure" : "" );
}

// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) {
 if ( Get_Cookie( name ) ) document.cookie = name + "=" +
  ( ( path ) ? ";path=" + path : "") +
  ( ( domain ) ? ";domain=" + domain : "" ) +
  ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function getURLArg(name) {
 var queryString = location.search.substring(1);
 var valuePairs = queryString.split("&");
 var temp = '';
 var urlValue = '';
 for(var x = 0; x < valuePairs.length; x++) {
  temp = valuePairs[x].split("=");
  if(temp[0].toLowerCase() == name.toLowerCase()) {
	urlValue = temp[1];
	break;
  }
 }
 return urlValue;
}

// Flash close  - Added 10/09/07
function flashclose() {
	document.getElementById("flashbox").style.display = "none";
}

function bindCommentFunctions() {
	
if(document.getElementById('commentForm')) {
	
		var userCookie = Get_Cookie('cqRememberMe');
		if(userCookie) {
		 var tmpString = userCookie.split(":");		 
		 document.getElementById('name').value = tmpString[0];
		 document.getElementById('email').value = tmpString[1];	
		 document.getElementById('remember').checked=true;
		}
		$("#commentForm").submit(function(){
	        clearErrors(); 									   
			if(commentIsValid()) {			
			  if(document.getElementById('remember').checked) {				   
			   var cookieVal = document.getElementById('name').value+':'+document.getElementById('email').value;
			   Set_Cookie('cqRememberMe',cookieVal,365) ;			   
			  }
			  else {
			   if(Get_Cookie('cqRememberMe')) {
				Delete_Cookie('cqRememberMe');    
			   }
			  }
			  submitForm(document.getElementById('commentForm'),'/actions/_postComment.cfm','completeCommentPost');			 			 
			}
			else {
			 displayErrorMessages();	
			}
			return false;
		});	
	}	
	
	if ($("#captchaLink")) {
		$("#captchaLink").click(function(){										 
		  AjaxRequest.get(
          {
           'url':'/actions/getCaptchaImage.cfm'    
           ,'onSuccess':function(req){ document.getElementById('captchaImage').src=trimResponse(req.responseText); }
           ,'onError':function(req){ errorHandler(req.responseText); }   
          }
         );						 		 
		});	
	};
}

function showCommentForm() { 
 $("#commentFormContainer").load("/actions/_commentForm.cfm?docID="+getURLArg("docID"),'',bindCommentFunctions);
 $("#commentBtn").addClass("eyearrowOpen"); 
}

function hideCommentForm() {	
 clearErrors(); 				
 document.getElementById('commentFormContainer').innerHTML='';
 $("#commentBtn").removeClass("eyearrowOpen"); 
}

function rotateFeaturedItems() {
 featuredTabIdx++;
 if(featuredTabIdx > totalFeaturedTabs) {
  featuredTabIdx=1;	  
 }
 $("ul.featureditems li a").removeClass("selected");
 document.getElementById('featurebox').getElementsByTagName('a').item(featuredTabIdx-1).className='selected';
 getMarkup('/actions/getFeaturedContent.cfm?featuredContentIdx='+featuredTabIdx+'&section='+document.getElementById('primarySection').innerHTML,'displayFeaturedContent');														
}

function getRssFeed(rssFeed,displayType,maxrows,cacheTime,arg) {	
 var tag = '';	
 if(arg) {
  tag = arg;  
 }   
 
 var html = 
  $.ajax({
   url: '/actions/_getRSSFeed.cfm?rssFeed='+rssFeed+'&displayType='+displayType+'&maxrows='+maxrows+'&cacheTime='+cacheTime+'&parm1='+getURLArg("parm1")+'&tag='+tag,
   async: false
  }).responseText;  
  document.write(html);
}

function getDocList(args) {

 var args = args.toLowerCase();
 var valuePairs = args.split(","); 
 var valuePair = "";
 var parm1 = getURLArg('parm1');
 var qstring = uid=getUID();
 var list = 'yes';
 var argument = ''; 
 for(var x = 0; x < valuePairs.length; x++) {	
   valuePair = valuePairs[x].split(":");	   
   argument = $.trim(valuePair[0]); 
   
   switch(argument) {
    case 'tags':   
    qstring+='&tags='+valuePair[1];
    break;
   case 'tagdecisionoperator':  
    qstring+='&tagDecisionOperator='+valuePair[1];
    break;
   case 'tagbooleanoperator':  
    qstring+='&tagBooleanOperator='+valuePair[1];
    break;  
   case 'publicationtype':	 
	qstring+='&publicationtype='+valuePair[1];
	break;
   case 'section':	 
	qstring+='&section='+valuePair[1];
	break;	
   case 'byline':	 
    qstring+='&byline='+valuePair[1];
	break;
   case 'publication':	 
    qstring+='&publication='+valuePair[1];
    break;
   case 'oid':	 
	qstring+='&oid='+valuePair[1]; 
	break;
   case 'state':	 
	qstring+='&state='+valuePair[1];
	break;
   case 'district':	 
	qstring+='&district='+valuePair[1];
	break;
   case 'race':	 
	qstring+='&race='+valuePair[1];
	break;	
   case 'subjects':	 
	qstring+='&subjects='+valuePair[1];
	break;
   case 'subjectdecisionoperator':	 
	qstring+='&subjectDecisionOperator='+valuePair[1];
	break;
   case 'subjectbooleanoperator':	 
	qstring+='&subjectBooleanOperator='+valuePair[1];
	break; 
   case 'tags':	 
	qstring+='&tags='+valuePair[1];
	break;
   case 'tagdecisionoperator':	 
	qstring+='&tagDecisionOperator='+valuePair[1];
	break;
   case 'tagbooleanoperator':	 
	qstring+='&tagBooleanOperator='+valuePair[1];
	break; 
   case 'keywords':	 
	qstring+='&keywords='+valuePair[1];
	break;
   case 'keyworddecisionoperator':	 
	qstring+='&keywordDecisionOperator='+valuePair[1];
	break;
   case 'keywordbooleanoperator':	 
	qstring+='&keywordBooleanOperator='+valuePair[1];
	break;
   case 'maxrows':	 
	qstring+='&maxrows='+valuePair[1];
    
	break;
   case 'header':	 
    qstring+='&header='+valuePair[1];
	break; 
   case 'list':	
	list = valuePair[1];   
	break;
   case 'docoptioncode':	
	qstring+='&docoptioncode='+valuePair[1];     
	break;	
   case 'datetime':	
	qstring+='&dateTime='+valuePair[1];
	break;
   case 'datetimedecisionoperator':	 
	qstring+='&dateTimeDecisionOperator='+valuePair[1];
	break;	
   case 'displaytype':	 
	qstring+='&displayType='+valuePair[1];
	break;	
   case 'tagquery':	    
	qstring+='&tagQuery='+escape(valuePair[1]);
	break;		
  }
 }
 
 if(parm1 != "") {
   qstring+='&parm1='+parm1; 
 } 
 
 qstring+='&list='+list; 
 var html = 
  $.ajax({
   url: '/actions/_getDocList.cfm?'+qstring,
   cache: false,
   async: false
 }).responseText;
  
 

  
 document.write($.trim(html));
 
}

function getUID() { 	
 var date = new Date(); 
 var UID = ''+date.getSeconds()+date.getMinutes()+date.getHours()+date.getDate()+date.getMonth()+date.getFullYear()+(Math.floor(Math.random()*10000)+1000);
 return UID;
}

function stopFeaturedRotation() { 
 document.getElementById('rotateControlIcon').src=document.getElementById('rotateControlIcon').src.replace('cq_pause','cq_start');  
 clearInterval(featuredTimer);	
 featuredTimer=null;
}

function startFeaturedRotation() { 
 document.getElementById('rotateControlIcon').src=document.getElementById('rotateControlIcon').src.replace('cq_start','cq_pause');
 featuredTimer=setInterval("rotateFeaturedItems()",10000);	
}

function popularTabs(obj) { 
 $("div.mostpopular ul.selector li a").removeClass("selected");
 $('#'+obj.id).addClass("selected"); 
 $("#viewedlinks").css("display","none");
 $("#emailedlinks").css("display","none"); 
 $('#'+obj.id+'links').css("display","block"); 
}

function refreshAdZones() {
 if(document.getElementById('topAdContainer')) {
  $('#topAdContainer').attr('src',$('#topAdContainer').attr('src'));					
 }
 if(document.getElementById('sideAdContainer')) {
  $('#sideAdContainer').attr('src',$('#sideAdContainer').attr('src'));					
 } 
}

function getEventSource(e) {
 if(e.srcElement) {	  	  
  return e.srcElement;	
 }
 else if(e.target) {
  return e.target;	  
 } 	
 return null;
} 


/*
 *  Tab Function for Party Unity
 */ 

function showtab(index)
    {
      for( var i = 1; i <= 7; i++ )
      {
        var theDiv = document.getElementById( "tab" + i );
        if( i == index )
        {
          theDiv.style.display = 'block';
        }
        else
        {
          theDiv.style.display = 'none';
        }
      }
    }


/**
 * Opens a barebones pop-up window.
 * 
 * @param url    the URL of the window's contents
 * @param name   the name of the window
 * @param width  width of pop-up window
 * @param height height of pop-up window
 */
function simplePopup(url, name, width, height){
   openWindow(url, name, 'toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width='+width+',height='+height);
}



/**
 * Another function for generating a pop-up window.
 * 
 * @param url    url of the resource to display in the pop-up
 * @param name   name of pop-up window
 */
function startWin(url, name) {
   var popupWin = null;
   var winName = "cq" + name; // add cq to the name so that we can detect that it's one of our pop-ups
   popupWin = window.open(url, winName,'resizable,toolbar,scrollbars,menubar,width=680,height=400');
   
   // 2005-01-23 - Commented out code for ancient browsers.
   
   // focus window (only for Navigator >= 3.0)
   //if ( (navigator.appName != "Microsoft Internet Explorer") && (navigator.appVersion.substring(0,1) >= "3") )
     popupWin.focus();
}

function refreshAds() { 
 for(var k = 0; k < adsToRefresh.length; k++)
 {
  adsToRefresh[k].contentWindow.location.reload(true);
 } 
}

function getOrd() {
 return ord;	
}
