window.onload = changeLinks;
document.cookie = 'animation=true';

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}

function changeLinks() {

mainContent = document.getElementById('main-content');

if(getCookie('animation')) { mainContent.style.opacity = '0';mainContent.style.left= '10.25pc';
intervalUp = setInterval('mainContent.style.opacity = goToValue(mainContent.style.opacity,1,0.25,intervalUp,null);', 50);
intervalUp2 = setInterval('mainContent.style.left= (goToValue(mainContent.style.left,10,0.25,intervalUp2,null) + "pc");', 50);
}
var links;
links = document.getElementsByTagName('a');
var i;
var hrefValue =[];
var href = [];
i = 0;
while(link =links[i]) {
	link.permHref = link.getAttribute('href');
	link.onmousedown = fadeOutAndLink;
	//link.setAttribute('href',"javascript:;");
	
	i++;
}
}

function fadeOutAndLink() {
this.setAttribute('href',"javascript:;");
if(getCookie('animation')) {
clearInterval(intervalUp);
clearInterval(intervalUp2);
}
intervalDown = setInterval('mainContent.style.opacity = goToValue(mainContent.style.opacity,0.0,0.13,intervalDown,null);', 50);
intervalDown2 = setInterval('mainContent.style.left= (goToValue(mainContent.style.left,10.25,0.15,intervalDown2,null) + "pc");', 50);
var goTo = "window.location='"+this.permHref+"';";
setTimeout(goTo,300);

}


function goToValue(value,increase,time,inttostop,functiotostart)
{

	constant = (increase - parseFloat(value)) / (time * 15);
	
	
	if(!(constant > -0.0001 && constant < 0.01)) {
	
	
	string = parseFloat(value) + constant;
	
	return string +"";
	} else {
	clearInterval(inttostop);
	delete goToValue.counter;
	functiotostart();
	}
	
}