// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
function sleep(milliseconds) {
  var start = new Date().getTime();
  for (var i = 0; i < 1e7; i++) {
    if ((new Date().getTime() - start) > milliseconds){
      break;
    }
  }
}

function toggleTags(self) {
	if (self.className == 'keywords_down') {
		Effect.BlindUp('tagdd', {duration: 0.4} );
		self.className = 'keywords';	
	}
	else {
	 	Effect.BlindDown('tagdd', {duration: 0.4} );
		self.className = 'keywords_down';
	}
}
function reslide() {
	Slideshow.Control.Container = $('slideshow-container');
	Slideshow.Control.Images.All = $$('div#slideshow-container img');
	Slideshow.Control.Titlebar = $('slideshow-title');

	Slideshow.Control.Images.All.each(function(i) {
		if(!Slideshow.Control.Images.Widest || Slideshow.Control.Images.Widest.getWidth() < i.getWidth())
			Slideshow.Control.Images.Widest = i;
		if(!Slideshow.Control.Images.Tallest || Slideshow.Control.Images.Tallest.getHeight() < i.getHeight())
			Slideshow.Control.Images.Tallest = i;
		if(i != Slideshow.Control.Images.All.first())
			i.hide();
	});

	Slideshow.Methods.start();
}

function openModule(place){
	if (document.getElementById('tagdd').style.display != 'none') {
		var i = document.getElementById('tagbox');
		Effect.BlindUp('tagdd', {duration: 0.4} );
	
	i.className = 'keywords';
	}
//	alert('got here');

	var overlay = document.getElementById('overlay');
	if (place == '0') {
		overlay.style.left = '10px';
		overlay.style.top = '146px';

	}
	else if (place == '1' || place == '2') {
		overlay.style.left = '350px';
		overlay.style.top = '146px';
	}
	else if (place == '3') {
		overlay.style.left = '10px';
		overlay.style.top = '483px';
	}
	else if (place == '4' || place == '5') {
		overlay.style.left = '350px';
		overlay.style.top = '483px';
	}
	else if (place == '6') {
		overlay.style.left = '10px';
		overlay.style.top = '826px';
	}
	else if (place == '7' || place == '8') {
		overlay.style.left = '350px';
		overlay.style.top = '826px';
	}
   $('overlay').appear({duration: 0.4});

 
 //.show();
  //  center('box');
    return false;
}

function closeModule(){

	// = 'hidden';
    $('overlay').hide();
    return false;
}

function getPosition(e) {
    e = e || window.event;
    var cursor = {x:0, y:0};
    if (e.pageX || e.pageY) {
        cursor.x = e.pageX;
        cursor.y = e.pageY;
    } 
    else {
        var de = document.documentElement;
        var b = document.body;
        cursor.x = e.clientX + 
            (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
        cursor.y = e.clientY + 
            (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
    }
    return cursor;
}

