function confirmAction(msg,action,paramm,value,paramm2,value2)
{
	if (confirm(msg)) {
        document.forms['form'].action = document.forms['form'].action + (document.forms['form'].action.indexOf("?") == -1? "?": "&amp;") + "do[" + action + "]=1";
		if (paramm) document.forms['form'][''+paramm].value=value;
		if (paramm2) document.forms['form'][''+paramm2].value=value2;
		document.forms['form'].submit();
		return true;
	}
	else {
        return false;
	}
}

function _performAction(form, action, paramm, value, paramm2, value2, paramm3, value3, paramm4, value4, paramm5, value5)
{
    form.action = form.action + (form.action.indexOf("?") == -1? "?": "&amp;") + "do[" + action + "]=1";
	if (paramm) form[''+paramm].value=value;
	if (paramm2) form[''+paramm2].value=value2;
	if (paramm3) form[''+paramm3].value=value3;
	if (paramm4) form[''+paramm4].value=value4;
	if (paramm5) form[''+paramm5].value=value5;
	form.submit();
	return true;
}
function performAction(action, paramm, value, paramm2, value2, paramm3, value3, paramm4, value4, paramm5, value5)
{
    _performAction(document.forms['form'], action, paramm, value, paramm2, value2, paramm3, value3, paramm4, value4, paramm5, value5);
}
function performFilterAction(action,paramm,value,paramm2,value2,paramm3,value3, paramm4, value4, paramm5, value5)
{
    _performAction(document.forms['filterForm'], action, paramm, value, paramm2, value2, paramm3, value3, paramm4, value4, paramm5, value5);
}
function performSendEmailAction(action,paramm,value,paramm2,value2,paramm3,value3, paramm4, value4, paramm5, value5)
{
    _performAction(document.forms['sendEmailForm'], action, paramm, value, paramm2, value2, paramm3, value3, paramm4, value4, paramm5, value5);
}

function undoTypeChange(obj)
{
    for (var i = 0; i < obj.options.length; i++)
    {
        obj.options[i].selected = obj.options[i].value == originalType;
    }
}

function showEditor(name, lang) {
	lang = 'en';
    tinyMCE.init({
		mode : "exact",
		elements : name,
		language: lang,
		theme : "advanced",
		plugins : "table,preview,paste",
		theme_advanced_buttons1 : "bold,italic,underline,strikethrough,separator,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,undo,redo,separator,link,unlink,image,separator,charmap,separator,preview,code,cleanup",
		theme_advanced_buttons2 : "tablecontrols,separator,pastetext,pasteword,selectall",
		theme_advanced_buttons3 : "fontselect,fontsizeselect,forecolor,backcolor",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_path_location : "bottom",
		paste_create_paragraphs : false,
		paste_create_linebreaks : false,
		paste_use_dialog : true,
		paste_auto_cleanup_on_paste : true,
		paste_convert_middot_lists : false,
		paste_unindented_list_class : "unindentedList",
		paste_convert_headers_to_strong : true,
	//	paste_insert_word_content_callback : "convertWord"
		entity_encoding : "raw",
		cleanup : true,
		convert_fonts_to_spans : true,
		font_size_style_values : "8pt, 9pt, 10pt, 12pt, 14pt, 18pt, 20pt",
		relative_urls : false,
		remove_linebreaks : false,
		content_css : "../custom/css/tinymce.css",
		cleanup_debug : true,
		valid_elements : "*[*],object[classid|codebase|width|height|id|class],param[name|value],embed[src|quality|bgcolor|width|height|name|type|pluginspage]"	    		
    });
}

// je prohlizec podporovan?	
function checkBrowser() {    
	isn = new IsNavigator();
	if(isn.ie4up || isn.nav4up || isn.opera || isn.gecko)
		return true;
   
	// neznamy prohlizec
	return false;
}

// verze prohlizece
function IsNavigator ()
{   var agt=navigator.userAgent.toLowerCase();

    this.major = parseInt(navigator.appVersion);
    this.minor = parseFloat(navigator.appVersion);

    this.nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
    this.nav2 = (this.nav && (this.major == 2));
    this.nav3 = (this.nav && (this.major == 3));
    this.nav4 = (this.nav && (this.major == 4));
    this.nav4up = (this.nav && (this.major >= 4));
    this.navonly = (this.nav && ((agt.indexOf(";nav") != -1) ||
                          (agt.indexOf("; nav") != -1)) );
    this.nav6 = (this.nav && (this.major == 5));
    this.nav6up = (this.nav && (this.major >= 5));
    this.gecko = (agt.indexOf('gecko') != -1);

    this.ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    this.ie3    = (this.ie && (this.major < 4));
    this.ie4    = (this.ie && (this.major == 4) && (agt.indexOf("msie 4")!=-1) );
    this.ie4up  = (this.ie && (this.major >= 4));
    this.ie5    = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.0")!=-1) );
    this.ie5_5  = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.5") !=-1));
    this.ie5up  = (this.ie && !this.ie3 && !this.ie4);
    this.ie5_5up =(this.ie && !this.ie3 && !this.ie4 && !this.ie5);
    this.ie6    = (this.ie && (this.major == 4) && (agt.indexOf("msie 6.")!=-1) );
    this.ie6up  = (this.ie && !this.ie3 && !this.ie4 && !this.ie5 && !this.ie5_5);
    this.ie7    = (this.ie && (this.major == 4) && (agt.indexOf("msie 7.")!=-1) );
    this.ie7up  = (this.ie && !this.ie3 && !this.ie4 && !this.ie5 && !this.ie5_5 && !this.ie6);

    this.opera = (agt.indexOf("opera") != -1);
    this.opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1);
    this.opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1);
    this.opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);
    this.opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
    this.opera5up = (this.opera && !this.opera2 && !this.opera3 && !this.opera4);
}

// zobrazeni obrazku ve zvlastnim okne (popup) - pokud nejsou zadany rozmery, berou se automaticky podle obrazku
function view( image, width, height, descr) {
    if ( checkBrowser()) {
        var autResize = false;
    	if (width == null || height == null) {
    	  autResize = true;
    	  width = 600;
    	  height = 400;
    	}
    	if(autResize) {
    	  isn = new IsNavigator();
    	  if(isn.ie) {
    	    if(isn.ie7up) {
    	      diffWidth = 30; 
			  diffHeight = 75;
		    }
		    else {
		      diffWidth = 30; 
			  diffHeight = 50;
		    }
		  }
		  else {
		    diffWidth = 14; 
		    diffHeight = 56;
		  }
		}
		if(descr) {
		  addW = 0;
		  addH = 40;
		  diffWidth += addW;
		  diffHeight += addH;
		  width += addW;
		  height += addH;
		}
        var imgWindow = window.open( "", "view", "menubar=no,scrollbars=yes,resizable=yes,width=" + width + ",height=" + height + ",top=150,left=150");
        var imgDoc = imgWindow.document;
        imgDoc.clear();
        imgDoc.open();
        imgDoc.writeln("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">");
        imgDoc.writeln("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"cs\">");
        imgDoc.writeln("<head>");
        imgDoc.writeln("<title>", document.title, "<\/title>");
        if (autResize) {          
          imgDoc.writeln("<script type=\"text/javascript\">\nfunction resize() {\n  diffWidth = ", diffWidth,"; diffHeight = ", diffHeight,";\n  window.resizeTo(window.document.images[0].width + diffWidth, window.document.images[0].height + diffHeight);\n}\n<\/script>");
        }
        imgDoc.writeln("<\/head>");
        imgDoc.writeln("<body style=\"margin: 0; padding: 0;\"" + (autResize? " onload=\"resize()\"" : "") + ">");
        imgDoc.writeln("<center><a href=\"javascript:window.close()\">");
        imgDoc.writeln("<img src=\"",image,"\" border=\"0\" alt=\"\" />");
        imgDoc.writeln("<\/a>");
        if(descr) {
        	imgDoc.writeln("<br /><span style=\"font-family: Arial, Sans Serif; font-size: 12px;\">",decodeURI(descr),"</span>");
        }
        imgDoc.writeln("<\/center><\/body>");
        imgDoc.writeln("<\/html>");
        imgDoc.close();
    }

}

// nastavi fokus na prvni prvek v danem formu
function focusFirst(form) {
    var obj = document.getElementById('initialfocus');
    if(obj) {
        obj.focus();
    }
    else {
     i=0;
     if (form) {
       while (form[i]) {
         if (form[i].type=="text" || form[i].type=="checkbox" || form[i].type=="radiobutton") {
           form[i].focus();
           break;
         }
         i++;
       }
     }
    }
}

// prida volani funkce do window.onload
function addOnLoadEvent(func) {    
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } 
    else {
        window.onload = function() {
            oldonload();
            func();
        }
    }
}

function importImages(appletId) {
  isn = new IsNavigator();
  if(!isn.ie) appletId += '_EM';
  var elm = document.getElementById(appletId);  
  if(elm) {
	  var out = elm.importPhotogallery();	    
	  if (out != null && (isn.ie && out.length > 0 || out.length() > 0)) {
	    alert(out);
	  }
	  performAction('reloadData');
  }
}

function getMousePos(e) {
  if(document.all) {
	xmp = window.event.clientX+document.documentElement.scrollLeft;
	ymp = window.event.clientY+document.documentElement.scrollTop;        
  }
  else {    
	xmp = e.pageX;
	ymp = e.pageY;
  }
  
  return new Array(xmp, ymp);
}

function hideElement( elmID, overDiv )
{    
  elArr = document.getElementsByTagName( elmID );
  for( i = 0; i < elArr.length; i++ ) {
    obj = elArr[i];
    if( !obj || !obj.offsetParent ) {
      continue;
    }
        
    objLeft   = obj.offsetLeft;
    objTop    = obj.offsetTop;
    objParent = obj.offsetParent;

    while( objParent && objParent.tagName.toUpperCase() != "BODY" ) {
      objLeft  += objParent.offsetLeft;
      objTop   += objParent.offsetTop;
      objParent = objParent.offsetParent;
    }

    objHeight = obj.offsetHeight;
    objWidth = obj.offsetWidth;

    if(( overDiv.offsetLeft + overDiv.offsetWidth ) <= objLeft );
    else if(( overDiv.offsetTop + overDiv.offsetHeight ) <= objTop );
    else if( overDiv.offsetTop >= ( objTop + objHeight ));
    else if( overDiv.offsetLeft >= ( objLeft + objWidth ));
    else {
      obj.style.visibility = "hidden";
    }
  }     
}

function showElement( elmID )
{
  elArr = document.getElementsByTagName( elmID );
  for( i = 0; i < elArr.length; i++ ) {
    obj = elArr[i];
    if( !obj || !obj.offsetParent ) {
      continue;
    }
    obj.style.visibility = "";
  }     
}

function updateAjaxCalls()
{
  if(typeof initializeAjaxElements == 'function') {
  	initializeAjaxElements();
  }
}

// nastavi hodnotu title elementu me do podrizenych elementu IMG
// explorer nezobrazuje title rodicovskych elementu, pokud potomek ma alt="" 
function showImgTitle(me) { 
    if(!me) return;
    var thisChild = me.getElementsByTagName('IMG')[0];
    if(thisChild) {
		thisChild.title = me.title;
    } 
}
 
function writeCalAndMailDiv() {
 	document.write('<div id="cDiv" style="position:absolute; z-index: 1000; top: 0; left: 0;"></div>');
 	document.write('<div id="mDiv" style="position:absolute; z-index: 1000; top: 0; left: 0;"></div>');
}
 
writeCalAndMailDiv();
