var script_to_run;

function SetClassName(element, className)
{
	if(element != 'undefined')
		element.className = className
}

function tempToggleDetails(id)
{	 
	if(document.all(id) != null)
	{
		var items = document.all(id)
		if(document.getElementById(id).length != null)
		{
			var len = document.all(id).length					
			var display = items[0].style.display=='none'?'inline':'none'
			for(var index=0; index<len; index++)
				items[index].style.display = display
		}
		else
			items.style.display = items.style.display=='none'?'inline':'none'
	}	
	
}

function temp2ToggleDetails(id)
{
  if (navigator.appName == "Microsoft Internet Explorer") 
  {
    var items = document.all(id)
    items.style.display = items.style.display=='none'?'inline':'none'
  } 
  else if (navigator.appName == "Netscape") 
  {
    if (parseInt(navigator.appVersion) < 5) 
    {
      var items = document.layers[id]
      items.visibility = items.visibility=='hide'?'show':'hide'
    } 
    else
    {
      var items = document.getElementById(id)
      items.style.display = items.style.display=='none'?'inline':'none'
    }
  }
}


function CheckVisibleDetails(id)
{	 
	if(document.all(id) != undefined)
	{
		var items = document.all(id)
		if(document.all(id).length != undefined)
		{
			var len = document.all(id).length					
			var display = items[0].style.display=='none'?'inline':'none'
			for(var index=0; index<len; index++)
				items[index].style.display = display
		}
		else
			return items.style.display=='none'?false:true
	}			
}

function windowOpener(pagename, scrl, w, h) 
{
	window.open(pagename ,"displayWindow","scrollbars=" + scrl + ",status=no,toolbar=no,width=" + w + ",height=" + h + ", dependent=yes")
}

function windowOpener2(pagename, scrl, w, h) 
{
	window.open(pagename ,"displayWindow2","scrollbars=" + scrl + ",status=no,toolbar=no,width=" + w + ",height=" + h + ", dependent=yes")
}


function windowOpenerScript(script, pagename, scrl, w, h)
{
  var boolValue = window.parent.parent.CodesFrame.checkBrowser();
  if (boolValue)
  {
    script_to_run = script;
    windowOpener(pagename, scrl, w, h);
  }
}		

function loadURLIntoParent(url)
{
  parentwindow = self.opener
  parentwindow.location.href=url
  self.close()
}

function invoke_parent_script()
{
	eval(self.opener.script_to_run);
	self.close();
}

function gotoInput(input) { 
  var i=0, index=-1; 
  
  if( event.keyCode == 13 ) {      
  
      while (i < input.form.length && index == -1) { 
        if (input.form[i] == input)index = i; 
        else i++; 
      }        
      if( index>-1 ) {            
        var j= index+1; 
        while( j < input.form.length ) { 
            if( input.form.elements[j].type=="text" ) { 
              input.form.elements[j].focus(); 
              event.cancelBubble=true 
              return; 
            } 
            else j++; 
        } 
      }      
  }    
  event.cancelBubble=true  
  //do nothing because already in last text box      
} 

function trim(item) {
    worker = new String(item);
    if (worker.indexOf(" ") != -1) {
        if (worker.indexOf(" ") == 0) {
            worker = worker.substring(1,worker.length);
            trim(worker);
        }
    }
    if (worker.lastIndexOf(" ") != -1) {
        if (worker.lastIndexOf(" ") >= worker.length-1) {
            worker = worker.substring(0,worker.length-1);
            trim(worker);
        }
    }
    return worker;
}

