/*
 * Metadata - jQuery plugin for parsing metadata from elements
 *
 * Copyright (c) 2006 John Resig, Yehuda Katz, J?örn Zaefferer, Paul McLanahan
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * Revision: $Id: jquery.metadata.js 3620 2007-10-10 20:55:38Z pmclanahan $
 *
 */
(function($){$.extend({metadata:{defaults:{type:'class',name:'metadata',cre:/({.*})/,single:'metadata'},setType:function(type,name){this.defaults.type=type;this.defaults.name=name;},get:function(elem,opts){var settings=$.extend({},this.defaults,opts);if(!settings.single.length)settings.single='metadata';var data=$.data(elem,settings.single);if(data)return data;data="{}";if(settings.type=="class"){var m=settings.cre.exec(elem.className);if(m)data=m[1];}else if(settings.type=="elem"){if(!elem.getElementsByTagName)return;var e=elem.getElementsByTagName(settings.name);if(e.length)data=$.trim(e[0].innerHTML);}else if(elem.getAttribute!=undefined){var attr=elem.getAttribute(settings.name);if(attr)data=attr;}if(data.indexOf('{')<0)data="{"+data+"}";data=eval("("+data+")");$.data(elem,settings.single,data);return data;}}});$.fn.metadata=function(opts){return $.metadata.get(this[0],opts);};})(jQuery);

/**
 * swapImage - jQuery plugin for swapping image
 *
 * Copyright (c) 2010 tszming (tszming@gmail.com)
 *
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */
(function(a){a.swapImage=function(c,b,e,f,d){a.swapImage.files={};a.swapImage.data={};a.swapImage.uuid=0;a.swapImage.init=function(){var h=++a.swapImage.uuid;a(this).attr("swapImageId",h);var g=a(this).metadata();a.swapImage.data[h]=a.swapImage.data[h]||{};if(typeof g.src!="undefined"){a.swapImage.data[h]["src"]=g.src;a.swapImage.files[g.src]=false}a.each(a.grep([[g.sin,"sin"],[g.sout,"sout"]],function(i){return(typeof i[0]!="undefined"&&i[0].length>0)}),function(){var k=this[0];var o=this[1];for(var m=0;m<k.length;m++){var j=g[o][m].indexOf(":");var n=g[o][m].substring(0,j);var l=g[o][m].substring(j+1);a.swapImage.data[h][o]=a.swapImage.data[h][o]||[];if(j>1){a.swapImage.data[h][o].push([n,l]);a.swapImage.files[l]=false}else{a.swapImage.data[h][o].push([l])}}})};a.swapImage.preload=function(){a.each(a.swapImage.files,function(i,h){if(h==false){a.swapImage.files[i]=true;var g=new Image();g.src=i}})};a.swapImage.swapIn=function(){a.swapImage.swap(this,"sin")};a.swapImage.swapOut=function(){a.swapImage.swap(this,"sout")};a.swapImage.swap=function(j,g){var k=a(j).attr("swapImageId");if(typeof a.swapImage.data[k][g]!="undefined"){for(var h=0;h<a.swapImage.data[k][g].length;h++){if(a.swapImage.data[k][g][h].length>1){a(a.swapImage.data[k][g][h][0]).attr("src",a.swapImage.data[k][g][h][1])}else{a(a.swapImage.data[k][g][h][0]).each(a.swapImage._swap)}}}else{a.swapImage._swap.call(j)}};a.swapImage._swap=function(i){var j=a(this).attr("swapImageId");var h=a.swapImage.data[j];if(typeof h.src!="undefined"){var g=h.src;h.src=this.src;this.src=g}};a(document).ready(function(){if(typeof e=="undefined"){e=true}if(typeof b=="undefined"){b=true}a(c).each(a.swapImage.init);if(typeof f=="undefined"&&typeof f=="undefined"){f="mouseenter";d="mouseleave"}if(e){if(typeof d!="undefined"){a(c).bind(f,a.swapImage.swapIn).bind(d,a.swapImage.swapOut)}else{a(c).bind(f,a.swapImage.swapIn)}}else{a(c).one(f,a.swapImage.swapIn)}if(b){a(c).each(a.swapImage.preload)}})}})(jQuery);

// JavaScript Document

$(document).ready(function(){
    $("#HorizontalAccordian .academy").width(820);
	$(".newsitembox .readmorebox").hide();
	$("#HorizontalAccordian div.topitem").hide();
	
	
		$('#accordion').bind('accordionchangestart', function(event, ui) {
	showhideSolutionExamples(ui.newHeader.first().attr("iref")+"");
	//alert("*"+ui.newHeader.first().attr("iref")+"*");
 // ui.newHeader // jQuery object, activated header
 // ui.oldHeader // jQuery object, previous header
 // ui.newContent // jQuery object, activated content
 // ui.oldContent // jQuery object, previous content
	});
		
	
});
$(function(){
	HoriLastBlock = $("#HorizontalAccordian .academy");
	
	MaxWidth = 820;
	MinWidth = 40;
	$("#HorizontalAccordian .tab").click(function() {
	    $(HoriLastBlock).animate({ width: MinWidth + "px" }, { queue: false, duration: 450 });
		$(this).animate({width: MaxWidth+"px"}, {queue:false, duration:450});
		HoriLastBlock = this;		
	});
});
$(function(){
    $("#HorizontalAccordian .imageswap a").click(
		function(event) {
			$("#imageview").attr("src",$(this).attr("href"));
			event.preventDefault();
		}
	);
});

$(function(){
	$(".newsitembox").mouseenter(function() {

		$(this).find("div.readmorebox").show('fast');
		$(this).find("div.bottomBoxLine").css("background-color","#EEEEEE");
	
	});
});

$(function(){
	$(".newsitembox").mouseleave(function() {

		$(this).find("div.readmorebox").hide('fast');
		$(this).find("div.bottomBoxLine").css("background-color","#FFFFFF");
		
	});
});

$.swapImage(".swapImage");

function showHideTopDiv(n) {

	for(i=1;i<=$("#topContents").children().size();i++) {

		$("#topitem"+i).children().hide();
	}
	
	$("#topitem"+n).children().show();
	//$("#topitem"+n+" h2").show();
	//$("#topitem"+n+" p").show();
}

function showhideSolutionExamples(n) {

	for(i=1;i<=$("#solution_examples").children().size();i++) {
		$("#solution_example"+i).children().hide('fast');
	}
	
	$("#solution_example"+n).children().show('slow');
}


function theRotator() {
	//Set the opacity of all images to 0
	$('span#rotator ul li').css({opacity: 0.0});
	
	//Get the first image and display it (gets set to full opacity)
	$('span#rotator ul li:first').css({opacity: 1.0});
		
	//Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('rotate()',6000);
	
}

function rotate() {	
	//Get the first image
	var current = ($('span#rotator ul li.show')?  $('span#rotator ul li.show') : $('span#rotator ul li:first'));

	//Get next image, when it reaches the end, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('span#rotator ul li:first') :current.next()) : $('span#rotator ul li:first'));	
	
	//Set the fade in effect for the next image, the show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
};

