// QRZstd.js
// Copyright 2012 by QRZ.COM

function e(i) { return document.getElementById(i); }
function n(i) { return document.getElementsByName(i)[0]; }
var tid;

$(document).ready(function() {
    qrzLoad();
});

function qrzLoad()
{
    if ($('#topcall').length) {
        $('#topcall > #callsign').val('');
	if ($('#swaplist').length == 0) {
	    $('#topcall > #callsign').focus();
	}
    }

    if ($('#map').length) {loadMap()}
    if ($('#reloadtime').length) {tid = setTimeout("reLoad()",$('#reloadtime').val());}
    if ($('#jstest').length) {$('#jstest').hide();}
    if ($('#jq').length) {jqInit();}
    if ($('#qrzinit').length) {qrz_init(n);}
    if ($('#qrzacq').length) {acq_init();}
    if ($('.myMenu').length) {menu_init();}
    if ($('.nbg').length) {nbg_init();}
}

function showqem() {
    id = e('qem');
    var cem = qmail;
    var cl = new String('');
    var dem = new String('');
    for (i=cem.length-1; i>0; i--) {
	var c = cem.charAt(i);
	if (c != '!') { cl = cl.concat(c); } else { break; }
    }
    i--;
    for (x=0; x<cl; x++) { dem = dem.concat(cem.charAt(i)); i-=2; }
    id.innerHTML = '<a href="mailto:' + dem + '" id="eml">' + dem + '</a>';
    var eml = e('eml');
    id.onclick = eml.onclick;
    id.onmouseover = eml.onmouseover;
}

function reLoad() {
    document.reloadform.submit();
}

function blank() {
}

function callsign_focus() {
    qrzLoad();
}

function nbg_init() {
    $(".nbg").hover(
	function() {$(this).addClass('hho');},
	function() {$(this).removeClass('hho');}
    );    
}

function menu_init() {
    $(".myMenu").buildMenu(
    {
      template:"dmyqrz.html",
      additionalData:"pippo=1",
      menuWidth:100,
      openOnRight:false,
      menuSelector: ".menuContainer",
      iconPath:"/icons/mb/",
      hasImages:false,
      fadeInTime:100,
      fadeOutTime:300,
      adjustLeft:2,
      minZindex:9999,
      adjustTop:10,
      opacity:1,
      shadow:false,
      shadowColor:"#ccc",
      hoverIntent:100,
      openOnClick:false,
      closeOnMouseOut:true,
      closeAfter:1000,
      submenuHoverIntent:200
    });
}

function showMessage(msg){
    var msgBox=$("<div>").addClass("msgBox");
    $("body").append(msgBox);
    msgBox.append("You click on: <br>"+msg);
    setTimeout(function(){msgBox.fadeOut(500,function(){msgBox.remove();})},3000)
}



