addDOMLoadEvent=(function(){var e=[],t,s,n,i,o,d=document,w=window,r='readyState',c='onreadystatechange',x=function(){n=1;clearInterval(t);while(i=e.shift())i();if(s)s[c]=''};return function(f){if(n)return f();if(!e[0]){d.addEventListener&&d.addEventListener("DOMContentLoaded",x,false);/*@cc_on@*//*@if(@_win32)d.write("<script id=__ie_onload defer src=//0><\/scr"+"ipt>");s=d.getElementById("__ie_onload");s[c]=function(){s[r]=="complete"&&x()};/*@end@*/if(/WebKit/i.test(navigator.userAgent))t=setInterval(function(){/loaded|complete/.test(d[r])&&x()},10);o=w.onload;w.onload=function(){x();o&&o()}}e.push(f)}})();

function gQV(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0].toLowerCase() == variable) return pair[1];    
  }   
}

var videos = [];
videos[videos.length] = { title: 'Featured Videos', pid : '1649964947' };
videos[videos.length] = { title: 'Author Interviews', pid : '1640183585' };
videos[videos.length] = { title: 'Exploring Books', pid : '1640149541' };
videos[videos.length] = { title: 'Scholastic News', pid : '1648673895' };
videos[videos.length] = { title: 'Professional Development', pid : '1649964945' };
videos[videos.length] = { title: 'Product Information', pid : '1649964946' };



var initVid;
var which = 0;

var pid = gQV("pid");
if ( pid != null ) {

	for (var i=0; i<videos.length; i++) { 
		if ( pid == videos[i].pid ) {
			which = i;
			break;
		} 
	}
	
	//initVid = videos[which].pid;
}


addDOMLoadEvent(function(){
	jQuery('#schlVideoCategory a[title=' + videos[which].title + ']').addClass("on");
	var q = location.search ? location.search.replace(/pid/i, 'pID') : '?pID=' + videos[which].pid;
	jQuery('#schlVideos').attr('src', '/content/includes/www/video.html'  + q);
});
//initVid = videos[0]['pid'];



function schlSetCat(which) {
	jQuery('#schlVideoCategory a').removeAttr("class");
	which.className = "on";
	var q = '?pID=' + which.href.split('/').pop();
	jQuery('#schlVideos').attr('src', '/content/includes/www/video.html'  + q);
}
