//Yahoo search additions
// Activeaated 11/29/07 - 4:47est
function searchFormSubmit(form) {

//     if (form.aff.value == 'archives' || form.aff[1].checked == true) {
     if ($('input[name=aff]:checked').val() == 'archives') {
         window.location = "http://www.newslibrary.com/nlsearch.asp?search_mode=all&action=search&date_mode=year&year=last+180+days&sort=d%3Ah&nitems=10&region=we&dbquery=" + form.keywords.value;
             return false;
     }
//     else if (form.aff[2].checked == true || form.aff.value == 'web') {
     else if ($('input[name=aff]:checked').val() == 'web') {
         var encoded_keywords = encodeURIComponent(form.keywords.value);
         var section_num = '236';
         var url_version = 'ysr';
         var params = 'product=Yahoo%2COverture&' +
                      'collection=WEB&' +
                      'live_template=http%3A%2F%2Fwww.kansas.com%2F' + section_num + '%2Fv-' + url_version + '%2Findex.html&' +
                      'error_template=http%3A%2F%2Fwww.kansas.com%2F' + section_num + '%2Fv-yerr%2Findex.html&' +
                      'preview_template=http%3A%2F%2Fpreview.kansas.com%2F' + section_num + '%2Fv-' + url_version + '%2Findex.html&' +
                      'results_per_page=10' +
                      '&prop_related=1&prop_dym=1';
         window.location = "http://search.kansas.com/search-bin/search.pl.cgi?sf_Keywords=" + encoded_keywords + '&' + params;

         return false;
     }

     return true;
 }

// getParams *******************************************************************

function getParams(params) {
   var Params = new Object ();
   if ( ! params ) return Params; // return empty object
   var Pairs = params.split(/[;&]/);
   for ( var i = 0; i < Pairs.length; i++ ) {
      var KeyVal = Pairs[i].split('=');
      if ( ! KeyVal || KeyVal.length != 2 ) continue;
      var key = unescape( KeyVal[0] );
      var val = unescape( KeyVal[1] );
      val = val.replace(/\+/g, ' ');
      Params[key] = val;
   }
   return Params;

}

// end getParams *****************************************************************


// search **********************************************************************
//Rename this when yahoo goes live
function searchFormSubmit_OLDVERSION(form) {
	if (form.aff[1].checked == true) {
		// this address needs to be changed once search is set up
		window.location = "http://www.newslibrary.com/nlsearch.asp?search_mode=all&action=search&date_mode=year&year=last+180+days&sort=d%3Ah&nitems=10&region=WE&dbquery=" + form.keywords.value;
		return false;
	} else if (form.aff[2].checked == true) {
		window.location = "http://www.kansas.com/cgi-bin/mi/overture/overture.pl?Keywords=" + form.keywords.value;
		return false;
	}
	return true;
}

// end search ******************************************************************

function today_string() {
	// dependant on date functions defined in mi-utilities.js
	var today = new Date();
	return today.getDayString()+', '+today.getMonthString()+' '+today.getDate()+', '+today.getFullYear();
}


// script for accessible popups
var _POPUP_FEATURES = 'location=0,toolbar=0,statusbar=1,menubar=0,width=350,height=450';
function isUndefined(v) {var undef;return v===undef;}
function raw_popup(url, target, features) {if (isUndefined(features)) features=_POPUP_FEATURES;if (isUndefined(target)) target='_blank';var theWindow = window.open(url, target, features+",resizable=1");theWindow.focus();return theWindow;}
function link_popup(src,features){return raw_popup(src.getAttribute('href'),src.getAttribute('target')||'_blank',features);}


