var images_list;

/* Effect.scroll from 
http://www.garyharan.com/index.php/2007/11/26/how-to-unobtrusively-scroll-a-div-with-prototype-scriptaculous/
*/
Effect.Scroll = Class.create();
Object.extend(Object.extend(Effect.Scroll.prototype, Effect.Base.prototype), {
  initialize: function(element) {
    this.element = $(element);
    if(!this.element) throw(Effect._elementDoesNotExistError);
    this.start(Object.extend({x: 0, y: 0}, arguments[1] || {}));
  },
  setup: function() {
    var scrollOffsets = (this.element == window) 
                ? document.viewport.getScrollOffsets() 
                : Element._returnOffset(this.element.scrollLeft, this.element.scrollTop) ;
    this.originalScrollLeft = scrollOffsets.left;
    this.originalScrollTop  = scrollOffsets.top;
  },
  update: function(pos) {
    this.element.scrollTo(Math.round(this.options.x * pos + this.originalScrollLeft), Math.round(this.options.y * pos + this.originalScrollTop));
  }
});

function insertLightboxes() {
	if ( showLightboxImage== false) {
		/* kill existing lightbox instances */
		var links = $$(".lightwindow");
    links.each (function(link) {
				link.removeClassName("lightwindow");
				link.target = "_blank";
		});
  }
  if ( showLightboxVideo  == true) {
    var links = $$(".lightwindowvideo");
    links.each (function(link) {
      Event.observe(link,'click',function() {
        //myLightWindow.activate(null,link);
        myLightWindow.activateWindow({'href': link.href,'width': 480,'height': 370,'type': 'external','title':"video"});
      },false);
      link.onclick = function() {return false};
    });
  } else {
		  var links = $$(".lightwindowvideo");
      links.each (function(link) {
				link.target="_blank";
			});
	}
  if ( showLightboxImage== true) {
    var links = $$(".lightwindowlink");
    links.each (function(link) {
      Event.observe(link,'click',function() {
        //myLightWindow.activate(null,link);
        myLightWindow.activateWindow({
			'href': link.href,
			'rel': link.rel
	});
      },false);
      link.onclick = function() {return false};
    });
  }
}

function start_current_site() {
  var menu;
  $("image_left_bar").setOpacity(0.5);
  $("menu_spacing").setOpacity(0.8);
  menu = $("about_menu");
  if (menu) {
    $("content").insert(menu,{position: 'top'});
    menu.absolutize();
    menu.setStyle({
      left: '178px',
      width: '439px',
      top: '176px',
      height: '15px'
    });
    new Effect.Appear("about_menu");
  }
  video = $("videocontainer");
  if (video) {
    $("content").insert(video,{position: 'top'});
    video.absolutize();
    video.setStyle({
      left: '515px',
      width: '100px',
      top: '182px',
      height: '215px'
    });
    new Effect.Appear("videocontainer" );
  }
  contact = $("contactinfo");
  if (contact) {
    $("content").insert(contact,{position: 'top'});
    contact.absolutize();
    contact.setStyle({
      left: '475px',
      width: '150px',
      top: '179px',
      height: '155px',
      padding: '43px 3px'
    });
    new Effect.Appear("contactinfo" );
  }
  insertLightboxes();
  if ($("content_inner")) {
    $("content_inner").hide();
    new Effect.Appear("content_inner", {to: 0.9});
  } else {
    new Effect.MoveBy('menu',175,0);
  }
  //$$(".object_thumb").invoke('setOpacity',1.0); 
  var imgArray = new Array("/images/home/intro_foto2.jpg","/images/home/intro_foto5.jpg");
  nsvPartyPic("backgroundpicture",true );
  if ($("portfoliomenu")) {
    makeFullPage();
  }
//  imageRotate = new ImageRotator($("backgroundpicture"),imgArray);
}

function makeFullPage() {

}

function showGallery(gallery_name) {
	var g = gallery_name;

	//alert(g);
	if ($(g)) {
		Effect.Appear(g,{duration: 0.200,afterFinish: function (obj) {$("content_inner").scrollTop += 120;}});		 
	}
}

function end_current_site() {
  if ($("content_inner")) {
    new Effect.Fade("content_inner");
  }
}
/*
function rotate_images (pageName,element) {
  
  set_background_image("/images/home/intro_foto2.jpg");
}

function set_background_image(url) {
  $("backgroundpicture").style.backgroundImage = "url("+url+")";
}

function rotate_images_exec(i) {
  
}
*/
var ImageRotator = Class.create({
  initialize: function(elem,imgArray) {
    var imgArray = imgArray;
    var mainElement = elem;
    var imgIndex = 0;
    new PeriodicalExecuter(function() {
      imgIndex = (imgIndex + 1)% imgArray.length;
      curUrl = imgArray[imgIndex];
      new Effect.Fade("backgroundpicture");
      window.setTimeout('$("backgroundpicture").style.backgroundImage=\'url("+curUrl+");\'',2000);
      window.setTimeout('Effect.Appear("backgroundpicture");',2500);
      $("backgroundpicture").style.backgroundImage = "url("+curUrl+")";
      
    },8);
  },
  changeImage: function () {
    
  }
  
});

function showVideo(videoname) {
	if (!myLightWindow)
    myLightWindow = new lightwindow();
  myLightWindow.activateWindow({'href': '/videoplay-'+videoname,'width': 480,'height': 370,'type': 'external'});
  
}

function initImageContainer(element, cWidth, cHeight) {

}
