/****************************************
|
| Entrepreneur London
|
| Created by: Kevin Biskaborn
| Copyright 2009 ScriptReaction
| http://www.scriptreaction.com
|
*****************************************
| Load Dependencies	: None
| Run Dependencies	: None
****************************************/

var Global = {
	includePrefix: "",
	controls: {
		allowImageAltStripping: true
	},
	preload: function (){
		this.addEvent( window, "load", this.postload );
	},
	postload: function (){
		Global.format.pageImages();
	},
	exists: function ( object ){
		return ( typeof( object ) == "undefined" ) ? false : true;
	},
	addEvent: function ( object, eventType, functionName ){
		if( object.addEventListener ){
			object.addEventListener( eventType, functionName, false );
			return true;
		}
		else if( object.attachEvent )
			return object.attachEvent( "on" + eventType, functionName );
		else
			return false;
	},
	attach: {
		cssLink: function ( fileId ){
			output = "";
			output += "<link href=\"" + Global.includePrefix;
			output += "assets/css/" + fileId + ".css\"";
			output += " rel=\"stylesheet\" media=\"screen\" type=\"text/css\" />";
			this.toDoc( output );
		},
		jsLink: function ( fileId ){
			output = "";
			output += "<script type=\"text/javascript\"";
			output += " src=\"" + Global.includePrefix;
			output += "assets/srx/" + fileId + ".js\"></script>";
			this.toDoc( output );
		},
		toDoc: function ( output ){
			document.writeln( output );	
		}
	},
	format: {
		pageImages: function (){
			if( typeof( Browser ) != "undefined" && Browser.isIE() ){
				var imageArray = document.images;
				var whichImage;
				for( var i = 0; i < imageArray.length; i++ ){
					whichImage = imageArray[ i ];
					whichImage.galleryimg = "no";
					if( Global.controls.allowImageAltStripping )
						whichImage.alt = "";
				}
			}
		}
	},
	display: {
		goTop: function (){
			var y1=y2=y3=0;if(document.documentElement){y1=document.documentElement.scrollTop||0;};if(document.body){y2=document.body.scrollTop||0;};
			y3=window.scrollY||0;var y=Math.max(y1,Math.max(y2,y3));window.scrollTo(0,Math.floor(y/1.4));if(y>0){window.setTimeout("Global.display.goTop()",25);};
		}
	},
	modify: {
		setDivContent: function ( divId, content ){
			if( document.all )
				this.divContent( document.all[ divId ], content );
			else
				this.divContent( document.getElementById( divId ), content );
		},
		divContent: function ( div, content ){
			if( div )
				div.innerHTML = content;
		},
		setAlpha: function ( object, opacity ){
			opacity = ( opacity == 100 ) ? 99.999 : opacity;
			object.style.filter = "alpha(opacity:" + opacity + ")"; //ie/win
			object.style.KHTMLOpacity = opacity/100; //safari<1.2,konqueror
			object.style.MozOpacity = opacity/100; //older mozilla/firefox
			object.style.opacity = opacity/100; //safari 1.2,newer firefox/mozilla,css3
		}
	},
	email: {
		count: 0,
		attach: function ( requestObj ){
			
			var output	= "";
			var address	= this.build( requestObj );
				
			if( address ){
				output += "<span onclick=\"Global.email.execute(" + this.count + ")\">";
				output += "<a href=\"/\" onclick=\"return false\">";
				output += address + "</a></span>";
			}
			
			if( output )
				Global.attach.toDoc( output );
		},
		build: function ( requestObj ){
			var output	= null;
			
			var domain 	= ( typeof( requestObj.d ) == "undefined" ) ? null 	: requestObj.d.slice( 2 );
			var ext		= ( typeof( requestObj.e ) == "undefined" ) ? "com"	: requestObj.e.slice( 2 );
			var user	= ( typeof( requestObj.u ) == "undefined" ) ? null	: requestObj.u.slice( 2 );
				
			if( domain && user )
				this[ "emailObj_" + ++this.count ] = output = user + "@" + domain + "." + ext;
			
			return output;
		},
		execute: function (){
			var id = parseInt( arguments[ 0 ] );
			if( id && id > 0 && this[ "emailObj_" + id ] )
				top.location.href = "mailto:" + this[ "emailObj_" + id ];
		}
	}
}

/******** GLOBAL LAUNCH ********/
Global.preload();
