//@deprecated, use ei_show instead
function show(c)
{
	ei_show(c);
}

//@deprecated, use ei_hide instead
function hide(c)
{
	ei_hide(c);
}

  function ei_show(c)
  {
    if (document.getElementById && document.getElementById(c)!= null)
      node = document.getElementById(c).style.display='';
    else if (document.layers && document.layers[c]!= null)
      document.layers[c].display = '';
    else if (document.all && document.all[c] != null)
      document.all[c].style.display = '';
  }

  function ei_hide(c)
  {
    if (document.getElementById && document.getElementById(c)!= null)
      node = document.getElementById(c).style.display='none';
    else if (document.layers && document.layers[c]!= null)
      document.layers[c].display = 'none';
    else if (document.all && document.all[c] != null)
      document.all[c].style.display = 'none';
  }

  function ucword(id)
  {
    var str = new String(document.getElementById(id).value);
    var str = str.toUpperCase();
    document.getElementById(id).value = str;
  }

  function focuss(id)
  {
    var foc = document.getElementById(id);
    foc = document.engine.foc.focus;
  }


  function grey_icon (id,img_src)
  {
    document.getElementById(id).src=img_src;
  }

  function disable(cb,selId)
  {
    var sel = document.getElementById(selId);
    sel.disabled = cb.checked = true;

    var thetype  = sel.type;
    switch (thetype)
    {
      case "radio" :
      sel.className = "";
      break;
      default :
      sel.className = "input_desable";
      break;
    }
    //alert(sel.id.indexOf('_dis'));
  }

  function enable(cb,selId)
  {
    var sel = document.getElementById(selId);
    sel.disabled = cb.unchecked = false;
    var thetype  = sel.type;
    switch (thetype)
    {
      case "radio" :
      sel.className = "";
      break;
      default :
      sel.className = "input_enable";
      break;
    }
  }

  /* for doubleclick iframes - if changed, don't forget to do same changes in \Projects\website\web-einsurance\js\einsurance.js */
  function open2data(template, pid, wp)
  {
    var url = self.location.protocol + "//www.einsurance.de/common/php/comm/show.php";

    url = "http://zeus:90/common/php/comm/show.php" // THIS LINE MUST BE REMOVED for production!

    url += "?template=" + template
         + "&pid=" + pid
         + "&wp=" + wp
         + "&provider=einsurance"
         + "&frame="; //frame must be last, value is added in loop!!!

    for (var ix = 0; ix < 16; ix++)
    {
        if (parent.frames['ei' + ix])
            parent.frames['ei' + ix].location.href=url + ix;
    }
  }

function changeVis(id, visible)
{
  if (document.all && !window.opera)
  {
    document.getElementById(id).style.display = visible;
    return false;
  }
  return true;
}

/*
 * return int - if string is null or empty return default
 *        otherwise parse string to int
 * param default - has to be a valid int
 * param string  - will be parsed to int
 *         if the beginning of string can not be parsed to int
 *         parseInt will return NaN, thus we return default.
 */
function stringToInt(pString, pDefault) 
{
   if ( pString == null || pString == "" ) 
   {
       return pDefault;
   }
   var locInt = parseInt(pString);
   // Not valid: locInt == NaN
   // Usage of isNaN() is required.
   if ( isNaN(locInt) ) 
   {
       return pDefault;
   }
   return locInt;
}
/*
 * Removes whitespace from the beginning and from the end
 */
function trim(pString) 
{
  var locString = new String(pString+"");
  return locString.replace (/^\s+/, '').replace (/\s+$/, '');
}
/*
 * return selected value for a one-element select-box 
 */
function selectedValue(selBoxId) 
{   // TODO verify that selObject.type == "select-one"
    var selObject = null;
    if ( document.getElementById && document.getElementById(selBoxId) )
    {
        selObject = document.getElementById( selBoxId )
    }
    if ( selObject != null )
    {
        with (selObject) return options[selectedIndex].value;
    }
    return null;
}

/*
 * Reset select-box to show the default-values
 * selBoxId has to be the id from a select-element
 */ 
function resetSelectBox(selBoxId) 
{
    var sel = document.getElementById( selBoxId );
    // var type = sel.type;// TODO verify type == "select-*" or similar
    
    for (var i=0;i<sel.options.length;i++) 
    {
        sel.options[i].selected = sel.options[i].defaultSelected;
    }
}

/*
 * Select option by value for select-one element
 */ 
function selectOptionByValue(selBoxId, pValue)
{
    var sel = document.getElementById( selBoxId );
    // TODO verify that sel.type == "select-one"
    for (var i=0; i<sel.options.length; i++) 
    {
        if (sel.options[i].value == pValue) 
        {
            sel.options[i].selected = true;     
        }
        else
        {
            sel.options[i].selected = false;    
        }
    }
}

// return the value of the radio button that is checked
// return an empty string if none are checked, or there are no radio buttons
// param radioObj should be the name of the radiobuttongroup
function ei_getCheckedValue(radioGroupName) {
    var radioObj = document.getElementsByName( radioGroupName );
    // TODO verify that radioObj is a radio button group
    if(radioObj == null)
        return "";
    var radioLength = radioObj.length;
    if(radioLength == undefined)
        if(radioObj.checked)
            return radioObj.value;
        else
            return "";
    for(var i = 0; i < radioLength; i++) {
        if(radioObj[i].checked) {
            return radioObj[i].value;
        }
    }
    return "";
}

function ei_disable(id)
{
    if (document.getElementById && document.getElementById(id)!= null)
    {
        document.getElementById(id).disabled='disabled';
    } 
}

function ei_enable(id)
{
    if (document.getElementById && document.getElementById(id)!= null)
    {
        document.getElementById(id).removeAttribute("disabled");
    } 
}

function ei_helpwindow()
{
	var w = arguments[0] ? arguments[0] : '580';
	var h = arguments[1] ? arguments[1] : '360';

    var popup = window.open('', 'popup', 'width='+w+',height='+h+',scrollbars=yes, toolbar=no,status=no,resizable=yes,menubar=no,location=no,directories=no,top=10,left=10');
    popup.focus();
}


function c24()
{
	this.tts = [];
	
	this.delayedShow = function(id)
	{
		if (!this.tts[id])
		{
			this.tts[id] = window.setTimeout('c24.show("'+ id +'")', 500);
		}
	}
	
	this.show = function(id)
	{
		document.getElementById(id).style.display = 'block';
	}
	
	this.hide = function(id)
	{
		window.clearTimeout(this.tts[id]);
		this.tts[id] = false;
		document.getElementById(id).style.display = 'none';
	}	
}

var c24 = new c24();