window.defaultStatus = 'Faq Finance';

function search(from, kbn) {
  var v = $('txtSearch').value;
  if (v.trim().length > 0) {
    if (kbn == 0) {
      $('p').value = v;
    } else {
      $('p').value = "site:" + $('hdnDomain').value + " " + $('txtSearch').value;
    }
    from.submit();
  }
}

var nonIE = (window.navigator.appName.toLowerCase().indexOf('explorer') == -1);
function setDefaultButton(event, targetName) {
        if (event.keyCode == 13 && !(event.srcElement && (event.srcElement.tagName.toLowerCase() == "textarea"))) {
        var defaultButton;
        defaultButton = $(targetName);
        if (defaultButton && typeof(defaultButton.click) != "undefined") {
            defaultButton.click();
            event.cancelBubble = true;
            if (event.stopPropagation) event.stopPropagation();
            return false;
        }
    }
    return true;
}

var cTab=new Array();
function FT(i, id) { 
	var cPh;
	var temp = "Var" + id;
	if (typeof(cTab[temp]) == "undefined" || cTab[temp] == null) cTab[temp] = '1';
	cPh = $(id + 'A' + cTab[temp]);
	if (typeof(cPh) != "undefined" && cPh != null)
	  cPh.className=cPh.className.replace(new RegExp("( ?|^)active\\b"), "");

	cPh = $(id + 'A' + i);
	cPh.className+=(cPh.className.length>0? " ": "") + "active";
}
function CI(i, id) { 
	var cPh;
	var temp = "Var" + id;
	if (typeof(cTab[temp]) == "undefined" || cTab[temp] == null) cTab[temp] = '1';

	cPh = $(id + 'T' + cTab[temp]);
	if (typeof(cPh) != "undefined" && cPh != null)
	  //cPh.className = id + 'CNo';
	  cPh.style.display = 'none';
	  
	cPh = $(id + 'T' + i);
	//cPh.className = id + 'C';
	cPh.style.display = 'inline';
	cTab[temp] = i;
}

function $() { 
  var elements = new Array(); 
  
  for (var i = 0; i < arguments.length; i++) { 
    var element = arguments[i]; 
    if (typeof element == 'string') {
      if (nonIE) {
        element = document.getElementById(element); 
      } else {
        element = document.all[element];
      }
    }
    if (arguments.length == 1) 
      return element; 
      
    elements.push(element); 
  } 
  
  return elements; 
}

String.prototype.trim = function()
{
    return this.replace(/(^[\\s]*)|([\\s]*$)/g, "");
}
String.prototype.lTrim = function()
{
    return this.replace(/(^[\\s]*)/g, "");
}
String.prototype.rTrim = function()
{
    return this.replace(/([\\s]*$)/g, "");
}

String.prototype.realLength = function()
{
  return this.replace(/[^\x00-\xff]/g,"**").length;
}
function checkIsInteger(str)
{
  if(str == "")
      return true;
  if(/^\d+$/.test(str))
      return true;
  else
      return false;
}

function focusAndSelect(ctrl){
    if(ctrl.disabled==true)
        return;
    ctrl.focus();
    if(ctrl.type=='text')
        ctrl.select();
}

function focusWindow(targetName) {
  w = window.open("",targetName);
  w.focus();
}
function getParameter(key){
    var a = document.location.search.substr(1).split('&');
    for (i = 0; i < a.length; i++){
        try{
            var aa=a[i].split('=');
            var n=aa[0];
            var v=aa[1];
            if (n.toLowerCase() == key.toLowerCase()) {
            	return v.trim();
            }
        }catch(e){ 
        }
    }
    return "";
}
function readCookie(name)
{
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0)
  { 
    offset = document.cookie.indexOf(search);
    if (offset != -1)
    { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }
  }
  return cookieValue;
}
// Example:
// writeCookie("myCookie", "my name", 24);
// Stores the string "my name" in the cookie "myCookie" which expires after 24 hours.
function writeCookie(name, value, hours)
{
  var expire = "";
  if(hours != null)
  {
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + escape(value) + expire;
}
function showflash(fsource, fwidth, fheight) {  
  var str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + fwidth + '" height="' + fheight + '">';
  str += '  <param name="movie" value="' + fsource + '" />';
  str += '  <param name="quality" value="high" />';
  str += '  <param name="vmode" value="transparent" />';
  str += '  <param name="wmode" value="opaque" />';
  str += '  <embed src="' + fsource + '" qality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" vmode="transparent" wmode="opaque" width="' + fwidth + '" height="' + fheight + '"></embed>';
  str += '</object>';
  document.write(str);
}