var gaId = "UA-2209546-10";
function analytics()
{
	if (!gaId) return null;
	gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
	loadScript(gaJsHost + "google-analytics.com/ga.js", alalyticsLoaded);
}
function alalyticsLoaded()
{
	if (!gaId) return null;
	var pageTracker = _gat._getTracker(gaId);
	pageTracker._trackPageview();
}
function loadScript(url, aFunction)
{
	var e = document.createElement("script");
	e.onreadystatechange= function() 
	{
    	if ((this.readyState == 'completed' || this.readyState == 'loaded') && !this.loadScriptDone) 
    	{
        	this.loadScriptDone = true;
        	aFunction();
       	}
    }
    e.onload= aFunction;
	e.type = "text/javascript";
	e.src = url;
	document.getElementsByTagName("head")[0].appendChild(e);
	return e;
}
function enableNavRollOvers(menuId)
{
    var menu = document.getElementById(menuId);
    if (!menu) return false;
    var links = menu.getElementsByTagName('a');
    if (!links) return false;
    for (var i = 0; i < links.length; i++)
    {
        if (links.item(i).firstChild.getAttribute('id') == 'logo') continue;
        links.item(i).onmouseover = function() {this.firstChild.src = this.firstChild.src.replace(/0/, '1');};
        links.item(i).onmouseout = function() {this.firstChild.src = this.firstChild.src.replace(/1/, '0');};
        var image = new Image();
        image.src = links.item(i).firstChild.src.replace(/0/, '1');
        images.push(image);
    }
}
function init()
{
    if (!document.getElementById) return null;
    enableNavRollOvers('leftnav');
    enableNavRollOvers('topnav');
    if (jQuery.browser.mozilla) mozFormFix();
    jQuery('form').submit(function (){return submissionCheck();});
    jQuery('select#value').change(function(){
            if (this.value >= 10)
            {
                jQuery('input#other').attr('value', '');
            }
        });
    jQuery('input#other').change(function(){
            jQuery('select#value').attr('selectedIndex', 0).attr('value', 0);
        });



		// call google analytics last of all
		analytics();
}
function pdf(thepdf) {
	var w=window.open("/assets/pdf/" + thepdf + ".pdf","press_article","");
	w.focus();
}
function submissionCheck()
{
    var message = 'Please fill in this box';
    this.fieldsValid = true;
    jQuery('form textarea.warning')
            .removeClass('warning')
            .focus(null)
        ;
    jQuery('form input.warning')
            .removeClass('warning')
            .focus(null)
        ;
    jQuery('li.required input:not([type="password"])[value="'+message+'"], li.required textarea[value="'+message+'"]')
            .attr('value', '')
            .focus(function(){
                if (this.value == message) this.value = '';
                this.className = '';
              })
            .each(function(){
                this.form.fieldsValid = false;
              })
        ;
    jQuery('li.required input:not([type="password"])[value=""], li.required textarea[value=""]')
            .addClass('warning')
            .attr('value', message)
            .focus(function(){
                if (this.value == message) this.value = '';
                this.className = '';
               })
            .each(function(){this.form.fieldsValid = false;})
        ;

    return (jQuery('.warning').length == 0);
}
var images = new Array();
window.onload = init;