	
	function setBodyID(val){
		if(val != ''){
			switch(val){
				case "1047":
  					document.body.setAttribute('id','homepage');
  					break;

				case "1159":
  					document.body.setAttribute('id','search');
  					break;

				case "1169":
  					document.body.setAttribute('id','search');
  					break;

				case "1632":
  					document.body.setAttribute('id','search');
  					document.body.setAttribute('class','fourOhFour');
					break;

				//for home 2
				case "1572":
  					document.body.setAttribute('id','homepage');
  					break;

			}
		}
	}


	function page(p){
		var strHref = window.location.href;
		var subStrHref = "";
		
		if(strHref.indexOf("page") > 0){
			if(strHref.indexOf("page=") < strHref.indexOf("&")){
				subStrHref = strHref.substring(strHref.indexOf("page="),strHref.indexOf("&"));
			}else{
				subStrHref = strHref.substring(strHref.indexOf("page="));
			}
			strHref = strHref.replace(subStrHref,"page=" + p);
			location.href = strHref;
		}else{
			if(strHref.indexOf("?") > 0){
				location.href = strHref + "&page=" + p;
			}else{
				location.href = location.href + "?page=" + p;
			}
		}
	}


	function school(s){
		var strHref = window.location.href;
		var subStrHref = "";
		
		if(strHref.indexOf("school=") > 0){
			if(strHref.indexOf("&") > strHref.indexOf("school=")){
				subStrHref = strHref.substring(strHref.indexOf("school="),strHref.indexOf("&"));
			}else{
				subStrHref = strHref.substring(strHref.indexOf("school="));
			}
			strHref = strHref.replace(subStrHref,"school=" + s);
			location.href = strHref;
		}else{
			if(strHref.indexOf("?") > 0){
				if(strHref.indexOf("page=") > 0){
					subStrHref = strHref.substring(strHref.indexOf("page="));
					strHref = strHref.replace(subStrHref,"school=" + s);
					location.href = strHref;
				}else{
					location.href = location.href + "&school=" + s;
				}
			}else{
				location.href = location.href + "?school=" + s;
			}
		}
	}


	function sort(sortBy){
		var strHref = window.location.href;
		var subStrHref = strHref.substring(strHref.indexOf("?"));
		strHref = strHref.replace(subStrHref,"");		
		location.href = strHref + "?sort=" + sortBy;
	}


	//sets main nav 'on' state
	function setNav(p){

		switch(p){
			case "1047":
  				document.getElementById('home').className='on';
  				break;

			case "1048":
  				document.getElementById('watch').className='on';
  				break;

				case "1097":
  					document.getElementById('watch').className='on';
  					break;

			case "1288":
  				document.getElementById('centers').className='on';
  				break;

			case "1583":
  				document.getElementById('why').className='on';
  				break;

				case "1584":
  					document.getElementById('why').className='on';
  					break;

				case "1585":
  					document.getElementById('why').className='on';
  					break;

				case "1586":
  					document.getElementById('why').className='on';
  					break;

				case "1587":
  					document.getElementById('why').className='on';
  					break;

				case "1588":
  					document.getElementById('why').className='on';
  					break;

				case "1589":
  					document.getElementById('why').className='on';
  					break;

			case "1049":
  				document.getElementById('watch').className='on';
  				break;

		}
	}


	function setTabs(){
		var strHref = window.location.href;
		var subStrHref = "";
		if(strHref.indexOf("sort") < strHref.indexOf("&")){
			subStrHref = strHref.substring(strHref.indexOf("sort="),strHref.indexOf("&"));
		}else{
			subStrHref = strHref.substring(strHref.indexOf("sort="));
		}
		var sortStr = subStrHref.substring(5);

		//for searchresults page
		if(thisPage == '1159' && sortStr != 'topics'){
			sortStr = "videos";
		}		
		if(sortStr != ""){
			switch(sortStr){
				//case "mostPopular":
				//document.getElementById('mostPopular').className='on';
				//break;

				//case "mostRecent":
				//document.getElementById('mostRecent').className='on';
				//break;

				case "schools":
				document.getElementById('schools').className='on';
				break;

				case "category":
				document.getElementById('categories').className='on';
				break;

				case "videoSearch":
				document.getElementById('videoSearch').className='on';
				break;

				case "topics":
				document.getElementById('topics').className='on';
				break;

				default:
				document.getElementById('videoSearch').className='on';
				break;
			}	
		}
	}
	

	function moreVideos(){
		top.location.href="watch-videos.aspx";
	}


	function search(){
		var keyword = document.getElementById('searchKeyword').value;
		location.href="/search-results.aspx?keyword=" + keyword;
	}

	function searchRefine(){
		var keyword = document.getElementById('searchKeywordRefine').value;
		location.href="/search-results.aspx?keyword=" + keyword;
	}

	function search404(){
		var keyword = document.getElementById('searchKeyword404').value;
		location.href="/search-results.aspx?keyword=" + keyword;
	}

	function searchVideos(){
		var strHref = window.location.href;
		var subStrKeyword = "";
		if(strHref.indexOf("keyword=") < strHref.indexOf("&")){
			subStrKeyword = strHref.substring(strHref.indexOf("keyword="),strHref.indexOf("&"));
		}else{
			subStrKeyword = strHref.substring(strHref.indexOf("keyword="));
		}
		location.href="?"+subStrKeyword+"&sort=videos";
	}


	function searchTopics(){
		var strHref = window.location.href;
		var subStrKeyword = "";
		if(strHref.indexOf("keyword=") < strHref.indexOf("&")){
			subStrKeyword = strHref.substring(strHref.indexOf("keyword="),strHref.indexOf("&"));
		}else{
			subStrKeyword = strHref.substring(strHref.indexOf("keyword="));
		}
		location.href="?"+subStrKeyword+"&sort=topics";
	}


	function showAll(){
		var strHref = window.location.href;
		if(strHref.indexOf("show=") < 0){
			location.href=location.href + "&show=all";
		}
	}


	function yt_embed(videoID){
		document.getElementById('embedCode').value = '<object width="560" height="340"><param name="movie" value="http://www.youtube.com/v/'+videoID+'&hl=en&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'+videoID+'&hl=en&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object>';
	}


