var _vortex = {
	
	_is : {
		
		g : function(){
			var svs = 'dev,testing,live,live1,live2'.split(',');
			var dm = window.location.host.toLowerCase();
			var se = dm;
			for( var s = 0; s < svs.length; s++ ) se = se.replace(svs[s]+'.','');
			se = se.split('.');
			if( se.length == 2 ) se.unshift('www');
			var st = {
				website : se[0],
				domain : 'vortexstudio',
				extension : 'com',
				environment : ''
			}
			for( var s = 0; s < svs.length; s++ ) if( dm.indexOf(svs[s]) > -1 ) st.environment = svs[s];
			st.server = st.environment + (st.environment != '' ? '.' : '') + st.domain + '.' + st.extension;
			return st;
		},
		
		i : function(){
			_vortex.url = _vortex._is.g();
			_vortex.servers = {
				www : 'www.' + _vortex.url.server,
				code : 'code.' + _vortex.url.server,
				webmail : 'webmail.' + _vortex.url.server,
				ftp : 'ftp.' + _vortex.url.server,
				sql : 'sql.' + _vortex.url.server,
				templates : 'templates.' + _vortex.url.server,
				images : 'images.' + _vortex.url.server,
				advertisers : 'advertisers.' + _vortex.url.server,
				live1 : 'live1.' + _vortex.url.server,
				live2 : 'live2.' + _vortex.url.server,
				wwwAlias : _vortex.url.server
			};
			_vortex.progress = {
				development : _vortex.url.environment == 'dev',
				testing : _vortex.url.environment == 'testing',
				live : _vortex.url.environment != 'dev' && _vortex.url.environment != 'testing'
			}
		}
		
	},
	
	regex : {
		email : new RegExp( /^[\w\.=-]+@[\w\.-]+\.[\w]{2,3}$/g ), 
		password : new RegExp( /^(?=.*\d).{4,10}$/g ), username : new RegExp( /^[\w\.=-]+@[\w\.-]+\.[\w]{2,3}$/g )
	}

}; _vortex._is.i();


// create jquery library if is not defined
if( typeof($) == 'undefined' ) document.write( unescape('%3Cscript language="javascript" src="' + window.location.protocol + '//' + _vortex.servers.code + '/jquery/core.js"%3E%3C/script%3E') );

// link to jquery UI library
document.write( unescape('%3Cscript language="javascript" src="' + window.location.protocol + '//' + _vortex.servers.code + '/jquery/ui.js"%3E%3C/script%3E') );

		// supporting libraries and useful plugins
		//document.write( unescape('%3Cscript language="javascript" src="' + window.location.protocol + '//' + _vortex.servers.code + '/jquery/tools.js"%3E%3C/script%3E') );
		document.write( unescape('%3Cscript language="javascript" src="' + window.location.protocol + '//' + _vortex.servers.code + '/jquery/qtip.js"%3E%3C/script%3E') );

// write links to stylesheets
document.write( unescape('%3Clink rel="stylesheet" type="text/css" href="' + window.location.protocol + '//' + _vortex.servers.code + '/jquery/ui.css" /%3E') );

// write links to stylesheets
document.write( unescape('%3Clink rel="stylesheet" type="text/css" href="' + window.location.protocol + '//' + _vortex.servers.code + '/core.css" /%3E') );

// write initialization script
document.write( unescape('%3Cscript language="javascript" src="' + window.location.protocol + '//' + _vortex.servers.code + '/init/core.js"%3E%3C/script%3E') );

// google tracking
if( !_vortex.progress.development ) document.write( unescape("%3Cscript src='" + ( ( "https:" == document.location.protocol ) ? "https://ssl." : "http://www." ) + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E") );

// insert initial object
document.write( unescape('%3Cscript language="javascript" src="' + window.location.protocol + '//' + _vortex.servers.code + '/init/div.js"%3E%3C/script%3E') );