/* NAVIGATION SCRIPT */

startList = function() {

	if (document.all&&document.getElementById) {

		navRoot = document.getElementById("nav");

		for (i=0; i<navRoot.childNodes.length; i++) {

			node = navRoot.childNodes[i];

			if (node.nodeName=="LI") {

				node.onmouseover=function() {

					this.className+=" over";

					this.style.zIndex = 100;

  				}

  				node.onmouseout=function() {

  					this.className=this.className.replace(" over", "");

  					this.style.zIndex = 1;

				}

			}

		}

 	}

}

window.onload=startList;



//boxy
$(function() {
  $('.boxy').boxy();
});


var allDialogs = [];

var seq = 0;
function popup_register(options, title) {
	options = $.extend({title: " "+title}, options || {});
	var dialog = new Boxy("<div style='width:500px; height:200px;'><p><a href='index.php?action=register_collab'>Click here to register as a Collaborator</a> <br />Scientific collaborators, in many cases, are researchers who utilize &ldquo;broader impact&rdquo; resources from their federally funded grants to obtain outreach via this multi-faceted communications program.  As a collaborator, you can work directly with your local public broadcasting station to promote your research findings on-air and on-line to enhance the learning of children, teens and adults of all ages!  E-mail us here with any questions.  Our goal, simply put, is to be the most in-depth, credible and most easily understood science initiative in the world. </p> <p><a href='index.php?action=register_public'>Registration for children, teens and the general public</a> <br>HearTheAnswer.com is a cutting-edge tool for learning about and keeping pace with some of the greatest scientific discoveries on Earth and beyond!  People of all ages who register (it's free) can choose topics and/or scientists of interest and be notified anytime anything new of interest is posted on the site.  Become part of our community!</p> <!--<a href='#' onclick='Boxy.get(this).hide(); return false'>Close</a>--></p></div>", options);
	allDialogs.push(dialog);
	return false;
}

function popup_whyregister(options, title) {
	options = $.extend({title: " "+title}, options || {});
	var dialog = new Boxy("<div style='width:500px; height:200px;'><b>Why Register?</b><br/><br/>By taking advantage of the free registration option you’ll gain the ability to keep pace with scientific, environmental and technological discoveries as they’re announced – and become part of a community of like-minded teachers, students and others with inquisitive minds.<br/><br/>By registering, you can manage your subscriptions - and be one-click away from:<ul style=\"margin-left:20px;\"><li>Following your favorite researcher(s);</li><li>Following your favorite fields of study;</li><li>Learning about other researchers making discoveries in sectors of interest to you;</li><li>Automatically adding new media to your customized playlist.</li></ul></div>", options);
	allDialogs.push(dialog);
	return false;
}

function delete_category(options, qa_cat_id) {
	options = $.extend({title: "Confirm"}, options || {});
	var dialog = new Boxy("<div style='width:500px; height:150px;'><p>Do you really wish to delete this category? Deleting will also remove its sub categories. This action cannot be undone. <br> <div style='text-align:center; margin-top:10px; font-weight:bold;'><input type=button class='submit' onclick=\"javascript:window.open('index.php?action=qa_categories&qa_cat_id="+qa_cat_id+"&what=delete_category', '_self');\" value=Delete> &nbsp; <input type=button class='submit' onclick='Boxy.get(this).hide(); return false' value=Cancel> </div> </p></div>", options);
	allDialogs.push(dialog);
	return false;
}

function delete_subcategory(options, qa_subcat_id) {
	options = $.extend({title: "Confirm"}, options || {});
	var dialog = new Boxy("<div style='width:500px; height:150px;'><p>Do you really wish to delete this sub category? This action cannot be undone. <br> <div style='text-align:center; margin-top:10px; font-weight:bold;'><input type=button class='submit' onclick=\"javascript:window.open('index.php?action=qa_categories&qa_subcat_id="+qa_subcat_id+"&what=delete_subcategory', '_self');\" value=Delete> &nbsp; <input type=button class='submit' onclick='Boxy.get(this).hide(); return false' value=Cancel> </div> </p></div>", options);
	allDialogs.push(dialog);
	return false;
}

function delete_question(options, my_id) {
	options = $.extend({title: "Confirm"}, options || {});
	var dialog = new Boxy("<div style='width:500px; height:150px;'><p>Do you really wish to delete this question? This action cannot be undone. <br> <div style='text-align:center; margin-top:10px; font-weight:bold;'><input type=button class='submit' onclick=\"javascript:window.open('index.php?action=main&qa_question_id="+my_id+"&what=delete_question', '_self');\" value=Delete> &nbsp; <input type=button class='submit' onclick='Boxy.get(this).hide(); return false' value=Cancel> </div> </p></div>", options);
	allDialogs.push(dialog);
	return false;
}

function delete_answer(options, my_id) {
	options = $.extend({title: "Confirm"}, options || {});
	var dialog = new Boxy("<div style='width:500px; height:150px;'><p>Do you really wish to delete this answer? This action cannot be undone. <br> <div style='text-align:center; margin-top:10px; font-weight:bold;'><input type=button class='submit' onclick=\"javascript:window.open('index.php?action=main&qa_answer_id="+my_id+"&what=delete_answer', '_self');\" value=Delete> &nbsp; <input type=button class='submit' onclick='Boxy.get(this).hide(); return false' value=Cancel> </div> </p></div>", options);
	allDialogs.push(dialog);
	return false;
}


function alert_box(options, title, msg) {
	options = $.extend({title: title}, options || {});
	var dialog = new Boxy("<div style='width:450px; height:100px;'><p><div style='text-align:center;'>"+msg+"<br><input type=button class='submit' onclick='Boxy.get(this).hide(); return false' style='margin-top:10px' value=Close> </div> </p></div>", options);
	allDialogs.push(dialog);
	return false;
}


function playlist_edit_box(options, qa_answer_id) {
	options = $.extend({title: 'Playlist'}, options || {});
	var dialog = new Boxy("<div style='width:400px; height:160px;padding:0px;margin:0;'><iframe name='pl_edit' src='dsp_playlist_edit.php' width='400px' height='160px' frameborder=0 style='padding:0;margin:0;' ></iframe></div> ", options);
	allDialogs.push(dialog);
	return false;
}

function favorite_audio_edit_box(options) {
	options = $.extend({title: 'Favorite Audio'}, options || {});
	var dialog = new Boxy("<div style='width:400px; height:160px; padding:0px;margin:0;'><iframe name='pl_edit' src='dsp_favorite_audio_edit.php' width='400px' height='160px' frameborder=0 style='padding:0;margin:0;' ></iframe></div> ", options);
	allDialogs.push(dialog);
	return false;
}

function favorite_collab_edit_box(options) {
	options = $.extend({title: 'Favorite Collab'}, options || {});
	var dialog = new Boxy("<div style='width:400px; height:160px;padding:0px;margin:0;'><iframe name='pl_edit' src='dsp_favorite_collab_edit.php' width='400px' height='160px' frameborder=0 style='padding:0;margin:0;' ></iframe></div> ", options);
	allDialogs.push(dialog);
	return false;
}

function popup_howtoblog(options) {
	title = 'How to post your blog';
	options = $.extend({title: " "+title}, options || {});
	var dialog = new Boxy("<div style='width:500px; height:200px;'><p><b>How to post on your blog?</b> Managing your Blog on Hear The Answer is easy. You can add new entries by clicking the link &ldquo;Add new blog entry&rdquo;. You can Edit or Delete an existing Blog Entry by finding it in the list of entries, then clicking either the trash can icon (delete), or the pecil icon(edit). When writing or editing an entry you have several tools available to make text bold, underlined, italic, to help you add emphasis. With each entry you can also choose wether or not to allow comments. Your blog will be searchable, so we have included a optional keyword field. Adding keywords to each entry can help people find the most relevant information. When you are done click the button at the bottom to Add or Edit your blog entry. Thats it!</div>", options);
	allDialogs.push(dialog);
	return false;
}

function recent() { return allDialogs[allDialogs.length-1]; }
function tweenUp() { recent().tween(400,400); }
function tweenDown() { recent().tween(100,100); }
function getTitle() { alert(recent().getTitle()); }
function setTitle() { recent().setTitle(prompt("Enter new title:")); }





/* for audio player */
function popwin(url,ttl,w,h){	
	vjtop = (screen.height - h)/2;
   	vjleft = (screen.width - w)/2;
	window.open(url,ttl,'width='+w+',height='+h+',scrollbars=1,top='+vjtop+',left='+vjleft);
}

function AddAsFavoriteCollab(user_id) {
	$.ajax({
		type: "POST",
		url: "ajax_fav_collab_ae.php",
		data: "user_id=" + user_id + "&process=add",
		success: function(data) {
			eval(data);
		}
	});
}
	
function RemoveAsFavoriteCollab(user_id) {
	$.ajax({
		type: "POST",
		url: "ajax_fav_collab_ae.php",
		data: "user_id=" + user_id + "&process=remove",
		success: function(data) {
			eval(data);
		}
	});
}

