/*
|--------------------------------------------------------------------------
| --- > IVP Site-wide JS
|--------------------------------------------------------------------------
| @package		IVP JS
| @subpackage	Frontend - IVP Site-wide JS
| @company		Amedia Creative
| @phone		310.651.8733
| @fax			310.388.1210
| @author		Stew Mckinney
| @email		stew@amediacreative.com
| @link			www.amediacreative.com
| @copyright	Amedia Creative, 2008
| @requires		mootools.1.2.core.js
| @version		1.0
|
| Purpose: To fix certain CSS problems that cannot be resolved with pure CSS.
*/

/*
|--------------------------------------------------------------------------
| --- IVP Site-wide JS > sizeAdjuster Class
|--------------------------------------------------------------------------
|
| When instantiated, the size adjuster will listen for window resize events. If a window resize event occurs, the
| size adjuster will get adjustment classes from the style.css sheet and then set the following DOM elements to have
| new properties:
|
| #all
| #footer
| #drop_shadow
|
*/
var sizeAdjuster = new Class({
	fixed_x: false,
	fixed_y: false,
	all: {
		element: $empty,
		fix_style: '#all_fix_resize'
		},
	footer: {
		element: $empty,
		fix_style: '#footer_fix_resize'
		},
	drop_shadow: {
		element: $empty,
		fix_style: '#drop_shadow_fix_resize'
		},
	initialize: function(){
		
		this.all.element = $('all');
		this.footer.element = $('footer');
		this.drop_shadow.element = $('drop_shadow');
		
		window.addEvent('domready',this.checkSize.bind(this));
		window.onresize = this.checkSize.bind(this);
	
	},
	checkSize: function(event){

		windowDimensions = window.getSize();
		if(windowDimensions.x <= 900){
			this.fixed_x = true;
			this.fixSize('x');
		}
		else if(this.fixed_x == true){
			this.revertSize('x');
			this.fixed_x = false;
		}

		if(windowDimensions.y <= 650){

			this.fixed_y = true;
			this.fixSize('y');	
		}
		else if(this.fixed_y == true){
			this.revertSize('y');
			this.fixed_y = false;
		}
			
	},
	fixSize: function(coordinate){
	
		this.all.element.get('morph').set(this.all.fix_style  + '_' + coordinate);
		this.footer.element.get('morph').set(this.footer.fix_style + '_' + coordinate);
		this.drop_shadow.element.get('morph').set(this.drop_shadow.fix_style  + '_' + coordinate);
			
	},
	revertSize: function(coordinate){
	
		if(coordinate == 'y'){
			if(this.fixed_x){
				this.all.element.set('style','left: ; margin-left: ;');
				this.footer.element.set('style','left: ; width: ;');
				this.drop_shadow.element.set('style','left: ; margin-left: ;');
			}
			else{
				this.all.element.set('style','');
				this.footer.element.set('style','');
				this.drop_shadow.element.set('style','');
			}
		}
		else{
			if(this.fixed_y){
				this.all.element.set('style','top: ; margin-top: ;');
				this.footer.element.set('style','top: ; margin-top: ;');
				this.drop_shadow.element.set('style','top: ; margin-top: ;');			}
			else{
				this.all.element.set('style','');
				this.footer.element.set('style','');
				this.drop_shadow.element.set('style','');
			}
		}
	}
});

/*
|--------------------------------------------------------------------------
| --- IVP Site-wide JS > Starter Class
|--------------------------------------------------------------------------
|
| When instantiated, the Starter class will scan the DOM for for certain elements to decide which javascript classes need
| to be started and which functions need to be called.
|
|
|
*/
var Starter = new Class({

	initialize: function(){
			
			var myAdjuster = new sizeAdjuster();
			
			if($('portfolio_holder')){
			
				adjustHeight();
				
			}
			
			if($('featured_content')){
	
				verticalCenterTestimonial();
				var myTicker = new portfolioTicker('home_logos_box');

			}
			
			if($('analysts') || $('member') || $('team')){
			
				correctTeam();
				
			}
			
			if($('portfolio_results')){
			
				var myVert = new verticalSorter();
				addHighlights();
				
			}
			
			if($('company_list')){
			
				addHighlights2();
			
			}
			
			if($('company_text') || $('search_list')){
			
				adjustBackdrop();
			
			}
			
			if($('news_left_links')){
				
				fixNewsHovers();
			
			}
			
			if($('column1_case_down')){
			
				fixCaseHovers();
				
			}
			
			if($('analysts')){
			
				wakeScrollers(centerTarget());
				var detached_menu = new detachedMenu('analyst_list','team_member_content');
				detached_menu.adjust();
			}
			
			if($('flashcontent')){
			
				var so = new SWFObject(
					"/public/flash/about_us.swf",
					"about_us",
					"975",
					"510",
					"9",
					""
				);
				
				so.addVariable('autoplay', 'true');
				so.addVariable('play', 'true');
				so.addVariable('autostart', 'true');
				so.addParam('wmode','transparent');
				
				var success = so.write("flashcontent");
		
				if(!success){
				
					$('flash_error').setStyle('display','block');
				}
			}
	}
	
});


window.addEvent('domready',function(){
	
	var myStarter = new Starter();
	
});
