//browser detection
    var agt=navigator.userAgent.toLowerCase();
    var is_major = parseInt(navigator.appVersion);
    var is_minor = parseFloat(navigator.appVersion);
 
    var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
    var is_nav4 = (is_nav && (is_major == 4));
    var is_nav6 = (is_nav && (is_major == 5));
    var is_nav6up = (is_nav && (is_major >= 5));
    var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));

//tooltip Position
var offsetX = 0;
var offsetY = 5;
var opacity = 100;
var toolTipSTYLE;
 
function initToolTips(){
  if(document.getElementById){
          toolTipSTYLE = document.getElementById("toolTipLayer").style;
  }
  if(is_ie || is_nav6up)
  {
    toolTipSTYLE.visibility = "visible";
    toolTipSTYLE.display = "none";
    document.onmousemove = moveToMousePos;
  }
}
function moveToMousePos(e)
{
  if(!is_ie){
    x = e.pageX;
    y = e.pageY;
  }else{
    x = event.x + document.body.scrollLeft;
    y = event.y + document.body.scrollTop;
  }
 
  toolTipSTYLE.left = x + offsetX+ 15 +'px';
  toolTipSTYLE.top = y + offsetY+'px';
  return true;
}
 
 
function toolTip(msg)
{
  if(toolTip.arguments.length < 1) // if no arguments are passed then hide the tootip
  {
    if(is_nav4)
        toolTipSTYLE.visibility = "hidden";
    else
        toolTipSTYLE.display = "none";
  }
  else // show
  {
    bg = "#ffffff";
    var content = '<span style="background-color:white; padding:4px; line-height:160%">'
                                   + msg +
                                  '</span>';
   if(is_nav4)
    {
      toolTipSTYLE.document.write(content);
      toolTipSTYLE.document.close();
      toolTipSTYLE.visibility = "visible";
    }
 
    else if(is_ie || is_nav6up)
    {
      document.getElementById("toolTipLayer").innerHTML = content;
      toolTipSTYLE.display='block'
    }
  }
}

function getObject(obj) {
  var theObj;
  if(document.all) {
    if(typeof obj=="string") {
      return document.all(obj);
    } else {
      return obj.style;
    }
  }
  if(document.getElementById) {
    if(typeof obj=="string") {
      return document.getElementById(obj);
    } else {
      return obj.style;
    }
  }
  return null;
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

function toCount(entrance,exit,text,characters) {
  var entranceObj=getObject(entrance);
  var exitObj=getObject(exit);
  var length=characters - entranceObj.value.length;
  if(length <= 0) {
    length=0;
    text='<span class="disable"> '+text+' </span>';
    entranceObj.value=entranceObj.value.substr(0,characters);
  }
  exitObj.innerHTML = text.replace("{CHAR}",length);
}

function validate()
{
	phone = document.txtcall.phone2.value + "" + document.txtcall.phone3.value;
	
    if (phone == "" || isNaN(phone)) {
		alert ( "Please enter a 10-digit numeric phone number." );
		document.txtcall.phone1.focus();
		return false;
    }
	if (phone.length < 10) {
		alert("Friends number needs to be 10-digits long.");
		document.txtcall.phone1.focus();
		return false;
	}

	cid_num = document.txtcall.callid2.value + "" + document.txtcall.callid3.value;

	if (cid_num != "") {
		if (cid_num.length < 10 || isNaN(cid_num)) {
			alert("Caller ID number needs to be at least 10-digits long.");
			document.txtcall.callid1.focus();
			return false;
		}
	}
	if (document.txtcall.msg.value == "") {
		alert ( "Please enter a message to say to the user." );
		document.txtcall.msg.focus();
		return false;
	}
	if (!document.txtcall.tos.checked) {
		alert("You must agree with Terms of Service to continue.");
		document.txtcall.tos.focus();
		return false;
	} 
    return true;
}

function validate2()
{

	
	phone = document.txtcall.phone2.value + "" + document.txtcall.phone3.value;
	
    if (phone == "" || isNaN(phone)) {
		alert ( "Please enter a 10-digit numeric phone number." );
		document.txtcall.phone1.focus();
		return false;
    }
	if (phone.length < 10) {
		alert("Friends number needs to be 10-digits long.");
		document.txtcall.phone1.focus();
		return false;
	}

	cid_num = document.txtcall.callid2.value + "" + document.txtcall.callid3.value;

	if (cid_num != "" || isNaN(cid_num)) {
		if (cid_num.length < 10) {
			alert("Caller ID number needs to be atleast 10-digits long.");
			document.txtcall.callid1.focus();
			return false;
		}
	}


    return true;
}

function SelectAll(id)
{
    document.getElementById(id).focus();
    document.getElementById(id).select();
}

function validateLogin () {
	var tokenlogin = document.tokenloginer.tokenlogin.value;
		//Friends Cellphone number
	if (tokenlogin == "") {
		alert ( "Please enter your token id correctly." );
		return false;
	}
    return true;
}