// Google Internal Site Search script- By JavaScriptKit.com (http://www.javascriptkit.com)
// For this and over 400+ free scripts, visit JavaScript Kit- http://www.javascriptkit.com/
// This notice must stay intact for use

//Enter domain of site to search.
var domainroot="www.tjcog.dst.nc.us"

function Gsitesearch(curobj){
curobj.q.value="site:"+domainroot+" "+curobj.qfront.value
}

/* IMAGE PRELOADER */

var arImages=new Array();
function Preload() {
var temp = Preload.arguments; 
for(x=0; x < temp.length; x++) {
 arImages[x]=new Image();
 arImages[x].src=Preload.arguments[x];
}
}

/* 'DISPLAY' scripts 1 and 2 */

function display(proj) {
var proj1 = proj
if (document.getElementById('continfo')) {
transformXML('xmls/staff.xml', 'xmls/contactid.xsl', 'continfo', proj1);}
if (document.getElementById('meeting')) {
transformXML('xmls/calendar.xml', 'xmls/upcomingmtg.xsl', 'meeting', proj1);}
if (document.getElementById('dwnldbl')) {
transformXML('xmls/downloads2.xml', 'xmls/downloads.xsl', 'dwnldbl', proj1);}
if (document.getElementById('news')) {
transformXML('xmls/news.xml', 'xmls/news.xsl', 'news', proj1);}
if (document.getElementById('res2')) {
transformXML('xmls/links.xml', 'xmls/links.xsl', 'res2', proj1);}
if (document.getElementById('testblock')) {
transformXML('xmls/committee.xml', 'xmls/'+proj1+'.xsl', 'testblock', proj1);}
}

function display2(proj) {
var proj1 = proj
if (document.getElementById('continfo')) {
transformXML('../xmls/staff.xml', '../xmls/contactid2.xsl', 'continfo', proj1);}
if (document.getElementById('meeting')) {
transformXML('../xmls/calendar.xml', '../xmls/upcomingmtg.xsl', 'meeting', proj1);}
if (document.getElementById('dwnldbl')) {
transformXML('../xmls/downloads2.xml', '../xmls/downloads2.xsl', 'dwnldbl', proj1);}
if (document.getElementById('news')) {
transformXML('../xmls/news.xml', '../xmls/news.xsl', 'news', proj1);}
if (document.getElementById('res2')) {
transformXML('../xmls/links.xml', '../xmls/links.xsl', 'res2', proj1);}
if (document.getElementById('testblock')) {
transformXML('../xmls/committee.xml', '../xmls/'+proj1+'.xsl', 'testblock', proj1);
}
}

/* SIDEBAR FILLER */

function transformXML(xmlDocURL, xslDocURL, divID, proj1)
{
 // declare the local variables
 var xmlDoc, xslDoc, docProcessor, docCache, DocRequest, docFragment;
 var proj = proj1;
 // try the following
 try
 {
   // instantiate and load the xml document
   xmlDoc = new ActiveXObject("MSXML2.DOMDocument");
   xmlDoc.async = false;
   xmlDoc.load(xmlDocURL);
   // instantiate and load the xsl document
   xslDoc = new ActiveXObject("MSXML2.FreeThreadedDOMDocument");
   xslDoc.async = false;
   xslDoc.load(xslDocURL);
   // prepare the xsl document for transformation
   docCache = new ActiveXObject("MSXML2.XSLTemplate");
   docCache.stylesheet = xslDoc;
	// get date and set date variables
		var today = new Date();
		var theDay = today.getUTCDate();
		var theMonth = today.getMonth() + 1;
		var theYear = today.getFullYear()+"";
		if (theDay.toString().length==1)
		{
			theDay = "0" + theDay;
		}
		if (theMonth.toString().length==1)
		{
			theMonth = "0" + theMonth;
		}

		var myDate = theYear + theMonth + theDay;
		var dow = today.getDay();
   // instantiate the document processor and submit the xml document
   docProcessor = docCache.createProcessor();
   docProcessor.input = xmlDoc;
   // add parameters to the xsl document
   		docProcessor.addParameter("project", proj, "");
   		docProcessor.addParameter("today", myDate, "");
		docProcessor.addParameter("day", dow, "");
   // process the documents into html and submit to the passed div box
   docProcessor.transform();
   // divID.innerHTML = docProcessor.output;
   document.getElementById(divID).innerHTML = docProcessor.output;
 }
 // catch any errors from the above code
 catch(e)
 {
   // try the following
   try
   {
     // instantiate and load the xml document
     docRequest = new XMLHttpRequest();
     docRequest.open("GET", xmlDocURL, false);
     docRequest.send(null);
     xmlDoc = docRequest.responseXML;
     // instantiate and load the xsl document
     docRequest = new XMLHttpRequest();
     docRequest.open("GET", xslDocURL, false);
     docRequest.send(null);
     xslDoc = docRequest.responseXML;
	 // get date and set date variables
		var today = new Date();
		var theDay = today.getUTCDate();
		var theMonth = today.getMonth() + 1;
		var theYear = today.getFullYear()+"";
		if (theDay.toString().length==1)
		{
			theDay = "0" + theDay;
		}
		if (theMonth.toString().length==1)
		{
			theMonth = "0" + theMonth;
		}

		var myDate = theYear + theMonth + theDay;
		var dow = today.getDay();
     // instantiate the document processor and submit the xsl document
     docProcessor = new XSLTProcessor();
     docProcessor.importStylesheet(xslDoc);
     // add parameters to the xsl document
   		docProcessor.setParameter(null, "project", proj);
   		docProcessor.setParameter(null, "today", myDate);
		docProcessor.setParameter(null, "day", dow);
     // clear the passed div if anything was in it
     document.getElementById(divID).innerHTML = "";
     // process the documents into html and submit to the passed div
     docFragment = docProcessor.transformToFragment(xmlDoc, document);
     document.getElementById(divID).appendChild(docFragment);
   }
   // catch any errors from the above code
   catch(e)
   {
     // do nothing
   }
 }
}

/* URL JUMPER */
function openURL()
{ 
// grab index number of the selected option
selInd = document.quick2.sites.selectedIndex; 

// get value of the selected option
goURL = document.quick2.sites.options[selInd].value;

// redirect browser to the grabbed value (here a URL)
top.location.href = goURL; 
}

/* TEXT RESIZER */

		/***********************************************
		* Document Text Sizer- Copyright 2003 - Taewook Kang.  All rights reserved.
		* Coded by: Taewook Kang (http://www.txkang.com)
		* This notice must stay intact for use
		* Visit http://www.dynamicdrive.com/ for full source code
		***********************************************/


//Specify affected tags. Add or remove from list:
var tgs = new Array( 'div','td','tr');

//Specify spectrum of different font sizes:
var szs = new Array( 'xx-small','x-small','small','medium','large','x-large','xx-large' );
var startSz = 2;

function ts( trgt,inc ) {
	if (!document.getElementById) return
	var d = document,cEl = null,sz = startSz,i,j,cTags;	
	sz += inc;
	if ( sz < 0 ) sz = 0;
	if ( sz > 6 ) sz = 6;
	startSz = sz;		
	if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];
	cEl.style.fontSize = szs[ sz ];
	for ( i = 0 ; i < tgs.length ; i++ ) {
		cTags = cEl.getElementsByTagName( tgs[ i ] );
		for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = szs[ sz ];
	}
}

/* DIV TOGGLE */

  function toggleDiv(divid){
    if(document.getElementById(divid).style.display == 'none'){
      document.getElementById(divid).style.display = 'block';
    }else{
      document.getElementById(divid).style.display = 'none';
    }
  }
  
/* GALLERY */
  function gallery(pageloc){
  var pageloc1 = pageloc
  var design = [
			{title:'Gas Station Concept Photo Alteration', autor:'Chatham Major Corridor Ordinance Committee (MCOC)', date:'6 Dec 2007', link:'http://www.link1.com'},
			{title:'Photo Rendering of Pittsboro', autor:'Pittsboro Land Use Plan - Potential Development Patterns', date:'26 Oct 2007', link:'http://www.link8.com'},
			{title:'Triangle J New Website', autor:'Triangle J', date:'17 Oct 2008', link:'http://www.link3.com'},
			{title:'2005-2006 Annual Report Cover', autor:'Triangle J Annual Report', date:'22 Feb 2007', link:'http://www.link4.com'},
			{title:'NC Propane Roadshow Invite', autor:'Triangle Clean Cities Coalition', date:'27 Jul 2009', link:'http://www.link9.com'},
			{title:'TARPO Newsletter Design', autor:'Triangle Area Rural Planning Organization', date:'1 Nov 2009', link:'http://www.link11.com'},
			{title:'TDM Program Annual Report Cover 2009', autor:'Transportation Demand Management Program', date:'11 Nov 2009', link:'http://www.link13.com'},
			{title:'Triangle Clean Cities Website Redesign', autor:'Triangle Clean Cities Coalition', date:'9 Jul 2009', link:'http://www.link14.com'},
			{title:'Design Guidelines Poster Series', autor:'Pittsboro Land Use Plan - Design Guidelines', date:'16 Jan 2008', link:'http://www.link5.com'},
			{title:'Triangle Clean Cities Identity Package', autor:'Triangle Clean Cities Coalition', date:'3 Jul 2007', link:'http://www.link6.com'},
			{title:'Individual Program Information Brochures', autor:'Triangle J', date:'9 Nov 2007', link:'http://www.link7.com'},
			{title:'Driving Clean & Green Logo', autor:'Driving Clean & Green Event (Triangle Clean Cities)', date:'10 Feb 2009', link:'http://www.link2.com'},
			{title:'2007-2008 Annual Report Cover', autor:'Triangle J Annual Report', date:'17 Nov 2008', link:'http://www.link10.com'},
			{title:'Town of Butner Seal/Logo', autor:'Triangle J', date:'22 Jun 2009', link:'http://www.link12.com'}
		];
		
	var gis = [
			{title:'Map of Existing Walk/Bike Routes', autor:'Active Seniors Project', date:'20 Jun 2005', link:'http://www.link2.com'},
			{title:'Base Map of Triangle J Region with Relief', autor:'2007-2008 Triangle J Annual Report', date:'23 Feb 2009', link:'http://www.link1.com'},
			{title:'Map of American Tobacco Trail', autor:'American Tobacco Trail Update', date:'1 Jun 2007', link:'http://www.link3.com'},
			{title:'Map of Recent Developments in the CORE Region', autor:'Center of the Region Enterprise (CORE)', date:'20 Feb 2009', link:'http://www.link4.com'},
			{title:'Flex Fuel Fleets and Stations Map', autor:'Triangle Clean Cities Coalition', date:'28 Mar 2006', link:'http://www.link5.com'},
			{title:'Regional Transit Vision Plan Map', autor:'Regional Transit Infrastructure Blueprint ', date:'5 Nov 2007', link:'http://www.link6.com'},
			{title:'Status of Tax Parcel Data Map', autor:'Triangle Rural Planning Organization (TARPO)', date:'11 Jan 2007', link:'http://www.link7.com'},
			{title:'Transit Needs of Persons Below the Poverty Level', autor:'Triangle Rural Planning Organization (TARPO)', date:'30 Jun 2008', link:'http://www.link7.com'}
		];	
	if (pageloc1 == 'dsignpg') 
	{
	
	var sampleObjectItems = design;

	}
	else if (pageloc1 == 'gispg')
	{
	
	var sampleObjectItems = gis;
	
	}
	else document.write("<b>An Error Occured</b>");

	

  window.addEvent('domready',function slideshow(){	
		//SAMPLE 6 (on "mouseenter" walk)
		var info6 = $('box6').getNext().set('opacity',0.5);
		
		var nS6 = new noobSlide({
			mode: 'vertical',
			box: $('box6'),
			items: sampleObjectItems,
			size: 370,
			handles: $$('#handles6_1 div').extend($$('#handles6_2 div')),
			handle_event: 'mouseenter',
			addButtons: {
				previous: $('prev6'),
				play: $('play6'),
				stop: $('stop6'),
				playback: $('playback6'),
				next: $('next6')
			},
			button_event: 'click',
			fxOptions: {
				duration: 800,
				transition: Fx.Transitions.Back.easeOut,
				wait: false
			},
			onWalk: function(currentItem,currentHandle){
				info6.empty();
				new Element('h4').set('html',currentItem.title).inject(info6);
				new Element('p').set('html','<b>Project</b>: '+currentItem.autor+'<br /><b>Date</b>: '+currentItem.date).inject(info6);
				this.handles.set('opacity',0.3);
				currentHandle.set('opacity',1);
			}
		});
		//walk to next item
		nS6.next();		
});
}
