﻿function rozbalAjax(strURL, divID) {
    var xmlHttpReq = false;
   

    if (window.XMLHttpRequest) {
        xmlHttpReq = new XMLHttpRequest();

    }
   // IE
    
   else if (window.ActiveXObject) {
        xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }


    xmlHttpReq.open('POST', strURL, true);
    xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

    xmlHttpReq.onreadystatechange = function() {
        if (xmlHttpReq.readyState == 4) {
	   //alert("loading data");
            updatePopisekAjax(xmlHttpReq.responseText, divID);
        }
    }
    xmlHttpReq.send(null);
}

function updatePopisekAjax(str, divID){
    //if (document.getElementById(divID).innerHTML =="")
    //alert(divID);
    document.getElementById(divID).innerHTML = str;
    //else document.getElementById(divID).innerHTML = "";
}

function openWindow(width, height) {
	window.open("","B","toolbar=no,location=0,scrollbars=yes,width="+width+",height="+height+",resizable=1,left=150, top=100");	
}

function form_edit(startTag, endTag, form, area) {
    var myField=document.forms[form].elements[area];
    
 //IE support
 if (document.selection) {
     myField.focus();
     sel = document.selection.createRange();
     sel.text = startTag+sel.text+endTag;
     myField.focus();
 }
 //MOZILLA/NETSCAPE support
 else if (myField.selectionStart || myField.selectionStart == '0') {
     var startPos = myField.selectionStart;
     var endPos = myField.selectionEnd;
     myField.value = myField.value.substring(0, startPos)
                   + startTag
                   + myField.value.substring(startPos, endPos)
                   + endTag
                   + myField.value.substring(endPos, myField.value.length);
     myField.focus();
     myField.selectionStart = startPos + startTag.length;
     myField.selectionEnd = endPos + startTag.length;
 } else {
     myField.value += myValue;
     myField.focus();
 }
 
}


function ReadCookie(cookieName) {
 var theCookie=""+document.cookie;
 var ind=theCookie.indexOf(cookieName);
 if (ind==-1 || cookieName=="") return "";
 var ind1=theCookie.indexOf(';',ind);
 if (ind1==-1) ind1=theCookie.length; 
 return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}

function SetCookie(cookieName,cookieValue,nDays) {
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=1;
 var expireTime = 1000 * 60 * 2;
 expire.setTime(today.getTime() + expireTime);
 document.cookie = cookieName+"="+escape(cookieValue)
                 + ";expires="+expire.toGMTString();
}

