// JavaScript Document
// vytvor skript pre vkladanie kodu do stranky
var xmlhttp;
function loadReply(url)
{
xmlhttp=null;
if (window.XMLHttpRequest)
  {// code for IE7, Firefox, Opera, etc.
  xmlhttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
if (xmlhttp!=null)
  {
  xmlhttp.onreadystatechange=state_Change;
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);
  }
else
  {
  alert("Vas prehliadac nepodporuje XMLHTTP.");
  }
}

function state_Change()
{
if (xmlhttp.readyState==4)
  {// 4 = "loaded"
  if (xmlhttp.status==200)
    {// 200 = "OK"
    document.getElementById('p_area'+document.getElementById('id_area').value).innerHTML=xmlhttp.responseText;
	}
  else
    {
    alert("Problem pri prenose XML dat!");
    }
  }
}

function select (row){
row.style.background = '#F5F5F5';
}
function deselect (row){
row.style.background = 'none';
}

function refresh(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function CountLeft(field, count, max) {
	if (field.value.length > max) field.value = field.value.substring(0, max); else
	count.value = max - field.value.length; 
	} 

function getStyleObject(objectId) {
    if(document.getElementById && document.getElementById(objectId)) {
	return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
	return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
	return document.layers[objectId];
    } else {
	return false;
    }
} 

function changeObjectVisibility(objectId, newVisibility) {
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
	styleObject.visibility = newVisibility;
	return true;
    } else {
	return false;
    }
} 

var xOffset = 30;
var yOffset = -5;

function showPopup (targetObjectId, eventObj) {
    if(eventObj) {
	hideCurrentPopup();
	eventObj.cancelBubble = true;
	if( changeObjectVisibility(targetObjectId, 'visible') ) {
	    window.currentlyVisiblePopup = targetObjectId;
	    return true;
	} else {
	    return false;
	}
    } else {
	return false;
    }
} 

function hideCurrentPopup() {
    if(window.currentlyVisiblePopup) {
	changeObjectVisibility(window.currentlyVisiblePopup, 'hidden');
	window.currentlyVisiblePopup = false;
    }
} 

document.onclick = hideCurrentPopup;

// HELP BOX
var IB=new Object;
var posX=0;posY=0;
var xOffset=50;yOffset=7;
function ShowHelpbox(texte) {
	contenu='<table border="0" cellspacing="0" cellpadding="0"><tr><td><img src="images/spacer.gif" width="21" height="1" /></td><td><img src="images/inf1.gif" width="29" height="15" /></td></tr></table><table border="0" cellspacing="0" cellpadding="0"><tr><td><img src="images/inf2.gif" width="6" height="6" /></td><td background="images/inf3.gif"><table border="0" cellspacing="0" cellpadding="0"><tr><td><img src="images/spacer.gif" width="15" height="1" /></td><td><img src="images/inf4.gif" width="29" height="6" /></td></tr></table></td><td><img src="images/inf5.gif" width="6" height="6" /></td></tr><tr><td background="images/inf6.gif">&nbsp;</td><td bgcolor="#FFFED4"><table border="0" cellspacing="0" cellpadding="3"><tr><td>'+texte+'</td></tr></table></td><td background="images/inf7.gif">&nbsp;</td></tr><tr><td><img src="images/inf8.gif" width="6" height="6" /></td><td background="images/inf9.gif"><img src="images/spacer.gif" width="5" height="5" /></td><td><img src="images/inf10.gif" width="6" height="6" /></td></tr></table>';  
  var finalPosX=posX-xOffset;
  if (finalPosX<0) finalPosX=0;
  if (document.layers) {
    document.layers["bulle"].document.write(contenu);
    document.layers["bulle"].document.close();
    document.layers["bulle"].top=posY+yOffset;
    document.layers["bulle"].left=finalPosX;
    document.layers["bulle"].visibility="show";}
  if (document.all) {
    bulle.innerHTML=contenu;
    document.all["bulle"].style.top=posY+yOffset;
    document.all["bulle"].style.left=finalPosX;
    document.all["bulle"].style.visibility="visible";
  }
  
  else if (document.getElementById) {
    document.getElementById("bulle").innerHTML=contenu;
    document.getElementById("bulle").style.top=posY+yOffset;
    document.getElementById("bulle").style.left=finalPosX;
    document.getElementById("bulle").style.visibility="visible";
  }
}
function getMousePos(e) {
  if (document.all) {
  posX=event.x+document.body.scrollLeft; 
  posY=event.y+document.body.scrollTop;
  }
  else {
  posX=e.pageX; 
  posY=e.pageY; 
  }
}
function HideHelpBox() {
	if (document.layers) {document.layers["bulle"].visibility="hide";}
	if (document.all) {document.all["bulle"].style.visibility="hidden";}
	else if (document.getElementById){document.getElementById("bulle").style.visibility="hidden";}
}

function InitHelpBox(ColTexte,ColFond,ColContour,NbPixel) {
	IB.ColTexte=ColTexte;IB.ColFond=ColFond;IB.ColContour=ColContour;IB.NbPixel=NbPixel;
	if (document.layers) {
		window.captureEvents(Event.MOUSEMOVE);window.onMouseMove=getMousePos;
		document.write("<LAYER name='bulle' top=0 left=0 visibility='hide'></LAYER>");
	}
	if (document.all) {
		document.write("<DIV id='bulle' style='position:absolute;top:0;left:0;visibility:hidden;z-index:10;'></DIV>");
		document.onmousemove=getMousePos;
	}
	
	else if (document.getElementById) {
	        document.onmousemove=getMousePos;
	        document.write("<DIV id='bulle' style='position:absolute;top:0;left:0;visibility:hidden;z-index:10;'></DIV>");
	}

}

function vypBodOdporuc() {
	document.getElementById('pdenbod').value=document.getElementById('pden').value * 2;
	if (document.getElementById('pden').value!=0) {
	odporuc.butnastav.disabled=false;
	} else {
	odporuc.butnastav.disabled=true;
	}
}

function vypBodOdporucTxt() {
	document.getElementById('pdenbod').value=document.getElementById('pden').value * 2;
	if (document.getElementById('pden').value!=0) {
	textova_reklama.butnastav.disabled=false;
	} else {
	textova_reklama.butnastav.disabled=true;
	}
}

function vypBodOdporucTxtU() {
	document.getElementById('pdenbod_upr').value=document.getElementById('pden_upr').value * 2;
}


function vypSumaBody() {
	//document.getElementById('cenask').value=(document.getElementById('pocet').value * 0.5)+',-';
	$cislo = (document.getElementById('pocet').value * 0.015);
	document.getElementById('cenaeu').value=Math.round($cislo*Math.pow(10,2))/Math.pow(10,2);
}


function insertToText(kde, symbol) {
	document.getElementById(kde).value+=symbol;
}


function pic_v(theURL,sirka,vyska) { //v2.0
//  window.open(theURL,winName,features);

    var width = sirka;
    var height = vyska;
	var winName = '';
    var left = parseInt((screen.availWidth/2) - (width/2));
    var top = parseInt((screen.availHeight/2) - (height/2));
    var features = "width=" + width + ",height=" + height + ",left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;
    window.open(theURL, winName, features);
}


