/*
Created 6/26/2011
Amalgamation of existing js code at bottom of page to prevent multiple requests
plus a bit more for new features.
*/

/* Google Analytics async tracking */ 
var _gaq = _gaq || []; // if events tracking is added later, put this at the top
_gaq.push(['_setAccount', 'UA-66486-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();


/* Copied from wtn.count.js */
/* Counts page views, used for popular articles */
var args = new Array();
args['js'] = 1;
args['url'] = escape(document.location);
args['title'] = escape(document.title);

var windowHeight, windowWidth;
if(typeof(window.innerWidth) == 'number') {
    windowHeight = window.innerHeight;
    windowWidth = window.innerWidth;
}
else if(document.documentElement
        && (document.documentElement.clientWidth
        || document.documentElement.clientHeight)) {
    windowHeight = document.documentElement.clientHeight;
    windowWidth = document.documentElement.clientWidth;
}
else if(document.body &&
        (document.body.clientWidth || document.body.clientHeight)) {
    windowHeight = document.body.clientWidth;
    windowWidth = document.body.clientHeight;
}

args['wh'] = windowHeight;
args['ww'] = windowWidth;
args['sh'] = screen.height;
args['sw'] = screen.width;

arg_pairs = new Array();
for(key in args) {
    arg_pairs.push("" + key + "=" + args[key]);
}
arg_str = arg_pairs.join("&");

var recorder = document.createElement('script');
recorder.src = 'http://wistechnology.com/count/record/?' + arg_str
document.body.appendChild(recorder);

/* New feature request - collapsible text for profiles, etc */
/* Use HTML like:

<div class="collapsed">
<a class="collapsed-show">Show</a><a class="collapsed-hide">Hide</a>
<div class="collapsed-content">
    <p>Text goes here</p>
</div>
</div>

*/
$(function() {
    $('.collapsed').each(function(i) {
        var container = $(this);
        var content = container.find('.collapsed-content');
        var show = container.find('.collapsed-show');
        var hide = container.find('.collapsed-hide');
        content.hide();
        show.show();
        hide.hide();
        show.click(function() {
            content.show('fast');
            show.hide();
            hide.show();
        });
        hide.click(function() {
            content.hide('fast');
            show.show();
            hide.hide();
        });
    });
});



