<!--

function doAjax(url)
{	
	if($.browser.msie)
	{
		$.ajaxSetup(
		{
			cache: false,
		
			timeout: 1000
		});
	}
	
	$.ajax({ type: 'POST', url: url + ';ajax.do;', async:true, dataType: 'json',
		
		success: function(data)
		{
			$('#calendarHTML').html(data['calendarHTML']);
		}
		
	});
}

function checkParent()
{
	// alert(parent.window.location.href);
	
	if (parent.window.location.href	!= window.location.href)
	{
		parent.window.location.href	= window.location.href;	
	}
	
	// parent.window.location.href	= window.location.href;
}

function setPointer(theRow, thePointerColor)
{
	if (thePointerColor == '' || typeof(theRow.style) == 'undefined') {return false;}
	if (typeof(document.getElementsByTagName) != 'undefined') {var theCells = theRow.getElementsByTagName('td');}
	else if (typeof(theRow.cells) != 'undefined') {var theCells = theRow.cells;}
	else {return false;}
	var rowCellsCnt  = theCells.length;
	for (var c = 0; c < rowCellsCnt; c++) {theCells[c].style.backgroundColor = thePointerColor;}
	return true;
}
			
function setCookie( name, value ) 
{
	var systemDate = new Date(); 
	
	var expareDate = new Date(systemDate.getTime() + 315360000000);
	
	document.cookie = name + "=" + escape(value) + "; path=" + '/' + "; expires=" + expareDate.toGMTString();
}

function getCookie( name ) 
{
	var dc = document.cookie;
	
	var prefix = name + "=";
	
	var begin = dc.indexOf("; " + prefix);
	
	if (begin == -1)
	{
		begin = dc.indexOf(prefix);
		
		if (begin != 0) return null;
	} 
	else begin += 2;
	
	var end = document.cookie.indexOf(";", begin);
	
	if (end == -1) end = dc.length;
	
    return unescape(dc.substring(begin + prefix.length, end));
}

function popup( adresas, name, width, height ) 
{ 
	left = ((screen.width-width.replace('width=', ''))/2);
	
	topx = ((screen.height-height.replace('height=', ''))/2) - 40;
	
	newwindow=window.open(""+adresas+"", name,""+width+","+height+", toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes, top="+topx+", left="+left+""); 
	
	// newwindow=window.open(""+adresas+"", name,""+width+","+height+", toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes,left="+((screen.width-width)/2)+",top="+((screen.height-height)/2))+""); 
	
	if (window.focus) {newwindow.focus()}
}

/* -- External link -- */

function externalLinks() 
{
	if (!document.getElementsByTagName) return;
	
	var anchors = document.getElementsByTagName("a");
	
	for (var i=0; i<anchors.length; i++) 
	{
		var anchor = anchors[i];
		
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") anchor.target = "_blank";
	}
}

window.onload = externalLinks;

function showBox_save( boxId )
{
    var myBox = document.getElementById( boxId );

    if ( myBox.style.display == 'none' )
    {
    	setCookie( boxId + '_divBox', 'block' );
    
        myBox.style.display = 'block';
    } 
    else 
    {
    	setCookie( boxId + '_divBox', 'none' );
    
        myBox.style.display = 'none';
    }
}

function showBox( boxId, show )
{
    var myBox = document.getElementById( boxId );

    if ( show == 'TRUE' )
    {
        myBox.style.display = 'block';
        
        myBox.style.visibility="visible";
    } 
    else 
    {
        myBox.style.display = 'none';
        
        myBox.style.visibility="hidden";
    }
}

function setPause( millis )
{
	var date = new Date();
	
	var curDate = null;
	
	do { curDate = new Date(); }
	
	while(curDate-date < millis);
}

function flash( src, width, height )
{
    document.write(
        '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"' + (width ? ' width="'+width+'"' : '') + (height ? ' height="'+height+'"' : '') + ' id="padidintas" align="middle">' + "\n" +
        '    <param name="allowScriptAccess" value="sameDomain" />'+ "\n" +
        '    <param name="movie" value="'+src+'" />'+ "\n" +
        '    <param name="quality" value="high" />'+ "\n" +
        '    <embed src="'+src+'" quality="high"' + (width ? ' width="'+width+'"' : '') + (height ? ' height="'+height+'"' : '') + ' name="padidintas" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />' + "\n" +
        '</object>'
    );
}

/******************************************* 
  list handlers
*******************************************/

var list_active = new Array();
var list_inactive = new Array();

function updateField(form, u, a, x_name) 
{
  var field = a;
  var x_name = x_name;
              
  if (!form || !field) return;
       
  var mye = field.options;
  
  var addlist = "";
  
  for (ii = 0; ii < mye.length;ii++) 
  {
     if (mye[ii] == null) continue;
     
     if (!list_active[mye[ii].value]) 
     {
        if (addlist != "") addlist += ",";
        
        addlist += mye[ii].value;
     }
  }
  
  var list =  addlist.split(',');
  
  //var elem= document.getElementById(x_name);
  
  //elem.value= list; 

  //alert('kint='+x_name.name);
  
  form[x_name.name].value = ',' + list + ',';
}

function updateList(d,limit,lmsg, form, u, a, x_name) {
  //var form = document.formas;
  //var u = form.' . $name . ';
  //var a = form.' . $name_2 . ';

  var i = 0,j=0;
  var flimit=0;
  var x_name = x_name;
  //var form = document.formas;
  var to;
  var from;

  if (d == 1) {
     to =   u.options;
     from = a.options;
  } else {
     to =   a.options;
     from = u.options;
  }

  var tlength = to.length;
  var flength = from.length;

  var list = new Array(); 
  var newlist = new Array();

  for (i=0;i<flength;i++) {
     if (from[i] == null) continue;
     if (from[i].selected) {
        if (!d && limit && limit < tlength+1) { flimit=1; list[j] = i;j++; continue; }
        to[tlength++]  = new Option(from[i].text,from[i].value);
     } else {
        list[j] = i; 
        j++;
     }
  }

  //-- save from list 
  for (i=0,j=0;i<list.length;i++,j++) {
     newlist[j] = new Option(from[list[i]].text,from[list[i]].value);
  }

  //-- zero out the from list 
  from.length = 0;

  //-- repopulate the from list 
  for (i=0,j=0;i<newlist.length;i++,j++) {
     from[j] = new Option(newlist[i].text,newlist[i].value);
  }
  if (flimit && lmsg) { alert(lmsg); }

  //updatePlist(a,helement);
  
  updateField(form,u,a, x_name);
}

// -->