 /*SIFR ELEMENTS*/
 var ITCglow = {
  src: '/global/swf/ITCSlimbachStdMediumWShadow.swf'
  ,ratios: [8, 1.41, 11, 1.31, 15, 1.29, 16, 1.28, 24, 1.26, 27, 1.24, 33, 1.23, 44, 1.22, 47, 1.21, 48, 1.22, 73, 1.21, 74, 1.2, 75, 1.21, 76, 1.2, 78, 1.21, 79, 1.2, 80, 1.21, 84, 1.2, 85, 1.21, 1.2]
};
 var ITC = {
  src: '/global/swf/ITCSlimbachStdMedium.swf'
  ,ratios: [8, 1.41, 11, 1.31, 15, 1.29, 16, 1.28, 24, 1.26, 27, 1.24, 33, 1.23, 44, 1.22, 47, 1.21, 48, 1.22, 73, 1.21, 74, 1.2, 75, 1.21, 76, 1.2, 78, 1.21, 79, 1.2, 80, 1.21, 84, 1.2, 85, 1.21, 1.2]
};
 var ITCStd = {
  src: '/global/swf/ITCSlimbachStd.swf'
  ,ratios: [10, 1.32, 12, 1.26, 14, 1.27, 19, 1.23, 24, 1.22, 33, 1.2, 45, 1.19, 65, 1.18, 70, 1.17, 71, 1.18, 114, 1.17, 115, 1.16, 120, 1.17, 121, 1.16, 1.17]
};
sIFR.activate(ITCglow);
sIFR.activate(ITC);
sIFR.activate(ITCStd);

//sIFR.debug.ratios({ src: '/global/swf/ITCSlimbachStd.swf', selector: 'h6' });

function ShowSeminarRegPeople() {
    html = $("select.showextras-control option:selected").html();
    if (html == "Yes" || html == "yes" || html == "y" || html == "Y") {
        $("div.extras").removeClass("hidden");
        $("div.extras div div label").css("display", "block");
    }
    else {
        if (!($("div.extras").attr("class").match("hidden"))) {
            $("div.extras").addClass("hidden");
            $("div.extras div").addClass("hidden");
            $("div.extras div div").removeClass("hidden");
            $("div.extras div div label").css("display", "none");
            $("div.extras div:first").removeClass("hidden");
            $("div.extras div a.shownext").removeClass("hidden");
        }
    }
}

//browser detect FF2 on Mac
function detectMacXFF2() {
  var userAgent = navigator.userAgent.toLowerCase();
  if (/firefox[\/\s](\d+\.\d+)/.test(userAgent)) {
    var ffversion = new Number(RegExp.$1);
    if (ffversion < 3 && userAgent.indexOf('mac') != -1) {
      return true;
    }
  }
}

/*BEHAVIOURS*/
$(document).ready(function(){

	$("div.menu ul li span.sifr").each(
		function(i)
		{
			w = $(this).width();
			nw = w+5;
			$(this).css("width", nw+"px");
		}
	);
	
	//main nav hover
	$("div.menu ul li").hover(
		function()
		{
			$(this).addClass("hover");
			if($(this).attr("class"))
			{
				if($(this).attr("class").match("home"))
				{
					$(this).addClass("homehover");
				}
			}
		},
		function()
		{
			$(this).removeClass("hover");
			if($(this).attr("class"))
			{
				if($(this).attr("class").match("home"))
				{
					$(this).removeClass("homehover");
				}
			}
		}
	);
	
	/*home flash element*/
	if(document.getElementById("flashHome"))
	{
		var so = new SWFObject("/global/swf/rotator.swf", "Rotator", "949", "386", "9", "#FFFFFF");
		
		so.addParam("wmode", "transparent");
		thepath = $("#flashHome").attr("rel");
		so.addVariable("path", thepath);
		so.write("flashHome");
	}
	
	/*webcast flash*/
	if(document.getElementById("flashPlayer"))
	{
		var so = new SWFObject("/global/swf/player.swf", "Video Player", "402", "289", "9", "#FFFFFF");
		
		so.addParam("wmode", "transparent");
		thepath = $("#flashPlayer").attr("rel");
		so.addVariable("source", thepath);
		so.write("flashPlayer");
	}
	
	/*feature links*/
	$(".feature-link").hover(
	    function()
	    {
	        $(this).addClass("feature-link-hover");
	    },
	    function()
	    {
	        $(this).removeClass("feature-link-hover");
	    }
	);
	
	/*feat box links*/
	$(".feature-box div.fb-body a.more").hover(
		function()
		{
			$(this).addClass("hover");
		},
		function()
		{
			$(this).removeClass("hover");
		}
	);
	$(".feature-box div.fb-header").hover(
	    function()
	    {
	        $(this).addClass("fb-header-hover");
	    },
	    function()
	    {
	        $(this).removeClass("fb-header-hover");
	    }
	);
	
	/*image link list*/
	$("div.image-link-list div.item a").hover(
		function()
		{
			$(this).addClass("hover");
		},
		function()
		{
			$(this).removeClass("hover");
		}
	);
	
	
	/*glossary*/
	$(".glossary-listing dt a").click(
		function()
		{
			$(this).parents("dl").toggleClass("selected");
			return false;
		}
	);

	/*Seminar Registration, add more ppl show fields*/
	$("div.extras").addClass("hidden");
	$("select.showextras-control").change(ShowSeminarRegPeople);
	
	$("div.extras a.shownext").click(
	    function()
	    {
	        $(this).parent().parent().next().removeClass("hidden");
	        $(this).addClass("hidden");
	        return false;
	    }
	);
	
	$("div.search input.btn").hover(
	    function()
	    {
	        $(this).addClass("btnhover");
	    },
	    function()
	    {
	        $(this).removeClass("btnhover");
	    }
	);
	
	expandableMenu();
	sifrText();
	$("body").addClass("sifr-complete");
		
	//table rendering
	$("div.content table").each(
	    function(i)
	    {
	        if($(this).attr("class") && $(this).attr("class").match("nojs"))
	        {
	        }
	        else
	        {
	            altrow = true;
	            firstrow = true;
	            rowspanning = 1;
	            rowspancount = 0;
	            checkedrowspan = false;
    	        
	            $(this).attr("id", "table"+i);
    	        
	            $("#table"+i+" tr").each(
	                function()
	                {
	                    rowspancount++;
	                    $(this).children("td").each(
	                        function()
	                        {
	                            $(this).attr("class", "");
	                            if(firstrow == true)
	                            {
	                                $(this).addClass("thead");
	                            }
	                            else if(altrow == true)
	                            {
	                                $(this).addClass("alt-cell");
	                            }
	                            else
	                            {
	                                $(this).addClass("normal-cell");
	                            }
	                            if(checkedrowspan == false)
	                            {
	                                rs = parseInt($(this).attr("rowspan"));
	                                if(rs > rowspanning)
	                                {
	                                    rowspanning = rs;
	                                }
	                                checkedrowspan = true;
	                            }	                        
	                        }
	                    );	
	                    //check to see if the related rows have been styled right  
	                    if(rowspancount == rowspanning)
	                    {
	                        //all rows have been styled
	                        //reset vars
	                        rowspancount = 0;
	                        rowspanning = 1;
	                        checkedrowspan = false;
	                        if(firstrow == true)
	                        {
	                            firstrow = false;
	                        }
	                        else if(altrow == true)
	                        {
	                            altrow = false;
	                        }
	                        else if(altrow == false)
	                        {
	                            altrow = true;
	                        }
	                    }              
	                }
	            );
	        }
	    }
	);
});

function expandableMenu()
{
    /*expandable menu*/
	$("ul.expandable a").click(
		function()
		{
		
			if(!($(this).parents("div").attr("class").match("info")))
			{
				$(this).parent().toggleClass("selected");
				$(this).toggleClass("open");
				$(this).siblings().toggleClass("show");
				return false;
			}
			else
			{
				return true;
			}
		}
	);
}

function sifrText()
{
	sIFR.replace(ITCglow, {
		selector: 'div.menu ul li span.sifr',
		css: [
	        '.sIFR-root { }'
	        ,'a { text-decoration: none; }'
	        ,'a:link { color: #ffffff; font-weight: bold; text-align: center; }'
	        ,'a:hover { color: #ffffff; }'
	      ]
	});
	
	sIFR.replace(ITC, {
		selector: 'div.blurb p',
		css: [
	        '.sIFR-root { color: #293885; text-align: right; line-height: 0.8em;}'
	      ]
	});
	
	sIFR.replace(ITC, {
		selector: 'h1',
		css: [
	        '.sIFR-root { color: #293885; }'
	      ]
	});
	
	sIFR.replace(ITC, {
		selector: 'h2',
		css: [
	        '.sIFR-root { color: #293885; }'
	      ]
	});
		
	sIFR.replace(ITC, {
		selector: 'div.blue-box div.top h3',
		css: [
	        '.sIFR-root { color: #ffffff;}'
	      ]
	});
	
	sIFR.replace(ITC, {
		selector: 'div.member-calc div.box div.heading h3',
		css: [
	        '.sIFR-root { color: #ffffff;}'
	      ]
	});
	sIFR.replace(ITC, {
		selector: 'div.member-calc div.box div.heading h4',
		css: [
	        '.sIFR-root { color: #ffffff;}'
	      ]
	});
	
	sIFR.replace(ITC, {
		selector: 'div.member-calc div.results div.heading h3',
		css: [
	        '.sIFR-root { color: #ffffff;}'
	      ]
	});
	sIFR.replace(ITC, {
		selector: 'div.member-calc div.results div.heading h4',
		css: [
	        '.sIFR-root { color: #ffffff;}'
	      ]
	});
	
	macff2 = detectMacXFF2();
	if(!macff2)
	{
	    sIFR.replace(ITC, {
		    selector: 'div.feature-section div.main-col h3',
		    css: [
	            '.sIFR-root { color: #ffffff;}'
	          ]
	    });
    	
	    sIFR.replace(ITCglow, {
		    selector: 'div.feature-link div.body p',
		    css: [
	            '.sIFR-root { color: #ffffff; leading: -2px; }'
	            ,'a { text-decoration: none; }'
	            ,'a:link { color: #ffffff; }'
	            ,'a:hover { color: #ffffff; }'
	          ]
	    });
	}
	sIFR.replace(ITCglow, {
		selector: 'div.feature-boxes div.fb-header h3',
		css: [
	        '.sIFR-root { color: #ffffff; line-height: 0.8em;}'
	        ,'a { text-decoration: none; line-height: 0.8em;}'
	        ,'a:link { color: #ffffff; }'
	        ,'a:hover { color: #ffffff; }'
	      ]
	});
	
	sIFR.replace(ITCglow, {
		selector: 'div.image-link-list div.heading h3',
		css: [
	        '.sIFR-root {color: #ffffff;}'
	      ]
	});
}

function scrollToBpayResults()
{
	if(document.getElementById("memberCalcResults"))
	{
		//get the offset
		offset = $("div#memberCalcResults div.results").offset();
		window.scrollTo(0, offset.top);
	}
}


function enableJSClass()
{
	document.body.className = document.body.className + " jsEnabled";
}

function openNewWindow(url)
{
	my_window = window.open(url, "mywindow","status=1,scrollbars=1,fullscreen=1,resizable=1");
	//return false;
}