/**********************************************************************************************

  CSS on Sails Framework
  Title: Victorian Government Schools
  Author: XHTMLized (http://www.xhtmlized.com/)
  Date: March 2010

***********************************************************************************************/

// Configure sIFR
var meta_normal = {  
  src: '/deecd/app_templates/coretemplates/flash/meta_normal.swf'  
};   

sIFR.activate(meta_normal);

// Welcome & Success Stories
sIFR.replace(meta_normal, {
  selector: 'div.success-stories blockquote',
  css: '.sIFR-root { color: #003e74; }',
  wmode: 'transparent'
});

sIFR.replace(meta_normal, {
  selector: 'div.welcome p.intro',
  css: [
                 '.sIFR-root { color: #003e74; }'
                 , 'a:link { color:#003e74;  }'
                 , 'a:hover { color:#091d3b; text-decoration:underline; }'
                 ],
  wmode: 'transparent',
  offsetTop: -5,
  tuneHeight: -8
});

// Content h1
sIFR.replace(meta_normal, {
  selector: '.content h1, .landingMedia h2',
  css: [
	'.sIFR-root { color: #333333; }'
	,'a:link { color:#333333; text-decoration:none; }'
	,'a:hover { color:#666666; } '
	],
  wmode: 'transparent'
});

// Content section title
sIFR.replace(meta_normal, {
  selector: '.content p.section',
  css: '.sIFR-root { color: #ccc; }',
  wmode: 'transparent'
});

// Content h2
sIFR.replace(meta_normal, {
  selector: '.content .content-col h2, .content .landing h2, .content .gallery h2, .content .galleryDetail h2',
  css: [
    '.sIFR-root { color: #003e74; }',
    'a { color: #003e74; text-decoration: none; }',
    'a:hover { color: #2c75b1; }'
  ],  
  wmode: 'transparent'
  , offsetTop: -2
  , tuneHeight: -5
});

// DD_belatedPNG fix for IE6
var PNG_fix_selectors = [
  '.header .slogan span',
  '.top .banners .info',
  '.top .banners .controls li img',
  '.top .title h2 span',
  '.top .title p span',
  '.top .navigation ul',
  '.top .navigation li',
  '.top .navigation a.current',
  'img.smiley',
  '.sidebar .right-school .download strong',
  '.sidebar .succeed ul'
]; 
/*@cc_on 
    if (@_jscript_version == 5.6 || (@_jscript_version == 5.7 && !window.XMLHttpRequest)) {
        DD_belatedPNG.fix(PNG_fix_selectors.join(','));
    }    
@*/

var VGS = {
	init: function () {
		
		VGS.Banner.init();
		VGS.Utils.rollovers($('div.search input.submit'));
	  VGS.Utils.preloadImages(["_ui/images/bg_banner_info.png"]);

	  
	  // Empty on focus
    $('div.search input.search-text').bind('focus', function() {
      if ($(this).val() == 'Search this site') {
        $(this).val('');
      }
    });
	},

	Utils: {
    /**
     * Rollovers buttons
     */
    rollovers: function (items) {
        $(items).hover(
            function () {
                $(this).attr('src', $(this).attr('src').replace(/.png/, '_over.png'));
            },
            function () {
                $(this).attr('src', $(this).attr('src').replace(/_over.png/, '.png')); 
            }
        );
     },

    /**
     * Preload images
     * @param {Array} images array with names of images   
     */               
    preloadImages: function (images) {
        for (var i = 0; i < images.length; i++) {
            var image = new Image();
            image.src = images[i];
        }
    }     
  },
	
	Banner: {
		current: false,
		
		element: $('div.banners'),
		container: $('div.banners ul.slides'),
		
		init: function () {
			
			VGS.Banner.container.cycle({
				fx: 'fade',
				timeout: 4000,
				prev: 'ul.controls .prev',
				next: 'ul.controls .next'
			});
			
			//VGS.Banner.element.find('a.info').bind('click', VGS.Banner.toggleInfo);		
			VGS.Banner.element.find('a.info').hover(function(){
				// hi1
				//alert('hi');
				VGS.Banner.showInfo();
			}, function(){
				//hi2
				//alert('hi2');
				VGS.Banner.hideInfo();
			});
		},
		
		pause: function () {
			VGS.Banner.container.cycle('pause');
		},
		
		resume: function () {
			VGS.Banner.container.cycle('resume');
		},
		
		toggleInfo: function (e) {
			
			e.preventDefault();
			
			if (VGS.Banner.element.find('a.info').hasClass('on')) {
				VGS.Banner.hideInfo();
			}
			else {
				VGS.Banner.showInfo();
			}
		
		},
		
		showInfo: function (e) {
			VGS.Banner.pause();
			
			VGS.Banner.element.find('a.info').addClass('on');
			VGS.Banner.element.find('div.info').show();
		},
		
		hideInfo: function (e) {
			VGS.Banner.element.find('a.info').removeClass('on');
			VGS.Banner.element.find('div.info').hide();

			VGS.Banner.resume();
		}
	}
};

$(document).ready(VGS.init);

