function start()
{
  if (!document.getElementsByTagName || !document.getElementById) return false;
  
	projectimages()
	gallery();
	firstimage();
	lang()
}

function lang()
 {
  if (!document.getElementById('language')) return false;	
  
	obj = document.getElementById('language');
		obj.onmouseover = function() {
			this.style.borderTop ="4px solid #294f7b";
		}
  
 		obj.onmouseout = function() {
			this.style.borderTop ="4px solid #afc4dc";
		} 
 }

function firstimage()
 {
  if (!document.getElementById) return false;	
  if (!document.getElementById('thumb0')) return false;	
	obj = document.getElementById('thumb0');
		obj.onmouseover = function() {
			this.style.cursor="pointer";
		}
  
 		obj.onmouseout = function() {
			this.style.cursor="hand";
		} 
		
		
		obj.onclick = function() {
			if(this.lang == 'en')
				document.location = '/about/internships/'
			else if(this.lang == 'se')
				document.location = '/om/praktik';	
		} 
 }

function projectimages()
{
  if( !document.getElementById('content') ) return false;
  // Get our images within the div with ID blockID (set by config)
  var links = document.getElementById('content').getElementsByTagName('div');
  
  // Loop our images
  for (var i=0; i < links.length; i++) {	
  	if(links[i].className == 'hover_')
  	 {
	     // Bind onMouseOver
		links[i].onmouseover = function() {
			this.className="hover_hover";
		}
  
 		links[i].onmouseout = function() {
			this.className="hover_";
		} 
  	 }
  }
	
}

function gallery()
{

  if (!document.getElementById('gallery')) return false;
  // Get our images within the div with ID blockID (set by config)
  var links = document.getElementById('gallery').getElementsByTagName('img');
  
  // Loop our images
  for (var i=0; i < links.length; i++) {
  
  	// links[i].src
  
    if(links[i].src.indexOf('/thumb') > 0)
	{
 	      links[i].style.cursor = "pointer";
 	    
 	    // Bind onClick
		links[i].onclick = function() {
	     setImage(this.src);
	     return false;	
	    }
	     
	     // Bind onMouseOver
		links[i].onmouseover = function() {
			this.className = "gallery-over";
		}
  
 		links[i].onmouseout = function() {
			this.className = "gallery-out";
		} 
  
	
	}
 
  }
	

}



function setImage(src)
 {
 	
 	// This is a mess, javascript that generates javascript is just nasty
 	document.getElementById('extracontent').innerHTML = "<p style='color: #ef821c;'>"	  	// Text container
 	+ "<span onclick='document.getElementById(\"content\").innerHTML = "				     	// onClick for image (in a span), used for removing the image 
 	+ "\"<span id=\\\"extracontent\\\"></span><span id=\\\"regularcontent\\\">\""			// Setup the empty spans
 	+ " + document.getElementById(\"regularcontent\").innerHTML + " 						// Insert main content
 	+ "\"</span>\";" +																		// Close span
 	"' style='cursor: pointer; '>"+
 	"<img src='" + src.replace(/thumbs/, "large") + "' class='gallery-img-large'/><br/>» Close<br/><br/></span></p>";

 }

window.onload = start;
