// Newscenter General Scripts
// Author: Nathan Wiens
// Date: 04/18/09

// Event pop-up windows
function showEvent(url) {	 
	eventwindow = window.open(url, 'event', 'width=550,height=460,scrollbars=yes,resizable=yes,location=yes');
	eventwindow.focus();
//	if (window.focus) {eventwindow.focus();}
	return false;
}

function emailForm(headline){
//    var email = "";
    var story = window.location; 
    var mailto_link = 'mailto:?subject='+ headline +'&body='+ story;
    win = window.open(mailto_link,'emailWindow'); 
    if (win && win.open &&!win.closed) win.close();
 
} 

function sendToDelicious() {
	window.open('http://del.icio.us/post?url='+ encodeURIComponent(window.location) +'&title='+ encodeURIComponent(document.title), 'Del.icio.us');
	return false;
}

// Document Ready
$(function() {
	var web_field = $("#websearch input[type=text]");
	var people_field = $("#peoplesearch input[type=text]");
	var default_txt = 'SEARCH';

	$("#peoplesearch").hide();
	web_field.val(default_txt);
	web_field.addClass('default');
	people_field.val(default_txt);
	people_field.addClass('default');

	$("#searchweb").bind("click", function() {
		$("#peoplesearch").hide();
		$("#websearch").show();
		if (!people_field.hasClass('default')) {
			web_field.val(people_field.val());	
			web_field.removeClass('default');
			web_field.unbind('focus');
		}
	});

	$("#searchpeople").bind("click", function() { 
		$("#websearch").hide(); 
		$("#peoplesearch").show(); 
		if (!web_field.hasClass('default')) {
			people_field.val(web_field.val());
			people_field.removeClass('default');
			people_field.unbind('focus');
		}
	});

	web_field.bind("focus", function() { $(this).val(''); $(this).removeClass('default'); $(this).unbind(); });
	people_field.bind("focus", function() { $(this).val(''); $(this).removeClass('default'); $(this).unbind(); });

	$("#websearch").bind("submit", function() {
		if (web_field.val() == default_txt) {
			web_field.focus();
			return false;
		}
	});

	$("#peoplesearch").bind("submit", function() { 
		if (people_field.val() == default_txt) {
			people_field.focus();
			return false;
		}
	});

});