function isDefined(variable){
	return (!(!( variable||false )));
}

 var Site = {
	init: function() {
		//console.log('Site.init()');

		if ( $chk($$('.hover_left')) ) {
			
			// Navigation_global.hover_info();
			
		}
		if ( $chk($('hosting_content')) ) {
			$$('a.fancy').each(function(el) {

				new FancyZoom(el);  
			});
		}
		
		if ( $chk($$('.ediscovery')) ) {
			console.log('teach');
			$$('a.fancy').each(function(el) {

				new FancyZoom(el);  
			});

		}
		if ( $chk($$('.index')) ) {
			
		}
		if ( $chk($$('.global_hover')) ) {
			
		}	
		
		var sPath = window.location.pathname;

		var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
		if(sPath.search(/capax_alpha/i) != -1){
			var suburl = "../";
		}else if(sPath.search(/capax_discovery/i) != -1){
			var suburl = "../";
		}else{
			var suburl = "";
		}		
	}
}
var Navigation_alpha = {
	
	hover_info: function() {
		$('hover_info').addEvents({
			'mouseenter': function(e){
				e.stop();
				$$('#hover_info .hover').set('styles', {
					'visibility': 'visible'
				});
			},
			'mouseleave': function(e){
				e.stop();
				$$('#hover_info .hover').set('styles', {
					'visibility': 'hidden'
				});
			}
		});
		$$('.hover_left').addEvents({
			'mouseenter': function(e){
				e.stop();
				$$('.hover_left .info_box').set('styles', {
					'visibility': 'visible'
				});
			},
			'mouseleave' : function(e){
				e.stop();
				$$('.hover_left .info_box').set('styles', {
					'visibility': 'hidden'
				});
			}
		});
		$$('.hover_right').addEvents({
			'mouseenter': function(e){
				e.stop();
				$$('.hover_right .info_box').set('styles', {
					'visibility': 'visible'
				});
			},
			'mouseleave' : function(e){
				e.stop();
				$$('.hover_right .info_box').set('styles', {
					'visibility': 'hidden'
				});
			}
		});
	}	

}


var Navigation_discovery = {
	
	hover_info: function() {
		$('hover_info').addEvents({
			'mouseenter': function(e){
				e.stop();
				$$('#hover_info .hover').set('styles', {
					'visibility': 'visible'
				});
			},
			'mouseleave': function(e){
				e.stop();
				$$('#hover_info .hover').set('styles', {
					'visibility': 'hidden'
				});
			}
		});
		$$('.hover_left').addEvents({
			'mouseenter': function(e){
				e.stop();
				$$('.hover_left .info_box').set('styles', {
					'visibility': 'visible'
				});
			},
			'mouseleave' : function(e){
				e.stop();
				$$('.hover_left .info_box').set('styles', {
					'visibility': 'hidden'
				});
			}
		});
		$$('.hover_right').addEvents({
			'mouseenter': function(e){
				e.stop();
				$$('.hover_right .info_box').set('styles', {
					'visibility': 'visible'
				});
			},
			'mouseleave' : function(e){
				e.stop();
				$$('.hover_right .info_box').set('styles', {
					'visibility': 'hidden'
				});
			}
		});
	}	

}

function tagline_carousel () {

		var el = new Fx.Morph('tagline_div', {duration: 3000, transition: Fx.Transitions.Sine.easeOut});
		el.start({'opacity':[0, 1], 'left':[70,0]}).chain(function(){
		

		this.start({
			'opacity': 1
		});
	}).chain(function() {
		
		
		this.start.delay(5000, this, {
			'left' : -140,
			'opacity' : 0
		});
	}).chain(function() {
		tagline_carousel_two.delay(10);
			
	});
}

function tagline_carousel_once () {

		var el = new Fx.Morph('tagline_div', {duration: 5000, transition: Fx.Transitions.Sine.easeOut});
		el.start({'opacity':[0, 1], 'left':[70,0]}).chain(function(){
		

		this.start({
			'opacity': 1
		});
	
	});
}

function tagline_carousel_one () {

		$('tagline').removeProperty('src');
		$('tagline').setProperties({src: 'images/logos/tagline_logo.png', alt: 'whatever dude'});
		$('tag_anchor').removeProperty('href');
		$('tag_anchor').setProperties({href: 'staffing_solutions.php'});
		var el = new Fx.Morph('tagline_div', {duration: 3000, transition: Fx.Transitions.Sine.easeOut});
		el.start({'opacity':[0, 1], 'left':[70,0]}).chain(function(){
		

		this.start({
			'opacity': 1
		});
	}).chain(function() {
		
		
		this.start.delay(5000, this, {
			'left' : -140,
			'opacity' : 0
		});
	}).chain(function() {
		tagline_carousel_two.delay(10);
			
	});

}

/*
function tagline_carousel_one () {

		el_img = $('tagline')
		el_a = $('tag_anchor')
		
		el_img.removeProperty('src').setProperties({src: 'images/logos/tagline_logo.png', alt: 'whatever dude'}).set('style', {'left':-280});
		el_a.removeProperty('href').setProperties({href: 'staffing_solutions.php'});
		
		
		var el = new Fx.Morph('tagline', {duration: 3000, transition: Fx.Transitions.Sine.easeOut});
		el.start({'left':[70, 0]}).chain(function(){
			$('tagline').fade('in');
		}).chain(function(){
			$('tagline').delay(3000);
		}).chain(function(){
			$('tagline').fade('out');
		});
}
*/
function tagline_carousel_two () {
		
		$('tagline').removeProperty('src');
		$('tagline').setProperties({src: 'images/logos/tagline_logo2.png', alt: 'whatever dude'});
		$('tag_anchor').removeProperty('href');
		$('tag_anchor').setProperties({href: '#'});
		
		var el = new Fx.Morph('tagline_div', {duration: 3000, transition: Fx.Transitions.Sine.easeOut});
		el.start({'opacity':[0, 1], 'left':[70,0]}).chain(function(){
		

		this.start({
			'opacity': 1
		});
	}).chain(function() {
		
		
		this.start.delay(5000, this, {
			'left' : -140,
			'opacity' : 0
		});
	}).chain(function() {
		tagline_carousel_three.delay(10);
			
	});

}

function tagline_carousel_three () {

		$('tagline').removeProperty('src');
		$('tagline').setProperties({src: 'images/logos/tagline_logo3.png', alt: 'whatever dude'});
		$('tag_anchor').removeProperty('href');
		$('tag_anchor').setProperties({href: 'technologies.php'});
		
		var el = new Fx.Morph('tagline_div', {duration: 3000, transition: Fx.Transitions.Sine.easeOut});
		el.start({'opacity':[0, 1], 'left':[70,0]}).chain(function(){
		

		this.start({
			'opacity': 1
		});
	}).chain(function() {
		
		
		this.start.delay(5000, this, {
			'left' : -140,
			'opacity' : 0
		});
	}).chain(function() {
		tagline_carousel_one.delay(10);
			
	});

}

function background_setter() {
		/*this is the rotating background image */
 		var backgrounds = new Array("global_bg1.jpg", "global_bg3.jpg", "leaders.jpg", "bg_mark.jpg");
       	var hover_text1 = new Array();
    	var hover_text3 = new Array();
    	var hover_text4 = new Array();
    	var hover_text5 = new Array();
    	var hover_text_selector = new Array(hover_text1, hover_text3, hover_text4, hover_text5 );
    	
    	//Jerry
    	hover_text1[0] = new Array("profile.php?x=2", "1. This is a url. <a href='profile.php?x=2' class='hover_link' title=''>This is the link to the profile page.</a>", "Hands-on CIO and managing partner of our Microsoft practice. Learn more.", "Industry through leader in database management and business intelligence. Learn more.", "Former VP of R&D and CIO at The Associated Press. Learn more.", "45%","","","","","");
    	
    	//Chris
    	hover_text3[0] = new Array("profile.php?x=4", "3. This is a url. <a href='profile.php?x=4' class='hover_link' title=''>This is the link to the profile page.</a>", "Manages an Application Development platform practice for Capax. Learn more.", "Deep financial services and real estate expertise.  Learn more.", "Thought leader on Cloud Computing.  Learn more.", "","","","","","");
    	
    	//Jeff, Jerry
    	hover_text4[0] = new Array("profile.php?x=3", "4. This is a url. <a href='profile.php?x=1' class='hover_link' title=''>This is the link to the profile page.</a>", "Founder of Capax Global and managing partner since 1998. Learn more.", "Hands-on CIO and managing partner of our Microsoft practice. Learn more.", "Innovative business leaders with a true partnering attitude. Learn more.", "","","","","",""); 
    	
    	//Mark Smith 
		hover_text5[0] = new Array("profile.php?x=0", "5. This is a url. <a href='profile.php?x=0' class='hover_link' title=''>This is the link to the profile page.</a>","One of the first Microsoft Certified Masters worldwide in Exchange Server 2010. Learn more." ,"Has a strong passion for the great sport of Lacrosse. Learn more.","Manages the Capax infrastructure practice and has an impressive Capax client list . Learn more.", "","","","","","");
    	
		var rand_index = $random(0, 3);

		$$('body').set('styles', {'background': '#54727D url(\'images/background/' + backgrounds[rand_index] + '\')  no-repeat center top'	});
	
		//$$("span")[14].set('html', hover_text_selector[rand_index][0][0]);
		//$$("span")[16].set('html', hover_text_selector[rand_index][0][1]);
		
		//New Tags for HTML injection
		$$(".hover_txt1").set('html', hover_text_selector[rand_index][0][2]);
		$$(".hover_txt2").set('html', hover_text_selector[rand_index][0][3]);
		$$(".hover_txt3").set('html', hover_text_selector[rand_index][0][4]);
		//set the links
		$$(".hover_link1").set('href', hover_text_selector[rand_index][0][0]);
		$$(".hover_link2").set('href', hover_text_selector[rand_index][0][0]);
		$$(".hover_link3").set('href', hover_text_selector[rand_index][0][0]);
		
		background_setter.delay(20000);
}

function modal_maker1() {

	$$('a.fancy').each(function(el) {
				new FancyZoom(el);  
			});

}

window.addEvents({
'domready': function() {

	$$('.hover_box1').addEvents({
	
			'mouseenter': function(e){
				e.stop();
				$$('.hover_img1').set('styles', {
					'visibility': 'visible',
					'opacity' : 1
				});
				$$('.hover_txt2').set('styles', {
					'visibility' : 'hidden',
					'opacity':0
				});
				$$('.hover_txt3').set('styles', {
					'visibility' : 'hidden',
					'opacity':0
				});

				/*
				$$('.hover_txt1').set('styles', {
					'visibility' : 'visible'
				})
				*/
			},
			'mouseleave': function(e){
				e.stop();
				$$('.hover_img1').set('styles', {
					'visibility': 'hidden',
					'opacity' : 0
				});
				
				$$('.hover_txt1').set('styles', {
					'visibility' : 'hidden',
					'opacity':0
				});
				$$('.hover_txt2').set('styles', {
					'visibility' : 'hidden',
					'opacity':0
				});
				$$('.hover_txt3').set('styles', {
					'visibility' : 'hidden',
					'opacity':0
				});
				
			}
	});
	
	$$('.hover_img1').addEvents({
		
			'mouseenter': function(e){
			e.stop();
			
				var el = new Fx.Morph('hover_txt1', {duration: 700});
 
					el.start({
					'opacity':[0, 1],
					'visability':'visible'
    				
				});
				$$('.hover_txt3').set('styles', {
					'visibility' : 'hidden',
					'opacity':0
				});
				$$('.hover_txt2').set('styles', {
					'visibility' : 'hidden',
					'opacity':0
				});
			}
		
	});
	$$('.hover_box2').addEvents({
	
			'mouseenter': function(e){
				e.stop();
				$$('.hover_img2').set('styles', {
					'visibility': 'visible',
					'opacity' : 1
				});
				$$('.hover_txt1').set('styles', {
					'visibility' : 'hidden',
					'opacity':0
				});
				$$('.hover_txt3').set('styles', {
					'visibility' : 'hidden',
					'opacity':0
				});

				/*
				$$('.hover_txt1').set('styles', {
					'visibility' : 'visible'
				})
				*/
			},
			'mouseleave': function(e){
				e.stop();
				$$('.hover_img2').set('styles', {
					'visibility': 'hidden',
					'opacity' : 0
				});
				
				$$('.hover_txt2').set('styles', {
					'visibility' : 'hidden',
					'opacity':0
				});
				
			}
	});
	
	$$('.hover_img2').addEvents({
		
			'mouseenter': function(e){
			e.stop();
			
				var el = new Fx.Morph('hover_txt2', {duration: 700});
 
					el.start({
					'opacity':[0, 1],
					'visability':'visible'
    				
				});
				$$('.hover_txt3').set('styles', {
					'visibility' : 'hidden',
					'opacity':0
				});
				$$('.hover_txt1').set('styles', {
					'visibility' : 'hidden',
					'opacity':0
				});
			}
		
	});
	$$('.hover_box3').addEvents({
	
			'mouseenter': function(e){
				e.stop();
				$$('.hover_img3').set('styles', {
					'visibility': 'visible',
					'opacity' : 1
				});
				$$('.hover_txt2').set('styles', {
					'visibility' : 'hidden',
					'opacity':0
				});
				$$('.hover_txt1').set('styles', {
					'visibility' : 'hidden',
					'opacity':0
				});

				/*
				$$('.hover_txt1').set('styles', {
					'visibility' : 'visible'
				})
				*/
			},
			'mouseleave': function(e){
				e.stop();
				$$('.hover_img3').set('styles', {
					'visibility': 'hidden',
					'opacity' : 0
				});
				
				$$('.hover_txt3').set('styles', {
					'visibility' : 'hidden',
					'opacity':0
				});
				
			}
	});
	
	$$('.hover_img3').addEvents({
		
			'mouseenter': function(e){
			e.stop();
			
				var el = new Fx.Morph('hover_txt3', {duration: 700});
 
					el.start({
					'opacity':[0, 1],
					'visability':'visible'
    				
				});
			}
		
	});
	}
	
});
window.addEvents({
	'domready': function() {
		//console.log('Window DOM Ready');
		
		Site.init();
		//console.log($('enterprise'));
	},
	
	'load': function(){
		//console.log('Window Locked and Loaded');
		//background_setter();
	}
	
});

