var is_roll=0;
var up=0;
var chi=0;

function roll(elt,ih,fh)
{
e=elt;
initial_h=ih;
final_h=fh;

if(is_roll==0 && up==0)
{
to1 = window.setInterval("roll_up(e,initial_h,final_h);",10);
is_roll=1;
}
else
{
to1 = window.setInterval("roll_down(e,initial_h,final_h);",10);
is_roll=1;
}
}


function roll_up(el,im,fm)
{
a = document.getElementById(el).offsetHeight;
if(a<fm)
{
a=a+16;
document.getElementById(el).style.height = a;
if(a>62)
{
document.getElementById(el).style.backgroundColor = "F9F9F9";
}
}
else
{
window.clearInterval(to1);
is_roll=0;
document.getElementById(el).style.overflow = "visible";
up=1;
}
}


function roll_down(el,im,fm)
{
a = document.getElementById(el).offsetHeight;
if(a>im)
{
a=a-16;
document.getElementById(el).style.overflow = "hidden";
document.getElementById(el).style.height = a;
if(a<=62)
{
document.getElementById(el).style.backgroundColor = "transparent";
}
}
else
{
window.clearInterval(to1);
is_roll=0;
document.getElementById(el).style.height = im;
up=0;
}
}

function swap(A_obr, B_obr)
{
document.images[A_obr].src=B_obr;
}

function f_show_mpos(event,a,b)
{
if(navigator.appName=='Microsoft Internet Explorer')
{
x=event.clientX+document.body.scrollLeft;
y=event.clientY+document.body.scrollTop;
}
else
{
x=event.pageX;
y=event.pageY;
}
document.getElementById(a).style.left=x;
document.getElementById(a).style.top=y;
document.getElementById(a).style.visibility="visible";
}

function f_change(a)
{
var is_hidden = document.getElementById(a).style.visibility;
if(is_hidden != 'visible')
{
document.getElementById(a).style.visibility = 'visible';
}
else
{
document.getElementById(a).style.visibility = 'hidden';
}
}

function clear_search()
{
document.search.search_inp.value="";
}

function clear_name()
{
document.login_form.login_name.value="";
}

function clear_pass()
{
document.login_form.login_pass.value="";
}

function sel_item(a)
{
document.trouble_form.trouble_q.value=a;
}

function f_hide(a)
{
document.getElementById(a).style.visibility='hidden';
}

function change_info(b_div,h_div,cena)
{
if(chi==0)
{
if(h_div == "tws_h4")
{
document.getElementById(b_div).innerHTML="<span style=\"float: left;\"><img src=\"images/less_info.png\" alt=\"menej\" class=\"tws_image_info\">Menej informácií</span>";
}
else
{
document.getElementById(b_div).innerHTML="<span style=\"float: left;\"><img src=\"images/less_info.png\" alt=\"menej\" class=\"tws_image_info\">Menej informácií</span><span style=\"float: right\">od <span class=\"red_price\">"+cena+"</span> <span class=\"red_euro\">&#8364</span></span>";
}
document.getElementById(h_div).style.position = "relative";
document.getElementById(h_div).style.visibility = "visible";
document.getElementById(h_div).style.overflow = "visible";
chi=1;
}
else
{
document.getElementById(b_div).innerHTML="<span style=\"float: left;\"><img src=\"images/more_info.png\" alt=\"viac\" class=\"tws_image_info\">Viac informácií</span><span style=\"float: right\">od <span class=\"red_price\">"+cena+"</span> <span class=\"red_euro\">&#8364</span></span>";
document.getElementById(h_div).style.position = "absolute";
document.getElementById(h_div).style.visibility = "hidden";
document.getElementById(h_div).style.overflow = "hidden";
chi=0;
}
}

function f_show_mpos_ref(event,a,obrazok,nadpis,poziadavka,technologie,ref_nr)
{
if(navigator.appName=='Microsoft Internet Explorer')
{
x=event.clientX+document.body.scrollLeft;
y=event.clientY+document.body.scrollTop;
}
else
{
x=event.pageX;
y=event.pageY;
}
s='<img src="referencie/'+obrazok+'" alt="'+obrazok+'" class="sr_img">';
s=s+'<div class="sr_div">';
s=s+'<h4 class="sr_h4">'+nadpis+'</h4>';
s=s+'<b>Požiadavka</b><br>';
s=s+poziadavka+'<br><br>';
s=s+'<b>Technológie</b><br>';
s=s+technologie+'<br>';
s=s+'<div class="sr_a" onClick=\"show_reference_big('+ref_nr+');\">';
s=s+'<img src="images/ref_more_info.gif" alt="&gt;" class="sr_img_more_info">Zobraziť projekt';
s=s+'</div>';
s=s+'</div>';
document.getElementById(a).innerHTML=s;
document.getElementById(a).style.top=y;
document.getElementById(a).style.left=x;
document.getElementById(a).style.visibility='visible';
}

function f_hide(a)
{
document.getElementById(a).style.visibility='hidden';
}

function f_show(a)
{
document.getElementById(a).style.visibility='visible';
}


function eshop_select(selected_item,q,w,e,r)
{
var XMLhttp = false;

if(window.XMLHttpRequest)
{
XMLhttp = new XMLHttpRequest();
}

else if(window.ActiveXObject)
{
XMLhttp = new ActiveXObject("Microsoft.XMLHTTP");
}

else
{
alert("Your browser could not create XMLHttpRequest.");
}

if(XMLhttp)
{
XMLhttp.open("POST","ajax/ajax_eshop.php",true);
XMLhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
XMLhttp.onreadystatechange=function()
{
if(XMLhttp.readyState == 4 && XMLhttp.status == 200)
{
document.getElementById('flash_content').innerHTML=XMLhttp.responseText;
}
}

XMLhttp.send("eshop_si="+selected_item+"&eshop_q="+q+"&eshop_w="+w+"&eshop_e="+e+"&eshop_r="+r);
}

else
{
alert("Error loading item.");
}
}


function show_reference_big(ref_nr)
{
var XMLhttp = false;
if(window.XMLHttpRequest)
{
XMLhttp = new XMLHttpRequest();
}
else if(window.ActiveXObject)
{
XMLhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else
{
alert("Your browser could not create XMLHttpRequest.");
}
if(XMLhttp)
{
XMLhttp.open("POST", "ajax/ajax_show_reference.php", true);
XMLhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
XMLhttp.onreadystatechange = function()
{
if(XMLhttp.readyState == 4 && XMLhttp.status == 200)
{
document.getElementById('references_big').innerHTML = XMLhttp.responseText;
document.getElementById('references_big').style.top = document.body.scrollTop;
document.getElementById('ref_bgr').style.top = document.body.scrollTop;
document.getElementById('references_big').style.visibility = "visible";
document.getElementById('ref_bgr').style.visibility = "visible";
}
}
XMLhttp.send("ref_nr="+ref_nr);
}
else
{
alert("Error");
}
}



function select_ref(sel, s0, s1, s2, s3)
{
var XMLhttp = false;
if(window.XMLHttpRequest)
{
XMLhttp = new XMLHttpRequest();
}
else if(window.ActiveXObject)
{
XMLhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else
{
alert("Your browser could not create XMLHttpRequest.");
}
if(XMLhttp)
{
XMLhttp.open("POST", "ajax/ajax_select_ref.php", true);
XMLhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
XMLhttp.onreadystatechange = function()
{
if(XMLhttp.readyState == 4 && XMLhttp.status == 200)
{
document.getElementById('reference').innerHTML = XMLhttp.responseText;
}
}
XMLhttp.send("sel="+sel+"&s0="+s0+"&s1="+s1+"&s2="+s2+"&s3="+s3);
}
else
{
alert("Error");
}
}
