jQuery(document).ready(function($) {

	//Add js class to body tag in order to flag the availability of javascript
	$(document.body).addClass('js');
	
	// Testimonials Rotator - Rotate Home Page Testimonials At Random
	var hero = jQuery("div#testimonial-quotes > div"),
		heroPosition = Math.floor(Math.random() * hero.length);

	hero.attr("style", "display: none;")
		.eq(heroPosition)
		.attr("style", "display: block;");

	// Truncate Text - Truncate Home Page News Paragraph Text
	if(typeof jQuery.fn.jTruncate != 'undefined')
	{
		jQuery('div#news-pannel div.news-item p').jTruncate({
			length: 130,
			minTrail: 0,
			moreText: "",
			lessText: "",
			ellipsisText: "..",
			moreAni: "fast",
			lessAni: 2000
		});
	}
	
	
	
//---------------------------------------------------------------------------------------- START	- Login overlay
	
	
		function generateContent(obj)
		{
			var oDiv = $('<div></div>');
			oDiv.append('<h2><span>Select your school</span></h2><p>Please choose from the list below...(for non DEC schools only)</p>');
			oDiv.append(obj);
			return oDiv;
		}
		
	
		if(typeof $.fn.SimpleOverlay == 'function')
		{	
			var ooSelect = null;
			var ooType = null;
			
			var overlay = $('.anchor-overlay').click(function(){
					
				switch(true)
				{
					case $(this).hasClass('overlay-teachers'):
						ooType = 'T';
						ooSelect = $(listShops('Teachers'));
						break;
					case $(this).hasClass('overlay-students'):	
						ooType = 'S';
						ooSelect = $(listShops('Students'));
						break;
					default:
				}
					
				}).SimpleOverlay({
					overlayRef: '#overlay-school',
					closeBtnText: 'x',
					overlayTop: 100,
					overlayStyle:{
						'z-index':1000	
					},
					
					overlayContent: function(){
						return generateContent(ooSelect.change(function(){if($(this).val() != 'Select your school') window.location = '/shop-others.html?CT='+ooType+':' + $(this).val();}));
					},
					
					before: function(){
						if(ooSelect.children().length < 1)  return false
						if(ooSelect.children().length < 2)
						{
							window.location = '/shop-others.html?CT='+ooType+':' + ooSelect.children().last().attr('value');
							return false;
						}
						return true;	
						
					}
				});
		}
	//---------------------------------------------------------------------------------------- END	- 	  Login overlay

	
	

});
