//<![CDATA[

function lite(obj) {
 if(document.all&&!window.opera) {
  obj.filters.blendTrans.apply();
  obj.filters.blendTrans.play();
 }
}

var dragapproved=false
var z,x,y

function move(){
 if (event.button==1&&dragapproved){
  z.style.pixelLeft=temp1+event.clientX-x
  z.style.pixelTop=temp2+event.clientY-y
  return false
 }
}

function drags(){
 if (!document.all)
 return
 if (event.srcElement.className=="drag"){
  dragapproved=true
  z=event.srcElement
  temp1=z.style.pixelLeft
  temp2=z.style.pixelTop
  x=event.clientX
  y=event.clientY
  document.onmousemove=move
 }
}

document.onmousedown=drags
document.onmouseup=new Function("dragapproved=false")

function refreshPage() {
 var keyValue;
 keyValue = document.frmMasterView.key.options[document.frmMasterView.key.selectedIndex].value;
 //alert(keyValue);
 document.location.href = "default.aspx?page=search&key=" + keyValue;
}



//Generic show and Hide functionality
function show(a) {
    var is_getElementById   = (document.getElementById) ? true : false;
    var agt=navigator.userAgent.toLowerCase();
    if ((agt.indexOf('mac')==-1||agt.indexOf('msie')==-1) && is_getElementById){
		try {
			document.getElementById(a).style.display='';
		}
		catch (e )
		{
		}
	}
}
function hide(a) {
    var is_getElementById   = (document.getElementById) ? true : false;
    var agt=navigator.userAgent.toLowerCase();
    if ((agt.indexOf('mac')==-1||agt.indexOf('msie')==-1) && is_getElementById){
		try {
			document.getElementById(a).style.display='none';
		}
		catch (e )
		{
		}
	}
}


//-------Expand / Collapse all divs (+ / -) on a page
function expandCollapse(process)
		{
			for(var i=0;i<=document.all.length;i++)
			{
				try
				{
					if(document.all[i].id.substring(0,3) == 'lbl')
					{
						var divName = document.all[i].id;
						var imgName = 'img' + document.all[i].id.substring(3);
						if(process == 'expand')
						{
							document.getElementById(imgName).src='../../common/controlimages/open.gif';
							document.getElementById(divName).style.display='';
						}
						else
						{
							document.getElementById(imgName).src='../../common/controlimages/closed.gif';
							document.getElementById(divName).style.display='none';
						}
					}
					
				}
				catch(e)
				{
					//alert(e.message);				
				}
			}
		}	
		
		function collapseAll()
		{
			for(var i=0;i<=document.all.length;i++)
			{
				try
				{
					if(document.all[i].id.substring(0,3) == 'lbl')
					{
						var divName = document.all[i].id;
						var imgName = 'img' + document.all[i].id.substring(3);
						document.getElementById(imgName).src='../../common/controlimages/closed.gif';
						document.getElementById(divName).style.display='none';
					}
					
				}
				catch(e)
				{
					//alert(e.message);				
				}
			}
		}
		
		function expandAll()
		{
			for(var i=0;i<=document.all.length;i++)
			{
				try
				{
					if(document.all[i].id.substring(0,3) == 'lbl')
					{
						var divName = document.all[i].id;
						var imgName = 'img' + document.all[i].id.substring(3);
						document.getElementById(imgName).src='../../common/controlimages/open.gif';
						document.getElementById(divName).style.display='';
					}
					
				}
				catch(e)
				{
					//alert(e.message);				
				}
			}
		}



 /*
 * Copyright © 2005, Ashley van Gerven (ashley.vg@gmail.com)
 * All rights reserved.
 *
 * Use in source and binary forms, with or without modification, is permitted 
 * provided that the above copyright notice and disclaimer below is not removed.
 * 
 * However if you wish to include this control as part of a redistributable 
 * project, contact the author.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
 * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
 * OF SUCH DAMAGE.
 */
 
 
function initScrollingGrid(scrollingGridID, gridID, lastRowIsPager)
{
	if (navigator.userAgent.toLowerCase().indexOf("opera") != -1) // opera not supported
		return;
		
	if (!document.getElementById) // old browsers not supported
		return;


	var tblHdr = document.getElementById(scrollingGridID + "$tblHdr");
	var tblDataGrid = document.getElementById(gridID);
	var tblPager = document.getElementById(scrollingGridID + "$tblPager");

	// get header table's first row
	var tbodyEl = tblHdr.childNodes[firstChildElIndex(tblHdr, "TBODY")];
	var trEl = tbodyEl.childNodes[firstChildElIndex(tbodyEl, "TR")];

	// get datagrid table's first row
	var tbodyEl2 = tblDataGrid.childNodes[firstChildElIndex(tblDataGrid, "TBODY")];
	var trEl2 = tbodyEl2.childNodes[firstChildElIndex(tbodyEl2, "TR")];

	// delete empty TR on placeholder table
	tbodyEl.removeChild(trEl);

	// move the header row from datagrid table to our placeholder table
	tbodyEl.appendChild(trEl2);

	if (lastRowIsPager)  // if grid pager is last row then move it below the scrolling DIV (i.e. freeze it)
	{
		// get pager table's first row
		var tbodyEl3 = tblPager.childNodes[firstChildElIndex(tblPager, "TBODY")];
		var trEl3 = tbodyEl3.childNodes[firstChildElIndex(tbodyEl3, "TR")];

		// get datagrid table's last row
		var trEl4 = tbodyEl2.childNodes[lastChildElIndex(tbodyEl2, "TR")];

		// delete empty TR on placeholder table
		//tblPager.childNodes[0 + indexAdjustment].removeChild(tblPager.childNodes[0 + indexAdjustment].childNodes[0]);
		tbodyEl3.removeChild(trEl3);

		// move the footer from datagrid table to our seperate table
		//tblPager.childNodes[0 + indexAdjustment].appendChild(tblDataGrid.childNodes[0 + indexAdjustment].childNodes[tblDataGrid.childNodes[0 + indexAdjustment].childNodes.length - 1 - indexAdjustment])
		tbodyEl3.appendChild(trEl4);

		// set table width to match content DIV
		tblPager.width = document.getElementById(scrollingGridID + "$divContent").offsetWidth;
	}


	setWidths(scrollingGridID, gridID);
}


function setWidths(scrollingGridID, gridID)
{
	// reset scroll positions since FF remembers them on page-refresh
	document.getElementById(scrollingGridID + "$divHdr").scrollLeft = 0;
	document.getElementById(scrollingGridID + "$divContent").scrollLeft = 0;
	document.getElementById(scrollingGridID + "$divContent").scrollTop = 0;

	// for FF: ensure enough space to expand columns
	document.getElementById(scrollingGridID + "$headerCntr").style.width = 10000;
	document.getElementById(scrollingGridID + "$contentCntr").style.width = 10000;


	var widths = new Array();
	var totalWidth = 0;

	var tblHdr = document.getElementById(scrollingGridID + "$tblHdr");
	var tblGrid = document.getElementById(gridID);

	// get header row
	var tbodyEl = tblHdr.childNodes[firstChildElIndex(tblHdr, "TBODY")];
	var trEl = tbodyEl.childNodes[firstChildElIndex(tbodyEl, "TR")];

	// get first content row
	var tbodyEl2 = tblGrid.childNodes[firstChildElIndex(tblGrid, "TBODY")];
	var trIndex = firstChildElIndex(tbodyEl2, "TR");
	if (trIndex == -1) // i.e. no content rows
	{
		document.getElementById(scrollingGridID + "$contentCntr").style.width = 1;
		return;
	}
	var trEl2 = tbodyEl2.childNodes[trIndex];


	for (var i=0; i<trEl.childNodes.length; i++)
	{
		if (trEl.childNodes[i].nodeName != "TD") // skip #text nodes
			continue;

		// TD element for the header row
		var tdHdr = trEl.childNodes[i];

		// TD element for the content row
		var tdContent = trEl2.childNodes[i];

		// get width of of the header or content cell (depends which is widest)
		if (tdHdr.offsetWidth > tdContent.offsetWidth)
			widths[i] = tdHdr.offsetWidth;
		else
			widths[i] = tdContent.offsetWidth;

		totalWidth += widths[i];
	}


	if (document.all) // IE: set table-layout style
	{
		tblGrid.style.tableLayout = "fixed";
		tblHdr.style.tableLayout = "fixed";
	}


	for (var i=0; i<widths.length; i++)
	{
		if (widths[i]+"" == "undefined")
			continue;

		// TD element for the header row
		var tdHdr = trEl.childNodes[i];

		// TD element for the content row
		var tdContent = trEl2.childNodes[i];

		var widthAdjustment = 0;
		if (!document.all)
			widthAdjustment = -2 * parseInt(tblGrid.getAttribute("cellpadding")); // FF: subtract cellpadding

		// Update either the header cell or content cell (not both, otherwise FF stuffs up)
		if (tdHdr.offsetWidth != widths[i])
			tdHdr.style.width = widths[i] + widthAdjustment; // update header column width
		if (tdContent.offsetWidth != widths[i])
			tdContent.style.width = widths[i] + widthAdjustment; // update content column width
	}

	// update the content container table width from 10000 to correct width
	document.getElementById(scrollingGridID + "$contentCntr").style.width = tblGrid.offsetWidth;
}


// find the index of first child element (e.g. TBODY) - handy for FF which creates #text nodes from whitespace
function firstChildElIndex(el, searchFor)
{
	for (var i=0; i<el.childNodes.length; i++)
	{
		if (el.childNodes[i].nodeName == searchFor)
			return i;
	}
	return -1;
}

// find the index of last child element
function lastChildElIndex(el, searchFor)
{
	for (var i=el.childNodes.length-1; i>=0; i--)
	{
		if (el.childNodes[i].nodeName == searchFor)
			return i;
	}
	return -1;
}


// content scroll event handler (matches the header row with the horizontal scroll position of content)
function updateScroll(divObj, scrollingGridID)
{
	if (document.getElementById(scrollingGridID + "$divHdr") != null)
		document.getElementById(scrollingGridID + "$divHdr").scrollLeft = divObj.scrollLeft;
}




// ** optional ** scrolls the content (e.g by cellspacing amount to avoid double up on cellspacing)
function adjustScrollTop(scrollingGridID, gridID)
{
	document.getElementById(scrollingGridID + "$divContent").scrollTop = parseInt(document.getElementById(gridID).getAttribute("cellspacing"));
}

// ** optional **  reduce the height of the header div to avoid double up of cellspacing
function cropHeader(scrollingGridID, gridID)
{
	document.getElementById(scrollingGridID + "$divHdr").style.height = document.getElementById(scrollingGridID + "$divHdr").offsetHeight - parseInt(document.getElementById(gridID).getAttribute("cellspacing"));
}

  // setup more and top
  window.onresize = moreandtop;
  window.onscroll = moreandtop;
  moreandtop();






//CON//
//** More and top buttons
function moreandtop()       
  {
  //alert('More and Top');
  var objBody = document.body;  
  var objBTT;
  var objMOR;
  
  if ( document.all )
    {
    objBTT = document.all('divBackToTop');
    objMOR = document.all('divMoreOnPage');
    }
  else
    {
    objBTT = document.getElementById('divBackToTop');
    objMOR = document.getElementById('divMoreOnPage');    
    }
  
  if (objBTT) 
    {
    if ( ( objBody.clientHeight >> 2 ) < objBody.scrollTop )
      {
      //objBTT.style.left = objBody.clientLeft + objBody.clientWidth - objBTT.offsetWidth - 2;
      objBTT.style.left = 760; 
      objBTT.style.top = objBody.scrollTop + 2;
      objBTT.style.visibility = "visible";
      }
    else
      {
      objBTT.style.visibility = "hidden";
      }
    }  
  if (objMOR)
    {
    if ( ( objBody.scrollTop + objBody.clientHeight ) < objBody.scrollHeight )
      {
      //objMOR.style.left = objBody.clientLeft + objBody.clientWidth - objBTT.offsetWidth - 2;
      objMOR.style.left = 760;
      objMOR.style.top = objBody.scrollTop + objBody.clientHeight - objMOR.offsetHeight - 2;
      objMOR.style.visibility = "visible";
      }
    else
      {
      objMOR.style.visibility = "hidden";
      }   
    } 
  }

function mt_pagedown()
  {
  window.scrollBy(0, document.body.clientHeight);
  moreandtop();
  }
  
function mt_pagetop()
  {
  window.scrollTo(document.body.scrollLeft,0);
  moreandtop();
  }  
  
  


function EditorEventHandler() {
	try {
		if(typeof(document.getElementById('Editor1').EscapeUnicode) == 'undefined') {
			throw "Error"
		} else {
			document.getElementById('Editor1').EscapeUnicode = true;
			document.getElementById('txtDescr').value = document.getElementById('Editor1').value;
		}			
	}
	catch(er) {
		document.getElementById('txtDescr').value = document.getElementById('Alt1').value;
	}
}
//]]>
