window.onload = function(){
	$(".jcarousel-control").each(
		function(){
			this.style.zoom = "1"
		}	
	);
}

function mycarousel_initCallback_TEST(carousel) {
    
	// Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
	
};

function mycarousel_initCallback(carousel,state) {
    
	jQuery('.jcarousel-control a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).attr('name')));
        return false;
    });
	/** /
	

    jQuery('.jcarousel-scroll select').bind('change', function() {
        carousel.options.scroll = jQuery.jcarousel.intval(this.options[this.selectedIndex].value);
        return false;
    });

    jQuery('.jcarousel-next').bind('click', function() {
		carousel.next();
        return false;
    });

    jQuery('.jcarousel-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
	
	carousel.clip.hover(function() {
		carousel.stopAuto();
	}, function() {
		carousel.startAuto();
	});
	/**/
	
	/*
	if (state == 'init') {
    	$('#mainCarousel').append("<li class='jcarousel-item jcarousel-item-horizontal jcarousel-item-6 jcarousel-item-6-horizontal' style=''>&nbsp;</li>")
	}
	*/

};

jQuery(document).ready(function() {

			$('#mainCarousel').jcarousel({
		        buttonNextHTML: "<div class=\"tr\" href=\"#\">Next<span></span></div>",
				buttonPrevHTML: "<div class=\"tr\" href=\"#\">Last<span></span></div>",
				scroll: 1,
                wrap: 'last',
				initCallback: mycarousel_initCallback
		    });
								
		    $('#mycarousel').jcarousel({
		        buttonNextHTML: "<div href=\"#\">Next</div>",
				buttonPrevHTML: "<div href=\"#\">Last</div>",
				scroll: 1,
                wrap: 'last'
		    });
		
			$(function() {
			    $("form.dropList").jqTransform();
			});
			
			$(".func .print").click(function(){window.print()})
			$(".func .bookmark").click(function(){
				title = document.title;
				url = location.href;
				
				if (window.sidebar)
				{
					// Mozilla Firefox Bookmark
					window.sidebar.addPanel(title, url,"");
				}
				else if( window.external )
				{
					// IE Favorite
					window.external.AddFavorite( url, title);
				}
				else if(window.opera && window.print)
				{
					// Opera Hotlist
					var link = document.createElement('a');
					link.setAttribute('rel','sidebar');
					link.setAttribute('href',url);
					link.setAttribute('title',title);
					link.click();
					// return true;
				} else {
					// Safari and others
					alert('This function is not supported in your web browser. Please press Ctrl-D/Command-D to bookmark this page.');
				} 
			})
			
			
			$("div.expander> h3").each(function(){
				$(this).parent().each(function() {
					this.style.overflow = "hidden";
					this.style.height = "1em";
				});
				this.state = 0;
				this.style.cursor = "pointer";
				$(this).each(function(){
					this.innerHTML = "<span>Open</span>" + this.innerHTML;
				});
			});
			$("div.expander> h3").click(function(){
				if(this.state == 0){
					var contentHeight = 0;
					$(this).parent().each(function() {
						$(this).children('h3, div').each(function(){
							contentHeight = contentHeight + this.offsetHeight;
						});
						$(this).animate({ 
							height: contentHeight - 15
						  }, 200, "linear", function(){this.style.height = "auto";});
						$(this).children('h3').children('span').each(function(){
							this.className = "close"
							this.innerHTML = "close";
						});
					});
					this.state = 1;
				}
				else {
					var contentHeight = 0;
					$(this).parent().each(function() {
						$(this).children('h3').each(function(){
							contentHeight = contentHeight + this.offsetHeight;
						});
						$(this).animate({ 
							height: contentHeight-8
						  }, 200, "linear", function(){this.style.height = "1em";});
						$(this).children('h3').children('span').each(function(){
							this.className = "";
							this.innerHTML = "open";
						});
					});
					this.state = 0;
				}
			});
			
			// font tools
			var tempSize = $.cookie("mySize");
			if(tempSize != undefined) document.body.style.fontSize = "" + tempSize + "em";
			if($.cookie("mySize") == 0.9){
				$(".head .fontSize .font2").each(
					function(){
					$(".head .fontSize a").each(
						function(){
							var myClass = this.className;
							if(myClass.match("selected")){
								var mySlice = myClass.indexOf("selected");
								myClass = myClass.slice(0, mySlice);
								this.className = myClass;
							}
						}
					)
					this.className = this.className + " selected";
				})
			}
			else if($.cookie("mySize") == 1.1){
				$(".head .fontSize .font3").each(
					function(){
					$(".head .fontSize a").each(
						function(){
							var myClass = this.className;
							if(myClass.match("selected")){
								var mySlice = myClass.indexOf("selected");
								myClass = myClass.slice(0, mySlice);
								this.className = myClass;
							}
						}
					)
					this.className = this.className + " selected";
				})
			}
			
			$(".head .fontSize a").click(
				function(){
					var mySize;
					if(this.className.match("font1")) mySize = 0.75;
					else if(this.className.match("font2"))mySize = 0.9;
					else if(this.className.match("font3"))mySize = 1.1;
					
					document.body.style.fontSize = mySize + "em"
					$.cookie("mySize", mySize)
					
					$(".head .fontSize a").each(
						function(){
							var myClass = this.className;
							if(myClass.match("selected")){
								var mySlice = myClass.indexOf("selected");
								myClass = myClass.slice(0, mySlice);
								this.className = myClass;
							}
						}
					)
					this.className = this.className + " selected";
				}
			)
			
			var height = 0;
			var vidHeight = 0;
			$('.sideBar .item').each(function(){
				height = height + this.offsetHeight;
			});
			$('.video').each(function(){
				vidHeight =  this.offsetHeight;
			});
			$('#mycarousel .jcarousel-list li, #mycarousel .jcarousel-item').each(function(){
				this.style.height = this.offsetHeight + (vidHeight - height - 1) + "px";
			});
			
			$(".bot, .top, .logo").each(
				function(){
					this.style.zoom = "1"
				}	
			);
			
			
			
			
			//$('#submit_btn').bind('click', function() {
			//					 alert($('.droplistt li a.selected').attr('name'));
			//					 document.location = '/new_location.htm';
								  
			//					});
			
			
											
	// unordered list
	
		//$('ul.shuffle').shuffle();
		
		
		

	//	if($('ul.shuffle li').index() >= 5){
	//		$(this).hide();
	//	}

		
		$('ul.shuffle').find('li:eq(9)').hide();
		$('ul.shuffle').find('li:eq(8)').hide();
		$('ul.shuffle').find('li:eq(7)').hide();
		$('ul.shuffle').find('li:eq(6)').hide();
		
		// Setup rollovers for table rows (can't do this in CSS)
		$('table.table_01 tr, table.table_02 tr').hover(function () {
				$(this).css('background-color','#eeeeee');
				$(this).css('cursor','default');
			}, 
			function () {
				$(this).css('background-color','white');
			}
	  	);
		
		// Setup rollover style change for arrow in Read More links
		$('ul.pullOut li').hover(function() {
				$(this).find('span').css('background', 'url(\'../_/bullet_blue.gif\') no-repeat center right');
			},
			function() {
				$(this).find('span').css('background', 'url(\'../_/bullet.gif\') no-repeat center right');				
			}
		);
			
		});
		
		
		
	if(document.images){
      preload_image_object = new Image();
	  
      image_url = new Array();
      image_url[0] = "_/nav_centres.gif";
      image_url[1] = "_/nav_home.gif";
      image_url[2] = "_/nav_kids.gif";
      image_url[3] = "_/nav_parents.gif";
      image_url[4] = "_/nav_centres.png";
      image_url[5] = "_/nav_home.png";
      image_url[6] = "_/nav_kids.png";
      image_url[7] = "_/nav_parents.png";
      var i = 0;
      for(i=0; i<=7; i++)preload_image_object.src = image_url[i];
	}
	
	/*
	document.getElementsByName('mainNavMap').onMouseOver(function(){
		alert('text');
	});*/
	
	
	
	
	
	
	
	
