
/*
**
    This file is meant for turning PHP variables into JS variables
    This should be reserved for global variables only
**
*/

var config;
config = {
	URL : 'http://www.okcommerce.gov',
	AdminURL : 'http://www.okcommerce.gov/admin',
	url: { components: 'http://www.okcommerce.gov/core/components' },
	imageLibrary : 'http://www.okcommerce.gov/Libraries/Images/Commerce',
	contentImageLibrary : 'http://www.okcommerce.gov/Libraries/Images/Commerce/stories',
	jsLibrary : 'http://www.okcommerce.gov/Libraries/JS',
	autocompleteURL : 'http://www.okcommerce.gov/admin/js/application/ajax_autocomplete.php',
	adminJsFolder : 'http://www.okcommerce.gov/admin/js',
	AbsolutePath : '/webdocs/v2',
	AdminPath : '/webdocs/v2/admin',
	ErrorPage : 'http://www.okcommerce.gov/Error/404',
	DefaultSection : '8',
	DocumentFolder : '/webdocs/v2/Libraries/Documents',
	DocumentURL : 'http://www.okcommerce.gov/file',
	FaceboxImages: 'http://www.okcommerce.gov/images/scripts',
	FlashChartsURL: 'http://www.okcommerce.gov/js/module/flashCharts',
	chartColors: ['#3f75a4', '#594f38', '#c49c23', '#f99d14']
};


/*-------------------------------------------------------------------------------------------------------
   
    Function for looping through long lists of JS includes this function, when fed an array will
    write the script tag to include the specified files as JS include files.
    
    NOTE: This written to look in the 'js' folder under the site's root folder (http://domain.com/js/)
    
    Directions:
	  config.loadComponents( { foldername:['filename.js'] } );
    
    Example:
	  config.loadComponents( { jquery:['jquery-ui'] } );
	  OUTPUT: <script src='http://domain.com/js/jquery/jquery-ui.js' type='text/javascript'></script>

-------------------------------------------------------------------------------------------------------*/

config.loadComponents = function (components) {
    for ( var key in components ) {
	  var obj = components[key];
	  for (var prop in obj) {
		var fileName = obj[prop];
		var ext = '.js';
		if (fileName.indexOf(ext) > -1){ext='';}
		var file = key + "/" + fileName + ext;
		
		file = (key == 'jquery' || key == 'OFC2')?config.jsLibrary + '/' + file:file = config.URL + '/js/' + file;
		//if (key == 'jquery') { file = config.jsLibrary + '/' + file; }
		//else { file = config.URL + '/js/' + file; }
		document.write(unescape("%3Cscript src='" + file + "' type='text/javascript'%3E%3C/script%3E"));
	  }
    }
}
