var uri_shoppingcart=null;
var uri_home=null;
function getObject(id){
  if(document.getElementById) return document.getElementById(id);
  if(document.all) return document.all[id];
  return null;
}
function show(id, parent, ofsx, ofsy){
  var o=getObject(id);
  if(o==null)return;
  var s=o.style;
  if(s==null)return;
  s.left=findPosX(parent)+ofsx+'px';
  s.top=findPosY(parent)+ofsy+'px';
  s.display='block';
}
function hide(id){
  var o=getObject(id);
  if(o==null)return;
  o.style.display="none";
}
function findPosX(obj) {var curleft = 0;
  if (obj.offsetParent){
    while (obj.offsetParent){
      curleft += obj.offsetLeft;
      obj = obj.offsetParent;
    }
  }
  else if (obj.x)
    curleft += obj.x;
  return curleft;
}
function findPosY(obj){
  var curtop = 0;
  if (obj.offsetParent){
    while (obj.offsetParent){
      curtop += obj.offsetTop;
      obj = obj.offsetParent;
    }
  } else if (obj.y)
    curtop += obj.y;
  return curtop;
}
function goResults(){
  var destrination=document.fm.callTo.value;
  destrination=destrination.replace(" ", "_");
  destrination=destrination.replace(" ", "_");
  destrination=destrination.replace(" ", "_");
  document.fm.action=destrination+".calling-cards";
  //document.fm.action="search";
  document.fm.submit();
}
function goShoppingCart(){
  if(uri_shoppingcart==null)
  uri_shoppingcart="shoppingcart";
  document.fm.action=uri_shoppingcart;
  document.fm.submit();
}
function goHome(){
  if(uri_home==null)
  uri_home="home";
  document.fm.action=uri_home;
  document.fm.submit();
}
function goTerms(){
  document.fm.action="terms";
  document.fm.submit();
}
function goFAQ(){
  document.action="faq";
  document.fm.submit();
}
function goContactUs(){
  if(uri_contactus==null)
  uri_contactus="contactus";
  document.fm.action=uri_contactus;
  document.fm.submit();
}
function help(page){
  day = new Date();
  id = day.getTime();
  window.open(page, id, "height=350,width=500,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,top=100, left=100")
}
function showCard(card_id, location_from_id, location_id){
  document.fm.action="cardinfo";
  document.fm.card_id.value=card_id;
  document.fm.submit();
}
function showCardLnk(card_id){
  document.fm.action=card_id;
  document.fm.submit();
}
function addOne(card_id, denom){
  document.fm.fn.value="add";
  document.fm.card_id.value=card_id;
  document.fm.denom.value=denom;
  goShoppingCart();
}
function addBookmark(url,title) {
  if (window.sidebar) {
	window.sidebar.addPanel(title,url,"");
  } else if( document.all ) {
    window.external.AddFavorite( url, title);
  } else if( window.opera && window.print ) {
    return true;
  }
}
function setSelectValue(obj, val){
	for(var i=0;i<obj.options.length;i++){
		if(obj.options[i].value==val){
			obj.selectedIndex=i;
			break;
		}
	}
}
function serachInSelect(obj, val){
	for(var i=0;i<obj.options.length;i++){
		if(obj.options[i].text.substr(0,val.length).toUpperCase()==val.toUpperCase()){
			obj.selectedIndex=i;
			return val;
			break;
		}
	}
	return val.substr(0, val.length-1);
}
