/* Works with Email Obfuscator */
/*
 * This script is written by Geert Van Aken
 * Please read the official documentation for more information
 * about the functions of this file.
 *
 * http://altum.be/products/emailobfuscator
 *
 * Please do not remove this information from the file and
 * report improvements that you make to this sourcecode
 *
 * Version 1.1.0
 * Date    2006/04/11
 */

var monkeyCode = 4 << 4;
var oldStatusText = "";

function EOa() {
  return String.fromCharCode(monkeyCode);
}

function EOd(pText) {
  var splitted = pText.split(",");
  var result = "";

  for (i = 0 ; i < splitted.length ; i++) {
    result += String.fromCharCode(splitted[i]);
  }
  return result;
}

function EOp() {
  var prefix = EOd('109,97,105');
  prefix += EOd('108,116');
  return prefix + EOd('111,58');
}

function EOad(pName, pdomain) {
  EOad(pName, pDomain, null);
}

function EOinitStatus(pName, pDomain) {
  oldStatusText = window.status;
  window.status = Loc(pName, pDomain);
}

function EOrestoreStatus() {
  window.status = oldStatusText;
}

function EOae(pName, pDomain, pSubj, pHover, pText, pClass) {

//  alert("pName = " + pName + "\npDomain = " + pDomain + "\npSubj = " + pSubj + "\npHover = " + pHover + "\npText = " + pText + "\npClass = " + pClass);

  var result = "<a href=\"JavaScript:EOad('" + pName + "','" + pDomain + "'";
  if (pSubj != null && pSubj.length > 2) {
    result += ",'" + pSubj + "'";
  }
  result += ");\"";

  if (pHover != null && pHover.length > 0) {
    result += " title=\"" + EOd(pHover) + "\"";
  }

  if (pClass != null && pClass.length > 0) {
    result += " class=\"" + pClass + "\"";
  }

  result += " onMouseOver=\"EOinitStatus('" + pName + "','" + pDomain + "');return true;\" onMouseOut=\"EOrestoreStatus();\"";

  result += ">" + EOd(pText) + "</a>";

//  alert(result);

  document.write(result);

}

function EOad(pName, pDomain, pSubj) {
  var loc = Loc(pName, pDomain);
  if (pSubj != null && pSubj.length > 0) {
    loc += "?" + EOd('115,117,98,106,101,99,116') + "=" + encodeURIComponent(EOd(pSubj));
  }

  document.location = loc;
}

function Loc(pName, pDomain) {
  var first = EOd(pName);
  var second = EOd(pDomain);
  var loc = EOp() + first + EOa() + second; 
  
  return loc;
}

/* Get radio button list value*/
function CheckOtherJobFunction(radioID, textID) {
    /*alert(document.getElementById(radioID)[0].checked);*/
    var radio = document.getElementById(radioID);
    var text = document.getElementById(textID);
    alert(radioID.value + " / " + textID.value);
    /*for (var j = 0; j < radio.length; j++) {
    if (args.value == ''){
       alert(args.value);
       }
    }*/
}

function gXRnvcvOOsXOIKU()
{
/* Munged addy code - YOU CAN EDIT COMMENT THIS TAG BETWEEN THE TWO STARS */
/* SAYS "I'm Having trouble using the events calendar " */
var AguLkxpuivmqijF=["x6e","114","x61","109","x72","x61","116","116","97","x6e","x40","x62","x69","x7a","105","110","102","x6f","x67","x72","x6f","x75","112","x2e","99","97"];
var pHEReGqOYxglSlS=[" "];
var fGsnKtxQhGuqJNJ=["x49","x27","x6d","x20","72","x61","118","105","110","103","32","x74","114","x6f","x75","x62","108","x65","32","117","115","105","x6e","x67","x20","116","x68","x65","x20","x65","118","101","x6e","x74","115","32","99","97","x6c","101","110","100","x61","x72","x20"];
document.write("<a href=\"&#x6d;&#97;&#105;&#x6c;&#x74;&#x6f;&#x3a;");
for (i=0; i<AguLkxpuivmqijF.length; i++) document.write("&#"+AguLkxpuivmqijF[i]+";");
for (i=0; i<pHEReGqOYxglSlS.length; i++) document.write(pHEReGqOYxglSlS[i]);
document.write("\">");
for (i=0; i<fGsnKtxQhGuqJNJ.length; i++) document.write("&#"+fGsnKtxQhGuqJNJ[i]+";");
document.write('</a>');
/* Munged addy code - YOU CAN EDIT COMMENT THIS TAG BETWEEN THE TWO STARS */
}


function enableDisableSearchByDatesButton(triggerPreRenderId, triggerRenderId) {
    /*enable/disable the search button in the search by dates page*/
    var dropdownList;

    dropdownList = document.getElementById(triggerRenderId)
    if(triggerPreRenderId == "ddlYears"){
        document.getElementById('btnSearchByDate').disabled = "disabled";
    }

    if (triggerPreRenderId == "ddlMonths"){
        /*alert(triggerPreRenderId + " / " + dropdownList.options(dropdownList.selectedIndex).value);*/
        if (dropdownList.options(dropdownList.selectedIndex).value > 0) {
            document.getElementById('btnSearchByDate').disabled = "";
            }
            else {
                document.getElementById('btnSearchByDate').disabled = "disabled";
        }
    }
}

function SubmitSearchByDates() {
    /*change the querystring for search by date and submit the form*/

    document.getElementById('seby').value = "date";
    document.getElementById('type').value = "new";
    document.forms[0].action = "/events/search.aspx?seby=date&type=new";
    document.forms[0].submit();
    /*alert(document.getElementById('seby').value + " / " + document.getElementById('type').value);*/
    return false;
}

function testForEnter() 
{    
if (event.keyCode == 13) 
{        
event.cancelBubble = true;
event.returnValue = false;
     }
} 

function ViewPhoto(w, h, aImage, aCaption, aSource) 
{
  h = h + 170;
  w = w + 30;
  var options = "width=" + w + ",height=" + h + ",top=190 ,left=10,";
  options += "resizable=yes,scrollbars=yes,status=no,";
  options += "menubar=no,toolbar=no,location=no,directories=no";
  
   /*sHTML = "";*/
  
  sHTML = "<html><head>";
  sHTML += "<title>Larger photo and full caption</title>";
  sHTML += "<style type='text/css'> ";
  sHTML += "body{font-family:Arial;font-size:11px;} ";
  sHTML += ".caption{font-weight:bold;padding-right:5px;} ";
  sHTML += ".source{color:#666;} ";
  sHTML += "</style>";
  sHTML += "</head>";
  sHTML += "<body>";
  sHTML += "<img src='" + aImage + "'><br/>";
  sHTML += "<span class='caption'>" + aCaption + "</span>";
  if(aSource.length >0) 
    sHTML += "<p class='source'>" + aSource +"</p>"; 
  sHTML += "<p><input type='button' onclick='window.close();' value='Close' /></p>";
  sHTML += "</body></html>";
  
  var photowindow = window.open('', 'actualphotosize', options);
  photowindow.document.write(sHTML);
  photowindow.document.close();
  photowindow.focus();
}

function resizeText(multiplier, aContainer) {
  	var children = document.getElementById(aContainer).getElementsByTagName('*');
	if(children.length > 0) {
	  	for (i=0;i<children.length;i++){
			if (children[i].style.fontSize == "" || children[i].style.fontSize == "small" || children[i].style.fontSize == "x-small") {
			    children[i].style.fontSize = "12px";
			}
			children[i].style.fontSize = parseFloat(children[i].style.fontSize) + (multiplier * 2) + "px";
		}
	} else {
		if (document.getElementById(aContainer).style.fontSize == "") {
			document.getElementById(aContainer).style.fontSize = "12px";
  		}
		document.getElementById(aContainer).style.fontSize = parseFloat(document.getElementById(aContainer).style.fontSize) + (multiplier * 0.2) + "em";
 	}
}

function ReadCookie(name)
{
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}


function SetCookie(c_name, value, expireDays, expireHours)
{
	var exdate = new Date();
	
	exdate.setDate(exdate.getDate() + expireDays);
	exdate.setTime(exdate.getTime() + expireHours * 60 * 60 * 1000);

	document.cookie = c_name + "=" + escape(value) + 
		((expireDays == null) ? "" : ";expires=" + exdate.toGMTString()) + "; path=/";
}

/* For Article TabContainer tabbed controls (used to remember which tab was selected after page reload)*/
function SetActiveTab(sender, args) 
{
	SetCookie(sender.get_id(), sender.get_activeTabIndex(), 0, 1);
	
}


function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
   if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "parent")
     anchor.target = "_top";
 }
}

function openwin(aurl, awidth, aheight, atop, aleft) {
	winpops=window.open(aurl,'smallwindow', 'top=' + atop + ',left=' + aleft + ',width=' + awidth + ',height=' + aheight,'scrollbars=no');
	winpops.focus();
}

     


function NewsletterCalloutPopUp() {
    $(window).scroll(function() {
        AdjustCalloutPosition();
    });

    $('#enews-popup-link').colorbox({
        opacity: 0.5,
        href: "/subscribe/enews-popup.html",
        transition: "fade",
        onComplete: function() {
            if ($("#enews-popup-link").offset().top - $(window).scrollTop() - $("#cboxWrapper").height() < 0)
                $('html, body').animate({ scrollTop: 200 }, 'slow');
            AdjustCalloutPosition();
        },
        onClosed: function() {
            $("#enews-email").focus();
        }
    });
}

function NewsletterCalloutPopUp2() {
    $('#enews-popup-link').colorbox({
        opacity: 0.5,
        href: "/subscribe/enews-popup.html",
        transition: "fade",
        onClosed: function() {
            $("#enews-email").focus();
        }
    });
}

function AdjustCalloutPosition() {
    $("#cboxWrapper").css("position", "fixed").css("top", $("#enews-popup-link").offset().top - $(window).scrollTop() - $("#cboxWrapper").height() + 7 + "px");
    $("#cboxWrapper").css("overflow", "hidden").css("left", $("#enews-popup-link").offset().left - $(window).scrollLeft() - $("#cboxWrapper").outerWidth() + 70 + "px");
}

function TopicAlertsCalloutPopUp() {
    $(window).scroll(function() {
        AdjustCalloutPosition();
    });

    $('#topic-alerts-popup-link').colorbox({
        opacity: 0.5,
        transition: "fade",
		escKey: true,
		inline: true, 
		href:"#topic-alerts-inline-content",
        onComplete: function() {
            //if ($("#enews-popup-link").offset().top - $(window).scrollTop() - $("#cboxWrapper").height() < 0)
            //    $('html, body').animate({ scrollTop: 200 }, 'slow');
            //AdjustCalloutPosition();
        },
        onClosed: function() {
            //$("#enews-email").focus();
        }
    });
}

function _gaqTrackEvent(ga_category, ga_action, ga_label) {
	try {
		_gaq.push(['_trackEvent', ga_category, ga_action, ga_label]);
		//alert(ga_category + ' ' + ga_action + ' ' + ga_label);
	} catch(err) {
	
	}	
}

$(document).ready(function() {
    $('a[href$=".pdf"]').click(function() {
        _gaqTrackEvent('PDF Downloads', 'Download', $(this).attr('href'));
    });
    $('a[href$=".doc"],a[href$=".docx"]').click(function() {
        _gaqTrackEvent('MS Word Downloads', 'Download', $(this).attr('href'));
    });
    $('a[href$=".xls"],a[href$=".xlsx"]').click(function() {
        _gaqTrackEvent('MS Excel Downloads', 'Download', $(this).attr('href'));
    });
    $('a[href$=".ppt"],a[href$=".pptx"],a[href$=".pps"],a[href$=".ppsx"]').click(function() {
        _gaqTrackEvent('MS PowerPoint Downloads', 'Download', $(this).attr('href'));
    });
    $('a[href$=".csv"]').click(function() {
        _gaqTrackEvent('CSV Downloads', 'Download', $(this).attr('href'));
    });
});


