//function
function OverMenu(id) {
	document.getElementById(id).style.display = 'block';
}

function OutMenu(id) {
	document.getElementById(id).style.display = 'none';
}

function ShowThisNews(id) {
	var oid = getCookie('idnews');
	if (oid == id) {
		return;
	}
	var cook = "idnews="+id+";";
	document.cookie = cook;
	var newid = 'id'+id;
	var newdate = 'post'+id;

	var oldobj = document.getElementById('activenews');
	oldobj.setAttribute('id','id'+oid);
	oldobj = document.getElementById('activedate');
	oldobj.setAttribute('id','post'+oid);
	var newobj = document.getElementById(newid);
	newobj.setAttribute('id','activenews');
	newobj = document.getElementById(newdate);
	newobj.setAttribute('id','activedate');
	
	if (id=="") {
	  document.getElementById("newsbox").innerHTML="";
	  return;
	} 
	if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	} else {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	  {
	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			var str = xmlhttp.responseText;
			var reg = /width="(.*?)" height="(.*?)"/;
			document.getElementById("newsbox").innerHTML = str.replace(reg, '');
			//fix bag of height in ff
			t1 = window.setTimeout("document.getElementsByTagName('div').item(0).style.height = '99%'",100);
			t2 = window.setTimeout("document.getElementsByTagName('div').item(0).style.height = '100%'",200);
		}
	  }
	xmlhttp.open("GET","templates/goodp/returnNews.php?id="+id,true);
	xmlhttp.send();
}

function getCookie(name) {
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}

function ShowServiceBlock(id) {
	var old_id = getCookie('serviceid');
	document.cookie='serviceid='+id+';';
	if (id == 14) { //download breefs production and design show or hide
		document.getElementById('breefblock').style.display = 'block';
	} else {
		document.getElementById('breefblock').style.display = 'none';
	}
	if (id == old_id) return;
	var old_lp = 'lp' + old_id;
	var new_lp = 'lp' + id;
	var old_rp = 'rp' + old_id;
	var new_rp = 'rp' + id;
	document.getElementById('activeleftpick').setAttribute('id',old_lp);
	document.getElementById(new_lp).setAttribute('id','activeleftpick');
	
	document.getElementById(new_rp).style.display = 'block';
	document.getElementById(old_rp).style.display = 'none';
}

function ShowThisService(left_id, id) {
    if (window.location.pathname == '/goodpeople/about.html') {
        document.cookie='right_id='+id+';';
        document.cookie='serviceid='+left_id+';';
        window.location.pathname = '/goodpeople/uslugi.html';
    } else {
        document.cookie='right_id='+id+';';
        document.cookie='serviceid='+left_id+';';
    }
	if (id=="") {
	  document.getElementById("servicebox").innerHTML="";
	  return;
	} 
	if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	} else {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4 && xmlhttp.status==200) {
			document.getElementById("servicebox").innerHTML=xmlhttp.responseText;
			//fix bag of height in ff
			t1 = window.setTimeout("document.getElementsByTagName('div').item(0).style.height = '99%'",100);
			t2 = window.setTimeout("document.getElementsByTagName('div').item(0).style.height = '100%'",200);
		}
	}
	xmlhttp.open("GET","templates/goodp/returnService.php?id="+id,true);
	xmlhttp.send();
}

function ShowOrHide(vac_id) {
    if (document.getElementById(vac_id).style.display == 'block') {
        document.getElementById(vac_id).style.opacity = '0';
        document.getElementById(vac_id).style.display = 'none';
    } else {        
        document.getElementById(vac_id).style.opacity = '0';
        document.getElementById(vac_id).style.display = 'block';        
        for(i=0; i<=5; i++) {
            ChangeOp(vac_id,i);
        }     
    }
}

function ChangeOp(id,op) {
    var inter = window.setInterval(function() {document.getElementById(id).style.opacity = (op*0.2)+'';
    window.clearInterval(inter);}, 100*i);
}

function PrevPortf() {
	var num = getCookie('mainimg');
	var prev = parseInt(num)-1;
	if (prev == -1) {
		prev = getCookie('maxmainimg');
	}
	try {
		nextimg = document.getElementById(prev).innerHTML;
		document.cookie='mainimg='+prev+';';
		document.getElementById('mainimg').innerHTML = nextimg;
	}
	catch(err) {
		alert(err);	
	}
}

function NextPortf() {
	var num = getCookie('mainimg');
	var next = parseInt(num)+1;
	if (next > getCookie('maxmainimg')) {
		next = 0;
	}
	try {
		nextimg = document.getElementById(next).innerHTML;
		document.cookie='mainimg='+next+';';
		document.getElementById('mainimg').innerHTML = nextimg;
	}
	catch(err) {
		alert(err);
	}
}

function ChangeOtziv(doit) {
    replacement = 92;
    replIncrase = 4;
	id = getCookie('otzivid');
	maximum = getCookie('countotz');
	obj = document.getElementById('headotzivi');
	switch (doit) {
	case 1: //>>
		if (id == maximum) return;
		for (var i=0; i<=replacement; i=i+replIncrase) {
			margin = ((id*(-1*replacement)) - i);
			ChangeTop(obj,i,margin);
		}
		id++;
	break;
	case 0: //<<
		if (id == 0) return;
		for (var i=0; i<=replacement; i=i+replIncrase) {
			margin = ((id*(-1*replacement)) + i);
			ChangeTop(obj,i,margin);
		}
		id--;
	break;
	}
	document.cookie='otzivid='+ id +';';
}

function ChangeTop(ob,mt,mgrn) {
	inter = window.setTimeout(
			function() {
			ob.style.marginTop = (mgrn)+'px';
			}, 3*mt);
}

function ChangeGoodPpl(doit) {
    replacement = 68;
    replIncrase = 4;
	id = getCookie('gpid');
	maximum = getCookie('countgp');
	obj = document.getElementById('ctrl');
	switch (doit) {
	case 1: //>>
		if (id == maximum) return;
		for (var i=0; i<=replacement; i=i+replIncrase) {
			margin = ((id*(-1*replacement)) - i);
			ChangeLeft(obj,i,margin);
		}
		id++;
	break;
	case 0: //<<
		if (id == 0) return;
		for (var i=0; i<=replacement; i=i+replIncrase) {
			margin = ((id*(-1*replacement)) + i);
			ChangeLeft(obj,i,margin);
		}
		id--;
	break;
	}
	document.cookie='gpid='+ id +';';
}

function ChangeLeft(ob,mt,mgrn) {
	inter = window.setTimeout(
			function() {
			ob.style.left = mgrn+'px';
			}, 2*mt);
}

function OutFromGP() {
    document.getElementById('gpdialog').innerHTML = '';
}
function OverThisGP(obj) {
    document.getElementById('gpdialog').innerHTML = obj.getAttribute('title');
}
