if(typeof console=='undefined'){console={log:function(){}};}  

var Tabs = {
    handleClick:  function() {
        $('.Tabs a').click( function(e) {
            //Only execute the js tab switch
            //if the tab link doesn't have a url
            if($(this).attr('href') === '#' || $(this).attr('href') === '') {
                $('.TabBody').hide();
                $('.Tabs td').removeClass('Selected');
                $(this).parent().addClass('Selected');
                $('#TabBody'+this.id.replace('Tab','')).show();

                if(typeof tabSwitchCallback == 'function') {
                    tabSwitchCallback(); 
                }

                e.preventDefault();
                return false;
            }
        });
    }
};

function getRef(obj){
  if(typeof obj == "string") {obj= document.getElementById(obj);}

  return obj;
}

function PopUpload(formName,UploadPath, fileName) {
  var n = window.open("upload.asp?field=" + formName + "&path=" + UploadPath ,'uploader','toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=no,width=320,height=285');
}

$(document).ready( function() {
    //Uncomment this to highlight links that point to #
    //$('a[href=#]').css('border','1px solid red');
    Tabs.handleClick();

	$('a.PDF,a[href$="pdf"]').click(function(){
		PDFPopup(this.href);
		return false;
	});
	$('a.Offsite').click(function(){
		offsitePopup(this.href);
		return false;
	});
	$('a.popup').click(function(e){
            //Attempt to extract the width and height of the popup from the rel.  Default is 740x500
            var match = /width=(.*?);\s*height=(.*?);/.exec($(this).attr('rel')); 
            width = !match ? 740 : match[1];
            height = !match ? 500 : match[2];
            popupScrollWindow(this.href, width, height);
            return false;
	});

        $('.clearOnFocus').live('focus', function() { $(this).val(''); });

        $.getScript('/res/js/functions.js');
        $.getScript('/res/js/functions_validation.js');
        $.getScript('/res/js/functions_popups.js');
});

