/*
1.  root_Path()				            //-- generates the base directory based off of edit.js
2.  generated scripts	                //-- generates file links, makes use of root_Path()
3.  addEvent, onPageLoad, onPageUnload	//-- attaches events to onload and onunload and any other "on" event
*/
	
//--1. -----------------------------------------------------------------//
    function root_Path(){
		var currentPath = "/";
  	    
  	    if( !document.location.href.match(/http:\/\/www\.ncdot\.org/i) && 
  	        !document.location.href.match(/http:\/\/stage\//i) && 
  	        !document.location.href.match(/http:\/\/stage\.dot\.state\.nc\.us/i) &&
  	        !document.location.href.match(/http.*?:\/\/apps\.dot\.state\.nc\.us/i)
  	        )
  	    {
  		    if(document.location.href.match(/https:\/\//i)){
  		        currentPath = "https://apps.dot.state.nc.us/";
  		    }else{
  		        currentPath = "http://www.ncdot.org/";
  		    }
  	    }
  	    return currentPath;
  	    //return "/";
	}
	
//--2. -----------------------------------------------------------------//
	document.write('<script src="'+root_Path()+'_js/standard/swfobject.js"></' + 'script>');
	document.write('<script src="'+root_Path()+'_js/standard/common.js"></' + 'script>');
	document.write('<script src="'+root_Path()+'_js/standard/innerxhtml.js"></' + 'script>');
	document.write('<script src="'+root_Path()+'_js/standard/xmlhttp.js"></' + 'script>');
	document.write('<script src="'+root_Path()+'_js/standard/graphics.js"></' + 'script>');
	document.write('<script src="'+root_Path()+'_js/standard/viewer.js"></' + 'script>');
	
	if(!document.location.href.match(/http.*?:\/\/search|http.*?:\/\/apps/i)){
	    document.write('<script src="'+root_Path()+'_js/standard/hashslide.js"></' + 'script>');
	}
	
	document.write('<script src="'+root_Path()+'_js/standard/collapsible_old.js"></' + 'script>');
	document.write('<script src="'+root_Path()+'_js/standard/collapsible.js"></' + 'script>');
	document.write('<script src="'+root_Path()+'_js/standard/dotelements.js"></' + 'script>');
	//document.write('<script src="'+root_Path()+'_js/standard/trail.js"></' + 'script>');
	
	if(!document.location.href.match(/http.*?:\/\/search|http.*?:\/\/apps/i)){
		document.write('<script src="'+root_Path()+'_js/standard/gallery.js"></' + 'script>');
		document.write('<script src="'+root_Path()+'_js/standard/calendar.js"></' + 'script>');
	}
    
    
//--3. -----------------------------------------------------------------//

	function addEvent(elm, evType, fn, useCapture){
		if(!document.getElementById)return;
        	if(elm.addEventListener){
            		elm.addEventListener(evType, fn, useCapture);
            		return true;
        	}else if(elm.attachEvent){
            		var r = elm.attachEvent("on"+evType, fn);
            		return r;
        	}else{
            		elm['on'+evType] = fn;
        	}
	}
	
	function onPageLoad(){
	    createSearch.go();          //-- create searchField
	    writeClassesLinks.go();     //-- write pdf link and pdf,doc,xls classes       
	    writePDFDownload.go();      //-- write pdf reader download icon/link
	    findInfoDropdown();         //-- write the find information select listing
	    openClosedList();           //-- old collapsibles
        viewerJS.loadEvent();       //-- expand your pics with a class and link
        if(!document.location.href.match(/http.*?:\/\/search|http.*?:\/\/apps/i)){
            hashslideJS.loadEvent();    //-- smooth page scrolling
        }
        //createTrail.go();         //-- create a trail / rollover 
        
        collapseJS.exceptionArray = new Array("search.dot.state.nc.us","apps.dot.state.nc.us","appsut.dot.state.nc.us","localhost");	                                
	    collapseJS.menuElements = new Array("tBody_left","tBody_right");  //-- input class and/or ids of menus
	    collapseJS.rtTopBodyElements = new Array("tBody_middle");
    	collapseJS.iconPlusClass = "plusmark";
		collapseJS.iconMinusClass = "minusmark";
		collapseJS.rootPath = root_Path();
		collapseJS.loadEvent();
    }
    
    function onPageUnload(){
    }
    	
	addEvent(window,"load",onPageLoad);
	addEvent(window,"unload",onPageUnload);