//////////////////////////////////////////////////////
function Redirect(url)
{
  window.location.href = url;
}

//////////////////////////////////////////////////////
function OpenPopupWindow(url)
{
	hdlWindow = window.open(url,"_blank","titlebar=no,toolbar=no,menubar=no,width=1,height=1,top=200,left=200");

  return hdlWindow
}
//////////////////////////////////////////////////////
function OpenPopupWindow2(url, name, attribs)
{
	hdlWindow = window.open(url, name, attribs);

  return hdlWindow
}
//////////////////////////////////////////////////////
function OpenPopupWindow3(url)
{
	hdlWindow = window.open(url,"_","titlebar=no,toolbar=no,menubar=no,width=1,height=1,top=200,left=200");

  return hdlWindow
}

//////////////////////////////////////////////////////
function Browse(obj, url)
{
  var hdlWindow = OpenPopupWindow2("/kennel/admin/tool/filebrowse.asp?url=" + url + "&objid=" + obj.id, "browse", "scrollbars=yes,titlebar=no,toolbar=no,menubar=no,width=500,height=500,top=200,left=200");

  return hdlWindow;
}

//////////////////////////////////////////////////////
function setBrowseFile(objid, filename)
{
  var obj = document.getElementById(objid);
  obj.value = filename;
  obj.onchange();
}

//////////////////////////////////////////////////////
function Preview(url)
{
  var hdlWindow = OpenPopupWindow2(url, "preview", "titlebar=no,toolbar=no,menubar=no,top=200,left=200");
  return hdlWindow
}

//////////////////////////////////////////////////////
function UploadFile(url)
{
  var hdlWindow = OpenPopupWindow2("/kennel/admin/fileupload.asp?dest=" + url, "upload", "scrollbars=yes,titlebar=no,toolbar=no,menubar=no,width=500,height=200,top=200,left=200");
  return hdlWindow
}

function ClearSelectedItem(selectboxid)
{
  var select = document.getElementById(selectboxid);
  if(select.value != "")
  {
    if(select.selectedIndex>=0)
      select.remove([select.selectedIndex]);
    
    select.selectedIndex = 0;
    select.value = select.options[select.selectedIndex].value;
  }  
}
function OpenSelectedItem(selectboxid, path)
{
  var select = document.getElementById(selectboxid);
  if(select.value != "")
  {
    Preview(path + "/" + select.value);
  }
  else
  {
    alert("Please, select an item to open");
  }  
}

//////////////////////////////////////////////////////
function ResizeToContent(objid)
{
  var obj = document.getElementById(objid);
  var iWidth = obj.offsetWidth;
  var iHeight = obj.offsetHeight;

  resize(iWidth,iHeight);
}

//////////////////////////////////////////////////////
function resize(iWidth, iHeight)
{
  window.resizeTo(iWidth,iHeight);
	window.focus();
}

//////////////////////////////////////////////////////
//trims strings of white space front and rear
function trim(s) 
{
	s = s.replace(/^\s*/g,"").replace(/\s*$/g,"");
	return s;
}

//////////////////////////////////////////////////////
//rotates the imagecontrol
function rotateimage(direction)
{
  alert(direction);
}

//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
//CALENDAR FUNCTIONS
var CalendarTextBox;
function Calendar(obj) 
{
	CalendarTextBox = obj;
	var newWindow = window.open('/kennel/admin/calendar.asp','Calendar','width=260,height=260');
	newWindow.focus();
}

function getCalendarTextBox()
{
	return CalendarTextBox;
}

function DaySelected()
{
	var stringDate;
	var sName;
	
	if(arguments.length == 4)
	{
		stringDate = '' + arguments[0] + '/' + arguments[1] + '/' + arguments[2];
		sName = arguments[3];
	}
	else
	{
		stringDate = "";
		sName = arguments[0];
	}

	sName.value = stringDate;
}
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
function SetValue(objid, value)
{
  var obj = document.getElementById(objid);
  obj.value = value;
}
