////////////////////////////////////////// // // results.js // // javascript code for results page // ////////////////////////////////////////// function init() { //document.getElementById('dsettings').style.display = 'block'; showPane(0); showPane(1); showFeaturesPane(3); // default to showing saved searches } //todo: preload images // toggles display of settings / saved searches panes function showPane(pane_idx) { var d = document.getElementById(panes[pane_idx]); var bar, i; // set refs to objects for passed index if (pane_idx == 1) // saves { bar = document.getElementById('hbarr'); // set ref to clicked toggle bar div i = document.getElementById('hbarr_i'); // set ref to image in clicked div } else // settings { bar = document.getElementById('hbarl'); i = document.getElementById('hbarl_i'); } if (d != null) { // toggle the display // turn on if (d.style.display == 'none' || d.style.display == '') { // set right or left border of clicked bar div //if (pane_idx == 0) // settings //{ //bar.style.borderRight = "solid white 1px"; //} d.style.display = 'block'; // on // flip tab image i.src = 'images/' + tab_imgs[pane_idx] + '_hide.gif'; if (pane_idx == 1) repositionSLDiv(); } else // turn off { // turn border off on clicked div bar.style.border = "0px;" d.style.display = 'none'; // off // flip up/down button & label i.src = 'images/' + tab_imgs[pane_idx] + '_show.gif'; if (pane_idx == 1) repositionSLDiv(-1); } } } // showPane(pane_idx) // show / hide "features" link lists function showFeaturesPane(idx) { // hide last pane & swap any 'down' btn img if (g_last_pane_div != null) g_last_pane_div.style.display = 'none'; if (g_last_pane_img != null) swap_image(g_last_pane_img, -1); // remember current div & img g_last_pane_div = document.getElementById(lists[idx]); g_last_pane_img = document.getElementById('isaves' + idx); // swap current image if (null != g_last_pane_div) { swap_image(g_last_pane_img); // show div g_last_pane_div.style.display = 'block'; repositionSLDiv(); } } // showFeaturesPane() // move sponsored links div to bottom of link list div function repositionSLDiv(dir) { // find bottom of link list div var dspons = document.getElementById('dsl_right'); // sponsored links div var dlinks = document.getElementById('dres-links'); // top right links div var xTop = dlinks.offsetTop; var xHeight = dlinks.clientHeight; //dwrite('clientHeight= ' + dlinks.clientHeight); //dwrite('offsetTop= ' + dlinks.offsetTop); if (dspons != null) { if (dir == -1) { dspons.style.top = dSLStartTop; } else { dspons.style.top = xTop + xHeight + 10; } } } // repositionSLDiv() // button image swap // params: object to act upon, direction (-1 = backward) function swap_image(ctl, dir) { // assert passed ctl is not null if (null == ctl) { alert('null control passed to swap_image() - exiting'); return; } // back if (dir == -1) { // reset img scr to original ctl.src = ctl.src_bak; } else { // get new image name var isrc = ctl.src; // munge image name after last "." var new_img = isrc.substring(0, isrc.lastIndexOf('.') ); var ext = isrc.substring(isrc.lastIndexOf('.'), isrc.length); new_img += ('_over' + ext); // save current properties ctl.src_bak = ctl.src; ctl.src = new_img; } } // swap_image() // over state for link list labels // params: object to act upon, color to highlight, direction (non-null = backward) function highlight(ctl, clr, dir) { // back if (dir) { ctl.style.backgroundColor = ctl.clr_bak; } else // forward { ctl.clr_bak = ctl.style.backgroundColor; ctl.style.backgroundColor = clr; } } // highlight() // params: url of site window, id of media stream, result position index, search term //doMediaClick('http://www.sxsw.com', 'id://singingfish0/59936869', 1, 'Supersuckers') function doMediaClick(url, id, idx, term) { // open window for media stream openMediaWin(url, id); // log media click log(id, idx, term); } // doMediaClick() function openMediaWin(url) { if (url != "") { var win = window.open(url, 'media_win', 'toolbar=1,location=1,directories=0,status=1,menubar=1,width=780,height=348,scrollbars=1,resizable=1'); win.focus(); } } // openMediaWin() // log media click by calling image w/ codified name function log(){ var args = log.arguments; var spk = args[0]; var pos = args[1]; var queryXml = args[2]; var cm = new Image(); cm.src = getClickMark(spk,pos,queryXml); } // log() function getClickMark(spk,pos,queryXml) { var gifUrl = 'http://metrics.singingfish.com/clikmark.gif?' + window.location.host + '&spk=' + spk + '&t=' + new Date().getTime() + '&pos=' + pos + '&qx=' + queryXml; return gifUrl; } //debug function dwrite(msg) { document.getElementById("ddwrite").innerText += ("\n" + msg); } //'submit' adult splash page form function adultSubmit() { sUrl = sUrl + '?' + sQs + '&' + CGI_ARG_NAME_ADULT_RESULTS + '=1'; var oCheck = document.forms['adultresults'][CGI_ARG_NAME_P_ADULT_RESULTS]; if (oCheck.checked) { sUrl += '&' + CGI_ARG_NAME_P_ADULT_RESULTS + oCheck.value } //redirect document.location.href = sUrl; } //open email form window function email_current_search(name, qs) { var url = 'email_search.jsp?search_name='+ name + '&search_qs=' + qs + '&email_type=' + EMAIL_SEARCH_CURRENT; win = window.open(url, 'email_win', 'height=535,width=437,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0'); win.focus(); } //open email form window function email_saved_searches() { var ss = get_saved_searches(); if (ss.length == 0) { alert("Please select a search to email"); return; } var url = 'email_search.jsp?&email_type=' + EMAIL_SEARCH_SAVED + '&' + CGI_ARG_NAME_EMAIL_SEARCH + '=1'; //tack on saved searches var x; for (x = 0; x < ss.length; x++) { url+= '&saved_search=' + ss[x] } win = window.open(url, 'email_win', 'height=535,width=437,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0'); win.focus(); } // email_saved_searches() function get_saved_searches() { var bChecked = false; var cb = document.forms['fSearch'].elements['saved_search']; //alert('saved_search.length= ' + cb.length); var ss = new Array(); // if no saved searches return empty array if (null == cb) return ss; var x; // check every checkbox if array - just the one if not if (cb.length) { for (x = 0; x < cb.length; x++) { if (cb[x].checked) { ss.push(cb[x].value); } } } else { if (cb.checked) { ss.push(cb.value); } } return ss; } // get_saved_searches() //////////////////////////////////////////////////////////////// // globals // array indexing display panes (divs) var panes = new Array(); panes = ['dsettings', 'dres-links']; var lists = new Array(); lists = ['topten', 'toprecent', 'staffpicks', 'savedsearches']; var tab_imgs= new Array(); tab_imgs = ['srchsettab', 'featurestab']; var g_last_pane_div; // remember last features pane shown var g_last_pane_img; var dSLStartTop = 126;