<!--

/* ----------------------------------------------------------- */
// RYGIEL
/* ----------------------------------------------------------- */
function OpenCenteredWindow(url, xHeight, xWidth)
{
   var myWindow;
   var height = xHeight;
   var width = xWidth;
   var left = parseInt((screen.availWidth/2) - (width/2));
   var top =  parseInt((screen.availHeight/2.2) - (height/2.2));
   //var top = 1;
   var windowFeatures = 'width=' + width + ',height=' + height + ',resizable=0,dependent,titlebar=no,scrollbars=no,menubar=no,status=no,left=' + left + ',top=' + top + 'screenX=' + left + ',screenY=' + top;
   
   //Window called PopUp is named here so only one window can be opened at a time.
   myWindow = window.open(url, 'PopUp', windowFeatures);
}


/* ----------------------------------------------------------- */
// Browser Sniff
/* ----------------------------------------------------------- */

var InstantASP_UserAgent = navigator.userAgent.toLowerCase();
var InstantASP_Opera = (InstantASP_UserAgent.indexOf('opera') != -1); // is opera
var InstantASP_Opera8 = ((InstantASP_UserAgent.indexOf('opera 8') != -1 || InstantASP_UserAgent.indexOf('opera/8') != -1) ? 1 : 0); // is opera8
var InstantASP_NS4 = (document.layers) ? true : false; // is netscape 4
var InstantASP_IE4 = (document.all && !document.getElementById) ? true : false; // is IE 4
var InstantASP_IE5 = (document.all && document.getElementById) ? true : false; // is IE 5+
var InstantASP_NS6 = (!document.all && document.getElementById) ? true : false; // is netscape 6
var InstantASP_FireFox = (InstantASP_UserAgent.indexOf("firefox/") != -1); // is firefox
var InstantASP_Transitions = (InstantASP_IE5 || InstantASP_IE4) ? true : false // do we support transitions
 
/* ----------------------------------------------------------- */
// Get a reference to an object on the client-side                   
/* ----------------------------------------------------------- */

function InstantASP_FindControl(strControlName) {

	var objReturn = '';
		if (InstantASP_IE5 || InstantASP_NS6 || InstantASP_Opera || InstantASP_Opera8)
		{
			objReturn = document.getElementById(strControlName);
		}
		else if (InstantASP_IE4)
		{
			objReturn = document.all[strControlName];
		}
		else if (InstantASP_NS4)
		{
			objReturn = document.layers[strControlName];
		}

	return objReturn

}


/* ----------------------------------------------------------- */
// Get top offset for object
/* ----------------------------------------------------------- */

function InstantASP_GetOffsetTop(objControl) {

	var top = objControl.offsetTop;
	var parent = objControl.offsetParent;
	while (parent != document.body) {
	top += parent.offsetTop;
	parent = parent.offsetParent;}
	return top;
	
}

/* ----------------------------------------------------------- */
// Get left offset for object
/* ----------------------------------------------------------- */

function InstantASP_GetOffsetLeft(objControl) {

	var left = objControl.offsetLeft;
	var parent = objControl.offsetParent;
	while (parent != document.body) {
	left += parent.offsetLeft;
	parent = parent.offsetParent;}
	return left;
	
}

/* ----------------------------------------------------------- */
// Starting with the given node, find the nearest contained element             
/* ----------------------------------------------------------- */

function InstantASP_GetContainer(node, tagName) {

  while (node != null) {
    if (node.tagName != null && node.tagName == tagName)
      return node; node = node.parentNode;
  }
  return node;
}

/* ----------------------------------------------------------- */
// Removes px and percentage markers from css style properties and returns an integer      
/* ----------------------------------------------------------- */

function InstantASP_StyleWidthToInt(strInput)	{

	var strOutput = 0;
	if (strInput.toLowerCase().indexOf("px") >= 0) {
		strOutput = strInput.substr(0, strInput.toLowerCase().indexOf("px"));
	} else if (strInput.indexOf("%") >= 0) {
		strOutput = strInput.substr(0, strInput.indexOf("%"));
	}
	return parseInt(strOutput);	
	
}

/* ----------------------------------------------------------- */
// XmlHttpRequest    
/* ----------------------------------------------------------- */

function InstantASP_XmlHttpRequest()
{
  var XmlHttp, bComplete = false;
  try { XmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); }
  catch (e) { try { XmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); }
  catch (e) { try { XmlHttp = new XMLHttpRequest(); }
  catch (e) { XmlHttp = false; }}}
  if (!XmlHttp) return null;
  this.Connect = function(sURL, sMethod, sVars, oEvent)
  {
    if (!XmlHttp) return false;
    bComplete = false;
    sMethod = sMethod.toUpperCase();

    try {
      if (sMethod == "GET")
      { 
        XmlHttp.open(sMethod, sURL+"?"+sVars, true);
        sVars = "";
      }
      else
      {
        XmlHttp.open(sMethod, sURL, true);
        XmlHttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");
        XmlHttp.setRequestHeader("Content-Type",
          "application/x-www-form-urlencoded");
      }
      XmlHttp.onreadystatechange = function(){
        if (XmlHttp.readyState == 4 && !bComplete)
        {
          bComplete = true;
          oEvent(XmlHttp);
        }};
      XmlHttp.send(sVars);
    }
    catch(e) { return false; }
    return true;
  };
  return this;
}

/* ----------------------------------------------------------- */
// Encode a string for including within a URL      
/* ----------------------------------------------------------- */

function InstantASP_EncodeString(strInput) {

	if (!strInput) {return '';}
	strInput = strInput.replace(/^\s*/, '');
	strInput = strInput.replace(/\s+/, ' ');
	strInput = strInput.replace(/\+/g, '%2B');
	strInput = strInput.replace(/\"/g,'%22').replace(/\'/g, '%27');
	return escape(strInput);
	
}

/* ----------------------------------------------------------- */
// Opens a new window
/* ----------------------------------------------------------- */

function InstantASP_OpenWindow(Url, Width, Height, Scroll, ToolBar, Location, Status, MenuBar, Resizeable, Unique) {	
	var String;
	var winName = Width.toString() + Height.toString()
   	String =  "toolbar=" + ToolBar + ",location=" + Location 
   	String += ", directories=0,status=" + Status + ",menubar=" + MenuBar + ","
	String += "scrollbars=" + Scroll + ",resizable=" + Resizeable + ",copyhistory=0,";
   	String += ",width=";
   	String += Width;
   	String += ",height=";
   	String += Height;
   	
   	// should we center popup window
   	if (InstantASP_IE4 || InstantASP_IE5 || InstantASP_Opera || InstantASP_NS6)	{
	WndTop  = (screen.height - Height) / 2;
	WndLeft = (screen.width  - Width)  / 2;
	String += ",top=";
   	String += WndTop;
   	String += ",left=";
   	String += WndLeft;}
   	
   	// should we display single popup or allow multiple
   	try {
   		if (Unique == true) {WinPic = window.open(Url,WinNum++,String);}
   		else {WinPic = window.open(Url,winName,String);WinPic.focus();}}
   	catch (e) {};
}


/* ----------------------------------------------------------- */
// This funtion removes any trialing anchor points within a string
/* ----------------------------------------------------------- */

function InstantASP_RemoveBookMark(strInput) {
	var uri = new String(strInput)
	var strOutput; var intPos = uri.indexOf('#');
	if (intPos > 0) {strOutput = uri.substring(0, intPos);}
	else {strOutput = uri;} return strOutput;
}

/* ----------------------------------------------------------- */
// This funtion removes any querystring from a string
/* ----------------------------------------------------------- */

function InstantASP_RemoveQueryString(strInput) {
	var uri = new String(strInput)
	var strOutput; var intPos = uri.indexOf('?');
	if (intPos > 0) {strOutput = uri.substring(0, intPos);}
	else {strOutput = uri;} return strOutput;
}

/* ----------------------------------------------------------- */
// Get the height of an object.
/* ----------------------------------------------------------- */

function InstantASP_GetObjHeight(obj) {
	var height = 0; 
	if (InstantASP_NS4) {var height = obj.clip.height;}
	else {var height = obj.offsetHeight;}
	return height;  
}

/* ----------------------------------------------------------- */
// Start simple menu client side script
/* ----------------------------------------------------------- */

var InstantASP_MenusActive = false; // determines if a menu is active
var InstantASP_MenuItems = new Array(); // holds a collection of current active menus
var InstantASP_MenuLeft = 0;
var InstantASP_MenuRight = 0;
var InstantASP_MenuTop = 0;
var InstantASP_MenuBottom = 0;

/* ----------------------------------------------------------- */
// Set-up document event handlers	
/* ----------------------------------------------------------- */
								   
if (InstantASP_IE4 || InstantASP_IE5 || InstantASP_Opera) {
	document.onclick = InstantASP_HideAllMenusOnClick;
	document.onscroll = InstantASP_HideAllMenusOnClick;
	window.onresize = InstantASP_HideAllMenus;
}    
else if (InstantASP_NS6) { 
	document.addEventListener("mousedown", InstantASP_HideAllMenusOnClick, true);
	window.addEventListener("onresize", InstantASP_HideAllMenus, true);
} 
else if (InstantASP_NS4) {
	document.onmousedown = InstantASP_HideAllMenusOnClick;
	window.captureEvents(Event.MOUSEMOVE);
}

/* ----------------------------------------------------------- */
// Open Menu on MouseOver Event
/* ----------------------------------------------------------- */

function InstantASP_OpenMenuMouseOver(Caller, DivLayer, InnerHTML, Width) {

	if (InstantASP_MenusActive) {InstantASP_OpenMenu(Caller, DivLayer, InnerHTML, Width);}
		
}

/* ----------------------------------------------------------- */
// Open Menu on MouseClick Event
/* ----------------------------------------------------------- */

function InstantASP_OpenMenu(Caller, DivLayer, InnerHTML, Width) {
		
	// create unique identity for generated div layer
	DivLayer = DivLayer + "_" + Caller
	
	// create iframe to hold menu, this ensures we render over dropdownlists
	var Iframe = DivLayer + "_Iframe"
	
	// determine if we can create elements dynamically
	if (!document.createElement) {return false;}
	
	// check to see if item is already within active menu array if so just quit and return false
	for (count = 0; count < InstantASP_MenuItems.length; count++)	{
		if (InstantASP_MenuItems[count] == DivLayer) {
			return false;
		}
	}
	
	// hide any menus that maybe open
	InstantASP_HideAllMenus();
	
	// add active menu to array and set active state to true
	InstantASP_MenuItems[InstantASP_MenuItems.length] = DivLayer;
	InstantASP_MenusActive = true;
	
	// create the div layer container for this menu
	InstantASP_CreateLayer(InnerHTML, DivLayer, Iframe, Width);
    
    // get object references to div layer and div_layer that called this function
	var div_layer = InstantASP_FindControl(DivLayer);
    var div_layerIframe = InstantASP_FindControl(Iframe);
    var div_layer_caller = InstantASP_FindControl(Caller);
     	
        // set default offset for div layer from the caller div
    var offsetTopDefault; offsetTopDefault = div_layer_caller.offsetHeight + 4;
		          	
	// position div layer relative to the opening link  
	var top = InstantASP_GetOffsetTop(div_layer_caller) + offsetTopDefault;
	var left = InstantASP_GetOffsetLeft(div_layer_caller); 

	// set position of controls
    div_layer.style.top = top;
    div_layer.style.left = left;
    div_layerIframe.style.top = top;
    div_layerIframe.style.left = left;
     	
    //  calculate left and top positions of current div layer
    if (InstantASP_IE4 || InstantASP_IE5 || InstantASP_Opera) { 
 		InstantASP_MenuLeft = div_layer.style.posLeft;
		InstantASP_MenuTop = div_layer.style.posTop - offsetTopDefault; 
	} else if (InstantASP_NS6) {
		InstantASP_MenuLeft = InstantASP_StyleWidthToInt(div_layer.style.left);
		InstantASP_MenuTop = InstantASP_StyleWidthToInt(div_layer.style.top);
	}
	
	// calculate right and bottom positions of current div layer
	InstantASP_MenuRight = parseInt(InstantASP_MenuLeft) + parseInt(mnu_extent.x);			
	InstantASP_MenuBottom = parseInt(InstantASP_MenuTop) + parseInt(mnu_extent.y);
	
	// now ensure Iframe sits tidy behind Div
	div_layerIframe.style.height = (InstantASP_MenuBottom - InstantASP_MenuTop);
	
	// ensure width is tidy
	Width = InstantASP_StyleWidthToInt(Width)
	
	// attempt to keep menu on screen			
	if (InstantASP_IE4 || InstantASP_IE5 || InstantASP_Opera || InstantASP_NS6) { 
 		win_width = document.body.clientWidth;
		if (InstantASP_MenuRight > win_width) {
			div_layer.style.left = win_width - Width - 10;
			div_layerIframe.style.left = win_width - Width - 10;
		}
	}
			
	// finally display the menu		
	// if this is not IE we don't need to display the Iframe
	if ((InstantASP_IE4 || InstantASP_IE5 && !InstantASP_Opera)) {div_layerIframe.style.display = "";}
	div_layer.style.display = "";
		
}

/* ----------------------------------------------------------- */
// Create div layer to hold menu
/* ----------------------------------------------------------- */

function InstantASP_CreateLayer(InnerHTML, DivLayer, Iframe, mnu_width) {     

	// create iframe to hold div later
    var frameDiv = document.createElement('iframe');     	
    frameDiv.id = Iframe;
    frameDiv.setAttribute('class','');
    frameDiv.setAttribute('src','blank.htm');
    frameDiv.style.position = 'absolute';
    frameDiv.style.zindex = 1;
    frameDiv.style.width = mnu_width;
    
	// create div layer container to holder table
    var elemDiv = document.createElement('div');     	
    elemDiv.id = DivLayer;
    elemDiv.setAttribute('class','');
    elemDiv.style.position = 'absolute';       
    elemDiv.style.zindex = 50;
	elemDiv.style.width = mnu_width;
	
	// deteremine what table to apply as the innerHTML of the div layer container
	elemDiv.innerHTML = InnerHTML;
	
	// add elements to document
	document.body.appendChild(frameDiv);   
	document.body.appendChild(elemDiv);    
	
	// get layer height now content has been added
	var mnu_height;
	
	if ((InstantASP_IE4 || InstantASP_IE5) || InstantASP_NS6)
		{mnu_height = elemDiv.offsetHeight;}
	else if (InstantASP_NS4)	
		{mnu_height = elemDiv.clip.height;}
	
	mnu_extent = {
		x : mnu_width,
		y : mnu_height
	};
		
	// finally hide the layer 
	frameDiv.style.display = "none";			
	elemDiv.style.display = "none";
		
}

/* ----------------------------------------------------------- */
// Hide all menus on click event of document
/* ----------------------------------------------------------- */

function InstantASP_HideAllMenusOnClick(event) {

    // are menus active
	if (InstantASP_MenusActive) {
		// find the element that was clicked
		if (InstantASP_IE4 || InstantASP_IE5 || InstantASP_Opera) {
			el = window.event.srcElement;
		}
		else {
			el = (event.target.tagName ? event.target : event.target.parentNode);
		}
		
		// did we find a parent div layer
		if (InstantASP_GetContainer(el, "DIV") != null) {		
		    // if we have click anywhere outside our menu
			if (InstantASP_GetContainer(el, "DIV").id.indexOf("_SimpleMenuDivLayer") == -1) {
			    // hide all menus
				InstantASP_HideAllMenus();
			}	
		} else {
			// hide all menus
			InstantASP_HideAllMenus();
		}
	}
}

/* ----------------------------------------------------------- */
// Hide all active menus 
/* ----------------------------------------------------------- */

function InstantASP_HideAllMenus() {

	if (InstantASP_MenusActive) {	
		for (count = 0; count < InstantASP_MenuItems.length; count++)	{
			var div_layer = InstantASP_FindControl(InstantASP_MenuItems[count]);
			var iframe_layer = InstantASP_FindControl(InstantASP_MenuItems[count] + "_Iframe");
			if (div_layer != null && iframe_layer != null)	{
				iframe_layer.style.display = 'none';
				div_layer.style.display = 'none';
				InstantASP_MenuItems[count] = '';
				InstantASP_MenusActive = false;
			}
		}			
	}
}


/* ----------------------------------------------------------- */
// Toggles and objects visibliity
/* ----------------------------------------------------------- */

function InstantASP_ToggleVisability(obj, visible) {

	obj = InstantASP_FindControl(obj);
	if (visible) {obj.style.display = "";}
	else {obj.style.display = "none";}
		
}

//-->