//---v- Get page name
var furl  = window.location.href;
var spos  = (furl.lastIndexOf('\/'))?furl.lastIndexOf('\/'):furl.lastIndexOf('\\');
var epos  = (furl.lastIndexOf('.'));
var fname = furl.substring(spos+1,epos);
//---^-
$(function(){
    var spt = $('span');
    $(spt).each(function(){
        var cln = $(this).attr("class");
        switch(cln){
            case 'email':// Create email
                var at = / at /;
                var dot = / dot /g;
                var addr = $(this).text().replace(at,"@").replace(dot,".");
                $(this).after('<a href="mailto:'+addr+'" title="Send an email">'+addr+'</a>')
                    .hover(function(){window.status="Send a letter!";},function(){window.status="";});
                $(this).remove();
                break;
            case 'y':    // Replace Year
                $(this).html((new Date()).getFullYear());
                break;
        };
    });
    switch(fname){
        case 'settings':
            siteName = (typeof(siteName)!= "undefined")?siteName:"Application Name";
            $('#moblist').html(gml(1));
            break;
        case 'supportedmobiles':
            $('#moblist').html(gml(0));
            break;
        case 'usingtheservice':
            var dlt = $('#faq');
            $("dt",dlt).each(function(i){$(this).prepend('<span>'+(i+1)+'. </span>')});
            $("dd",dlt).append('<a href="#top" class="ttop" title="Back to top">Back to top</a>');
            break;
        case 'faq':
            $("dl.faq dt").each(function(i){$(this).html('<b>'+$(this).html()+'</b>').prepend('<span>'+(i+1)+'. </span>')});
            break;
    };
    $('a').focus(function(){this.blur()});
    $('a.tblank').attr("target","_blank");
});
function gml(sd){       // Get phone list
    var len = mobiles.length;
    var cnt = '';
    for (i=0;i<len;i++){
        cnt+='<h2>'+mobiles[i][0]+':<\/h2><p>'+mobiles[i][1]+'<\/p>';
        cnt+=(sd)?mobiles[i][2].replace(/\(AppName\)/g,siteName):'';
    }
    return cnt;
}