﻿// JScript File

var toolmenu_id;
var toolmenu_panel;

function toolmenu(id,panel){
    if(getID(toolmenu_id)){getID(toolmenu_id).className = "normal"}
    if(getID(toolmenu_panel)){getID(toolmenu_panel).className = "toolpanelfalse"}
    if(getID(id)){getID(id).className = "down"}
    if(getID(panel)){getID(panel).className = "toolpaneltrue"}
    toolmenu_panel = panel;
    toolmenu_id = id;
}

function logoff()
{
    window.location.href = "/Site/logoff.aspx";
}

function Printer(){
    if(getID("tool")){
        getID("tool").style.visibility="hidden";
        tooltimer = setTimeout("ToolShow()", 2500);
    }
    WindowOpen("/sitepages/printer.aspx",800,550,"scrollbars=yes,toolbar=no,resizable=yes,status=no,location=no");
}

function WindowOpen(URL, dialogWidth, dialogHeight, CommandPlus){
  if (CommandPlus == ''){CommandPlus='scrollbars=no,toolbar=no,resizable=no,status=no,location=no'}
	var iTop  = (screen.height - dialogHeight) / 2 ;
	var iLeft = (screen.width  - dialogWidth)  / 2 ;
  return window.open(URL, '', 'width='+dialogWidth+',height='+dialogHeight+',left='+iLeft+',top='+iTop+','+CommandPlus);
  if (WindowOpen.focus) {WindowOpen.focus()}}

function send_id(id,url,target,param,paramvalue){
      var forma = document.createElement("FORM");
      forma.method = "POST";
      forma.action = url;
      //forma.target = target;      
      document.body.appendChild(forma);
      var input = document.createElement("INPUT");
      input.type = "hidden";
      input.name = "page_id";
      input.value = id;
      forma.appendChild(input);      
      
      if(param){
        var input = document.createElement("INPUT");
        input.type = "hidden";
        input.value = paramvalue;
        input.name = param;
        forma.appendChild(input);
      }

      forma.submit();
      document.body.removeChild(forma);
      forma = null;
      input = null;
}

function send(url,target,posttrue,params,values){
      var forma = document.createElement("FORM");
      forma.method = posttrue ? "POST" : "GET";
      forma.action = url;
      //forma.target = "_self";
      document.body.appendChild(forma);

      for(var i = 0; i < params.length; i++)
      {
            if(params[i] == "")
                continue;
            if(values[i] == "")
                continue;
            var input = document.createElement("INPUT");
            input.type = "hidden";
            input.name = params[i];
            input.value = values[i];
            forma.appendChild(input);      
      }

      forma.submit();
      document.body.removeChild(forma);
      forma = null;
      input = null;
}

function trhighlight(obj,highlight,color){
    if(!obj){return}
    if(color){
        if(highlight){obj.style.background = color} else {obj.style.background = color}
    } else {
        if(highlight){obj.style.background = "#CCFF00"} else {obj.style.background = "white"}
    }
}

function getID(id){
    return document.getElementById(id);
}

function onMeradlo(IDobjTextBox, IDobjMeradlo, MaxLength){
    var o1 = getID(IDobjTextBox);
    var o2 = getID(IDobjMeradlo);
    if((!o1) || (!o2)){
        return false;
    }
    var size = (parseInt(o1.value.length) * 100) / MaxLength;
    if(size==0){size=1}
    o2.style.width = size.toString() + "%";
    o2.style.height = "6px";
}

    function input_check(id,typ){
       var obj = id.split(",");
       input_id = id;
       input_typ = typ;
       for(var i=0; i<obj.length; i++){
            if(obj[i]==""){continue}
            if(!getID(obj[i])){continue}
            getID(obj[i]).onblur = input_onchange;
            getID(obj[i]).onblur(getID(obj[i]));
       }
    }
    
    function input_error(id,error){
       var obj = document.getElementById(id);
       if(!obj){return}    
       if(!error){
         obj.className = "labelnormal";
       } else {
         obj.className = "labelerror";       
       }    
       return !error;
    }
    
    function input_onchange(){
       var typ = input_typ.split(",");
       var obj = input_id.split(",");
       var index = -1;
       for(var i=0; i<obj.length; i++){
         if(obj[i]==this.id){
            index = i;
            break;
         }
       }
       if(index==-1){return}
       var form = getID(obj[index]);
       var output = getID(obj[index].replace("ctl00_pageBody_z", "c"));
       var error = false;       
       switch(typ[index]){
        case "text":
            if(form.value==""){error=true} else {error=false}
            break;
        case "email":
            if(!check_email(form.value)){error=true} else {error=false}
            break;
        case "url":
            if(!check_url(form.value)){error=true} else {error=false}
            break;            
        case "number":
            if(!check_integer(form.value)){error=true} else {error=false}
            break;
            
        default:
            eval(typ[index]);
       }
       if(!error){
         output.className = "labelnormal";
       } else {
         output.className = "labelerror";       
       }
    }


function check_integer(n){return RegExp ( "^[-+]?[0-9]+$" ).test(n)}
function check_string(s){return RegExp ( "^[a-zA-Z]+$" ).test(s)}
function check_alfanum_string(s){return RegExp ( "^[a-zA-Z0-9]+$" ).test(s)}
function check_date(s){return RegExp ( "[0-9]{2,2}.[0-9]{2,2}.[0-9]{4,4}$" ).test(s)}
function check_time(s){return RegExp ( "^[012][0-9]:[0-5][0-9]$" ).test(s)}
function check_email(s){return RegExp ( "^[a-zA-Z0-9-_.]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}$" ).test(s)}
function check_url(s){var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/; return regexp.test(s)}
function check_sqldate(s){reg_date = /^\d{4}-\d{2}-\d{2}$/; return reg_date.test(s)}
function check_hex(n) {return (n<16 ? '0' : '' ) + n.toString(16)}

function check_skdate(s){
  re = /^\d{2}[\.]\d{2}[\.]\d{4}$/;
  if (!re.test(s)) return false;
  var dp = s.split(/[\.]/);
  var day   = parseInt(dp[0],10);
  var month = parseInt(dp[1],10);
  var year  = parseInt(dp[2],10);
  if (!((month >= 1) && (month <= 12))) return false;
  var limit = [ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
  if (day > limit[month-1]) return false;
  if ((month == 2) && (day == 29)){
    if ((year % 4) != 0) return false;
    if (((year % 100) == 0) && ((year % 400) != 0)) return false}
  return true}

function check_sktime(s){
  re = /^\d{2}[:]\d{2}$/;
  if (!re.test(s)) return false;
  var dp = s.split(/[:]/);
  var hour   = parseInt(dp[0],10);
  var minute = parseInt(dp[1],10);
  if (!((hour > 2) && (hour < 18))) return false;
  if (!(minute <= 59)) return false;
  return true}

function check_float(n){
	if (n.length == 0) return false;
	var first_char = n.charAt(0);
	if (first_char != '-' && first_char != '.' && (first_char < '0' || first_char > '9')) return false;
	var dot = false;
	var digit_expected = false;
	if (first_char == '.') {
		dot = true;
		digit_expected = true;
	} else if (first_char == '-')
		digit_expected = true;
	if (digit_expected && n.length < 2) return false;
	for (var count = 1; count < n.length; count++) {
		var c = n.charAt(count);
		if (c == '.') {
			if (dot) return false;
			dot = true;
		} else if (c < '0' || c > '9')
			return false}
	return true}

function IsNumeric(strString){
var strValidChars = "0123456789.-+()*/ ";
var strChar;
var blnResult = true;
  if (strString.length == 0) return false;
  for (i=0; i<strString.length && blnResult==true; i++){
    strChar = strString.charAt(i);
    if (strValidChars.indexOf(strChar) == -1){blnResult = false}}
  return blnResult}


DHTML_modalMessage = function()
{
	var url;								// url of modal message
	var htmlOfModalMessage;					// html of modal message
	
	var divs_transparentDiv;				// Transparent div covering page content
	var divs_content;						// Modal message div.
	var iframe;								// Iframe used in ie
	var layoutCss;							// Name of css file;
	var width;								// Width of message box
	var height;								// Height of message box
	
	var existingBodyOverFlowStyle;			// Existing body overflow css
	var dynContentObj;						// Reference to dynamic content object
	var cssClassOfMessageBox;				// Alternative css class of message box - in case you want a different appearance on one of them
	var shadowDivVisible;					// Shadow div visible ? 
	var shadowOffset; 						// X and Y offset of shadow(pixels from content box)
	var MSIE;
		
	this.url = '';							// Default url is blank
	this.htmlOfModalMessage = '';			// Default message is blank
	this.layoutCss = 'modal-message.css';	// Default CSS file
	this.height = 200;						// Default height of modal message
	this.width = 400;						// Default width of modal message
	this.cssClassOfMessageBox = false;		// Default alternative css class for the message box
	this.shadowDivVisible = true;			// Shadow div is visible by default
	this.shadowOffset = 5;					// Default shadow offset.
	this.MSIE = false;
	if(navigator.userAgent.indexOf('MSIE')>=0) this.MSIE = true;
	

}

DHTML_modalMessage.prototype = {
	// {{{ setSource(urlOfSource)
    /**
     *	Set source of the modal dialog box
     * 	
     *
     * @public	
     */		
	setSource : function(urlOfSource)
	{
		this.url = urlOfSource;
		
	}	
	// }}}	
	,
	// {{{ setHtmlContent(newHtmlContent)
    /**
     *	Setting static HTML content for the modal dialog box.
     * 	
     *	@param String newHtmlContent = Static HTML content of box
     *
     * @public	
     */		
	setHtmlContent : function(newHtmlContent)
	{
		this.htmlOfModalMessage = newHtmlContent;
		
	}
	// }}}		
	,
	// {{{ setSize(width,height)
    /**
     *	Set the size of the modal dialog box
     * 	
     *	@param int width = width of box
     *	@param int height = height of box
     *
     * @public	
     */		
	setSize : function(width,height)
	{
		if(width)this.width = width;
		if(height)this.height = height;		
	}
	// }}}		
	,		
	// {{{ setCssClassMessageBox(newCssClass)
    /**
     *	Assign the message box to a new css class.(in case you wants a different appearance on one of them)
     * 	
     *	@param String newCssClass = Name of new css class (Pass false if you want to change back to default)
     *
     * @public	
     */		
	setCssClassMessageBox : function(newCssClass)
	{
		this.cssClassOfMessageBox = newCssClass;
		if(this.divs_content){
			if(this.cssClassOfMessageBox)
				this.divs_content.className=this.cssClassOfMessageBox;
			else
				this.divs_content.className='modalDialog_contentDiv';	
		}
					
	}
	// }}}		
	,	
	// {{{ setShadowOffset(newShadowOffset)
    /**
     *	Specify the size of shadow
     * 	
     *	@param Int newShadowOffset = Offset of shadow div(in pixels from message box - x and y)
     *
     * @public	
     */		
	setShadowOffset : function(newShadowOffset)
	{
		this.shadowOffset = newShadowOffset
					
	}
	// }}}		
	,	
	// {{{ display()
    /**
     *	Display the modal dialog box
     * 	
     *
     * @public	
     */		
	display : function()
	{
		if(!this.divs_transparentDiv){
			this.__createDivs();
		}	
		
		// Redisplaying divs
		this.divs_transparentDiv.style.display='block';
		this.divs_content.style.display='block';
		this.divs_shadow.style.display='block';		
		if(this.MSIE)this.iframe.style.display='block';	
		this.__resizeDivs();
		
		/* Call the __resizeDivs method twice in case the css file has changed. The first execution of this method may not catch these changes */
		window.refToThisModalBoxObj = this;		
		setTimeout('window.refToThisModalBoxObj.__resizeDivs()',150);
		
		this.__insertContent();	// Calling method which inserts content into the message div.
	}
	// }}}		
	,
	// {{{ ()
    /**
     *	Display the modal dialog box
     * 	
     *
     * @public	
     */		
	setShadowDivVisible : function(visible)
	{
		this.shadowDivVisible = visible;
	}
	// }}}	
	,
	// {{{ close()
    /**
     *	Close the modal dialog box
     * 	
     *
     * @public	
     */		
	close : function()
	{
		//document.documentElement.style.overflow = '';	// Setting the CSS overflow attribute of the <html> tag back to default.
		
		/* Hiding divs */
		this.divs_transparentDiv.style.display='none';
		this.divs_content.style.display='none';
		this.divs_shadow.style.display='none';
		if(this.MSIE)this.iframe.style.display='none';
		
	}	
	// }}}	
	,
	// {{{ __addEvent()
    /**
     *	Add event
     * 	
     *
     * @private	
     */		
	addEvent : function(whichObject,eventType,functionName,suffix)
	{ 
	  if(!suffix)suffix = '';
	  if(whichObject.attachEvent){ 
	    whichObject['e'+eventType+functionName+suffix] = functionName; 
	    whichObject[eventType+functionName+suffix] = function(){whichObject['e'+eventType+functionName+suffix]( window.event );} 
	    whichObject.attachEvent( 'on'+eventType, whichObject[eventType+functionName+suffix] ); 
	  } else 
	    whichObject.addEventListener(eventType,functionName,false); 	    
	} 
	// }}}	
	,
	// {{{ __createDivs()
    /**
     *	Create the divs for the modal dialog box
     * 	
     *
     * @private	
     */		
	__createDivs : function()
	{
		// Creating transparent div
		this.divs_transparentDiv = document.createElement('DIV');
		this.divs_transparentDiv.className='modalDialog_transparentDivs';
		this.divs_transparentDiv.style.left = '0px';
		this.divs_transparentDiv.style.top = '0px';
		
		document.body.appendChild(this.divs_transparentDiv);
		// Creating content div
		this.divs_content = document.createElement('DIV');
		this.divs_content.className = 'modalDialog_contentDiv';
		this.divs_content.id = 'DHTMLSuite_modalBox_contentDiv';
		this.divs_content.style.zIndex = 900;
		
		if(this.MSIE){
			this.iframe = document.createElement('<IFRAME src="about:blank" frameborder=0>');
			this.iframe.style.zIndex = 800;
			this.iframe.style.position = 'absolute';
			document.body.appendChild(this.iframe);	
		}
			
		document.body.appendChild(this.divs_content);
		// Creating shadow div
		this.divs_shadow = document.createElement('DIV');
		this.divs_shadow.className = 'modalDialog_contentDiv_shadow';
		this.divs_shadow.style.zIndex = 850;
		document.body.appendChild(this.divs_shadow);
		window.refToModMessage = this;
		this.addEvent(window,'scroll',function(e){ window.refToModMessage.__repositionTransparentDiv() });
		this.addEvent(window,'resize',function(e){ window.refToModMessage.__repositionTransparentDiv() });
		

	}
	// }}}
	,
	// {{{ __getBrowserSize()
    /**
     *	Get browser size
     * 	
     *
     * @private	
     */		
	__getBrowserSize : function()
	{
    	var bodyWidth = document.documentElement.clientWidth;
    	var bodyHeight = document.documentElement.clientHeight;
    	
		var bodyWidth, bodyHeight; 
		if (self.innerHeight){ // all except Explorer 
		 
		   bodyWidth = self.innerWidth; 
		   bodyHeight = self.innerHeight; 
		}  else if (document.documentElement && document.documentElement.clientHeight) {
		   // Explorer 6 Strict Mode 		 
		   bodyWidth = document.documentElement.clientWidth; 
		   bodyHeight = document.documentElement.clientHeight; 
		} else if (document.body) {// other Explorers 		 
		   bodyWidth = document.body.clientWidth; 
		   bodyHeight = document.body.clientHeight; 
		} 
		return [bodyWidth,bodyHeight];		
		
	}
	// }}}	
	,
	// {{{ __resizeDivs()
    /**
     *	Resize the message divs
     * 	
     *
     * @private	
     */	
    __resizeDivs : function()
    {
    	
    	var topOffset = Math.max(document.body.scrollTop,document.documentElement.scrollTop);

		if(this.cssClassOfMessageBox)
			this.divs_content.className=this.cssClassOfMessageBox;
		else
			this.divs_content.className='modalDialog_contentDiv';	
			    	
    	if(!this.divs_transparentDiv)return;
    	
    	// Preserve scroll position
    	var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
    	var sl = Math.max(document.body.scrollLeft,document.documentElement.scrollLeft);
    	
    	window.scrollTo(sl,st);
    	setTimeout('window.scrollTo(' + sl + ',' + st + ');',10);

    	this.__repositionTransparentDiv();
    	

		var brSize = this.__getBrowserSize();
		var bodyWidth = brSize[0];
		var bodyHeight = brSize[1];
    	
    	// Setting width and height of content div
      	this.divs_content.style.width = this.width + 'px';
    	this.divs_content.style.height= this.height + 'px';  	
    	
    	// Creating temporary width variables since the actual width of the content div could be larger than this.width and this.height(i.e. padding and border)
    	var tmpWidth = this.divs_content.offsetWidth;	
    	var tmpHeight = this.divs_content.offsetHeight;
    	
    	
    	// Setting width and height of left transparent div
    	
    	

    	
    	
		
    	this.divs_content.style.left = Math.ceil((bodyWidth - tmpWidth) / 2) + 'px';;
    	this.divs_content.style.top = (Math.ceil((bodyHeight - tmpHeight) / 2) +  topOffset) + 'px';
    	
 		if(this.MSIE){
 			this.iframe.style.left = this.divs_content.style.left;
 			this.iframe.style.top = this.divs_content.style.top;
 			this.iframe.style.width = this.divs_content.style.width;
 			this.iframe.style.height = this.divs_content.style.height;
 		}
 		
    	this.divs_shadow.style.left = (this.divs_content.style.left.replace('px','')/1 + this.shadowOffset) + 'px';
    	this.divs_shadow.style.top = (this.divs_content.style.top.replace('px','')/1 + this.shadowOffset) + 'px';
    	this.divs_shadow.style.height = tmpHeight + 'px';
    	this.divs_shadow.style.width = tmpWidth + 'px';
    	
    	
    	
    	if(!this.shadowDivVisible)this.divs_shadow.style.display='none';	// Hiding shadow if it has been disabled
    	
    	
    }
    // }}}	
    ,
	// {{{ __insertContent()
    /**
     *	Insert content into the content div
     * 	
     *
     * @private	
     */	    
    __repositionTransparentDiv : function()
    {
    	this.divs_transparentDiv.style.top = Math.max(document.body.scrollTop,document.documentElement.scrollTop) + 'px';
    	this.divs_transparentDiv.style.left = Math.max(document.body.scrollLeft,document.documentElement.scrollLeft) + 'px';
		var brSize = this.__getBrowserSize();
		var bodyWidth = brSize[0];
		var bodyHeight = brSize[1];
    	this.divs_transparentDiv.style.width = bodyWidth + 'px';
    	this.divs_transparentDiv.style.height = bodyHeight + 'px';		
		   	
    }
	// }}}	
	,
	// {{{ __insertContent()
    /**
     *	Insert content into the content div
     * 	
     *
     * @private	
     */	
    __insertContent : function()
    {
		if(this.url){	// url specified - load content dynamically
			ajax_loadContent('DHTMLSuite_modalBox_contentDiv',this.url);
		}else{	// no url set, put static content inside the message box
			this.divs_content.innerHTML = this.htmlOfModalMessage;	
		}
    }		
}

function DropDownListEnabled(truefalse){
    
    var obj = document.getElementsByTagName("select-one");
    if(obj.length==0){
        obj = document.getElementsByTagName("select");
    }
    for(var i = 0; i<obj.length; i++){
        obj[i].disabled = !truefalse;
    }

}

        function displayStaticMessage(messageContent,width,height)
        { 
	        messageObj.setHtmlContent(messageContent);
	        messageObj.setSize(width,height);
	        messageObj.setCssClassMessageBox(false);
	        messageObj.setSource(false);	// no html source since we want to use a static message here.
	        messageObj.setShadowDivVisible(true);	// Disable shadow for these boxes	
	        messageObj.display();
            DropDownListEnabled(false);
	    }

        function closeMessage()
        {
            DropDownListEnabled(true);
	        messageObj.close();	
        }


var offsetfromcursorX=12 //Customize x offset of tooltip
var offsetfromcursorY=10 //Customize y offset of tooltip

var offsetdivfrompointerX=10 //Customize x offset of tooltip DIV relative to pointer image
var offsetdivfrompointerY=14 //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).

document.write('<div id="dhtmltooltip" style="z-index:1000"></div>') //write out tooltip DIV
document.write('<img id="dhtmlpointer" style="z-index:1000" src="/sitedata/img/arrow.gif">') //write out pointer image

var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

var pointerobj=document.all? document.all["dhtmlpointer"] : document.getElementById? document.getElementById("dhtmlpointer") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thewidth, thecolor){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip){
var nondefaultpos=false
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20

var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX
var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY

var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000;

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth){
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=curX-tipobj.offsetWidth+"px"
nondefaultpos=true
}
else if (curX<leftedge)
tipobj.style.left="5px"
else{
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px"
pointerobj.style.left=curX+offsetfromcursorX+"px"
}

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight){
tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
nondefaultpos=true
}
else{
tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px"
pointerobj.style.top=curY+offsetfromcursorY+"px"
}
tipobj.style.visibility="visible"
if (!nondefaultpos)
pointerobj.style.visibility="visible"
else
pointerobj.style.visibility="hidden"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
pointerobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

document.onmousemove=positiontip;

function generateGuid()
{
    var result, i, j;
    result = '';
    for(j=0; j<32; j++)
    {
    if( j == 8 || j == 12|| j == 16|| j == 20)
    result = result + '-';
    i = Math.floor(Math.random()*16).toString(16).toUpperCase();
    result = result + i;
    }
    return result;
}

HttpRequest.prototype.MS_PROGIDS = new Array(
	"Msxml2.XMLHTTP.7.0",
	"Msxml2.XMLHTTP.6.0",
	"Msxml2.XMLHTTP.5.0",
	"Msxml2.XMLHTTP.4.0",
	"MSXML2.XMLHTTP.3.0",
	"MSXML2.XMLHTTP",
	"Microsoft.XMLHTTP");
HttpRequest.prototype.READY_STATE_UNINITIALIZED = 0;
HttpRequest.prototype.READY_STATE_LOADING       = 1;
HttpRequest.prototype.READY_STATE_LOADED        = 2;
HttpRequest.prototype.READY_STATE_INTERACTIVE   = 3;
HttpRequest.prototype.READY_STATE_COMPLETED     = 4;
HttpRequest.prototype.successCallback = null;
HttpRequest.prototype.failureCallback = null;
HttpRequest.prototype.url             = null;
HttpRequest.prototype.username        = null;
HttpRequest.prototype.password        = null;
HttpRequest.prototype.requestHeaders  = new Array();
HttpRequest.prototype.status          = null;
HttpRequest.prototype.statusText      = null;
HttpRequest.prototype.responseXML     = null;
HttpRequest.prototype.responseText    = null;
HttpRequest.prototype.abort                 = HttpRequestAbort;
HttpRequest.prototype.setRequestHeader      = HttpRequestSetRequestHeader;
HttpRequest.prototype.clearRequestHeaders   = HttpRequestClearRequestHeaders;
HttpRequest.prototype.get                   = HttpRequestGet;
HttpRequest.prototype.post                  = HttpRequestPost;
HttpRequest.prototype.initiateRequest       = HttpRequestInitiateRequest;
HttpRequest.prototype.getResponseHeader     = HttpRequestGetResponseHeader;
HttpRequest.prototype.getAllResponseHeaders = HttpRequestGetAllResponseHeaders;

function HttpRequest(id){
    this.id = id;
	this.xmlHttpRequest = null;
	if (window.XMLHttpRequest != null)
		this.xmlHttpRequest = new window.XMLHttpRequest();
	else if (window.ActiveXObject != null){
		var success = false;
		for (var i = 0; i < HttpRequest.prototype.MS_PROGIDS.length && !success; i++){
			try{
				this.xmlHttpRequest = new ActiveXObject(HttpRequest.prototype.MS_PROGIDS[i]);
				success = true}
			catch (ex){}}}

	if (this.xmlHttpRequest == null){
		alert("Error in HttpRequest():\n\nCannot create an XMLHttpRequest object.");
		return}}

function HttpRequestAbort(){this.xmlHttpRequest.abort()}

function HttpRequestSetRequestHeader(name, value){
	for (var i = 0; i < this.requestHeaders.length; i++){
		var pair = this.requestHeaders[i].split("\n");
		if (pair[0].toLowerCase() == name.toLowerCase()){
			this.requestHeaders[i] = name + "\n" + value;
			return}}
	var n = this.requestHeaders.length;
	this.requestHeaders.push(name + "\n" + value)}

function HttpRequestClearRequestHeaders(){this.requestHeaders = new Array()}

function HttpRequestGet(){this.initiateRequest("GET", null)}
function HttpRequestPost(data){this.initiateRequest("POST", data)}
function HttpRequestGetResponseHeader(name){return this.xmlHttpRequest.getResponseHeader(name)}
function HttpRequestGetAllResponseHeaders(){return this.xmlHttpRequest.getAllResponseHeaders()}

function HttpRequestInitiateRequest(method, data){
	this.status       = null;
	this.statusText   = null;
	this.responseText = null;
	this.responseXML  = null;
	var refObj = this;
	this.xmlHttpRequest.onreadystatechange =
		function(){
			refObj.readyState = refObj.xmlHttpRequest.readyState
			if (refObj.readyState == HttpRequest.prototype.READY_STATE_COMPLETED){
				refObj.status       = refObj.xmlHttpRequest.status;
				refObj.statusText   = refObj.xmlHttpRequest.statusText;
				refObj.responseText = refObj.xmlHttpRequest.responseText;
				refObj.responseXML  = refObj.xmlHttpRequest.responseXML;
				if (refObj.status == 200){if (refObj.successCallback != null)refObj.successCallback(refObj)}
				else{
					if (refObj.failureCallback != null)
						refObj.failureCallback(refObj)}}
		}
	var url = this.url;
	if (this.queryString != null)
		url = url + "?" + this.queryString;
	this.xmlHttpRequest.open(method, url, true, this.username, this.password);
	for (var i = 0; i < this.requestHeaders.length; i++){
		var pair = this.requestHeaders[i].split("\n");
		this.xmlHttpRequest.setRequestHeader(pair[0], pair[1])}
	this.xmlHttpRequest.send(data)}

var _AjaxHTML_loading = false;
var _AjaxHTML_id;

function ajax_error(httpRequest){

   if(_AjaxHTML_loading)
        closeMessage();

   _AjaxHTML_loading = false;    
   alert(_AjaxHTML_errorMessage);
   //alert("Chyba, HTTP: " + httpRequest.status + " " + httpRequest.statusText + ".");
}

function ajax_call(url){
    var ajax_id = new HttpRequest();
    ajax_id.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    ajax_id.failureCallback = ajax_error;
    ajax_id.url = url;
    return ajax_id;
}

function onMeradlo(IDobjTextBox, IDobjMeradlo, MaxLength){
    var o1 = getID(IDobjTextBox);
    var o2 = getID(IDobjMeradlo);
    if((!o1) || (!o2)){
        return false;
    }
    var size = (parseInt(o1.value.length) * 100) / MaxLength;
    if(size==0){size=1}
    o2.style.width = size.toString() + "%";
    o2.style.height = "6px";
}

function AjaxHTML_result(http)
{
    try
    {
       var value = unescape(http.responseText.replace(/<!-+(.??)+-->/g, ""));
        if(getID(_AjaxHTML_id))
            getID(_AjaxHTML_id).innerHTML = value;

        if(_AjaxHTML_loading)
            closeMessage();  
    }
    catch (ex)
    {
    } 
}

function AjaxHTML(url,post,idobj,loading){
    _AjaxHTML_loading = loading;
    _AjaxHTML_id = idobj;
    if(loading)
        WindowLoading();
    var ajax_id = ajax_call(url);
    ajax_id.successCallback = AjaxHTML_result;
    ajax_id.post(post);
}

 function WindowLoading(){
    var value = '<div style="font-size:11px; background-color:black; padding:10px; padding-top:15px" align="center"><div style="padding:5px; padding-top:15px; color:white;"><img src="/sitedata/img/loading2.gif" width="48" height="48" alt="" style="vertical-align:middle; margin-right:10px" /><b>Čakajte prosím ...</b></div></div>';
    webloading = true;
    displayStaticMessage(value,200,100);
} 

function jc_encloseText(text1,text2,textarea)
{if(typeof(textarea.caretPos)!="undefined"&&textarea.createTextRange)
{var caretPos=textarea.caretPos,temp_length=caretPos.text.length;caretPos.text=caretPos.text.charAt(caretPos.text.length-1)==' '?text1+caretPos.text+text2+' ':text1+caretPos.text+text2;if(temp_length==0)
{caretPos.moveStart("character",-text2.length);caretPos.moveEnd("character",-text2.length);caretPos.select();}
else
textarea.focus(caretPos);}
else if(typeof(textarea.selectionStart)!="undefined")
{var begin=textarea.value.substr(0,textarea.selectionStart);var selection=textarea.value.substr(textarea.selectionStart,textarea.selectionEnd-textarea.selectionStart);var end=textarea.value.substr(textarea.selectionEnd);var newCursorPos=textarea.selectionStart;var scrollPos=textarea.scrollTop;textarea.value=begin+text1+selection+text2+end;if(textarea.setSelectionRange)
{if(selection.length==0)
textarea.setSelectionRange(newCursorPos+text1.length,newCursorPos+text1.length);else
textarea.setSelectionRange(newCursorPos,newCursorPos+text1.length+selection.length+text2.length);textarea.focus();}
textarea.scrollTop=scrollPos;}
else
{textarea.value+=text1+text2;textarea.focus(textarea.value.length-1);}}

