
//function reloadPage(init) {  //reloads the window if Nav4 resized
//  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
//    document.pgW=innerWidth; document.pgH=innerHeight; onresize=reloadPage; }}
//  else if (innerWidth!=document.pgW || innerHeight!=document.pgH) location.reload();
//}
//reloadPage(true);

function findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function swapImgRestore() { //v3.0
  var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function swapImageFirst(id, p){
	var element;
	if((element = document.getElementById(id)) != null){
		element.src = p;
	}
}

function swapImageBack(id,p){
	var element;
	if((element = document.getElementById(id)) != null){
		element.src = p;
	}
}

// sets the default style to the editor's content on its loading
function OnRadEditorLoad(editor)
{   
	if (editor)
	{
	   // this is done in order to disable the default parent div css class when the radeditor is loading
	   // unfortunately, this is the best solution I found
	   if (document.getElementById('TheVeryEasyIdWhichCanBeFoundByJavascript'))
	   {
	       document.getElementById('TheVeryEasyIdWhichCanBeFoundByJavascript').className = "TextMainContainer";	
	   }	   	
	}
}

// a small anti-spam function (taken from old website)
function sendTo(sName, sDomain)
{ 
	document.location.href = "mailto:" + sName + "@" + sDomain
}


// used to assign a default button to a textbox
function clickButton(e, buttonid){
      var evt = e ? e : window.event;
      var bt = document.getElementById(buttonid);
      if (bt){
          if (evt.keyCode == 13){
                bt.click();
                return false;
          }
      }
}	


function stringFormat(inputString)
{
    for(i = 1; i < arguments.length; i++)
    {
        inputString = inputString.replace('{' + (i - 1) + '}', arguments[i]);
    }
    return inputString;
}

function clearTextbox(textboxid)
{
   var textbox = document.getElementById(textboxid);
   if (textbox)
    {
        if (textbox.value != null && textbox.value.length>0)
        {
            textbox.value='';   
        }
    }    
    return false;
}

function resetDropdown(dropdownid)
{
    var dropdown = document.getElementById(dropdownid);
    if (dropdown)
    {
        if (dropdown.selectedIndex != null)
        {
            dropdown.selectedIndex = 0;
        }
    }    
    return false;
}

function modifyEventsHref(txtDateId, ddlCategoryId, oldHref)
{

    var dropdown = document.getElementById(ddlCategoryId);
    if (dropdown)
    {
        if (dropdown.selectedIndex != null)
        {
            var myIndex = dropdown.selectedIndex;
            var myValue = dropdown[myIndex].value;
            oldHref+= '&Classes=' + myValue;
        }
    }
    
    if (txtDateId != '')
    {
        var textbox = document.getElementById(txtDateId);
        if (textbox)
        {
            if (textbox.value != null && textbox.value.length>0)
            {
                oldHref+= '&Date=' + textbox.value;   
            }
        } 
    }    

    return oldHref;
}

function myServicesRedirect(ddlId)
{
    var dropdown = document.getElementById(ddlId);
    if (dropdown)
    {
         if (dropdown.selectedIndex != null)
         {
                var myIndex = dropdown.selectedIndex;
                var myValue = dropdown[myIndex].value;
                var myId = dropdown[myIndex].id;
                if (myId == '1')
                {
                    window.open(myValue);
                }
                else
                {
                   window.location.href = myValue;
                }                               
         }
    }
}

// the function is referenced in all masterpages, so DO NOT DELETE until you 
// don't remove the references from masterpages
function replaceOnKeyPress()
{
 var theFunction = "S6F789EBA_Submit();";
 var theInputID = "ctl00_SearchBox_S6F789EBA_InputKeywords";

 var txt = document.getElementById(theInputID);
 var browser=navigator.appName;

 if (txt && (browser == "Netscape"))
 {
  txt.onkeypress = function(e)
  { 
   var key = String.fromCharCode(e.keyCode);
  
   if (key == "\n" || key == "\r")
   {
    eval(theFunction);
    return false;     
   }  
  }
 }
}


