// Check page name
function thispg(pg){
    page = pg+'.html';
    return (window.location.href.indexOf(page)!=-1)?true:false;
};
$(function(){
// ---v- Remove focus, save anchor list
    var anchors = $('a').focus(function(){$(this).blur();});
// ---^-
// ---v- FAQ/MailFAQ pages: number answers, add "Back to top" links
    var toTop = '<a href="#top" class="ttp">Back to Top</a>';
    if (thispg('faq')) {
        var faqs = document.getElementsByTagName('dl');
        var flen = faqs.length;
        for(var i=0;i<flen;i++){
            if(faqs[i].className=='faqa'){
                var dtel = faqs[i].getElementsByTagName('dt');
                var ddel = faqs[i].getElementsByTagName('dd');
                var dtln = dtel.length;
                for(var n=0;n<dtln;n++){
                    dtel[n].innerHTML = 1+n+'. '+dtel[n].innerHTML;
                    ddel[n].innerHTML = ddel[n].innerHTML+toTop;
                }
            }
        }
    }
// ---^-
// ---v- Unobtrusive popup Windows
     $('a.newwin').click(function(){
        cls = $(this).attr('class');
        url = $(this).attr('href');
        w   = ((cls.match(/w:(\d+)/)||[])[1]) || 310;
        h   = ((cls.match(/h:(\d+)/)||[])[1]) || 200;
        // Available param values:
        // toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=600,height=400
        parm = "width="+w+",height="+h+",scrollbars=1,resizable=1";
        window.open(url,'InfoWindow',parm).focus();
        return false;
    });
// ---^-
// ---v- Create stripped table
    $('table.strips tr:even').attr('class','tdd');
// ---^-
// ---v- Change Chathost Profile pictures
    if (thispg('exhibprofile')) {
        $('#profsmallpic a').click(function(){
            $('#profbigpic img').attr("src",$(this).attr('href'));
            return false;
        });
    }
// ---^-

// ---v- Warning message for all links on register page
/*    if (thispg('register')) {
        var AREYOUSURE = "Are you sure you want to leave this page?\n If yes, all data entered will be lost!"; 
        var makesure = function(){return confirm(AREYOUSURE);};
        anchors.not($('a.newwin')).click(makesure);
    }*/
// ---^-
    if (thispg('whoisonlineoverview')) {
        // Flash loader
        $("#fla").append('<object type="application/x-shockwave-flash" data="/misc/ptp1/flash1.swf" width="491" height="160">'+
                        '<param name="movie" value="/misc/ptp1/flash1.swf" />'+
                        '<param name="quality" value="high">'+
                        '<param name="base" value="/misc/ptp1" />'+
                        '<p style="text-align:center">You don\'t have Adobe Flash player installed! <br />'+
                        'It can be found <a href="http://www.adobe.com/shockwave/download/" target="_blank">here</a></p>'+
                    '</object>');
        $("#fla0").append('<object type="application/x-shockwave-flash" data="/misc/ptp0/flash1.swf" width="414" height="160">'+
                        '<param name="movie" value="/misc/ptp0/flash1.swf" />'+
                        '<param name="quality" value="high">'+
                        '<param name="base" value="/misc/ptp0" />'+
                        '<p style="text-align:center">You don\'t have Adobe Flash player installed! <br />'+
                        'It can be found <a href="http://www.adobe.com/shockwave/download/" target="_blank">here</a></p>'+
                    '</object>');
    }
    g = Math.ceil(3*Math.random());
    $("#hr1bg img").each(function(i){$(this).attr("src","/img/ptp0/hpc"+(i+1)+g+".jpg")});
});

// Year
function y() {
    var today = new Date();
    var year = today.getFullYear();
    document.write(year)
}
// ---v- Display emotions
function showico(){
    var tags = $('.sttl')
    var tlen = tags.length;
    if(tlen>0){
        for (var i = 0; i < tlen; i++) display.changeSmiles(tags[i], '/img/icons/emoticons/');
    }
}
// ---^-
