function randomVideo () {
	var keywords =  
	[ 
 	"3609701",  
 	"4002722",  
 	"2262241",
 	"2684960",
 	"5241416",
 	"5250273",
 	"5653900",
 	"6069314",
 	"6071557",
 	"6072423",
 	"6073226",
 	"6671935",
 	"7492896",
 	"7120665",
 	"7613184",
 	"7743597"
	]
	var keyword = keywords[Math.floor(Math.random()*keywords.length)]
    //<![CDATA[
	document.write('<object width=\"288\" height=\"169\" type=\"application/x-shockwave-flash\" data=\"http://vimeo.com/moogaloop.swf?clip_id=' + keyword + '&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1\"><param name=\"allowfullscreen\" value=\"true\" /><param name=\"allowscriptaccess\" value=\"always\" /><param name=\"movie\" value=\"http://vimeo.com/moogaloop.swf?clip_id=' + keyword + '&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1\" /></object>');
	//]]>
}

function randomMainImage () {
	var keywords =  
	[ 
 	"main1.jpg",
 	"main2.jpg",
 	"main3.jpg",
 	"main4.jpg",
 	"main5.jpg",
 	"main6.jpg",
 	"main7.jpg" 
	]
	var keyword = keywords[Math.floor(Math.random()*keywords.length)]
    //<![CDATA[
	document.write('<img src=\"./images/' + keyword + '\" width=\"500\" height=\"240\" alt=\"Titulní obrázek\"/>');
	//]]>
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

var rootdomain="http://"+window.location.hostname;

function includePage(url) {
var page_request = false;
if (window.XMLHttpRequest) // if Mozilla, Safari etc
    page_request = new XMLHttpRequest();
    else if (window.ActiveXObject){ // if IE
        try {
        page_request = new ActiveXObject("Msxml2.XMLHTTP");
        } 
        catch (e){
            try {
            page_request = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e){}
        }
    }
else
    return false;
    page_request.open('GET', url, false); //get page synchronously 
    page_request.send(null);
    writecontent(page_request);
    HideShow('PromoPop', 'block')
}

function writecontent(page_request){
    if (window.location.href.indexOf("http")==-1 || page_request.status==200) {
        if (document.getElementById) {
            var myID = document.getElementById('PromoPop');
            myID.innerHTML = page_request.responseText;
         }
    }
}

function HideShow(element_id, action) {
		var link = element_id;
		var a = action;
		document.getElementById(link).style.display=a;
	}

//clear input field default value
function clearbox(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = ""
} 

var activeItem = activeItemID = null;

// http://www.xs4all.nl/~ppk/js/findpos.html
function findPosY(obj)
{	
	var curtop = 0;
	if (document.getElementById || document.all)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	return curtop;
}


function displayObj(objId) {
	obj = document.getElementById(objId);
	if (obj) {
		if (obj.style.display == "block") obj.style.display = "none";
		else {obj.style.display = "block"; }
		}
}

function toggleObjectDisplay(objId, hideObj)
	{
	obj = document.getElementById(objId);
	//hideobj = document.getElementById(hideObj);
	if (obj)
		{
		if (obj.style.display == "block") obj.style.display = "none";
		else {obj.style.display = "block"; }
		}
	}
	
	
function sg_screenObject()
	{
	this.bottom = function(){
		if (document.body.scrollHeight) return document.body.scrollHeight};
	
	this.height = function() {
		if (document.body.offsetHeight) return document.body.offsetHeight;}
	
	this.visHeight = function() {
		if (window.innerHeight) return window.innerHeight;
		if (document.body.clientHeight) return document.body.clientHeight;}
	
	this.width = function() {
		if (document.body.offsetWidth) return document.body.offsetWidth;}
	
	this.scrollTop = function() {
		if(document.body.scrollTop) return document.body.scrollTop
		if (window.pageYOffset) return window.pageYOffset;
		else return 0;};
	}


function gID(o)
	{
	return document.getElementById(o);
	}

function inArray(string, arr)
	{
	for(var i=0; i < arr.length; i++)
		{
		if(arr[i] == string) return i;

		}
	return false;
	}


function goNavLink()
	{
	document.location = nav_link;
	}

function showHomePage()
	{
	try{
		gID("pg_title").style.visibility = "hidden";
		gID("nav_button").style.visibility = "visible";
		//gID("nav_arrow").style.visibility = "visible";
		}
	catch(err){}
	}
	

function hideHomePage()
	{
	try{
		gID("pg_title").style.visibility = "visible";
		gID("nav_button").style.visibility = "hidden";
		//gID("nav_arrow").style.visibility = "hidden";
		}
	catch(err){}
	}

function hightlight(o)
	{
	activeItem.style.background = "transparent";
	activeItem = o;
	activeItem.style.background = "#666666";
	}

function scrollColumn(mod)
	{
	
	colPos = colPos + mod;
	var newPos = COL_HEIGHT * colPos;

	if (newPos <= 0 && newPos > (-1 * gID("project_list").offsetHeight))
		{
		gID("project_list").style.top = (COL_HEIGHT * colPos) - LINE_HEIGHT + "px"; //"-100px";
		}
	else colPos = colPos - mod;
	}


function scrollTo(o)
	{
	pos = findPosY(o)-141;

	if (pos < 0)
		{
		parent.scrollColumn(1);
		parent.scrollTo(o);
		}
	if(pos > COL_HEIGHT)
		{
		parent.scrollColumn(-1);
		parent.scrollTo(o);
		}
	}

function makeActiveItem(o)
	{
	try 
		{
		parent.gID(parent.activeItem).style.color = "#666666";
		}
	catch(err) {}
	
	parent.activeItem = "client_"+o;
	parent.activeItemID = o;
	
	p = parent.gID(parent.activeItem);
	
	//make sure active item is in view
	//parent.scrollTo(p);
	
	parent.gID(parent.activeItem).style.color = "#ffffff";
	}

//change to next/previous project dir:direction
function turnProject(dir)
	{
	var pos = inArray(parent.activeItemID, parent.allProjects);
	if (pos == false) pos = -1;
	
		
	if (pos+dir >= 0 && pos+dir < parent.allProjects.length)
		{

		id = parent.allProjects[pos+dir];
		document.location = "portfolio.php?project_id="+id;
		}
	else 
		{
		if (pos+dir < 0)			
			document.location = "portfolio.php?project_id="+parent.allProjects[parent.allProjects.length-1];
		
		if (pos+dir >= parent.allProjects.length)
			document.location = "portfolio.php?project_id="+parent.allProjects[0];
		}
	}

function centerPage()
	{
	try
		{
		//alert(thisScreen.width);
		if (thisScreen.width() > 610)
		gID("pageCon").style.left = Math.round((thisScreen.width()-600)/2);
		}
		
	catch(err){}
	}

function windowInit()
	{
	//window.resizeTo(900,800)
	}
	
function closeScreen()
	{
	try
		{
		//document.location = "";
		document.getElementById("screen").style.visibility = "hidden";
		//document.getElementById("bodyNode").innerHTML = "";
		document.getElementById("desc").style.visibility = "visible";
		document.getElementById("screens_nav").style.visibility = "visible";
		}
	catch(err)
		{
		alert("Your browser appears not to be compatible with this script, my apologies");
		}
	}

function showScreen(id)
	{
	try
		{
		document.getElementById("screen").style.visibility = "visible";
		document.getElementById("desc").style.visibility = "hidden";
		document.getElementById("screens_nav").style.visibility = "hidden";
		}
	catch(err)
		{
		alert("Your browser appears not to be compatible with this script, my apologies");
		}
	}

function sizeFrame(width, height)
	{
	
	try {
		parent.document.getElementById("screen").style.height= height+26;
		}
	catch(err){}
	}

function windowClose()
	{
	
	try {
		parent.document.getElementById("project_detail").style.visibility= "hidden";
		}
	catch(err){}
	}

window.onload = windowInit;
window.onresize = centerPage;
document.onunload = windowClose;


function prepareImageSwap(elem,mouseOver,mouseOutRestore,mouseDown,mouseUpRestore,mouseOut,mouseUp) { 
//Do not delete these comments. 
//Non-Obtrusive Image Swap Script V1.1 by Hesido.com 
    if (typeof(elem) == 'string') elem = document.getElementById(elem); 
    if (elem == null) return; 
    var regg = /(.*)(_nm\.)([^\.]{3,4})$/ 
    var prel = new Array(), img, imgList, imgsrc, mtchd; 
    imgList = elem.getElementsByTagName('img'); 
    for (var i=0; img = imgList[i]; i++) { 
        if (!img.rolloverSet && img.src.match(regg)) { 
            mtchd = img.src.match(regg); 
            img.hoverSRC = mtchd[1]+'_hv.'+ mtchd[3]; 
            img.outSRC = img.src; 
            if (typeof(mouseOver) != 'undefined') { 
                img.hoverSRC = (mouseOver) ? mtchd[1]+'_hv.'+ mtchd[3] : false; 
                img.outSRC = (mouseOut) ? mtchd[1]+'_ou.'+ mtchd[3] : (mouseOver && mouseOutRestore) ? img.src : false; 
                img.mdownSRC = (mouseDown) ? mtchd[1]+'_md.' + mtchd[3] : false; 
                img.mupSRC = (mouseUp) ? mtchd[1]+'_mu.' + mtchd[3] : (mouseOver && mouseDown && mouseUpRestore) ? img.hoverSRC : (mouseDown && mouseUpRestore) ? img.src : false; 
                } 
            if (img.hoverSRC) {preLoadImg(img.hoverSRC); img.onmouseover = imgHoverSwap;} 
            if (img.outSRC) {preLoadImg(img.outSRC); img.onmouseout = imgOutSwap;} 
            if (img.mdownSRC) {preLoadImg(img.mdownSRC); img.onmousedown = imgMouseDownSwap;} 
            if (img.mupSRC) {preLoadImg(img.mupSRC); img.onmouseup = imgMouseUpSwap;} 
            img.rolloverSet = true; 
        } 
    } 
    function preLoadImg(imgSrc) { 
        prel[prel.length] = new Image(); prel[prel.length-1].src = imgSrc; 
    } 
} 
function imgHoverSwap() {this.src = this.hoverSRC;} 
function imgOutSwap() {this.src = this.outSRC;} 
function imgMouseDownSwap() {this.src = this.mdownSRC;} 
function imgMouseUpSwap() {this.src = this.mupSRC;}