if ( !window.SCHL ) { window.SCHL = {}; } else if ( typeof window.SCHL != 'object' ) { throw new Error("SCHL not an object."); }
SCHL.tc = {
	btns : ['', '218', '200', '190', '226'],
	ddContents : ['',
	'<a href="' + CONTENT_HOST + '/browse/lessonplans.jsp?lnkid=TNav:TR:Lesson Plans&ESP=TR/ib//acq/lesson_plans_tnav_TR///nav/txtl////" onclick="saveCookie(\'header\',\'teacherTeach\');">Lesson Plans</a><a href="http://teachershare.scholastic.com/?lnkid=TNav:TR:TeacherShare&ESP=TR/ib//acq/teacher_share_tnav_TR///nav/txtl////">TeacherShare</a><a href="' + TEACHER_HOST + '/teachingstrategies/?lnkid=TNav:TR:Strategies&ESP=TR/ib//acq/strategies_tnav_TR///nav/txtl////">Strategies</a><a href="' + TEACHER_HOST + '/tools/?lnkid=TNav:TR:Tools&ESP=TR/ib//acq/tools_tnav_TR///nav/txtl////">Tools</a><a href="' + DOTCOM_HOST + '/premium/?lnkid=TNav:TR:Printables and Mini-Books&ESP=PRT/ib//acq/printables_and_minibooks_tnav_TR///nav/txtl////">Printables &amp; Mini-Books</a><a href="' + TEACHER_HOST + '/newteacher/index.htm?lnkid=TNav:TR:New Teacher&ESP=TR/ib//acq/new_teacher_tnav_TR///nav/txtl////">New Teacher</a><a href="' + DOTCOM_HOST + '/freeprograms/?lnkid=TNav:TR:Free Programs and Giveaways&ESP=SMP/ib//acq/free_program_and_giveaways_tnav_TR///nav/txtl////">Free Programs &amp; Giveaways</a>',
	'<a href="' + CONTENT_HOST + '/browse/scholasticNews.jsp?FromBrowseMod=true&Ns=Pub_Date_Sort|1&CurrPage=scholasticNews.jsp&TopicValue=Scholastic%20News&lnkid=TNav:SA:Scholastic News&ESP=SA/ib//acq/scholastic_news_tnav_SA///nav/txtl////">Scholastic News</a><a href="' + TEACHER_HOST + '/activities/clf/tguidesitemap.htm?lnkid=TNav:SA:Computer Lab Favorites&ESP=SA/ib//acq/comp_lab_fav_tnav_SA///nav/txtl////">Computer Lab Favorites</a><a href="' + TEACHER_HOST + '/dictionary/?lnkid=TNav:SA:Word Wizard Dictionary&ESP=SA/ib//acq/word_wiz_dict_tnav_SA///nav/txtl////">Word Wizard Dictionary</a><a href="' + TEACHER_HOST + '/writewit/?lnkid=TNav:SA:Write and Publish&ESP=SA/ib//acq/write_publish_tnav_SA///nav/txtl////">Write &amp; Publish</a><a href="' + TEACHER_HOST + '/activities/swyar/?lnkid=TNav:SA:Reading Response&ESP=SA/ib//acq/reading_response_tnav_SA///nav/txtl////">Reading Response</a><a href="' + TEACHER_HOST + '/whiteboards/languagearts.htm?lnkid=TNav:SA:Interactive Whiteboard&ESP=SA/ib//acq/interactive_WB_tnav_SA///nav/txtl////">Interactive Whiteboard</a>',
	'<a href="' + TBW_CONTENT_HOST + '/tbw/homePage.do?lnkid=TNav:BA:Teacher Book Wizard&ESP=TBW/ib//acq/teach_book_wiz_tnav_BA///nav/txtl////">Teacher Book Wizard</a><a href="' + TEACHER_HOST + '/products/tradebooks/?lnkid=TNav:BA:New and Noteworthy&ESP=BA/ib//acq/news_noteworthy_tnav_BA///nav/txtl////">New &amp; Noteworthy</a><a href="' + TBW_CONTENT_HOST + '/tbw/viewBooklistExchangeHomepage.do?lnkid=TNav:BA:List Exchange&ESP=TBW/ib//acq/list_exchange_tnav_BA///nav/txtl////">List Exchange</a><a href="' + TEACHER_HOST + '/read/all-about-authors.htm?lnkid=TNav:BA:All About Authors&ESP=BA/ib//acq/all_about_authors_tnav_BA///nav/txtl////">All About Authors</a><a href="' + TEACHER_HOST + '/read/teaching-with-books.htm?lnkid=TNav:BA:Teaching With Books&ESP=BA/ib//acq/teach_w_books_tnav_BA///nav/txtl////">Teaching With Books</a>',
	'<a href="' + TEACHER_HOST + '/products/read180/?lnkid=TNav:Products:READ 180&ESP=PI/ib//acq/READ_180_tnav_PI///nav/txtl////" style="font-style:italic;">READ 180</a><a href="' + TEACHER_HOST + '/products/foundational_reading_phonics/system44/?lnkid=TNav:Products:System 44&ESP=PI/ib//acq/System_44_tnav_PI///nav/txtl////">System 44</a><a href="' + TEACHER_HOST + '/products/classroombooks/index.asp?lnkid=TNav:Products:Classroom Books&ESP=PI/ib//acq/Classroom_Books_tnav_PI///nav/txtl////">Classroom Books</a><a href="' + TEACHER_HOST + '/products/guidedreading/index.htm?lnkid=TNav:Products:Guided Reading&ESP=PI/ib//acq/Guided_Reading_tnav_PI///nav/txtl////">Guided Reading</a><a href="' + TEACHER_HOST + '/products/expert21/index.htm?lnkid=TNav:Products:Expert 21&ESP=PI/ib//acq/Expert_21_tnav_PI///nav/txtl////">Expert 21</a><a href="' + TEACHER_HOST + '/products/scholasticprofessional/index.htm?lnkid=TNav:Products:Scholastic Professional&ESP=PI/ib//acq/Scholastic_Prof_tnav_PI///nav/txtl////">Scholastic Professional</a><a href="' + DOTCOM_HOST + '/economicrecovery/index.htm?lnkid=TNav:Products:Economic Stimulus Fund&ESP=PI/ib//acq/Econ_Stim_Fund_tnav_PI///nav/txtl////">Economic Stimulus Funding</a><a href="' + TEACHER_HOST + '/products/product_info/contact_us.asp?lnkid=TNav:Products:Request a Catalog&ESP=PI/ib//acq/Catalog_tnav_PI///nav/txtl////">Request a Catalog</a><a href="' + TEACHER_HOST + '/products/product_info/index.asp?lnkid=TNav:Products:See All Products&ESP=PI/ib//acq/See_Prod_tnav_PI///nav/txtl////">See All Products</a>'
	],
	current : '',
	currentID : '',
	dd : false,
	searchDefaultTab : '2',
	searchModule : ['','scholastic.com','book wizard','student activites','lesson plans','teacher store'],
	searchDefaultValue : { 'tab1' : '', 'tab2' : 'Enter Author / Title / Keyword', 'tab3' : 'Search Student Activities', 'tab4' : 'Search Lesson Plans', 'tab5' : 'Search Item #, Keyword, Product Name' },
	searchAction : {
		'tab1' : CONTENT_HOST + '/browse/search?query=',
		'tab2' : TBW_CONTENT_HOST + '/tbw/quickSearch.do?N=1763&Ntk=TBW_QuickSearch_SI&Ntx=mode+matchallpartial&Ne=1314&Ntt=',
		'tab3' : CONTENT_HOST + '/browse/search?Nr=OR(Resource_Type:Online Activity)&query=',
		'tab4' : CONTENT_HOST + '/browse/search?Nr=OR(Resource_Type:Lesson Plan,Resource_Type:Informal Lesson Article,Resource_Type:Unit Plan)&query=',
		'tab5' : 'http://shop.scholastic.com/webapp/wcs/stores/servlet/SearchEndecaCmd?storeId=10001&langId=-1&catalogId=10002&viewParam=Search&searchTerm='
	}
}

jQuery('#header .searchTabs a').each(function(index){
	jQuery(this).click(function(){
		searchTab(this, index+1);
		return false;
	});	
});
jQuery('#header input.txtSearch').bind('focus', function(){ tcClearField(this, SCHL.tc.searchDefaultTab); });

var $tcDD, tcTimer, tcDelayHide, tcDisappearDelay = 1, tcVisible;
				
jQuery('#tcNav a').each(function(index){		
	if (index == 0) { return; }
	jQuery(this).bind('mouseover', function(){
		$this = jQuery(this);
		clearTimeout(tcTimer);
		tcTimer = setTimeout( function() {
			setUpDD($this);													
			populateDD(index);				
			setDDPosition($this, index);	
			$this.addClass('hov');
			$tcDD.show();			
			tcVisible = true;					
		}, 1);     
	});		
	jQuery(this).bind('mouseout', function(){
		$this = jQuery(this);
		if (tcVisible) {
			tcDelayHide=setTimeout(function() {
				jQuery('#tcNav a').removeClass('hov');
				$tcDD.hide();						
				cVisible = false;
			},tcDisappearDelay);
		}
		else { clearTimeout(tcTimer); }
	});
});

function setUpDD() {
	if( !jQuery('#tc-dd').get(0) ) {
		jQuery('#header').append('<div id="tc-dd"></div>');	
		$tcDD = jQuery('#tc-dd');				
		$tcDD.bind('mouseover', function(){
			if ( typeof tcDelayHide != "undefined" ) clearTimeout(tcDelayHide);
		});
		$tcDD.bind('mouseout', function(){
			if (tcVisible) {
				tcDelayHide=setTimeout(function() {
					jQuery('#tcNav a').removeClass('hov');
					$tcDD.hide();
					tcVisible = false;
				},tcDisappearDelay);
			}
			else {
				clearTimeout(tcTimer);
			}
		});
	}
}
function populateDD(index) { jQuery('#tc-dd').html(SCHL.tc.ddContents[index]); }

function setDDPosition(obj, index) {
	var offset = obj.offset();
	$tcDD.css({left: offset.left - 1 + 'px', top: offset.top + 25 + 'px', width : SCHL.tc.btns[index] + 'px'});
}

function searchTab(which, tab) {
	SCHL.tc.searchDefaultTab = tab;
	jQuery('.searchTabs li').removeClass('onsup').removeClass('on');
	jQuery(which).parent().addClass('on').prev('li').addClass('onsup');
	document.forms['searchForm'].query.value = SCHL.tc.searchDefaultValue['tab'+ tab];	
}

function tcClearField(){ if (document.forms['searchForm'].query.value == SCHL.tc.searchDefaultValue['tab' + SCHL.tc.searchDefaultTab]) { document.forms['searchForm'].query.value = ""; } } 

function searchSubmit() {
	q = document.searchForm.query.value;
	q=q.trim();
	if(q == '') { return false; }
	else {
		var s = s_gi('schosmclicks');
		s.linkTrackVars='prop1,prop2';
		s.trackingServer='stats.scholastic.com';
		s.prop1=SCHL.tc.searchModule[SCHL.tc.searchDefaultTab];
		s.prop2=q;
		s.tl(true,'o',SCHL.tc.searchModule[SCHL.tc.searchDefaultTab] + ':' + q);
		window.location = SCHL.tc.searchAction['tab' + SCHL.tc.searchDefaultTab] + q;
	    return false;
	}
}