//
// tlacitka - starting code
buttons = new Array()
buttons_over = new Array()

// 
// priptava tlacitek
if( !button) 
	alert('button.defined')
else
for (i=0;i<button.length;i++) 
  {
  buttons[i] = new Image()
  buttons_over[i] = new Image()
  buttons[i].src = buttons_directory + button[i] + ".gif"
  buttons_over[i].src = buttons_directory + button[i] + "_over.gif"
}

//
// MouseOver akce pro ImageButton
function ShowHint(text, image)
{
//if (showhint.arguments.length < 2) return

var i
var f=false

for (i=0;i<button.length;i++) {
  if (image.name == button[i]) {
     f=true
     break
     }
  }
if (f) {
	image.src = (text != "") ? buttons_over[i].src : buttons[i].src;
	self.status = text
	}
} // ShowHint



/***[ A_Href_StatusBar ]****************************************************/

function A_Href_StatusBar(txt)
{ 
  window.status = txt;
}

  
/***[ A_Href_Over ]*********************************************************/

function A_Href_Over(txt,iname,ipath,iext)
{
  if( iname!='') {
    document.images[iname].src = ipath+iname+'_over.'+iext;   
  }
  window.status = txt;
}

/***[ A_Href_Out ]**********************************************************/

function A_Href_Out(iname,ipath,iext) { 
  if( iname!='')
    document.images[iname].src = ipath+iname+'.'+iext;   
  window.status = ''; 
}  

/***[ Image_Over ]*********************************************************/
function Image_Over(iname,file)
{
//	alert(iname);
//	alert(file);
//nomFormulaire.elements[index].nomPropriété
//document.form.reset()valuename
alert(document.forms[0].submit.value);
//  if( iname!='')
//      document.form.button.iname.src = file;
	  
//    document.images[iname].src = file;
}

/***[ Image_Out ]*********************************************************/
function Image_Out(iname)
{
  if( iname!='')
    document.images[iname].src = iname;
}

/***[ Question ]************************************************************/
/*
function Question(text) { 
	//return window.confirm(text)
	okno=window.confirm(text);
	return okno;
} 
*/

function Question(id,text,link) {
	//alert( id)
	okno=window.confirm(text);
	if( !okno) {
		id.href="javascript:void(0);";
	}
	else id.href=link;
	return okno;
}

function Alert(text) { 
	alert(text);
//	return true;
}  

function AlertQuestion(text_alert,text_question) { 
	alert(text_alert);
//	return true;
    if(!confirm(text_question))
    {
      return false;
    }
	return true;
}  

/***[ ClearValue ]**********************************************************/

function ClearValue(id,text) {
	if (id.value==text) 
	{
		id.value='';
	}
}


/***[ BackgroundColor ]*****************************************************/

function BackgroundColor(id,color) {
	id.style.backgroundColor = color;
}


// Return a boolean value telling whether 
// the first argument is an Array object. 
function isArray() {

if (typeof arguments[0] == 'object') {
  var criterion =
    arguments[0].constructor.toString().match(/array/i);
   return (criterion != null);
  }
return false;
} 


function showInfoMessage(text) {
if( typeof(text)=="undefined")
;
else
	if( isArray(text)) {
		for(i=0;i<text.length;i++)
			alert(text[i]);
	}
	else
		alert(text);
}

/***[ RefreshValue ]********************************************************/

function RefreshValue( id, text) {
	if (id.value=='') 
	{ 
		id.value=text;
	}
}

/***[ PrintPage ]***********************************************************/
function PrintPage() {
   if(document.all || document.layers)
      { window.print(); }
   else { 
	    text = 'Pokud chcete vytisknout stránku, tak  použijte volbu svého prohlížeče:\n\nTISK (PRINT). tlačítkem \nZPĚT (BACK) se dostanete znovu do celého článku.'
   		window.alert( text); 
	}
}


/***[ ShowImage ]***********************************************************/
function ShowImage(URL, x, y) {
    var left_, top_;

    with (window.screen) {
        left_ = width_ - width_/2;
        top_ = height_ - height_/2;
    }

	myurl = "URL"+Math.floor(Math.random()*10000);
	aWindow = 
window.open(URL, myurl, "top=" + top_ +  ",left=" + left_ + ",width="+x+",height="+y+",toolbar=0,directories=0,menubar=0,status=no,resizable=0,location=no,scrollbars=0,copyhistory=0");
	aWindow.focus();
	}

/***[ OpenWindow ]**********************************************************/
function OpenWindow(URL, x, y, parameters) {
    var left_, top_;

    with (window.screen) {
        left_ = width/2 - x/2;
        top_ = height/2 - y/2;
    }

	myurl = "URL"+Math.floor(Math.random()*10000);
	aWindow = 
window.open(URL, myurl, "top=" + top_ +  ",left=" + left_ + ",width="+x+",height="+y+",toolbar=0,directories=0,menubar=0,status=no,resizable=0,location=no,scrollbars=0,copyhistory=0,"+parameters);
	aWindow.focus();
}

	
/***[ OpenWindow2 ]*********************************************************/
function OpenWindow2(URL, params, wid, hei) {
    var left_, top_, width_, height_;

	if( wid>0) 
		width_ = wid;
	else
		width_ = window.screen.width/2;
		
	if( hei>0) 
		height_ = hei;
	else
		height_ = window.screen.height/2;


    with (window.screen) {
		
        left_ = window.screen.width/2 - width_/2;
        top_ = window.screen.height/2 - height_/2;
    }
	
	if( params.length>0)
		sep = ",";
	else
		sep = "";
//		alert( params.length);

	myurl = "URL"+Math.floor(Math.random()*10000);
	aWindow = 
window.open(URL, myurl, "top=" + top_ +  ",left=" + left_ + ",width=" + width_ + ",height=" + height_ + sep + params);
	aWindow.focus();
	}
	
/***[ class Cookie ]********************************************************/
var wapi_Cookie = {
    Write:function(name,value,days) {
        var D = new Date();
        D.setTime(D.getTime()+86400000*days)
        document.cookie = escape(name)+"="+escape(value)+
            ((days == null)?"":(";expires="+D.toGMTString())) + ";path=/"
        return (this.Read(name) == value);
    },
    Read:function(name) {
        var EN=escape(name);
        var F=' '+document.cookie+';', S=F.indexOf(' '+EN);
        return S==-1 ? null : unescape(     F.substring(EN=S+EN.length+2,F.indexOf(';',EN))    );
    }
} 

/*
	\param	id_object	id objekt, ktery se ma roztahnout
	\param	used_height	už použíta velikost objektu, odecte se od citelne velikosti okna
*/
function wholePageHeight(id_object,used_height,xhtml) {
	if( xhtml==true)
		var sh = document.documentElement.clientHeight
	else
		var sh = document.body.clientHeight
	this.document.getElementById(id_object).style.height = sh - used_height-2
}

function preloadImages() { //v2.0
  if (document.images) {
    var imgFiles = preloadImages.arguments;
    if (document.preloadArray==null) document.preloadArray = new Array();
    var i = document.preloadArray.length;
    with (document) for (var j=0; j<imgFiles.length; j++) if (imgFiles[j].charAt(0)!="#"){
      preloadArray[i] = new Image;
      preloadArray[i++].src = imgFiles[j];
  } }
}


function checkBrowser(NSvers,NSpass,NSnoPass,IEvers,IEpass,IEnoPass,OBpass,URL,altURL) { //v3.0
  var newURL='', verStr=navigator.appVersion, app=navigator.appName, version = parseFloat(verStr);
  if (app.indexOf('Netscape') != -1) {
    if (version >= NSvers) {if (NSpass>0) newURL=(NSpass==1)?URL:altURL;}
    else {if (NSnoPass>0) newURL=(NSnoPass==1)?URL:altURL;}
  } else if (app.indexOf('Microsoft') != -1) {
    if (version >= IEvers || verStr.indexOf(IEvers) != -1)
     {if (IEpass>0) newURL=(IEpass==1)?URL:altURL;}
    else {if (IEnoPass>0) newURL=(IEnoPass==1)?URL:altURL;}
  } else if (OBpass>0) newURL=(OBpass==1)?URL:altURL;
  if (newURL) { window.location=unescape(newURL); document.MM_returnValue=false; }
}


//
// hideElement

function hideElement(id_object) {

	this.document.getElementById(id_object).style.display='none'; 
}


function findPosition( obj) {

    var offset = new Array();
    var offsetLeftTotal = 0;
    var offsetTopTotal = 0;
    
    //
    // find offset to screen of parent object
    //alert( 'parent: '+parent.getAttribute('id'));
//    obj = obj.parentNode;
    while( (obj != null)) {
        alert( offsetLeftTotal+" - "+obj.offsetLeft );
//        if( (obj != parent)) {
            offsetLeftTotal += obj.offsetLeft
            offsetTopTotal += obj.offsetTop
            isOk = true
//        }
        //divs += "\n"+obj.getAttribute('id');
//        alert( String(obj.nodeName) + obj.getAttribute('id') + obj.offsetLeft)
        obj = obj.parentNode;
        //alert( obj.getAttribute('id'));
    } // while

    offset['top'] = offsetTopTotal; 
    offset['left'] = offsetLeftTotal;
    alert( "offset ".offsetLeftTotal);
    return offset;
} // findPostionTop


function getposOffset(what, offsettype)
{
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null)
{
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function fncElmPos(strCurr)
  {
    var elmCurr = document.getElementById(strCurr);
    var pos = new Array();
    var intX = 0;
    var intY = 0;
    do 
      {
        intX += elmCurr.offsetLeft;
        intY += elmCurr.offsetTop;
      }
    while ((elmCurr = elmCurr.offsetParent));
    pos['left'] = intX;
    pos['top'] = intY;
    return pos;
//    alert('objekt: ' + strCurr + '\nsouradnice X: ' + intX + '\nsouradnice Y: ' + intY);
}