
	


// Zde se nastavuje virtualni cesta applikace, pokud je jina nez / tak se nastavi v zahlavi stranky
var ConstAppVirtualPath = '/';

if (window.addEventListener) {
   // window.addEventListener("load", createhintbox, false);
    window.addEventListener("load", initClearDefault, false);
}
else if (window.attachEvent) {
    //window.attachEvent("onload", createhintbox);
    window.attachEvent("onload", initClearDefault);
}
else if (document.getElementById) {
    //window.onload = createhintbox;
    window.onload = initClearDefault;
}




function initClearDefault() {

    var formInputs = document.getElementsByTagName('input');
    for (var i = 0; i < formInputs.length; i++) {
        var theInput = formInputs[i];

        if ((theInput.type == 'text') && theInput.className.match(/\bcleardefault\b/)) {
            /* Add event handlers */

            if (theInput.addEventListener) {
                theInput.addEventListener("focus", clearDefaultText, false)
            }
            else if (theInput.attachEvent) {
            theInput.attachEvent("onfocus", clearDefaultText)
            }
            else if (document.getElementById) {
            theInput.onfocus = clearDefaultText
            }
            if (theInput.addEventListener) {
                theInput.addEventListener("blur", replaceDefaultText, false)
            }
            else if (theInput.attachEvent) {
            theInput.attachEvent("onblur", replaceDefaultText)
            }
            else if (document.getElementById) {
            theInput.onblur = replaceDefaultText
            }            
            
            /* Save the current value */
            if (theInput.value != '') {
                theInput.defaultText = theInput.value;
            }
        }
    }
    var formInputs = document.getElementsByTagName('textarea');
    for (var i = 0; i < formInputs.length; i++) {
        var theInput = formInputs[i];

        if ( theInput.className.match(/\bcleardefault\b/)) {
            /* Add event handlers */
            if (theInput.addEventListener) {
                theInput.addEventListener("focus", clearDefaultText, false)
            }
            else if (theInput.attachEvent) {
                theInput.attachEvent("onfocus", clearDefaultText)
            }
            else if (document.getElementById) {
                theInput.onfocus = clearDefaultText
            }
            if (theInput.addEventListener) {
                theInput.addEventListener("blur", replaceDefaultText, false)
            }
            else if (theInput.attachEvent) {
                theInput.attachEvent("onblur", replaceDefaultText)
            }
            else if (document.getElementById) {
                theInput.onblur = replaceDefaultText
            } 

            /* Save the current value */
            if (theInput.value != '') {
                theInput.defaultText = theInput.value;
            }
        }
    }
    
    
    
}

function clearDefaultText(e) {
    
    var target = window.event ? window.event.srcElement : e ? e.target : null;
    if (!target) return;

    if (target.value == target.defaultText) {
        target.value = '';
    }
}

function replaceDefaultText(e) {
    var target = window.event ? window.event.srcElement : e ? e.target : null;
    if (!target) return;

    if (target.value == '' && target.defaultText) {
        target.value = target.defaultText;
    }
}



function getObject(obj) {
    var theObj;
    if (document.all) {
        if (typeof obj == 'string') {
            return document.all(obj);
        } else {
            return obj.style;
        }
    }
    if (document.getElementById) {
        if (typeof obj == 'string') {
            return document.getElementById(obj);
        } else {
            return obj.style;
        }
    }
    return null;
}



function countChars(field, cntfield) {
    cntfield.innerHTML = field.value.length;
}    



// vraci hodnotu z popup okna zpet do formulara
function backToForm(formID, elName, newId, newName){
	var opnr=window.opener;
	var desForm=opnr.document.getElementById(formID);
	opnr.document.getElementById(elName+'_fk').value=newId;
	opnr.document.getElementById(elName+'_name').innerHTML=newName;	
	window.setTimeout('window.close()',10);
}

// vraci hodnotu z popup okna zpet do formulara
function backToFormThema(formID, elName, newId, newName, themaPath){
	var bChangeParent
	var opnr=window.opener;
	var desForm=opnr.document.getElementById(formID);
	if(elName == 'tem_parent'){
		bChangeParent = (opnr.document.getElementById(elName+'_fk').value != newId);
	}
	opnr.document.getElementById(elName+'_fk').value=newId;
	opnr.document.getElementById(elName+'_name').innerHTML=newName;
	opnr.document.getElementById(elName+'_path').innerHTML=themaPath;
	if(bChangeParent){
		alert('Měníte rodičovské téma, zkontrolute \n"Kód (název URL)" zda koresponduje s \nnovým umístěním a případně jej upravte.');
	}
	var win = window.setTimeout('window.close()',10);
}

// smaza hodnoty z formulare u tematu 
function deleteThemaForm(name){
	document.getElementById(name+'_fk').value='';
	document.getElementById(name+'_name').innerHTML='';
	document.getElementById(name+'_path').innerHTML='';
}


// 22.7.2004 Lukas Nemec
function showhideElement(sShowName, sHideName) {
	if (sShowName) {
		objShow = document.getElementById(sShowName)
		objShow.style.display = 'block';
	}
	if (sHideName) {
		objHide = document.getElementById(sHideName)
		objHide.style.display = 'none';
	}
}
function showhideElementList(sValue,sValueWrong,sShowName) {
	if (sValue.toString() == sValueWrong.toString()) {
		objShow = document.getElementById(sShowName)
		objShow.style.display = 'none';
	}else{
		objShow = document.getElementById(sShowName)
		objShow.style.display = 'block';
	}
}
function validateForm(thisF) {
	var bOut = true;
	
	bOut = checkMeCZ(thisF,'a010102_lbl_cur_jmeno,jméno,a010103_lbl_cur_prijmeni,přijmení,a010311_lbl_cur_telefon,telefon,a010312_lbl_cur_mobil,mobilní telefon'); 
	if (bOut) {
		bOut2 = checkDate(thisF,'a010105_lbl_cur_narozen,narození')
	}
	if (bOut && bOut2) {
		bOut3 = checkEmail(thisF,'a010315_lbl_cur_email,e-mail')
	}
	if (bOut && bOut2 && bOut3) {
	    bOut4 = checkLength(thisF, 'a030233_lbl_cur_pozn_u_obchodniku,poznámky k pozici', 200)
    }
	return bOut && bOut2 && bOut3 && bOut4;
}
// 22.6.2003 Jan Pokorny
function check_all_checkboxes(strForm, strPrefix, bOn)
{
	var arrChk, i;
	arrChk = eval('self.document.'+strForm).elements;
	for (i = 0; i < arrChk.length; i++)
	{
		if(arrChk[i].name.substr(0, strPrefix.length) == strPrefix) arrChk[i].checked = bOn;
	}
};


function checkMe(tf, alertString, pars)
{
	pole=pars.split(',');
	for(i=0;i<pole.length;i+=2)
	{
		if(eval('typeof  tf.'+pole[i])!='undefined'){
			if(eval('tf.'+pole[i]+'.value')=='')
			{
				alert(pole[(i+1)]+' '+alertString);
				eval('tf.'+pole[i]+'.focus()');
				return false;
			}
		}
	}
	return true;
}

function alertDelivery(defaultValue, alertString) {

    if ( defaultValue!='') {

        alert(defaultValue+' '+alertString);
        return false;

    }
    return true;
}

function checkMeCZ(tf,  pars) {
    pole = pars.split(',');
    for (i = 0; i < pole.length; i += 2) {
        if (eval('typeof  tf.' + pole[i]) != 'undefined') {
            if (eval('tf.' + pole[i] + '.value') == '') {
                alert(pole[(i + 1)] + ' je povinná položka.');
                eval('tf.' + pole[i] + '.focus()');
                return false;
            }
        }
    }
    return true;
}


// 19.5.2010 Vojtech Bartos
function checkMeNoDefault(tf, alertString, pars) {
    pole = pars.split(',');
    for (i = 0; i < pole.length; i += 2) {
        if (eval('typeof  tf.' + pole[i]) != 'undefined' ) {
            if (eval('tf.' + pole[i] + '.value') == '' || eval('tf.' + pole[i] + '.value') == pole[(i + 1)]) {
                alert(pole[(i + 1)] +' '+ alertString);
                eval('tf.' + pole[i] + '.focus()');
                return false;
            }
        }
    }
    return true;
}

// 19.5.2010 Vojtech Bartos
function checkMeNoDefaultAsterisk(tf, alertString, pars) {
    pole = pars.split(',');
    var sValue,oSelect;

    for (i = 0; i < pole.length; i += 2) {
        if(eval('typeof  tf.' + pole[i]) != 'undefined') {
             if(eval('tf.' + pole[i] + '.style.display') != 'none') {
                if(eval('tf.' + pole[i] + '.type')=='select-one') {
                    oSelect = eval('tf.' + pole[i] + '.options'); 
                    if(oSelect.selectedIndex == 0) {
                        alert(pole[(i + 1)] + ' ' + alertString);
                        eval('tf.' + pole[i] + '.focus()');
                        return false;
                    }
                }
                else {
                    sValue = eval('tf.' + pole[i] + '.value');
                     if(sValue == '' || sValue == pole[(i + 1)]+'*') {
                        alert(pole[(i + 1)] + ' ' + alertString);
                        eval('tf.' + pole[i] + '.focus()');
                        return false;
                   }
                }
            }
        }
    }
    return true;
}

function checkSaleCode(sValue,sAlert) {
    var obj = document.getElementById('bas_contact_infofrom_salecode');
    if (obj.value != sValue) {
        if (obj.value.length!=5) {
            alert(sValue +  ' ' + sAlert);
            return false;
        }
    }    
    return true;
}



function checkMe2(tf,text,pars)
{
	pole=pars.split(',');
	for(i=0;i<pole.length;i+=2)
	{
		if(eval('typeof  tf.'+pole[i])!='undefined'){
			if(eval('tf.'+pole[i]+'.value')=='')
			{
				alert(pole[(i+1)]+' = '+text+'.');
				eval('tf.'+pole[i]+'.focus()');
				return false;
			}
		}
	}
	return true;
}

// 18.6.2004 Lukas Nemec
function checkEmail(tf,pars)
{
	var strEmail
	pole=pars.split(',');
	for(i=0;i<pole.length;i+=2)
	{
		strEmail = eval('tf.'+pole[i]+'.value')
		if(strEmail=='')
		{
			alert(pole[(i+1)]+' je povinná položka.');
			return (false);
		}
		
		if(strEmail.length != 0)
		{
			sta = 0
			for (i = 0; i < strEmail.length; i++)
			{                       
				if (strEmail.substring(i, i+1) == '.'  && sta == 1)
				{
					sta++;
				}
				if (strEmail.substring(i, i+1) == '@')
				{
					sta++;
				}
			}
		}
		if (sta != 2)
		{
	    	alert('Prosim zadejte správně email.');
	    	return (false);
		}
	}
	return true;
}


// 24.7.2006 Martin Mels
function checkLength(tf, pars, nLength)
{
    var sValue
	pole = pars.split(',');
	for(i = 0; i < pole.length; i += 2)
	{
		sValue = eval('tf.'+pole[i]+'.value')
		
		if(sValue.length > nLength)
		{
	    	alert(pole[(i+1)] + ' může mít maximálně ' + nLength + ' znaků.');
	    	eval('tf.'+pole[i]+'.focus()');
	    	return (false);
		}
	}
	return true;
}


function checkLengthArea(tf, msg, nLength) {
    var sValue
    sValue = eval('tf.value');
    if (sValue.length > nLength) {
        alert(msg +  nLength);
        eval('tf.focus()');
        return (false);
    }
    return true;
}


// 18.6.2004 Lukas Nemec
// Declaring valid date character, minimum year and maximum year
var dtCh= ".";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

// 18.6.2004 Lukas Nemec
function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

// 18.6.2004 Lukas Nemec
function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
// 18.6.2004 Lukas Nemec
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}
// 18.6.2004 Lukas Nemec
function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	day=parseInt(strDay)
	month=parseInt(strMonth)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("Formát datumu musí byt v teto formě : dd.mm.rrrr")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Prosím zadejte platný den")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Prosím zadejte platný měsíc")
		return false
	}
	
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Prosím zadejte správný 4 místný rok, mezi léty "+minYear+" a "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Prosím vložte správné datum (cele)")
		return false
	}
return true
}
// 18.6.2004 Lukas Nemec
function checkDate(tf,pars)
{
	pole=pars.split(',');
	for(i=0;i<pole.length;i+=2)
	{
		if (isDate(eval('tf.'+pole[i]+'.value'))==false){
			eval('tf.'+pole[i]+'.focus()');
			return false;
		}
	}
	return true;
}

function checkInteger(tf, pars) {
    pole = pars.split(',');
    for (i = 0; i < pole.length; i += 2) {
        if (isInteger(eval('tf.' + pole[i] + '.value')) == false || eval('tf.' + pole[i] + '.value') == '' || eval('tf.' + pole[i] + '.value') == '0') {
            eval('tf.' + pole[i] + '.focus()');
            return false;
        }
    }
    return true;
}

// 17.2.2003 Jan Pokorny
function OpenPicture(filename, title, width, height)
{
	wi = Math.floor(Math.random() * 1000) + 1000
	ImageWindow = window.open('', wi.toString(), 'status=no,width='+width.toString()+',height='+height.toString()+',resizable=no,menubar=no,scrollbars=no,toolbar=no')
	ImageWindow.document.write('<html><head><title>'+title+'</title></head><body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0>')
	ImageWindow.document.write('<img src="'+filename+'" width='+width.toString()+' height='+height.toString()+' alt="" /><br />')
	ImageWindow.document.write('</body></html>')
}

// 16.1.2003 Jan Pokorny
function file_show(strFile)
{
	var wndShow;
	wi = Math.floor(Math.random() * 1000) + 1000
	wndShow = window.open(strFile, wi.toString(), 'left=410,top=210,width=350,height=450,toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes');
	wndShow.focus();
}
// 27.5.2002 - Vojtech Braun
function open_file_select(strField,figID)
{
	var wndFileSel;
	wi = Math.floor(Math.random() * 1000) + 1000
	wndFileSel = window.open('../fileman/list.asp?viewSend=1&viewSendWhat=file&viewSendValue='+strField+'&fig_id='+figID, wi.toString(), 'left=100,top=100,height=500,width=900,status=yes,resizable=yes,toolbar=no,menubar=no,location=no,scrollbars=yes');
	wndFileSel.focus();
}

// 09.07.2002 - Vojtech Braun
function file_clear(strFormName, strFieldName)
{
	document.forms[strFormName].elements[strFieldName+'_id'].value = '';
	document.forms[strFormName].elements[strFieldName+'_name'].value = '';
	document.forms[strFormName].elements[strFieldName+'_file'].value = '';
}

//--------------------------------------------------------------------------------------
// 18.12.2003 - Jan Pokorny
// Smaze input v zadanem formulari a policku
//--------------------------------------------------------------------------------------
function input_clear(strFormName, strFieldName)
{
	document.forms[strFormName].elements[strFieldName].value = '';
}
//--------------------------------------------------------------------------------------
// 18.12.2003 - Jan Pokorny
// Otevre dokument v nvem okne (pouziva file_show)
//--------------------------------------------------------------------------------------
function document_show(docID,path){
	if(docID!='') file_show(path+docID);
}

//--------------------------------------------------------------------------------------
// 18.12.2003 - Jan Pokorny
// Otevre v novem okne formular pro zadani dokumentu
//--------------------------------------------------------------------------------------
function open_document_select(script,strField,docID,itmName,itmFrom,itmTo)
{
	var wndFileSel;
	wndFileSel = window.open('../document/'+script+'&doIt=insert&field='+strField+'&id='+docID+'&docName='+itmName+'&docFrom='+itmFrom+'&docTo='+itmTo, 'wndFileSel', 'left=100,top=100,height=400,width=850,status=yes,resizable=yes,toolbar=no,menubar=no,location=no,scrollbars=yes');
	wndFileSel.focus();
}

//--------------------------------------------------------------------------------------
// 6.1.2004 - Krystof Nemec
// Otevre v novem okne formular pro zadani odkazu
//--------------------------------------------------------------------------------------
function open_link_select(script, sourceThemaID, strFieldThema, strFieldItem, themaID, itmID)
{
	var wndFileSel;
	wndFileSel = window.open(script+'?doIt=insert&temID='+sourceThemaID+'&id='+themaID+'&itmID='+itmID +'&fieldthema='+strFieldThema +'&fielditem='+strFieldItem, 'wndLinkSel', 'left=100,top=100,height=400,width=700,status=yes,resizable=yes,toolbar=no,menubar=no,location=no,scrollbars=yes');
	wndFileSel.focus();
}

//--------------------------------------------------------------------------------------
// 5.1.2006 - Krystof Nemec
// obecna funkce pro otevreni dialogoveho okna
//--------------------------------------------------------------------------------------
function open_select_dialog(sScriptName, sParams)
{
	var wndFileSel;
	wndFileSel = window.open(sScriptName +'?'+ sParams, 'wndLinkSel', 'left=100,top=100,height=400,width=700,status=yes,resizable=yes,toolbar=no,menubar=no,location=no,scrollbars=yes');
	wndFileSel.focus();
}

function Validate(theForm, arr)
{
    for(var i = 0; i < theForm.length; i++)
    {
        if(arr[i])
        {
            if(!arr[i].Validate(theForm.elements[i]))
                return false
        }
    }
    return true;
}

function MeText(strName, fAllowEmpty)
{
    this.strName = strName
    this.fAllowEmpty = fAllowEmpty
    this.Validate = function(field)
    {
        if ((!this.fAllowEmpty) && (field.value == ""))
        {
            alert('Vložte prosím text do pole "' + this.strName + '".')
            field.focus()
            return false
        }
        return true
    }
}

function link(left1, main1)
{
	if (left1!='') 	parent.left.location.href = left1;
	if (main1!='') 	parent.main.location.href = main1;
}

function link1(main1, left1)
{
	if (main1!='') 	parent.main.location.href = main1;
	if (left1!='') 	parent.left.location.href = left1;
	return false;
}

function newWindow(url)
{
	window.open(url);
}
function new_window(url)
{
	newWindow(url);
}
function makeWindow(url)
{
	window.open(url, '', "toolbar=no,status=no,scrollbars=no,resizable=yes,width=700,height=400");
}

function makeWindowScrollable(url)
{
	window.open(url, '', "menubar=yes,toolbar=no,status=no,scrollbars=yes,resizable=yes,width=700,height=400");
}

function previewWindow(url, title)
{
	window.open(url, title, "toolbar=no,status=no,scrollbars=yes,resizable=yes,width=800,height=600");
}

function change_color()
{
	document.aa.style.textColor = '#00FF00';
}

function VRWindow(url, title)
{
	window.open(url, title, "toolbar=no,status=no,scrollbars=yes,resizable=yes,width=780,height=450");
}
function hop(ts,adr,what){
	if(ts.options[ts.selectedIndex].value=='0' || ts.options[ts.selectedIndex].value=='') return false;
	else document.location = adr+'?'+what+'='+ts.options[ts.selectedIndex].value;
}

//--------------------------------------------------------------------------------------
// Meni style.display u divu s divID na opacny
// 1.12.2003 Jan Pokorny
//--------------------------------------------------------------------------------------
function divSwapDisplay(divName){
	var myDiv=document.getElementById(divName);
	var myStyle=myDiv.style.display;
	if(myStyle==''){
		myDiv.style.display='none';
	}else{
		myDiv.style.display='';
	}
	return true;
}


//--------------------------------------------------------------------------------------
// Vola se na onfocus u checkboxu, zobraci confirm okno s textem a dle anvratove hodnoty
// pripadne prepne stav checkboxu
// druhym parametrem je originalni hodnota (true,false - textove)
// 1.12.2003 Jan Pokorny
//--------------------------------------------------------------------------------------
function checkboxFocusChange(tc,tcorig,textUncheck,textCheck){
	var origvalue
	origvalue=(tcorig=='true'?true:false) 
	if (tc.checked && origvalue!=tc.checked){
		if (textUncheck!='') tc.checked=!window.confirm(textUncheck)
	}else{
		if (!tc.checked && origvalue==tc.checked){
			if (textCheck!='') tc.checked=window.confirm(textCheck)
		}	
	}
}

//--------------------------------------------------------------------------------------
// 5.5.2006 DT, pouzito ve scriptu manage/thema/update.asp -> Přebírá obsah z:
// Otevira strom temat a porovnava hodnotu selectboxu "sAppField" s hodnotou nAppID,
// pokud se schoduji prida k url parametr sExParam
//--------------------------------------------------------------------------------------
function copyFromThemaByAppList(sLink, sFieldName, sAppListField){
	var nCurrApp = -1;
	var oAppList = document.all(sAppListField);
	var nIdx = oAppList.selectedIndex;
	nCurrApp = oAppList.options[nIdx].value;
	if(nCurrApp > 0){
		sLink += "&appID="+ nCurrApp		
	}
	previewWindow(sLink, sFieldName);
}


//--------------------------------------------------------------------------------------
// 19.5.2006 DT, otevre nove okno s url  sLinkPxf + hodnota listboxu sValueListName 
//--------------------------------------------------------------------------------------
function openWithListValue(sLinkPxf, sValueListName){
	var sCurrValue = "";
	var oList = document.all(sValueListName);
	var nIdx = oList.selectedIndex;
	sCurrValue = oList.options[nIdx].value;
	if(sCurrValue > 0){
		sLinkPxf += sCurrValue		
	}
	makeWindowScrollable(sLinkPxf);
}

//--------------------------------------------------------------------------------------
// 19.5.2006 DT, otevre nove okno s url  sLinkPxf + hodnota listboxu sValueListName nebo sAltLink 
//	pokud je vybrana kladna hodnota v listboxu vytori URL s retezce sLinkPxf a hodnoty,
//	 jinak URL = sAltLink
//--------------------------------------------------------------------------------------
function openWithListByValue(sLinkPxf, sAltLink, sValueListName){
	var sURL, sCurrValue = "";
	var oList = document.all(sValueListName);
	var nIdx = oList.selectedIndex;
	sCurrValue = oList.options[nIdx].value;
	if(sCurrValue > 0){
		sURL = sLinkPxf + sCurrValue;		
	}else{
		sURL = sAltLink;
	}
	makeWindowScrollable(sURL);
}


// Podpurne fce pro okno s detailem obrazku a galerie
// Otevreni okna:
//function openPictureDetail(sVirtualPath, nGaleryID, sOrder, nPicID){
//	var sUrl = sVirtualPath +'viewPicture.asp?';
//	sUrl += (nGaleryID != '' ? 'galery='+ nGaleryID +'&' : '');
//	sUrl += (sOrder != '' ? 'orderDir='+ sOrder +'&' : '');
//	sUrl += 'picture='+ nPicID;
//	window.open(sUrl, 'picture', "toolbar=no,status=no,scrollbars=no,resizable=yes,width=400,height=400");
//	return false;
//}

function ImageObj(sImgUrl){
	var oImg = new Image();
	oImg.src = sImgUrl;
	return oImg;
}

function openPictureDetail(imgObj, imgX, imgY, nGaleryID, sOrder, nPicID, bOpenerClose, bOpenerScbar, sArgs){ 	
	var maxX = screen.availWidth, maxY = screen.availHeight;
	var padX = 75, padY = 100;
	var offsetX = 0, offsetY = 25;
	var winX, winY;
	var bScroolbar = false;
	var winName  = "picture";
	
	imgX = (imgX == "" ? 0 : imgX);
	imgY = (imgY == "" ? 0 : imgY);
	
	try{
		if(imgObj != null){
			if(imgX == 0 && imgY == 0){
				imgX = imgObj.width;
				imgY = imgObj.height;
			}
		}
    }catch(e) {}
    
    if(imgX == 0 || imgY == 0){
		winX = 640 + offsetX;
		winY = 480 + offsetY;
		bScroolbar = true;

	}else{
		if((imgX + offsetX) > maxX || (imgY + offsetY) > maxY){
			winX = ((imgX + offsetX) > (maxX - (padX * 2))) ? (maxX - (padX * 2)) : imgX + offsetX ;
			winY = ((imgY + offsetY) > (maxY - (padY * 2))) ? (maxY - (padY * 2)) : imgY + offsetY ;
			bScroolbar = true;	
		}else{
			winX = imgX + offsetX;
			winY = imgY + offsetY;
			bFitSize = true;		
		}	
	}    
    //alert("maxX = "+ maxX +", maxY = "+ maxY +", winX = "+ winX +", winY = "+ winY +", winScroolbar = "+ winScroolbar +", bFitSize = "+ bFitSize);

    if(bOpenerClose && bScroolbar == bOpenerScbar){
		bOpenerClose = false;
		winName = self.window.name;
    }else if(bOpenerClose){
		winName += nPicID
		date = new Date();
		sUrl += '&t='+ date.getMilliseconds();
	}
	    
    var sUrl = ConstAppVirtualPath +'viewPicture.asp';
    sUrl += '?picture='+ nPicID;
	sUrl += (nGaleryID != '' ? '&galery='+ nGaleryID : '');
	sUrl += (sOrder != '' ? '&orderDir='+ sOrder : '');
	sUrl += (bOpenerClose ? '&openerCheck=1' : "");
	sUrl += (bScroolbar ? '&scb=1' : "");
	sUrl += '&winX='+ winX +'&winY='+ winY;	
	sUrl += (sArgs != "" ? '&'+sArgs : '');	

	var win = window.open(sUrl, winName , "toolbar=no,status=no,scrollbars="+ (bScroolbar ? "yes" : "no") +",resizable="+ (bScroolbar ? "yes" : "no") +",width="+ winX +",height="+ winY);
	if(bOpenerClose){
		win.blur();
		win.moveTo(padX, padY);
	}		
	return false;
}

//srovna vnitrni velikost na zadane hodnoty a pripadne zavre okno ktere otevrelo aktualni okno
function fitWindowSize(winX, winY, bOpenerClose, bScroolbar){
	var isIe = (!window.innerHeight);
	if(bScroolbar){
		var infoC = document.getElementById('pictureInfoC');
		var info  = document.getElementById('pictureInfo');
		var img   = document.getElementById('myImage');
		if(img){
			var widthIn = winWidth(winX) - (isIe ? 10 : 30);
			infoC.style.width =  img.width +'px';
			info.style.width = widthIn + 'px';
		}
	}else{
		if(isIe){
			self.window.resizeBy((winWidth(winX) - winX), (winHeight(winY) - winY));
		}
	}
	self.window.focus();
	if(bOpenerClose){
		window.opener.close();
	}
}


// Obecna fce na zjisteni velikosti pouzitelne plochy prohlizece
// podporuje vsehny bezne prohlizece
// zjisti vysku viditelne plochy prohlizece
function winHeight(nAltHeight) {
   if (window.innerHeight)	/* NN4 a kompatibilní prohlížeče */
      return window.innerHeight;
   else if(document.documentElement && document.documentElement.clientHeight)	/* MSIE */
      return document.documentElement.clientHeight;
   else if(document.body && document.body.clientHeight)	/* starší MSIE + MSIE6 v quirk režimu */
      return document.body.clientHeight;
   else
      return nAltHeight;
}
// zjisti sirku viditelne plochy prohlizece
function winWidth(nAltWidth) {
   if (window.innerWidth)	/* NN4 a kompatibilní prohlížeče */
      return window.innerWidth;
   else if(document.documentElement && document.documentElement.clientWidth) /* MSIE */
      return document.documentElement.clientWidth;
   else if(document.body && document.body.clientWidth) /* starší MSIE + MSIE6 v quirk režimu */
      return document.body.clientWidth;
   else
      return nAltWidth;
}


// MM 2007/03/21
function confirmBotDefender(sElementBaseName, sCode, nTimeStamp) {
    document.getElementById(sElementBaseName +'_code_hidden').value = sCode;
    document.getElementById(sElementBaseName +'_stamp_hidden').value = nTimeStamp;
}


// DT 2007/04/05 - Asynchroni desifrovani na serveru a otevreni emailu do outloku
var xmlHttp, oObject
function smOpen(srcObj, sEncEml, sEncSbj){
	if(sEncEml.length != 0 ){
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp!=null){
			var url= ConstAppVirtualPath +"getEmail.asp?e=" + sEncEml + "&s=" + sEncSbj + "&q=" + Math.random();		
			xmlHttp.onreadystatechange = openRequestedUri;
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);	
		} 
	}
}
// Zpracuje vracenou url emailu
function openRequestedUri(){ 
	if (xmlHttp.readyState==4){ 
		var txt = xmlHttp.responseText;
		if(txt.substr(0,7) == "mailto:"){
			window.open(txt);
		}
	}
}

// Vytvori XmlHttp objekt nezavisle na platforme
function GetXmlHttpObject(){
	var xmlHttp=null;
	// Firefox, Opera 8.0+, Safari
	try {			xmlHttp=new XMLHttpRequest();}
	catch(e){	// Internet Explorer
		try{		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
		catch(e){	xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
	}
	return xmlHttp;
}

// Otevre odkaz do noveho okna a na otevrenym okne spusti dialog Print
function openPrintablePage(sUrl){
	printWin = self.window.open(sUrl, '_print');
	printWin.print();
	return false;
}


var vertical_offset = "0" //horizontal offset of hint box from anchor link. No need to change.
var horizontal_offset = "0"


var ie = document.all
var ns6 = document.getElementById && !document.all

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 iecompattest() {
    return (document.compatMode && document.compatMode != "BackCompat") ? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge) {
    var edgeoffset = (whichedge == "rightedge") ? parseInt(horizontal_offset) * -1 : parseInt(vertical_offset) * -1
    if (whichedge == "rightedge") {
        var windowedge = ie && !window.opera ? iecompattest().scrollLeft + iecompattest().clientWidth - 30 : window.pageXOffset + window.innerWidth - 40
        dropmenuobj.contentmeasure = dropmenuobj.offsetWidth
        if (windowedge - dropmenuobj.x < dropmenuobj.contentmeasure)
            edgeoffset = dropmenuobj.contentmeasure + obj.offsetWidth + parseInt(horizontal_offset)
    }
    else {
        var windowedge = ie && !window.opera ? iecompattest().scrollTop + iecompattest().clientHeight - 15 : window.pageYOffset + window.innerHeight - 18
        dropmenuobj.contentmeasure = dropmenuobj.offsetHeight
        if (windowedge - dropmenuobj.y < dropmenuobj.contentmeasure)
            edgeoffset = dropmenuobj.contentmeasure - obj.offsetHeight
    }
    return edgeoffset
}

function showhint(menucontents, divId, obj, e, tipwidth) {
    if ((ie || ns6) && document.getElementById(divId)) {
        dropmenuobj = document.getElementById(divId)
        //dropmenuobj.innerHTML = menucontents
        dropmenuobj.style.left = dropmenuobj.style.top = -500
        if (tipwidth != "") {
            dropmenuobj.widthobj = dropmenuobj.style
            dropmenuobj.widthobj.width = tipwidth
        }
        dropmenuobj.x = getposOffset(obj, "left")-100
        dropmenuobj.y = getposOffset(obj, "top")
        dropmenuobj.style.left = dropmenuobj.x - clearbrowseredge(obj, "rightedge") + obj.offsetWidth + "px"
        dropmenuobj.style.top = dropmenuobj.y - clearbrowseredge(obj, "bottomedge") + "px"
        dropmenuobj.style.visibility = "visible"
        dropmenuobj.onmouseout = hidetip
        //document.onclick = hidetip
    }
}
function showhintBasket(menucontents, divId, obj, e, tipwidth) {
    if ((ie || ns6) && document.getElementById(divId)) {
        dropmenuobj = document.getElementById(divId)
        //dropmenuobj.innerHTML = menucontents
        dropmenuobj.style.left = dropmenuobj.style.top = -500
        if (tipwidth != "") {
            dropmenuobj.widthobj = dropmenuobj.style
            dropmenuobj.widthobj.width = tipwidth
        }
        dropmenuobj.x = getposOffset(obj, "left") - 200
        dropmenuobj.y = getposOffset(obj, "top")
        dropmenuobj.style.left = dropmenuobj.x - clearbrowseredge(obj, "rightedge") + obj.offsetWidth + "px"
        dropmenuobj.style.top = dropmenuobj.y - clearbrowseredge(obj, "bottomedge") + "px"
        dropmenuobj.style.visibility = "visible"
        dropmenuobj.onmouseout = hidetip
        //document.onfocusout = hidetip
        //document.onclick = hidetip
    }
}

function showhintBasketHelp(menucontents, divId, obj, e, tipwidth) {
    if ((ie || ns6) && document.getElementById(divId)) {
        dropmenuobj = document.getElementById(divId)
        //dropmenuobj.innerHTML = menucontents
        dropmenuobj.style.left = dropmenuobj.style.top = -500
        if (tipwidth != "") {
            dropmenuobj.widthobj = dropmenuobj.style
            dropmenuobj.widthobj.width = tipwidth
        }
        dropmenuobj.x = getposOffset(obj, "left") - 200
        dropmenuobj.y = getposOffset(obj, "top")
        dropmenuobj.style.left = dropmenuobj.x - clearbrowseredge(obj, "rightedge") + obj.offsetWidth + "px"
        dropmenuobj.style.top = dropmenuobj.y - clearbrowseredge(obj, "bottomedge") + "px"
        dropmenuobj.style.visibility = "visible"
        dropmenuobj.onmouseout = hidetip
        //document.onclick = hidetip
    }
}

function showhintClick(menucontents, divId, obj, e, Xoffset,Yoffset) { 
    dropmenuobj = document.getElementById(divId);
    dropmenuobj.style.left = dropmenuobj.style.top = +Yoffset

    dropmenuobj.x = getposOffset(obj, "left") + Xoffset;
    dropmenuobj.y = getposOffset(obj, "top") + Yoffset;
    dropmenuobj.style.left = dropmenuobj.x - clearbrowseredge(obj, "rightedge") + obj.offsetWidth + "px";
    dropmenuobj.style.top = dropmenuobj.y - clearbrowseredge(obj, "bottomedge") + "px";
    dropmenuobj.style.visibility = "visible";
}


function closeHintClick(id) {
    var obj = document.getElementById(id);
    obj.style.visibility = "hidden";
    obj.style.left = "-500px";
}



function hidetip(e) {

    dropmenuobj.style.visibility = "hidden"
    dropmenuobj.style.left = "-500px"
}

function createhintbox() {
    var divblock = document.createElement("div")
    divblock.setAttribute("class", "hintboxClass")
    divblock.setAttribute("id", "hintbox")
    document.body.appendChild(divblock)
}


function SubmitForm(formId) {
    objForm = document.getElementById(formId)
    objForm.submit()
}


    
function DeliverySelectServiceIdChange(DeliveryServiceSelect) {

    var obj = document.getElementById('basketRentCity');
    var clone = document.getElementById('basketRentCity_clone');
    
     // removes all options from select 2 
    //while (obj.options.length) {
    //    obj.options[0].remove();
    //}
    obj.length = 0;

    option = new Option(clone.options[0].text, clone.options[0].value);
    obj.options.add(option);
    
    for (var i = 1; i < clone.length; i++) {
    
        var group = parseInt(clone.options[i].attributes['group'].value);

        if (group == DeliveryServiceSelect.value) {

            option = new Option(clone.options[i].text, clone.options[i].value);
            obj.options.add(option);
        }                
    }
}



function ContactDeliverySelectChange(ContactDeliverySelect) {

    var obj = document.getElementById('BASKET_TXT_MAIL2_CONTACT_DELIVERY_LINET_DESC');
    if (ContactDeliverySelect.selectedIndex == 2) {
        obj.style.display = "";
    } else {
    obj.style.display = "none";

    }
    
}

function ContactInfoFromSelectChange(ContactInfoFromSelect) {

    var obj1 = document.getElementById('bas_contact_infofrom_hospital');
    var obj2 = document.getElementById('bas_contact_infofrom_salecode');
    var obj3 = document.getElementById('bas_contact_infofrom_other');

    obj1.style.display = "none";
    obj2.style.display = "none";
    obj3.style.display = "none";

    if (ContactInfoFromSelect.selectedIndex == 4) {
        obj1.style.display = "";
        obj2.style.display = "";
    }
    if (ContactInfoFromSelect.selectedIndex == 5) {
        obj3.style.display = "";
    }

}

function tablesRoundCorners(tbls, radius, radiusImgs) {
    var cells;
    var isIE = (navigator.appName.toLowerCase().indexOf('explorer') != -1);

    if (tbls[0] == null)
        return;

    for (var i = 0; i < tbls.length; i++) {
        if (tbls[i].toString().toLowerCase().indexOf('object') != -1) {
            if (isIE)
                tbls[i].style.borderCollapse = 'collapse';
            else {
                tbls[i].style.borderCollapse = 'separate';
                tbls[i].style.borderSpacing = 0;
            }

            for (var r = 0; r < tbls[i].rows.length; r++) {
                cells = tbls[i].rows[r].cells;
                for (var c = 0; c < cells.length; c++) {
                    if (isIE) {
                        if (r == 0 || r == tbls[i].rows.length - 1) {
                            if (c == 0) {
                                cells[c].style.borderLeftWidth = 0;
                                if (r == 0)
                                    cells[c].style.borderTopWidth = 0;
                                else
                                    cells[c].style.borderBottomWidth = 0;
                                
                                cells[c].style.background = 'url(' + (r == 0 ? radiusImgs[0] + ') top ' : radiusImgs[3] + ') bottom ') + ' left';
                            }
                            
                            if (c == cells.length - 1) {
                                cells[c].style.borderRightWidth = 0;
                                if (r == 0)
                                    cells[c].style.borderTopWidth = 0;
                                else
                                    cells[c].style.borderBottomWidth = 0;
                                    
                                cells[c].style.borderWidth = 0;
                                cells[c].style.background = 'url(' + (r == 0 ? radiusImgs[1] + ') top ' : radiusImgs[2] + ') bottom ') + ' right';
                            }
                        }
                    }
                    else {
                        if (c != 0)
                            cells[c].style.borderLeftWidth = 0;

                        if (r == 0) {
                            if (c == 0) {
                                cells[c].style.MozBorderRadiusTopleft = radius;
                                cells[c].style.borderTopLeftRadius = radius;
                            }

                            if (c == cells.length - 1) {
                                cells[c].style.MozBorderRadiusTopright = radius;
                                cells[c].style.borderTopRightRadius = radius;
                            }
                        }
                        else {
                            cells[c].style.borderTopWidth = 0;

                            if (r == tbls[i].rows.length - 1) {
                                if (c == 0) {
                                    cells[c].style.MozBorderRadiusBottomleft = radius;
                                    cells[c].style.borderBottomLeftRadius = radius;
                                }

                                if (c == cells.length - 1) {
                                    cells[c].style.MozBorderRadiusBottomright = radius;
                                    cells[c].style.borderBottomRightRadius = radius;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}


