$(document).ready(function(){
						   
	$('#header').load('includes/header.html', function() {
		gsearch();											   
		$("ul.sf-menu").supersubs({ 
			minWidth:    230,   // minimum width of sub-menus in em units 
			maxWidth:    230,   // maximum width of sub-menus in em units 
			extraWidth:  1     // extra width can ensure lines don't sometimes turn over 
						   // due to slight rounding differences and font-family 
		}).superfish({
			autoArrows:		false,
			dropShadows:   	false,
			speed:       	'fast',
			pathClass:  	'current',
			 pathLevels:    3, 
			delay:         	100
		}) 
				
		$('.sf-menu li').click(function() {
			$('.sf-menu li').removeClass('current');
			$(this).addClass('current');
		});
		
						
		$(".lined").children().append("<div class=\"bottomLine\"><img src=\"images/li_border.gif\" /></div>");
		
		
		/*jQuery.each(crumb, function() {
			if(this != lastcrumb){
				$("#breadcrumbs ul").append("<li><a href=\"#\">" + this + "</a> &raquo; </li>");
			}else{
				$("#breadcrumbs ul").append("<li><a href=\"#\">" + this + "</a></li>");
			}
			//return (this != "three"); // will stop running after "three"
		});*/
		
				
		$('#footer').load('includes/footer.html', function() {
			jQuery.each($("#footer_links a"), function() {
				if($(this).html() == currentSection){
					$(this).parent().addClass("current");
				}
				//return (this != "three"); // will stop running after "three"
			});
		});
		
		
		$('a').address();
		
		
		// CLEAN IE7 LINKS
		var ua = $.browser;
		if ( ua.msie && ua.version.slice(0,3) == "7.0" ) {
			jQuery.each($("a"), function() {
				//$(this).attr('href').replace('o','XXX');
				//$(this).attr('href', 'bb');
				this.href = this.href.replace(/http:\/\/www.educate-online.com\//,'');
				this.href = this.href.replace(/http:\/\/educate-online.com\//,'');
			});
		}
		
		
		document.title = document.title.replace(/_/g,' ');
		
		
		// SET BRREADCRUMBS
		$("#breadcrumbs ul").html('');
		hashStr = location.hash.replace('#/','');
		//alert(hashStr) ;
		var crumbs = new Array();
		crumbs = hashStr.split('/');
		lastcrumb = $(crumbs).last()[0];
		first = $(crumbs).first()[0];
		urltrail = '';
	//	alert('hashStr->' + hashStr + ' first->' + first + ' lastcrumb->' + lastcrumb) ;
		jQuery.each(crumbs, function(index) {
		/*if(this && this != 'Home'){
			$("#breadcrumbs ul").html('<li><a href="/">Home</a> &raquo; ');
		}*/
		urltrail = urltrail + "/" + crumbs[index];

//		alert(urltrail) ;
		if(this != 'Home'){
			thisEdit = this.replace('k12','k-12').replace('faq','FAQ').replace('new_york','New York City').replace('washington_dc','Washington, DC');
			
	//		alert(hashStr.length + ' ' + index)  ;
//			if (hashStr.length > 50 && index == 2) {
//				$("#breadcrumbs ul").append("<br />") ;
//			}

			copytrail = urltrail ;
			if (copytrail.substr(0,1)=='/') {
				usetrail = copytrail.substr(1) ;
			} else {
				usetrail = copytrail ;
			}
			
			if ( ua.msie && ua.version.slice(0,3) == "7.0" ) {
				usetrail = usetrail.replace(/http:\/\/www.educate-online.com\//,'');
				usetrail = usetrail.replace(/http:\/\/educate-online.com\//,'');
			}

			if(this != lastcrumb){
				//$("#breadcrumbs ul").append("<li><a href=" + urltrail + " address=\"true\">" + thisEdit.replace(/_/g,' ').capitalize() + "</a> &raquo; </li>");
				$("#breadcrumbs ul").append("<li><a href=" + usetrail + ">" + thisEdit.replace(/_/g,' ').capitalize() + "</a> &raquo; </li>");
			}else{
				//$("#breadcrumbs ul").append("<li><a href=" + urltrail + " address=\"true\">" + thisEdit.replace(/_/g,' ').capitalize() + "</a></li>");
				$("#breadcrumbs ul").append("<li><a href=" + usetrail + ">" + thisEdit.replace(/_/g,' ').capitalize() + "</a></li>");
			}
		}
		});


	
	    $('a.changelink img').click(function () {
	    	$('a.changelink').attr("href", location.hash.replace('#/',''));
	    }) ;
		
		$('#searchNext').attr('href',urltrail.toLowerCase());
		$('#searchPrev').attr('href',urltrail.toLowerCase());
		
		
		$("#breadcrumbs").show();
		
		

		
	});
	


	 
}); 

String.prototype.capitalize = function(){
	return this.replace( /(^|\s)([a-z])/g , function(m,p1,p2){ return p1+p2.toUpperCase(); } );
};

/* Home Page Content Rotator Functions */
function changeContent(contentID){
	//$("#rotator_content").html('<h1 style="color:#fff;margin:150px auto;width:200px;">Call Content ' + contentID + '</h1>');
	$("#contentLink01").css('background-position','0px -82px');
	$("#contentLink02").css('background-position','0px -82px');
	$("#contentLink03").css('background-position','0px -82px');
	$("#contentLink04").css('background-position','0px -82px');
	
	switch(contentID)
	{
	case 1:
	  $("#rotator_content").html('<object width="631" height="311"><param name="movie" value="http://www.youtube.com/v/P026-soEwQ4?fs=1&amp;hl=en_US&autoplay=1;rel=0;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><param name="WMode" value="transparent"></param><embed src="http://www.youtube.com/v/P026-soEwQ4?fs=1&hl=en_US&autoplay=1;rel=0;rel=0" wmode="transparent" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="631" height="311"></embed></object>');
	  $("#contentLink01").css('background-position','0px 0px');
	  $("#rotator_content").css('z-index','0');
	  $("#rotator_content iframe").css('z-index','0');
	  $("#rotator_content #embed-holder").css('z-index','0');
	  $("#main-menu-id").css('z-index','1001') ;
	  break;
	case 2:
	 $("#rotator_content").html('<object width="631" height="311"><param name="movie" value="http://www.youtube.com/v/w8JZ2DYr56w?fs=1&autoplay=0;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><param name="WMode" value="transparent"></param><embed src="http://www.youtube.com/v/w8JZ2DYr56w?fs=1&autoplay=0;rel=0" wmode="transparent" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="631" height="311"></embed></object>');
	  $("#contentLink02").css('background-position','0px 0px');
	  $("#rotator_content").css('z-index','1');
	  $("#rotator_content iframe").css('z-index','0');
	  $("#rotator_content #embed-holder").css('z-index','0');
	  $("#main-menu-id").css('z-index','1001') ;
	  break;
	case 3:
	  $("#rotator_content").html('<img src="images/home_graphic_03.gif" style="margin:9px auto;display:block" />');
	  $("#contentLink03").css('background-position','0px 0px');
	  $("#rotator_content").css('z-index','1');
	  $("#rotator_content iframe").css('z-index','0');
	  $("#rotator_content #embed-holder").css('z-index','0');
	  $("#main-menu-id").css('z-index','1001') ;
	  break;
	case 4:
	 $("#rotator_content").html('<object width="631" height="311"><param name="movie" value="http://www.youtube.com/v/ns8jmP4LQH8?fs=1&autoplay=0;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><param name="WMode" value="transparent"></param><embed src="http://www.youtube.com/v/ns8jmP4LQH8?fs=1&autoplay=0;rel=0" wmode="transparent" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="631" height="311"></embed></object>');
	 $("#contentLink04").css('background-position','0px 0px');
	  $("#rotator_content").css('z-index','1');
	  $("#rotator_content iframe").css('z-index','0');
	  $("#rotator_content #embed-holder").css('z-index','0');
	  $("#main-menu-id").css('z-index','1001') ;
	  break;
	}
}

/* Toggle languages */
function toggleLang(lang){
	if(lang == 'en'){
		$("#english").show();
		$("#spanish").hide();
	}
	if(lang == 'es'){
		$("#english").hide();
		$("#spanish").show();
	}
}

/* Header Image Rotator */
var faderSettings = {
	timing: 10000,
	fadeSpeed: 600,
	numberOfImages: 10,
	imagePrefix: "quotes_",
	imageSuffix: ".gif",
	imageDirectory: "images/"
};
var displayImage = function(displayImage){
	var imageURL = faderSettings.imageDirectory + displayImage;
	$("#inner_rotator").find("img").fadeOut(faderSettings.fadeSpeed, function(){
		/*$(this).css({
			'backgroundImage': 'url('+ imageURL + ')'
		}).fadeIn(faderSettings.fadeSpeed);*/
		
		$(this).parent().html("<img src='" + imageURL + "' />").fadeIn(faderSettings.fadeSpeed);
	});
};
function outer(){
	var a = 1;
	function inner(){
		if(a==faderSettings.numberOfImages){
			a = 1;
		} else {a++;}
		var imageNeeded = faderSettings.imagePrefix + a + faderSettings.imageSuffix;
		displayImage(imageNeeded);
	}
	return inner;
}
var imageFade = outer();
var cycleMe = setInterval(imageFade, faderSettings.timing);

function setlinks(){
	$("#blocks_leftGreen").html(
	'<ul>\
		<li><a href="our_programs/k12_academic_intervention"><img src="images/menu_green_01.gif" /></a></li>\
		<li><a href="our_programs/college_readiness"><img src="images/menu_green_02.gif" /></a></li>\
		<li><a href="our_programs/supplemental_educational_services"><img src="images/menu_green_03.gif" /></a></li>\
	</ul>'
	);
	
	$("#blocks_leftPurple").html(
	'<ul>\
		<li><a href="our_results"><img src="images/img_purplebox.gif" /></a></a></li>\
	</ul>'
	);
	
}

function footerlinks(){
	$("#footer_links li").removeClass();
	jQuery.each($("#footer_links a"), function() {
		if($(this).html() == currentSection){
			$(this).parent().addClass("current");
		}
		//return (this != "three"); // will stop running after "three"
	});
}

function goAnchor(pos){
	//get the top offset of the target anchor
	var target_offset = $("#"+pos).offset();
	var target_top = target_offset.top;

	//goto that anchor by setting the body scroll top to anchor top
	$('html, body').animate({scrollTop:target_top}, 500);
	//});
}

function insertContent(){
	pathArray = location.hash.split( '/' );
	
	//add getting started tab
	if(pathArray[1] == 'our_programs' && pathArray[3] != 'findout_more_general' && pathArray[3] != 'findout_more_new_york' && pathArray[3] != 'findout_more_puerto_rico'){
		$(".container_bottom").html(
		'<div id="tab_getting_started" class="rightHalf">\
			<a href="contact_us"><img src="images/get_started.gif" /></a>\
		</div>');
		$("#blocks_leftGreen").hide();
	}else{
		$(".container_bottom").html('');
	}
	//add home breadcrumb
	if(pathArray[1] != 'home'){
		//alert($("#breadcrumbs ul li").first());
		$("#breadcrumbs ul li").first().before('<li><a href="/">Home</a> &raquo; </li>');
		//$("#breadcrumbs ul li").first().css('background-color', 'red');
	}
	
	$("#col3").html(
	'<img src="images/youtube_header.png">\
		<object width="175" height="129">\
			<param value="http://www.youtube.com/v/-PA4WtUbWso?showinfo=0&amp;fs=1&amp;hl=en_US&amp;color1=0x006699&amp;color2=0x54abd6" name="movie">\
			<param value="true" name="allowFullScreen">\
			<param value="always" name="allowscriptaccess">\
			<param name="wmode" value="transparent">\
			<embed width="175" height="129" allowfullscreen="true" allowscriptaccess="always" wmode="transparent" type="application/x-shockwave-flash" src="http://www.youtube.com/v/-PA4WtUbWso?showinfo=0&amp;fs=1&amp;hl=en_US&amp;color1=0x006699&amp;color2=0x54abd6">\
		</object>');
}

//TIPS
window.size = function()
{
var w = 0;
var h = 0;
//IE
if(!window.innerWidth)
{
//strict mode
if(!(document.documentElement.clientWidth == 0))
{
w = document.documentElement.clientWidth;
h = document.documentElement.clientHeight;
}
//quirks mode
else
{
w = document.body.clientWidth;
h = document.body.clientHeight;
}
}
//w3c
else
{
w = window.innerWidth;
h = window.innerHeight;
}
return {width:w,height:h};
}
window.center = function()
{
var hWnd = (arguments[0] != null) ? arguments[0] : {width:0,height:0};
var _x = 0;
var _y = 0;
var offsetX = 0;
var offsetY = 0;
//IE
if(!window.pageYOffset)
{
//strict mode
if(!(document.documentElement.scrollTop == 0))
{
offsetY = document.documentElement.scrollTop;
offsetX = document.documentElement.scrollLeft;
}
//quirks mode
else
{
offsetY = document.body.scrollTop;
offsetX = document.body.scrollLeft;
}
}
//w3c
else
{
offsetX = window.pageXOffset;
offsetY = window.pageYOffset;
}
_x = ((this.size().width-hWnd.width)/2)+offsetX;
_y = ((this.size().height-hWnd.height)/2)+offsetY;
return{x:_x,y:_y};
}

function regionPop(e, point){
	var div = document.getElementById("regionpop");
	div.style.display = "block";
	e = e.id;
	
	switch(e)
	{
	case 'map_california':
	  div.innerHTML = '<h2>Districts in California</h2><ul><li>Los Angeles County</li><li>Rialto</li><li>San Bernardino City Unified School District</li><li>San Diego</li><li>Santa Ana</li></ul>';
	  $('#regionpop').append("<p class='rightHalf' onclick='javascript: closepop_region();'>close</p>");
	  break;
	case 'map_alaska':
	  div.innerHTML = '<h2>Districts in Alaska</h2><ul><li>Anchorage School District</li><li>Fairbanks North Star Borough School District (FNSBSD)</li></ul>';
	  $('#regionpop').append("<p class='rightHalf' onclick='javascript: closepop_region();'>close</p>");
	  break;
	case 'map_new_mexico':
	  div.innerHTML = '<h2>Districts in New Mexico</h2><ul><li>Albuquerque Public Schools</li><li>Cuba Independent Schools</li><li>Deming Public Schools</li><li>Gadsden Independent School District</li><li>Gallup-McKinley County Schools</li><li>Las Cruces Public Schools</li><li>Truth or Consequences Municipal School District</li><li>West Las Vegas Public Schools</li></ul>';
	  $('#regionpop').append("<p class='rightHalf' onclick='javascript: closepop_region();'>close</p>");
	  break;
	case 'map_oklahoma':
	  div.innerHTML = '<h2>Districts in Oklahoma</h2><ul><li>Oklahoma City Public Schools</li><li>Tulsa Public Schools</li></ul>';
	  $('#regionpop').append("<p class='rightHalf' onclick='javascript: closepop_region();'>close</p>");
	  break;
	case 'map_texas':
	  div.innerHTML = '<h2>Districts in Texas</h2><ul><li>Dallas</li><li>El Paso</li><li>Fort Worth Independent School District</li><li>Houston Independent School District</li><li>San Antonio Independent School District</li><li>Waco </li></ul>';
	  $('#regionpop').append("<p class='rightHalf' onclick='javascript: closepop_region();'>close</p>");
	  break;
	case 'map_louisiana':
	  div.innerHTML = '<h2>Districts in Louisiana</h2><ul><li>Caddo</li></ul>';
	  $('#regionpop').append("<p class='rightHalf' onclick='javascript: closepop_region();'>close</p>");
	  break;
	case 'map_south_dakota':
	  div.innerHTML = '<h2>Districts in South Dakota</h2><ul><li>Rapid City 51-4</li><li>Sioux Falls</li></ul>';
	  $('#regionpop').append("<p class='rightHalf' onclick='javascript: closepop_region();'>close</p>");
	  break;
	case 'map_minnesota':
	  div.innerHTML = '<h2>Districts in Minnesota</h2><ul><li>Minneapolis</li><li>St. Paul Public Schools</li></ul>';
	  $('#regionpop').append("<p class='rightHalf' onclick='javascript: closepop_region();'>close</p>");
	  break;
	case 'map_michigan':
	  div.innerHTML = '<h2>Districts in Michigan</h2><ul><li>Detroit Public Schools</li><li>Pontiac Academy For Excellence</li><li>Pontiac City School District</li><li>Willow Run Community Schools</li></ul>';
	  $('#regionpop').append("<p class='rightHalf' onclick='javascript: closepop_region();'>close</p>");
	  break;
	case 'map_wisconsin':
	  div.innerHTML = '<h2>Districts in Wisconsin</h2><ul><li>Milwaukee</li></ul>';
	  $('#regionpop').append("<p class='rightHalf' onclick='javascript: closepop_region();'>close</p>");
	  break;
	case 'map_illinois':
	  div.innerHTML = '<h2>Districts in Illinois</h2><ul><li>Aurora East School District 131</li><li>Chicago</li><li>Cicero School District</li><li>East St Louis School District 189</li><li>Joliet Public School District 86</li><li>Joliet Township High School District 204</li><li>Rockford Public Schools District 205</li><li>Roxana Community School District #1</li><li>Waukegan Community School District #60</li></ul>';
	  $('#regionpop').append("<p class='rightHalf' onclick='javascript: closepop_region();'>close</p>");
	  break;
	case 'map_missouri':
	  div.innerHTML = '<h2>Districts in Missouri</h2><ul><li>Kansas City Missouri</li><li>Riverview Gardens School District</li><li>St Louis Public Schools</li></ul>';
	  $('#regionpop').append("<p class='rightHalf' onclick='javascript: closepop_region();'>close</p>");
	  break;
	case 'map_ohio':
	  div.innerHTML = '<h2>Districts in Ohio</h2><ul><li>Cincinnati Public Schools</li><li>Dayton Liberty Academy</li><li>Dayton View Academy</li><li>Elyria City School District</li><li>Hope Academy Brown Street Campus</li><li>Hope Academy Northwest Campus</li><li>Lorain City School District</li><li>Toledo Public Schools</li></ul>';
	  $('#regionpop').append("<p class='rightHalf' onclick='javascript: closepop_region();'>close</p>");
	  break;
	case 'map_kentucky':
	  div.innerHTML = '<h2>Districts in Kentucky</h2><ul><li>Christian County</li><li>Fayette County Public Schools</li><li>Jackson County- KY</li><li>Jefferson County Board Of Education</li><li>McCreary County School District</li><li>Morgan County School District</li></ul>';
	  $('#regionpop').append("<p class='rightHalf' onclick='javascript: closepop_region();'>close</p>");
	  break;
	case 'map_tennessee':
	  div.innerHTML = '<h2>Districts in Tennessee</h2><ul><li>Memphis<li></li><li>Metropolitan Nashville Public Schools</li></ul>';
	  $('#regionpop').append("<p class='rightHalf' onclick='javascript: closepop_region();'>close</p>");
	  break;
	case 'map_new_york':
	  div.innerHTML = '<h2>Districts in New York</h2><ul><li>Albany City School District</li><li>Amityville Union Free School District</li><li>Hempstead Union Free School District</li><li>Horseheads Central School District</li><li>Middletown City School District- NY</li><li>New York City</li><li>Rome City School District - NY</li></ul>';
	  $('#regionpop').append("<p class='rightHalf' onclick='javascript: closepop_region();'>close</p>");
	  break;
	case 'map_new_jersey':
	  div.innerHTML = '<h2>Districts in New Jersey</h2><ul><li>Irvington Township (Irvington Public Schools) NJ</li><li>Newark Public Schools</li><li>Paterson Public Schools</li><li>PERTH AMBOY CITY-NJ</li><li>Plainfield City Public School District-NJ</li></ul>';
	  $('#regionpop').append("<p class='rightHalf' onclick='javascript: closepop_region();'>close</p>");
	  break;
	case 'map_virginia':
	  div.innerHTML = '<h2>Districts in Virginia</h2><ul><li>Alexandria City Public Schools-VA</li><li>Fairfax County School Board</li><li>Hampton City Schools</li><li>Newport News City Public Schools</li><li>Petersburg City Public Schools</li><li>Roanoke City Schools</li><li>Suffolk Public Schools</li></ul>';
	  $('#regionpop').append("<p class='rightHalf' onclick='javascript: closepop_region();'>close</p>");
	  break;
	case 'map_south_carolina':
	  div.innerHTML = '<h2>Districts in South Carolina</h2><ul><li>Aiken<li></li><li>Charleston County School District</li></ul>';
	  $('#regionpop').append("<p class='rightHalf' onclick='javascript: closepop_region();'>close</p>");
	  break;
	case 'map_georgia':
	  div.innerHTML = '<h2>Districts in Georgia</h2><ul><li>Atlanta Public Schools</li><li>Baldwin County- GA</li><li>Bibb County Public Schools</li><li>Clayton</li><li>Cobb County School District</li><li>Dougherty</li><li>Douglas County School District</li><li>Fulton County Public Schools</li><li>Griffin Spalding County School System</li><li>Muscogee School District</li><li>Newton County School</li><li>Richmond County School District- GA.</li><li>Savannah-Chatham County Public Schools</li><li>Valdosta City School District</li></ul>';
	  $('#regionpop').append("<p class='rightHalf' onclick='javascript: closepop_region();'>close</p>");
	  break;
	case 'map_florida':
	  div.innerHTML = '<h2>Districts in Florida</h2><ul><li>Escambia</li></ul>';
	  $('#regionpop').append("<p class='rightHalf' onclick='javascript: closepop_region();'>close</p>");
	  break;
	case 'map_puerto_rico':
	  div.innerHTML = '<h2>Districts in Puerto Rico</h2>';
	  $('#regionpop').append("<p class='rightHalf' onclick='javascript: closepop_region();'>close</p>");
	  break;
	case 'map_dc':
	  div.innerHTML = '<h2>Districts in District of Columbia</h2><ul><li>Cesar Chavez Public Charter-DC</li><li>District Of Columbia Public Schools</li><li>Friendship Public Charter School</li><li>Hyde Leadership Public Charter School</li><li>Ideal Academy Public Charter School District</li><li>Meridian Public Charter School- DC.</li><li>Tree of Life Community Public Charter School</li></ul>';
	  $('#regionpop').append("<p class='rightHalf' onclick='javascript: closepop_region();'>close</p>");
	  break;
	case 'map_delaware':
	  div.innerHTML = '<h2>Districts in Delaware</h2><ul><li>Christina School District</li></ul>';
	  $('#regionpop').append("<p class='rightHalf' onclick='javascript: closepop_region();'>close</p>");
	  break;
	case 'map_massachusetts':
	  div.innerHTML = '<h2>Districts in Massachusetts</h2><ul><li>Attleboro</li><li>Berkshire Hills Regional School District- MA.</li><li>Boston Public Schools</li><li>Cambridge Public Schools</li><li>Chicopee Public Schools</li><li>Lawrence Public Schools</li><li>Northampton Public Schools</li><li>South Hadley School District</li><li>Springfield</li></ul>';
	  $('#regionpop').append("<p class='rightHalf' onclick='javascript: closepop_region();'>close</p>");
	  break;
	case 'map_rhode_island':
	  div.innerHTML = '<h2>Districts in Rhode Island</h2><ul><li>Providence Public Schools</li></ul>';
	  $('#regionpop').append("<p class='rightHalf' onclick='javascript: closepop_region();'>close</p>");
	  break;
	  
	case 'map_maryland':
	  div.innerHTML = '<h2>Districts in Maryland</h2><ul><li>Baltimore City Public School System</li><li>Prince George\'s County Public Schools</li></ul>';
	  $('#regionpop').append("<p class='rightHalf' onclick='javascript: closepop_region();'>close</p>");
	  break;
	  
	default:
	  div.innerHTML = '';
	}
}

function closepop_region(){
	var div = document.getElementById("regionpop");
	div.style.display = "none";
}



