var scrolling = false;
var IE6 	  = false;

function openMenu(){
	var color = '#E71F76';	
	var win = new modalWindow('modal');
	win.setSize('750','400');
	win.open();
	$('overlay').setStyle({background: color});
	$('modal').setStyle({borderColor: color});
	$('modal').update("<div id='close'><a href='javascript:void(0)' id='closeLink'>close</a></div><br /><img src='themes/yoga/images/menu.png'>");
	$('close').observe('click',function(){win.closeAll().remove();});
}

function openTeam(){
	var color = '#E71F76';	
	var win = new modalWindow('modal');
	win.setSize('220','75');
	win.open();
	$('overlay').setStyle({background: color});
	$('modal').setStyle({borderColor: color});		
	$('modal').update("<div id='close'><a href='javascript:void(0)' id='closeLink'>close</a></div><br /><p>Thank you for your interest in joining our team. Please <a href='mailto:info@myyogaberry.com'>send us an e-mail</a> regarding your inquiry.</p>");
	$$('#modal a').invoke('setStyle',{color: color});
	$('close').observe('click',function(){win.closeAll().remove();});
}

function openNutrition(){
	var color = '#E71F76';	
	var win = new modalWindow('modal');
	win.setSize('250','540');
	win.open();
	$('overlay').setStyle({background: color});
	$('modal').setStyle({borderColor: color});
	$('modal').update("<div id='close'><a href='javascript:void(0)' id='closeLink'>close</a></div><br /><img src='themes/yoga/images/nutrition.gif'>");
	$('close').observe('click',function(){win.closeAll().remove();});
}

function openLocations(){
	var color = '#E71F76';	
	var win = new modalWindow('modal');
	win.setSize('250','270');
	win.open();
	$('overlay').setStyle({background: color});
	$('modal').setStyle({borderColor: color});
	$('modal').update("<div id='close'><a href='javascript:void(0)' id='closeLink'>close</a></div><h2>the beaches</h2>544-01 Marsh Landing Pkwy<br />Jacksonville Beach, FL 32250<br /><a href='mailto:info@yoga-berry.com'>info@yoga-berry.com</a><br />904.280.9652<h2>st. johns town center</h2>10275 Buckhead Branch Dr.<br />Jacksonville, FL 32246<br /><a href='mailto:info@yoga-berry.com'>info@yoga-berry.com</a><br />904.641.2883");
		$$('#modal a').invoke('setStyle',{color: color});
	$('close').observe('click',function(){win.closeAll().remove();});
}

/*function openBuddies(){
	var color = eval('items.'+active.top+'.'+active.bot+'.color');	
	var win = new modalWindow('modal');
	win.setSize('400','200');
	win.open();
	$('overlay').setStyle({background: color });	
	$('modal').setStyle({borderColor: color});
	$('overlay').observe('click',function(){win.closeAll().remove();});
}*/


function modalWindow(id){		
	var elID;
	
	this.elID = id;
	Element.insert($('overlay'),{'after':'<div id="'+this.elID+'" style="display:none;"></div>'});
	
	this.open = function(){ 
		$('overlay', this.elID).invoke('show');	
	}
	
	this.close = function(){		
		$(this.elID).hide();
		return this;
	}
	
	this.closeAll = function(){
		$('overlay', this.elID).invoke('hide');	
		return this;
	}
	
	this.remove = function(){
		$(this.elID).remove();		
		return this;
	}
	
	this.setSize = function(width,height){
		$(this.elID).setStyle({width:width+"px",height:height+"px"});		
		this._center();		
		return this;
	}
	
	this.setLocation = function(x,y){
		$(this.elID).setStyle({left:x+"px",top:y+"px"});		
		return this;
	}
	
	this.setContent = function(content){
		$(this.elID).update(content);
		return this;
	}
	
	this._center = function(){
		var my_width  = 0;
	    var my_height = 0;
	
	    if ( typeof( window.innerWidth ) == 'number' ){
	        my_width  = window.innerWidth;
	        my_height = window.innerHeight;
	    }else if ( document.documentElement &&
	             ( document.documentElement.clientWidth ||
	               document.documentElement.clientHeight ) ){
	        my_width  = document.documentElement.clientWidth;
	        my_height = document.documentElement.clientHeight;
	    }
	    else if ( document.body && 
	            ( document.body.clientWidth || document.body.clientHeight ) ){
	        my_width  = document.body.clientWidth;
	        my_height = document.body.clientHeight;
	    }
	        
	    var elementDimensions = $(this.elID).getDimensions();	    
	
	    var setX = ( my_width  - elementDimensions.width  ) / 2;
	    var setY = ( my_height - elementDimensions.height ) / 2;
	
	    setX = ( setX < 0 ) ? 0 : setX;
	    setY = ( setY < 0 ) ? 0 : setY;
	
	    $(this.elID).style.left = setX + "px";
	    $(this.elID).style.top  = setY + "px";
	    
	    return this;
	}
}

function preloadImages(){var d=document; if(d.images){ if(!d.p) d.p=new Array();var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)if(a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}}	
