/* ==================== NAVIGATIONS-MOTOR =========================*/
function elementPosition(obj) {
var curleft = 0, curtop = 0;

if (obj.offsetParent) {
curleft = obj.offsetLeft;
curtop = obj.offsetTop;

while (obj = obj.offsetParent) {
curleft += obj.offsetLeft;
curtop += obj.offsetTop;
}
}

return { x: curleft, y: curtop };
}

function ScrollToControl(id)
{
var elem = document.getElementById(id);
var scrollPos = elementPosition(elem).y;
scrollPos = scrollPos - document.documentElement.scrollTop;
var remainder = scrollPos % 50;
var repeatTimes = (scrollPos - remainder) / 50;
ScrollSmoothly(scrollPos,repeatTimes);
window.scrollBy(0,remainder);
}
var repeatCount = 0;
var cTimeout;
var timeoutIntervals = new Array();

var timeoutIntervalSpeed;
function ScrollSmoothly(scrollPos,repeatTimes)
{
if(repeatCount < repeatTimes)
{
window.scrollBy(0,50);
}
else
{
repeatCount = 0;
clearTimeout(cTimeout);
return;
}
repeatCount++;
cTimeout = setTimeout("ScrollSmoothly('" + scrollPos + "','"+ repeatTimes +"')",10);
}

/*StartScroll*/
function startscroll() {
ScrollToControl('astart');
document.getElementById("home").style.backgroundImage = "url(img/sne_navigation/start2.png)";
document.getElementById("portfolio").style.backgroundImage= "url(img/sne_navigation/portfolio1.png)";
document.getElementById("about").style.backgroundImage= "url(img/sne_navigation/terese1.png)";
document.getElementById("contact").style.backgroundImage = "url(img/sne_navigation/kontakt1.png)";
}
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(startscroll);
addLoadEvent(function() {
  /* more code to run on page load */ 
});

/*====================== Navigation ===============================*/

function navigation1() {
if(d.length < 1) { return; }
document.getElementById("home").style.backgroundImage = "url(img/sne_navigation/start2.png)";
document.getElementById("portfolio").style.backgroundImage= "url(img/sne_navigation/portfolio1.png)";
document.getElementById("about").style.backgroundImage= "url(img/sne_navigation/terese1.png)";
document.getElementById("contact").style.backgroundImage = "url(img/sne_navigation/kontakt1.png)";
/*window.location.hash="#homeposition";*/
/*self.scrollTo(0, 0)*/

}

function navigation2() {
if(d.length < 1) { return; }
document.getElementById("home").style.backgroundImage = "url(img/sne_navigation/start1.png)";
document.getElementById("portfolio").style.backgroundImage= "url(img/sne_navigation/portfolio2.png)";
document.getElementById("about").style.backgroundImage= "url(img/sne_navigation/terese1.png)";
document.getElementById("contact").style.backgroundImage = "url(img/sne_navigation/kontakt1.png)";
/*window.location.hash="#portfolioposition";*/

}

function navigation3() {
if(d.length < 1) { return; }
document.getElementById("home").style.backgroundImage = "url(img/sne_navigation/start1.png)";
document.getElementById("portfolio").style.backgroundImage= "url(img/sne_navigation/portfolio1.png)";
document.getElementById("about").style.backgroundImage= "url(img/sne_navigation/terese2.png)";
document.getElementById("contact").style.backgroundImage = "url(img/sne_navigation/kontakt1.png)";
/*window.location.hash="#aboutposition";*/

}

function navigation4() {
if(d.length < 1) { return; }
document.getElementById("home").style.backgroundImage = "url(img/sne_navigation/start1.png)";
document.getElementById("portfolio").style.backgroundImage= "url(img/sne_navigation/portfolio1.png)";
document.getElementById("about").style.backgroundImage= "url(img/sne_navigation/terese1.png)";
document.getElementById("contact").style.backgroundImage = "url(img/sne_navigation/kontakt2.png)";
/*window.location.hash="#contactposition";*/

}

/* ======================= fbox [START] ====================== */

function fbox(){

		var box=document.getElementById('fbox');

		if(box.style.visibility=='visible'){	box.style.visibility='hidden';}

		else{ box.style.visibility='visible';}

		return false;

	}
	
function HideContent(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "none";
}
function ShowContent(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "block";
}



function citatnr1function() {
if(d.length < 1) { return; }
document.getElementById("citatnr1").style.display = "block";
document.getElementById("citatval1").style.backgroundColor="#0a3247"
document.getElementById("citatnr2").style.display = "none";
document.getElementById("citatval2").style.backgroundColor="#000000"
document.getElementById("citatnr3").style.display = "none";
document.getElementById("citatval3").style.backgroundColor="#000000"
document.getElementById("citatnr4").style.display = "none";
document.getElementById("citatval4").style.backgroundColor="#000000"
}

function citatnr2function() {
if(d.length < 1) { return; }
document.getElementById("citatnr2").style.display = "block";
document.getElementById("citatval2").style.backgroundColor="#0a3247"
document.getElementById("citatnr1").style.display = "none";
document.getElementById("citatval1").style.backgroundColor="#000000"
document.getElementById("citatnr3").style.display = "none";
document.getElementById("citatval3").style.backgroundColor="#000000"
document.getElementById("citatnr4").style.display = "none";
document.getElementById("citatval4").style.backgroundColor="#000000"
}

function citatnr3function() {
if(d.length < 1) { return; }
document.getElementById("citatnr3").style.display = "block";
document.getElementById("citatval3").style.backgroundColor="#0a3247"
document.getElementById("citatnr2").style.display = "none";
document.getElementById("citatval2").style.backgroundColor="#000000"
document.getElementById("citatnr1").style.display = "none";
document.getElementById("citatval1").style.backgroundColor="#000000"
document.getElementById("citatnr4").style.display = "none";
document.getElementById("citatval4").style.backgroundColor="#000000"
}

function citatnr4function() {
if(d.length < 1) { return; }
document.getElementById("citatnr4").style.display = "block";
document.getElementById("citatval4").style.backgroundColor="#0a3247"
document.getElementById("citatnr3").style.display = "none";
document.getElementById("citatval3").style.backgroundColor="#000000"
document.getElementById("citatnr2").style.display = "none";
document.getElementById("citatval2").style.backgroundColor="#000000"
document.getElementById("citatnr1").style.display = "none";
document.getElementById("citatval1").style.backgroundColor="#000000"
}




/* ======================= Terése POP-UP ======================== */
function wopen(url, name, w, h)
{
// Fudge factors for window decoration space.
 // In my tests these work well on all platforms & browsers.
w += 32;
h += 96;
 var win = window.open(url,
  name, 
  'width=' + w + ', height=' + h + ', ' +
  'location=no, menubar=no, ' +
  'status=no, toolbar=no, scrollbars=yes, resizable=yes');
 win.resizeTo(w, h);
 win.focus();
}



