function thumbOver(id_num){
	document.getElementById("thumb"+id_num).style.cursor="pointer";
	fade("thumb"+id_num);
}
function thumbOut(id_num){
	fade("thumb"+id_num);
}
var ekip_selected;
function thumbOver2(id_num){
	if(ekip_selected!=id_num){
		document.getElementById("thumb"+id_num).style.backgroundPosition="bottom";
		document.getElementById("thumb"+id_num).style.cursor="pointer";
	}
}
function thumbOut2(id_num){
	if(ekip_selected!=id_num){
		document.getElementById("thumb"+id_num).style.backgroundPosition="top";
	}
}
function thumbClick2(id_num){
	if(ekip_selected!=id_num){
		var temp=ekip_selected;
		ekip_selected=id_num;
		if(temp!=undefined){
			thumbOut2(temp);
		}
		document.getElementById("team_image").src="images/tanya_img.jpg";
		document.getElementById("team_title").style.display="block";
	}
}
var job_selected;
function thumbOver3(id_num){
	if(job_selected!=id_num){
		document.getElementById("thumb"+id_num).style.backgroundPosition="bottom";
		document.getElementById("thumb"+id_num).style.cursor="pointer";
	}
}
function thumbOut3(id_num){
	if(job_selected!=id_num){
		document.getElementById("thumb"+id_num).style.backgroundPosition="top";
	}
}
function thumbClick3(id_num){
	if(job_selected!=id_num){
		var temp=job_selected;
		job_selected=id_num;
		if(temp!=undefined){
			thumbOut3(temp);
		}
	}
}


var viewportwidth;
var viewportheight;
function getViewPort(){
	 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
	 
	 
//		 alert(typeof document.documentElement+", "+typeof document.documentElement.clientWidth+", "+document.documentElement.clientWidth);
	 
	 if (typeof window.innerWidth != 'undefined')
	 {
		  viewportwidth = window.innerWidth,
		  viewportheight = window.innerHeight
	 }
	 
	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
	
	 else if (typeof document.documentElement != 'undefined'
		 && typeof document.documentElement.clientWidth !=
		 'undefined' && document.documentElement.clientWidth != 0)
	 {
		   viewportwidth = document.documentElement.clientWidth,
		   viewportheight = document.documentElement.clientHeight
	 }
	 
	 // older versions of IE
	 
	 else
	 {
		   viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
		   viewportheight = document.getElementsByTagName('body')[0].clientHeight
	 }
}
//	getViewPort();

var newwindow;
function poptastic(url)
{
	newwindow=window.open(url,'Banner popup','height='+viewportheight+',width='+viewportwidth+',scrollbars=yes');
	if (window.focus) {newwindow.focus()}
}


function changeFlashContent(vimeo_id, w, h){
	if(vimeo_id.indexOf("_")!=-1){
		str='<img src="'+vimeo_id+'" width="'+w+'" height="'+h+'" onload="getSizesAndCreateScroll()">';
	}else{
		str='<object id="FlashID" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+w+'" height="'+h+'">';
		str+='<param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id='+vimeo_id+'&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" />';
		str+='<param name="quality" value="high" />';
		str+='<param name="wmode" value="opaque" />';
		str+='<param name="allowScriptAccess" value="always" />';
		str+='<param name="swfversion" value="6.0.65.0" />';
		str+='<!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you don’t want users to see the prompt. -->';
		str+='<param name="expressinstall" value="Scripts/expressInstall.swf" />';
		str+='<!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. -->';
		str+='<!--[if !IE]>-->';
		str+='<object type="application/x-shockwave-flash" data="http://vimeo.com/moogaloop.swf?clip_id='+vimeo_id+'&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" width="'+w+'" height="'+h+'">';
		str+='<!--<![endif]-->';
		str+='<param name="quality" value="high" />';
		str+='<param name="allowScriptAccess" value="always" />';
		str+='<param name="wmode" value="opaque" />';
		str+='<param name="swfversion" value="6.0.65.0" />';
		str+='<param name="expressinstall" value="Scripts/expressInstall.swf" />';
		str+='<!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. -->';
		str+='<div>';
		str+='<h4>Content on this page requires a newer version of Adobe Flash Player.</h4>';
		str+='<p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" width="112" height="33" /></a></p>';
		str+='</div>';
		str+='<!--[if !IE]>-->';
		str+='</object>';
		str+='<!--<![endif]-->';
		str+='</object>';
	}
	document.getElementById("flash_player").innerHTML=str;
	document.getElementById("flash_player").style.height=h+"px";
	
	
	if(vimeo_id.indexOf("_")==-1){
		getSizesAndCreateScroll();
	}
	
}

function getSizesAndCreateScroll(){
	right_content_h=document.getElementById('right_content').offsetHeight;
	menu_h=document.getElementById('menu').offsetHeight;
	
	
	makeScroll();
}


var twit_count=0;
var twits_arr=new Array();
function changeTwits(){
	fade("twits");
}

var  TimeToFade = 300;

function fade(eid)
{
  var element = document.getElementById(eid);
  if(element == null)
	return;
   
  if(element.FadeState == null)
  {
	if(element.style.opacity == null
		|| element.style.opacity == ''
		|| element.style.opacity == '1')
	{
	  element.FadeState = 2;
	}
	else
	{
	  element.FadeState = -2;
	}
  }
  if(element.FadeState == 1 || element.FadeState == -1)
  {
	element.FadeState = element.FadeState == 1 ? -1 : 1;
	element.FadeTimeLeft = TimeToFade - element.FadeTimeLeft;
  }
  else
  {
	element.FadeState = element.FadeState == 2 ? -1 : 1;
	element.FadeTimeLeft = TimeToFade;
	setTimeout("animateFade(" + new Date().getTime() + ",'" + eid + "')", 33);
  }  
}
function  animateFade(lastTick, eid)
{  

	var curTick = new Date().getTime();
	var elapsedTicks = curTick - lastTick;
	
	var element = document.getElementById(eid);
	
	if(element.FadeTimeLeft <= elapsedTicks)
	{
		element.style.opacity = element.FadeState == 1 ? '1' : '0';
		element.style.filter = 'alpha(opacity = ' + (element.FadeState == 1 ? '100' : '0') + ')';
		element.FadeState = element.FadeState == 1 ? 2 : -2;
		
		if(element.FadeState==-2 && eid=="twits"){
			document.getElementById("twits").innerHTML=twits_arr[twit_count];
			twit_count++;
			if(twit_count==5){
				twit_count=0;
			}
			fade("twits");
		}
		
		
		return;
	}
	
	element.FadeTimeLeft -= elapsedTicks;
	var newOpVal = element.FadeTimeLeft/TimeToFade;
	if(element.FadeState == 1)
		newOpVal = 1 - newOpVal;
	
	element.style.opacity = newOpVal;
	element.style.filter = 'alpha(opacity = ' + (newOpVal*100) + ')';
	
	setTimeout("animateFade(" + curTick + ",'" + eid + "')", 33);
}


var instance = new SmoothMovement(0, 0);
var instance2 = new SmoothMovement(0, 0);
var right_content_h;
var menu_h;

var window_width;
var window_height;
function getWindowSize() {

  if( typeof( window.innerWidth ) == 'number' ) {
	//Non-IE
	window_width = window.innerWidth;
	window_height = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	//IE 6+ in 'standards compliant mode'
	window_width = document.documentElement.clientWidth;
	window_height = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	//IE 4 compatible
	window_width = document.body.clientWidth;
	window_height = document.body.clientHeight;
  }
//	  alert(window_width+", "+window_height);
}
window.onload=function(){
	getWindowSize();
	window.onscroll = makeScroll;
}
var scrol=getYOffset();

window.onresize=function(){
	getWindowSize();
	makeScroll();
}


function makeScroll(){
//		console.log("makeScroll "+bottom_limit+">"+right_content_h+", "+menu_h);
	if(bottom_limit!=null && right_content_h!=null && menu_h!=null && right_content_h<bottom_limit){
		
		var y;
		if(getYOffset()>129){
			y=(getYOffset()-129);
		}else{
			y=0;
		}
		
			
		var y2=y;
		if(window_height<right_content_h){
			if(getYOffset()>=scrol){
				//dvijenie na dolu
				if(y<right_content_h-window_height){
					y=0;
				}else{
					y-=right_content_h-window_height;
				}
			}else{
				//dvijenie na gore
			}
		}
		scrol=getYOffset();
		
//			alert("makeScroll "+right_content_h+", "++bottom_limit);
		
		if(y+right_content_h>bottom_limit){
			y=bottom_limit-right_content_h;
		}
		
		
		if(y2+menu_h>bottom_limit){
			y2=bottom_limit-menu_h;
		}
		
		instance.target = y;
		instance2.target = y2;

		instance.update();
		instance.animate(
		20,
		function(position){
		  document.getElementById("right_content").style.top=position+"px";
		},
		function(){
		});
		
		
		instance2.update();
		instance2.animate(
		20,
		function(position){
		  document.getElementById("menu").style.top=position+"px";
		},
		function(){
		});
	}
}

function getYOffset() {
	var pageY;
//		alert(document.body.scrollTop+", "+document.documentElement.scrollTop+", "+window.pageYOffset+", "+typeof window.pageYOffset+", "+typeof(window.pageYOffset));
	if(typeof(window.pageYOffset)=='number') {
	   pageY=window.pageYOffset;
	}
	else {
		//raboti na servera ne i lokalno
		if(document.body!=null)
		   pageY=document.body.scrollTop;
	   //document.documentElement.scrollTop;
	}
	return pageY;
}
