
$.extend({
getUrlVars: function(){
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
	hash = hashes[i].split('=');
	vars.push(hash[0]);
	vars[hash[0]] = hash[1];
}
return vars;
},
  
getUrlVar: function(name){
	return $.getUrlVars()[name];
}
	
});



//Code for translate drop down menu
$(document).ready(function(){  
		$("ul.subnav").parent().append("<span></span>");
		$("ul.topnav li span").click(function() { //When trigger is clicked...
			
			//Following events are applied to the subnav itself (moving subnav up and down)
			$(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click
	
			$(this).parent().hover(function() {
			}, function(){	
				$(this).parent().find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
			});
	
			//Following events are applied to the trigger (Hover events for the trigger)
			}).hover(function() { 
				$(this).addClass("subhover"); //On hover over, add class "subhover"
			}, function(){	//On Hover Out
				$(this).removeClass("subhover"); //On hover out, remove class "subhover"
		});
});  

//Code for school drop down menu
$(document).ready(function(){  
		$("ul.school-subnav").parent().append("<span></span>");
		$("ul.school-topnav li span").click(function() { //When trigger is clicked...
			
			//Following events are applied to the subnav itself (moving subnav up and down)
			$(this).parent().find("ul.school-subnav").slideDown('fast').show(); //Drop down the subnav on click
	
			$(this).parent().hover(function() {
			}, function(){	
				$(this).parent().find("ul.school-subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
			});
	
			//Following events are applied to the trigger (Hover events for the trigger)
			}).hover(function() { 
				$(this).addClass("subhover"); //On hover over, add class "subhover"
			}, function(){	//On Hover Out
				$(this).removeClass("subhover"); //On hover out, remove class "subhover"
		});
});

var currentURL = window.location.href;
var splitOne = currentURL.substring(currentURL.lastIndexOf("//") + 2);
var splitTwo = splitOne.split('.sharpschool.net/');

var byName = $.getUrlVar('hl');

if(byName == 'en')
{
	$(document).ready(function(){ 
		$('ul.topnav li span').click(function() {
			$('ul.subnav').remove();
			parent.location.replace('http://'+splitTwo[0]+'.sharpschool.net');
		});
	});
}

