if (window != top) {
  //top.location.replace(location.href);
}

function init(new_call) {
  if (typeof(init_calls) == 'undefined')
    init_calls = new Array();
  if (!new_call) {
    while (init_calls.length) {
      var func_call = init_calls.shift();
      //alert('calling: ' + func_call);
      if (typeof(func_call) == 'function')
        func_call();
      else
        eval(func_call + '()');
    }
  } else {
    init_calls.push(new_call);
  }
  onunload = function() {
    window.status = '---';
  }
}

function exec(name, parent) {
  if (!parent) parent = window;
  if (typeof(parent[name]) == 'function')
    return parent[name]();
  return void(0);
}

function props(o) {
  var s = "", d = ", ";
  for (var p in o)
    s = s + d + p + ": " + o[p];
  return s.length > 1 ? s.substring( d.length ) : s;
}

function get_cookie(name) {
  var start = document.cookie.indexOf(name + "=");
  var len = start + name.length + 1;
  if ((!start) && (name != document.cookie.substring(0, name.length)))
    return null;
  if (start == -1)
    return null;
  var end = document.cookie.indexOf(";", len);
  if (end == -1)
    end = document.cookie.length;
  return unescape(document.cookie.substring(len, end));
}

function set_cookie(name, value, expires, path, domain, secure) {
  var today = new Date();
  today.setTime(today.getTime());
  if (expires)
    expires = expires * 1000 * 60 * 60; // * 24;
  var expires_date = new Date(today.getTime() + (expires));
  document.cookie = name + "=" +escape(value) +
    ((expires) ? ";expires=" + expires_date.toGMTString() : "") +
    ((path) ? ";path=" + path : "") +
    ((domain) ? ";domain=" + domain : "") +
    ((secure) ? ";secure" : "");
}

function remove_cookie(name, path, domain) {
  if (get_cookie(name)) document.cookie = name + "=" +
      ((path) ? ";path=" + path : "") +
      ((domain) ? ";domain=" + domain : "") +
      ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function showterms() {
	var popurl = "http://www.securebiller.com/revitol.com/tos.php";
	winpops = window.open(popurl, "", "width=600,height=500,scrollbars,");
}

function intlphone(aid) {
	if (!aid) aid = '';
	var popurl = "http://securebiller.com/phone/index.php?aid=" + aid;
	winpops = window.open(popurl, "", "width=600,height=500,scrollbars,");
}

function additem(product) {
	document.forms['item_' + product].submit();
}

function fieldfocus(el) {
	if (typeof(field_el) != 'undefined') {
    	field_el.style.borderColor = field_el.prev_border_color;//"#999999";
		if (field_el.tagName.toLowerCase() == 'input')
		field_el.style.backgroundColor = field_el.prev_background_color;
  	}
	if (!el) return;
  	field_el = el;
  	field_el.prev_border_color = field_el.style.borderColor;
  	field_el.style.borderColor = "#000000";
  	field_el.prev_background_color = field_el.style.backgroundColor;
  	// if (field_el.tagName.toLowerCase() == 'input')
  	//field_el.style.backgroundColor = "#FEFDD3";
}

function _jbpb_evt(o,e) {
	if(e==1) {o.backgroundColorOut=o.style.backgroundColor;o.style.backgroundColor='#7993b0';}
	else if(e==0) {o.style.backgroundColor=o.backgroundColorOut;}
}

inel_mover = function() { this.style.backgroundColor = '#1f7a97'; this.style.cursor = 'pointer'; };
inel_mout = function() { this.style.backgroundColor = '#84b9c7'; };

init(function() {
	var inels = document.getElementsByTagName('input');
	var i = inels.length;
	while (--i>=0) {
		var inel = inels[i];
		if (inel.className.indexOf('pb_all') != -1) {
			inel.onmouseover = inel_mover;
			inel.onmouseout = inel_mout;
		}
	}
});


function jsValidateEmailAddress(str) {

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	
	if (str.indexOf(at)==-1){
		//alert("Invalid E-mail ID")
		return false
	}
	
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		//alert("Invalid E-mail ID")
		return false
	}
	
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		//alert("Invalid E-mail ID")
		return false
	}
	
	if (str.indexOf(at,(lat+1))!=-1){
		//alert("Invalid E-mail ID")
		return false
	}
	
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		//alert("Invalid E-mail ID")
		return false
	}
	
	if (str.indexOf(dot,(lat+2))==-1){
		//alert("Invalid E-mail ID")
		return false
	}
	
	if (str.indexOf(" ")!=-1){
		//alert("Invalid E-mail ID")
		return false
	}
	
	return true

}