var boxSwitchers = new Object();

$(document).ready(init);

function init() {
	$("a.switch").each (
		function () {
			var box = $(this).attr('rel');
			$("#"+box).css('display','none');			
		
			$(this).click (
				function () {
					var box = $(this).attr('rel');
					
					if ( boxSwitchers[box] ) {
						$("#"+box).hide();
					}
					else {
						$("#"+box).show();
					}
					boxSwitchers[box] = !boxSwitchers[box];
					
					return false;
				}
			);
		}
	);
}

//project logos
var currentImg = 0; 
//scroll none blocked
var scroll = 0;

function mail(user,domain,subject)
{
  if (subject == '')
  {
    loc = "mailto:" + user + "@" + domain;
  }
  else
  {
    loc = "mailto:" + user + "@" + domain + "?subject=" + subject + "";
  }
  
  window.location = loc;
}

function confirmation(text, loc)
{
  if (confirm(text))
  {
    location.replace(loc)
  }
}

function diving(div_id)
{
  if (document.getElementById(div_id).style.display == "none")
  {
    document.getElementById(div_id).style.display="block";
  }
  else
  {
    document.getElementById(div_id).style.display="none";
  }
}



function ScrollStart(dir)
{
  scroll = 0;
  ScrollDiv(dir);
}
function ScrollStop()
{
  scroll = 1;
}

function ScrollDiv(dir)
{ 
   if (dir == "up")
   { 
     currentImg--; 
   } 
   else if (dir == "down")
   { 
     currentImg++; 
   } 
   
   if (currentImg < 0) currentImg=0;

   var div = document.getElementById("logos"); 
   div.scrollTop = (currentImg * 5); 
   
   if (scroll != 1)
   {
     setTimeout("ScrollDiv('"+dir+"')", 100);
   }
} 



var Timer;

function ScrollLeft()
{
	Timer = setInterval("document.getElementById('sub-images').scrollLeft -= 2", 30);
}
function ScrollRight()
{
	Timer = setInterval("document.getElementById('sub-images').scrollLeft += 2", 30);
}






function ImageChange(link_id, middle_src, big_src)
{
	document.getElementById('gal-middle').src=middle_src;
	document.getElementById('gal-link').href=big_src;
	
	var d=document.getElementById('sub-images');
	var ass = d.getElementsByTagName('a');
	
	for (i=0; i<ass.length; i++) {
		ass[i].className='';
	}
	
	document.getElementById('link-' + link_id).className = 'active';
	
	return(false);
}
