var load = "";
var navPositions=new Array("525","607","697","780","853","932");
var ok = 0;
var page={
	initialize: function(){
		 
			nav.initialize();
	 
		DMP_lightbox();
		if($("mainTabs")){ // if we have tabs
			initTab();
		}
		
	}
}

var nav={
	initialize: function(){
	
		if(load.demo){
			load.demo();
		}
		
	}
}

 
    
			 


var vender = {
	return_type: function (){
			if(Browser.firefox){
				return 'Moz';
			}
			else if(Browser.safari){
				return 'Webkit';
			}
			else if(Browser.chrome){
				return 'Webkit';
			}
	},
	textShadowHash: function(){
		if(this.return_type() == "Moz"){
			return '@px @px @px rgb(@, @, @)'	
		}
		if(this.return_type() == "Webkit"){
			return 'rgb(@, @, @) @px @px @px'
		}
	},
	textShadowName: function(){
		if(this.return_type() == "Moz" || this.return_type() == "Webkit"){
			return 'textShadow'	
		}	
	},
	textShadowNavValueOne: function(){
		if(this.return_type() == "Moz"){
			return "0px 0px 0px #ffffff"	
		}	
		if(this.return_type() == "Webkit"){
			return "#ffffff 0px 0px 0px"	
		}	
	},
	textShadowNavValueTwo: function(){
		if(this.return_type() == "Moz"){
			return "-1px 5px 2px #cccccc"	
		}	
		if(this.return_type() == "Webkit"){
			return "#aaaaaa 1px 5px 3px"	
		}
	}
}



window.addEvent('domready', page.initialize);
 
  
 
 

function DMP_lightbox(){
	var imageLinks = $$(".popout_link");
		if(imageLinks.length > 0){
		imageLinks.addEvent('click', function(){
			//alert(this.getElement("img").src);
			
			var source= this;
			
			var co = this.getElement("img").getCoordinates();
			//var newIMG = this.getElement("img").src;
			var newIMG = this.rel;
			 
			var splitCo = newIMG.split(",");
			
			var width = parseInt(splitCo[0]);
			
			var height = parseInt(splitCo[1]);
		 
			
			var sc = $(document.body).getScroll();
		
			
			 
			
			
						
			var shadow = new Element('div', {
				'id': 'shadow',
				'styles': {
					'opacity': 0,
					'width': '100%',
					'position': 'fixed',
					'height': '100%',
				//	'background': 'url(http://127.0.0.1/~Richard/2010/DMP-Wordpress/wp-content/themes/DMP/style/images/backgrounds/main2.jpg)',
					'background': '#000',
					'z-index': '100000',
					'top': '0px',
					'left': '0px'
				}
			});
			
			
					 	  
		 	  
			var newImg = new Element('img', {
			'src': this.href,
			'class': 'popout_image',
			'styles': {
					'opacity': 0,
					'width': width+"px",
					'height': height+"px"
				}
			});
				
			 
			 			 
			 
			 
			 var container = new Element('div', {
				'class': 'popout_container',
				'styles': {
					'left': co.left  - sc.x,
					'top': co.top - sc.y,
					'width': co.width, //- 20,
					'height': co.height,//  - 20,
				//	'border': '10px solid #fff',
					'background': '#000',
					'opacity': '0',
					"MozBoxShadow": "0px 0px 50px rgba(0, 0, 0, 1)",
					'webkitBoxShadow': "0px 0px 50px rgba(0, 0, 0, 0.8)" 
				}//,
				//'html': "<img src=\'\' alt=\'DMP LightBox\'/>"
			});
			
			
					
								
				
				
				
			
		 
			
			container.inject($(document.body));
	
			shadow.inject($(document.body));
			
			
				
			
			
			 	shadow.set('morph', {duration: 350, transition: 'Sine:out', onComplete: function(){
		 		 
					var winEvent1 = window.addEvent('keydown', function(event){
					 
						if(event.key == "esc" || event.key == "space"){
								event.preventDefault();
								window.removeEvents('keydown');
								newImg.dispose();
									var co = source.getElement("img").getCoordinates();
									var sc = $(document.body).getScroll();
				
								shadow.set('morph', {duration: 350, transition: 'Sine:out', onComplete: function(){
								
								}});
								
								shadow.morph({
									"opacity": "0"
								});  
								
								container.set('morph', {duration: 550, transition: 'Sine:out', onComplete: function(){
										shadow.dispose();
										container.dispose();
								}});
								 
								container.morph({
									"opacity": "1",
									'left': co.left  - sc.x,
									'top': co.top - sc.y,
									'width': co.width - 20,
									'height': co.height  - 20,
									'opacity': 0
								});  
						}
					 	
					 	
							
					});
					
					
					
					
					$(document.body).addEvents({
						"click": function(){
								window.removeEvents('keydown');
								newImg.dispose();
								 	
								//var co = this.getElement("img").getCoordinates();
								var sc = $(document.body).getScroll();
				 
								shadow.set('morph', {duration: 350, transition: 'Sine:out', onComplete: function(){
								
								}});
								
								shadow.morph({
									"opacity": "0"
								});  
								
								
								
								container.set('morph', {duration: 350, transition: 'Sine:out', onComplete: function(){
										shadow.dispose();
										container.dispose();
								}});
								 
								 
							 
								 
 										
					container.morph({
									"opacity": "1",
									'left': co.left  - sc.x,
									'top': co.top - sc.y,
									'width': co.width - 20,
									'height': co.height  - 20,
									'opacity': 0
								});  
				 
				 
				
				
				
												 
					 
							
							
						} 
					});
					
			 
					
				}});
				shadow.morph({
						"opacity": "0.4"
				});  
				
				container.set('morph', {duration: 450, transition: 'Sine:out', onComplete: function(){
					 
								newImg.set('morph', {duration: 250, transition: 'Sine:out', onComplete: function(){
								
								}});
								
								newImg.morph({
									"opacity": "1"
								});  
					
					
					
				}});
				
 				
 				
 										
				
				container.morph({
						"opacity": "1",
						"width": width,
						"left": ($(document.body).getSize().x - width)/2,
						"top": ($(document.body).getSize().y - height)/2,
						"height": height+"px"
				});  
				
				
				
						 
				newImg.inject(container);
				
				var w = newImg.offsetWidth;
				var h = newImg.offsetHeight;
			
			
			
			return false;
			
			
			
			
			
		});
	
	
	imageLinks.each(function(item, index){
		
	

		
		
		
	});
	
	
	
	}
	
	
	
	
	
}





function DMP_popout(source, img, width, height){
	var co = source.getElement("img").getCoordinates();
	var sc = $(document.body).getScroll();
	
	var shadow = new Element('div', {
		'id': 'shadow',
		'styles': {
			'opacity': 0,
			'width': '100%',
			'position': 'fixed',
			'height': '100%',
		//	'background': 'url(http://127.0.0.1/~Richard/2010/DMP-Wordpress/wp-content/themes/DMP/style/images/backgrounds/main2.jpg)',
			'background': '#000',
			'z-index': '100000',
			'top': '0px',
			'left': '0px'
		}
	});
	
	
	
	var newImg = new Element('img', {
    'src': img,
    'class': 'popout_image',
    'styles': {
			'opacity': 0,
			'width': width+"px",
			'height': height+"px"
		}
	});
	
	
	 
	 var container = new Element('div', {
		'class': 'popout_container',
		'styles': {
			'left': co.left  - sc.x,
			'top': co.top - sc.y,
			'width': co.width, //- 20,
			'height': co.height,//  - 20,
		//	'border': '10px solid #fff',
			'background': 'rgba(0,0,0,0.8)',
			'opacity': '0',
		 	"MozBoxShadow": "0px 0px 50px rgba(0, 0, 0, 1)",
     		'webkitBoxShadow': "0px 0px 50px rgba(0, 0, 0, 0.8)"
		}//,
		//'html': "<img src=\'\' alt=\'DMP LightBox\'/>"
	});
	
	container.inject($(document.body));
	
	shadow.inject($(document.body));
	//.fade(0.9);
	
	shadow.set('morph', {duration: 350, transition: 'Sine:out', onComplete: function(){
		
		
		var winEvent1 = window.addEvent('keydown', function(event){
			if(event.key == "esc" || event.key == "space"){
					window.removeEvents('keydown');
					newImg.dispose();
						var co = source.getElement("img").getCoordinates();
						var sc = $(document.body).getScroll();
	
					shadow.set('morph', {duration: 350, transition: 'Sine:out', onComplete: function(){
					
					}});
					
					shadow.morph({
						"opacity": "0"
					});  
					
					container.set('morph', {duration: 750, transition: 'Sine:out', onComplete: function(){
							shadow.dispose();
							container.dispose();
					}});
					container.morph({
						"opacity": "1",
						'left': co.left  - sc.x,
						'top': co.top - sc.y,
						'width': co.width - 20,
						'height': co.height  - 20,
						'opacity': 0
					});  
			}
			
				
		});
		
		
		
		
		$(document.body).addEvents({
			"click": function(){
						window.removeEvents('keydown');
						newImg.dispose();
						var co = source.getElement("img").getCoordinates();
						var sc = $(document.body).getScroll();
	
					shadow.set('morph', {duration: 350, transition: 'Sine:out', onComplete: function(){
					
					}});
					
					shadow.morph({
						"opacity": "0"
					});  
					
					container.set('morph', {duration: 550, transition: 'Sine:out', onComplete: function(){
							shadow.dispose();
							container.dispose();
					}});
					container.morph({
						"opacity": "1",
						'left': co.left  - sc.x,
						'top': co.top - sc.y,
						'width': co.width - 20,
						'height': co.height  - 20,
						'opacity': 0
					});  
	 
				
			} 
		});
		
 
		
	}});
	shadow.morph({
			"opacity": "0.2"
	});  
	
	container.set('morph', {duration: 650, transition: 'Sine:out', onComplete: function(){
		
					newImg.set('morph', {duration: 250, transition: 'Sine:out', onComplete: function(){
					
					}});
					
					newImg.morph({
						"opacity": "1"
					});  
		
		
		
	}});
	container.morph({
			"opacity": "1",
			"width": width,
			"left": ($(document.body).getSize().x - width)/2,
			"top": ($(document.body).getSize().y - height)/2,
			"height": height
	});  
	 
	
	newImg.inject(container);
	
	var w = newImg.offsetWidth;
	var h = newImg.offsetHeight;
 
	
}





function initTab(){
		var tabs = $("mainTabs").getElements("li");		
			
		tabs.each(function(tab, i){
			tab.setStyles({
				'left': -(i*18),
				'z-index': 100-i
			});
 
		});
		
		$("mainTabs").getElement(".selectedTab").setStyle("z-index", "100");
	 
		tabs.addEvents({
				mouseover: function(){
					if(!this.hasClass("selectedTab")){
						this.getElement(".tab_middle").set('tween', {property: "color", transition: 'Sine:out', duration: 150}).get("tween").start("#ff7914");
					}
				},
				mouseout: function(){
					if(!this.hasClass("selectedTab")){
						this.getElement(".tab_middle").set('tween', {property: "color", transition: 'Sine:out', duration: 150}).get("tween").start("#555555"); 
					}
 				}
			})
	}

 
