var widthclose		= 25;
var widthopen			= 142;
var widthmax			= 602;
var heightinner1	= 302;
var heigthinner2	= 410;

	 
	function externalLinks() {
		if (!document.getElementsByTagName) return;
		var anchors = document.getElementsByTagName("a");
		for (var i=0; i<anchors.length; i++) {
			var anchor = anchors[i];
			if (anchor.getAttribute("href") &&
				anchor.getAttribute("rel") == "external")
				anchor.target = "_blank";
		}
	}
	 
	
	 
	// start linkuri prima page
	function linkuri_prima_page() { 
		var linkuri_design = $$('#menu_aboutme a');
		var divuri_design = $$('#first_page .design'); 
		//var img_design = $$('#first_page .right');
		for(ld=0; ld<linkuri_design.length; ld++) {
	   
			linkuri_design[ld].onclick = function (ld) { 
				for(ld2=0; ld2<linkuri_design.length; ld2++) { 
					linkuri_design[ld2].removeAttribute('id'); 
					divuri_design[ld2].style.visibility = 'visible';
					divuri_design[ld2].style.position = 'relative';
					divuri_design[ld2].style.top = -9999 + 'px';
					//img_design[ld2].style.display = 'none';
				}
				
				this.setAttribute('id','lks');
				for(ld3=0; ld3<linkuri_design.length; ld3++) {
		  		if(linkuri_design[ld3].getAttribute('id')=='lks') {
					  divuri_design[ld3].style.visibility = 'visible';
					  divuri_design[ld3].style.position = 'relative';
					  divuri_design[ld3].style.top = (-232)*ld3 + 'px';
					  //img_design[ld3].style.display = 'block';
					}
				}
				
				return false;
			}
		}
	}	
	// linkuri_prima_page ();
	// end linkuri prima page
	
	// start linkuri page 2
	function linkuri_page2 () { 
		var linkuri_sch = $$('#menu_teaching a');
		var divuri_sch = $$('#second_page .design'); 
		
		for(ls=0; ls<linkuri_sch.length; ls++) { 
		
			linkuri_sch[ls].onclick = function (ls) {
				for(ls2=0; ls2<linkuri_sch.length; ls2++) { 
					linkuri_sch[ls2].removeAttribute('id'); 
					divuri_sch[ls2].style.visibility = 'visible';
					divuri_sch[ls2].style.position = 'relative';
					divuri_sch[ls2].style.top = -9999 + 'px';
				}
				
				this.setAttribute('id','lks');
				for(ls3=0; ls3<linkuri_sch.length; ls3++) {
			  	if(linkuri_sch[ls3].getAttribute('id')=='lks') {
					  divuri_sch[ls3].style.visibility = 'visible';
					  divuri_sch[ls3].style.position = 'relative';
					  divuri_sch[ls3].style.top = (-350)*ls3 + 'px';
					}
				}
				return false;    
			}
	  }
	}
	// linkuri_page2 ();
	// end linkuri page 2
	
	// start linkuri page 3
	function linkuri_page3 () { 
		var linkuri_sch = $$('#menu_research a');
		var divuri_sch = $$('#third_page .design'); 
		
		for(ls=0; ls<linkuri_sch.length; ls++) { 
		
			linkuri_sch[ls].onclick = function (ls) {
				for(ls2=0; ls2<linkuri_sch.length; ls2++) {
					linkuri_sch[ls2].removeAttribute('id'); 
					divuri_sch[ls2].style.visibility = 'visible';
					divuri_sch[ls2].style.position = 'relative';
					divuri_sch[ls2].style.top = -9999 + 'px';
				}
				
				this.setAttribute('id','lks');
				for(ls3=0; ls3<linkuri_sch.length; ls3++) {
			  	if(linkuri_sch[ls3].getAttribute('id')=='lks') {
					  divuri_sch[ls3].style.visibility = 'visible';
					  divuri_sch[ls3].style.position = 'relative';
					  divuri_sch[ls3].style.top = (-350)*ls3 + 'px';
					}
				}
				return false;    
			}
	  }
	}
	// end linkuri page 3
	
	function init_site () {
		externalLinks();
		var real_page = $('real_page');	
		var stretcher = $$('.stretcher');
		var h2 = $$('#real_page h2');
		var div_inner = $$('.page');
		var logo = $('logo');
		
		logo.onmouseover = function () { 
			var logo_values = logo.getCoordinates();
		  var logo_move = new Fx.Style('logo', 'top', {duration:500});
		 	if(logo_values.top==0) { 
		 		logo_move.custom(0, -122); 
		 	} else { 
		  	logo_move.custom(logo_values.top, 0); 
		  }		 
		}
		
		logo.onmouseout = function () { 
			var logo_values = logo.getCoordinates();
		  var logo_move = new Fx.Style('logo', 'top', {duration:500});
		  if(logo_values.top==0) {  
		  	logo_move.custom(0, -122);
			}
		}
			
		logo.onclick = function () {
			// start logo
		  
			var div_unselected = $$('.unselected');
			
			var real_page_height =  $('real_page').style.height.toInt();
			if(div_unselected.length>0&&div_unselected.length<5) {
				var div_selected = $$('.selected')[0];
				var div_selected_h2 = $$('.selected h2')[0];
				var div_selected_page = $$('.selected .page')[0];
				var real_page = $('real_page');
				
				var div_selected_with = new Fx.Style(div_selected, 'width', {duration:500});
				div_selected_with.custom(widthmax,widthopen-2);
				
				var div_selected_height = new Fx.Style($('real_page'), 'height', {duration:500});
				div_selected_height.custom(real_page_height,heightinner1);
				
				var yyy = new Fx.Elements(div_unselected);
				yyy.custom({
				'0': { 
					 'width': [widthclose,widthopen-2]
				},
				'1': { 
					 'width': [widthclose,widthopen-2]
				},
				'2': { 
					 'width': [widthclose,widthopen-2]
				},
				'3': { 
					 'width': [widthclose,widthopen-2]
				}
				});
					 
				div_selected_h2.style.display = 'block';
				div_selected_page.style.visibility = 'hidden';
				div_selected.removeClass('selected');
				div_selected.addClass('unselected'); 
				 
				return false
			} else {}
			// end logo
		}
		
		
		for (h=0; h<h2.length; h++) {
			h2[h].onclick = function () {
				for(q=0; q<div_inner.length; q++) {
					//div_inner[q].innerHTML = '' ;
				}
		
				$('real_page').onmousemove = function() {
					return false;
				};
			
				////(function(){$('real_page').onmousemove = move_guides.bindAsEventListener($('real_page'));}).delay(800);  
			
			}
		} 
	 
	 
		// start stretcher	
		function navigare_pagini () {	
			for(i=0; i<stretcher.length; i++) { 
				stretcher[i].onclick = function () { 
					
					var logo_values = $('logo').getCoordinates();
					var logo_move = new Fx.Style('logo', 'top', {duration:500});
					
					if(logo_values.top==0) {logo_move.custom(0, -122);}
					if(this.getCoordinates().width == widthopen) { 
						for(z=0; z<stretcher.length; z++) { 
							h2[z].style.display = 'block';
							stretcher[z].addClass('unselected');
							stretcher[z].removeClass('selected');
						}
						
						this.removeClass('unselected');
						this.addClass('selected');
						this.getElementsByTagName('h2')[0].style.display = 'none';
			
						var array_nou = $$('.stretcher').copy();
						array_nou.remove(this); 
						var myElementsEffects = new Fx.Elements(array_nou);
						var mareste_latime = new Fx.Style(this, 'width', {duration:500});
						mareste_latime.custom(widthopen, widthmax);
			 
						//var inner_height = this.getElementsByTagName('div')[0].getStyle('height').toInt();
						var inner_height2 = this.getElementsByTagName('div')[0].getCoordinates();
						if(inner_height2.height<heightinner1) { 
							inner_height = heightinner1;
						} else {
							inner_height = inner_height2.height;
						}
						if(inner_height > heigthinner2) inner_height = heigthinner2;
	
						var mareste_inaltime = new Fx.Style($$('#real_page')[0], 'height', {duration:500});
						mareste_inaltime.custom(heightinner1, inner_height);
						
					  myElementsEffects.custom({
							'0': { 
								 'width': [widthopen,widthclose-2]
							},
							'1': { 
								 'width': [widthopen,widthclose-2]
							},
							'2': { 
								 'width': [widthopen,widthclose-2]
							},
							'3': { 
								 'width': [widthopen,widthclose-2]
							}
						});
			   
						for (n=0; n<stretcher.length; n++) {
							div_inner[n].style.visibility = 'hidden';
						}
						
						this.getElementsByTagName('div')[0].style.visibility = 'visible';
					}
				
					if(this.getCoordinates().width == widthclose) { 
					  
					  var array_nou2 = $$('.unselected');
					  
					  
					  var mareste_latime2 = new Fx.Style($$('.selected')[0], 'width', {duration:500});
					  mareste_latime2.custom(widthmax, widthclose-2);
					  var mareste_latime3 = new Fx.Style(this, 'width', {duration:500});
					  mareste_latime3.custom(widthclose,widthmax);
					  
					  var current_height2 = $$('#real_page')[0].getCoordinates(); 
					  current_height = current_height2.height;
					  var future_height2 = this.getElementsByTagName('div')[0];
					  future_height3 = future_height2.getCoordinates();
					  
					  if(future_height3.height < heightinner1) { future_height = heightinner1; }
					  else {future_height = future_height3.height;}
					  
					  if(future_height > heigthinner2) future_height = heigthinner2;
					  
					  var mareste_inaltime2 = new Fx.Style($$('#real_page')[0], 'height', {duration:500});
						mareste_inaltime2.custom(current_height, future_height);
			  
					  for(z=0; z<stretcher.length; z++) { 
					  	h2[z].style.display = 'block';
							stretcher[z].addClass('unselected');
							stretcher[z].removeClass('selected');
						}
						
						this.removeClass('unselected');
						this.addClass('selected');
						this.getElementsByTagName('h2')[0].style.display = 'none';
						
						for (n=0; n<stretcher.length; n++) {
							div_inner[n].style.visibility = 'hidden';
						}
						
						this.getElementsByTagName('div')[0].style.visibility = 'visible';
					}
				}
		  } 
		}
		
		navigare_pagini ();
		// end strectcher
	
	};

	function gallery() {
		var scroll = new Scroller('gallery', {area: 100, velocity: 1});
		$('gallery').addEvent('mouseover', scroll.start.bind(scroll));
		$('gallery').addEvent('mouseout', scroll.stop.bind(scroll));
		
		Lightbox.init({descriptions: '.lightboxDesc', showControls: true, loop: true});
		Reflection.addFromClass();
		
		
	}
