/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;
/* End SWFObject v1.5*/

/* add Array.push if needed */
if(Array.prototype.push == null){
        Array.prototype.push = function(item) { this[this.length] = item; return this.length; }
}

function getCookie(name) {
    if (new RegExp("\\b" + name + "=([^;]+)").test(document.cookie)){
        return unescape(RegExp.$1);}
    else
        return null;
}

function setCookie(name, value, days, path, domain, secure) {
    var c = name + "=" + escape(value);
    var expires = null;
    if (days)
        expires = new Date(new Date().getTime() + (days * 24 * 60 * 60 * 1000));
    if (expires)
        c += "; expires=" + expires.toUTCString();
    if (path)
        c += "; path=" + path;
    if (domain)
        c += "; domain=" + domain;
    if (secure)
        c += "; secure";
    document.cookie = c;
}

function addEvent(obj, evt, func) {
    if (obj.addEventListener)
        obj.addEventListener(evt, func, false);
    else if (obj.attachEvent)
        obj.attachEvent("on"+evt, func);
    else {
        var oldhandler = obj["on"+evt];
        obj["on"+evt] = (typeof oldhandler == "function")
            ? function() { oldhandler(); func(); } : func;
    }
}

function getElementsByTagNameFilter(root, tagName, filter) {
    var filtered = new Array();
    var elms = root.getElementsByTagName(tagName);
    for (var i = 0; i < elms.length; i++) {
        if (filter(elms[i])) {
            filtered[filtered.length] = elms[i];
        }
    }
    return filtered;
}

function hasClass(node, classname) {
    if (node) {
        var pattern = new RegExp("(?:^| )" + classname + "(?: |$)");
        return pattern.test(node.className);
    }
    return false;
}

function getParentByTagName(node, tagName) {
    var n = node;
    while (n && (n = n.parentNode) != null) {
        if (n.nodeType == 1 && n.tagName.toLowerCase() == tagName.toLowerCase())
            break;
    }
    return n;
}

function sethomepage(url) {
    window.open('http://static.cbslocal.com/CBS/national/htm/homepage/index.html','sethomepage','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=562,height=550,left=100,top=100,screenX=100,screenY=100');
}

function setOpacity(obj, opacity) {
    opacity = (opacity == 100) ? 99.999 : opacity;
    // IE/Win
    obj.style.filter = "alpha(opacity:" + opacity + ")";
    // Safari<1.2, Konqueror
    obj.style.KHTMLOpacity = opacity / 100;
    // Older Mozilla and Firefox
    obj.style.MozOpacity = opacity / 100;
    // Safari 1.2, newer Firefox and Mozilla, CSS3
    obj.style.opacity = opacity / 100;
}

function fadeIn(id, opacity) {
    obj = document.getElementById(id);
    if (obj == null) return;
    if (opacity < 100) {
        setOpacity(obj, opacity);
        opacity += 5;
        obj.fadeInTimeout = window.setTimeout("fadeIn('" + id + "'," + opacity + ")", 30);
        return;
    }
    // fix for Safari

}

function fadeOut(id, opacity) {
    obj = document.getElementById(id);
    if (obj == null) return;
    if (opacity > 0) {
        setOpacity(obj, opacity);
        opacity -= 5;
        obj.fadeOutTimeout = window.setTimeout("fadeOut('" + id + "'," + opacity + ")", 30);
        return;
    }
    obj.style.visibility = "hidden";
}

function savezip(anchor) {
    var img = new Image();
    img.src = anchor.href;
    var message = document.getElementById("pop_saved_generic");
    setOpacity(message, 100);
    message.style.left = (getRealLeft(anchor) - (((message.clientWidth || message.offsetWidth) - (anchor.clientWidth || anchor.offsetWidth)) / 2)) + "px";
    message.style.top = (getRealTop(anchor) + 30) + "px";
    message.style.visibility = "visible";
    setTimeout("fadeOut('" + message.id + "', 95)", 15000);
    return false;
}

function showZip(linkid, boxid) {
    var ziplink = document.getElementById(linkid);
    var zipbox = document.getElementById(boxid);
    setOpacity(zipbox, 0);
    zipbox.style.display = "block";
    ziplink.style.display = "none";
    fadeIn(zipbox.getAttribute("id"), 5);
}

function isFirefoxPC() {
    var ua = navigator.userAgent;
    return (/Firefox/.test(ua) && /Windows/.test(ua));
}

function selectTab(tabid, rest) {
    var tab = document.getElementById("tab" + tabid);
    var tabdata = document.getElementById("tab" + tabid + "data");
    if (tab && tabdata) {
        tab.className = "currenttab";
        tabdata.style.display = "block";
        for (var i = 1; i < arguments.length; i++) {
            var tab = document.getElementById("tab" + arguments[i]);
            var tabdata = document.getElementById("tab" + arguments[i] + "data");
            if (tab && tabdata) {
                tab.className = "";
                tabdata.style.display = "none"
            }
        }
    }
}

function selectCondition(anchor, max, displaytime) {
    var id;
    var now = document.getElementById("now");
    var h3title = document.getElementById("h3title");
    if (anchor == null) {
        now.style.display = "block";
        h3title.innerHTML = "Current Conditions";
        id = 0;
    } else {
        id = anchor.getAttribute("id").substring(5) - 0;
        now.style.display = "none";
        anchor.className = "shown";
    }
    for (var i = 1; i <= max; i++) {
        var cond = document.getElementById("hr" + i);
        var anchor = document.getElementById("navhr" + i);
        
        if (i == id) {
            cond.style.display = "block";
            h3title.innerHTML = "Forecast at " + displaytime;
        } else {
            cond.style.display = "none";
            anchor.className = "";
        }
    }
}

function showDetails(anchor, max) {
    var aid = anchor.getAttribute("id").substring(0,4);
    var detail = document.getElementById(aid + "detail");
    var display = detail.style.display;
    for (var i = 1; i <= max; i++) {
        var id = "day" + i;
        var trigger = document.getElementById(id + "trigger");
        var img = trigger.getElementsByTagName("img")[0];
        img.src = img.src.replace("_up_", "_down_");
        document.getElementById(id + "detail").style.display = "none";
    }
    if (display == "none" || display == "") {
        var trigger = document.getElementById(aid + "trigger");
        var img = trigger.getElementsByTagName("img")[0];
        img.src = img.src.replace("_down_", "_up_");
        detail.style.display = "block";
    }
}

function setDisplay(trigger, layerid, func) {
    var layer = document.getElementById(layerid);
    var display;
    if (layer) {
        display = layer.style.display;
        layer.style.display = (display == "block") ? "none" : "block";
    }
    if (typeof func == "function") {
        func(trigger, display);
    }
}

function setVisibility(trigger, layerid, func) {
    var layer = document.getElementById(layerid);
    var visibility;
    if (layer) {
        visibility = layer.style.visibility;
        layer.style.visibility = (visibility == "visible") ? "hidden" : "visible";
    }
    if (typeof func == "function") {
        func(trigger, visibility);
    }
}

function changeArrow(trigger, display) {
    if (trigger) {
        var id = trigger.getAttribute("id");
        var letter = id.substring(9);
        var arrow = document.getElementById("arrow_" + letter);
        if (arrow) {
            arrow.className = (display == "block") ? "showarrow" : "hidearrow";
            arrow.innerHTML = (display == "block") ? "Show" : "Hide";
        }
    }
}

function go(select) {
    if (select) {
        var index = select.selectedIndex;
        var value = select.options[index].value;
        if (value) {
            window.location = value;
        }
    }
}

function setFontSize(size) {
    var middle = document.getElementById("middle");
    var resultsbox = document.getElementById("resultsbox");
    var tdefault = document.getElementById("tdefault");
    var tmedium = document.getElementById("tmedium");
    var tlarge = document.getElementById("tlarge");
    switch (size) {
    case "medium":
        if (middle) middle.style.fontSize = "120%";
        if (middle) middle.style.lineHeight = "125%";
        if (resultsbox) resultsbox.style.fontSize = "120%";
        tdefault.className="none";
        tmedium.className="cbstv_text_select";
        tlarge.className="none";
        setCookie("style", "medium", 365, "/");
        break;
    case "large":
        if (middle) middle.style.fontSize = "140%";
        if (middle) middle.style.lineHeight = "125%";
        if (resultsbox) resultsbox.style.fontSize = "140%";
        tdefault.className="none";
        tmedium.className="none";
        tlarge.className="cbstv_text_select";
        setCookie("style", "large", 365, "/");
        break;
    default:
        if (middle) middle.style.fontSize = "110%";
        if (middle) middle.style.lineHeight = "125%";
        if (resultsbox) resultsbox.style.fontSize = "110%";
        tdefault.className="cbstv_text_select";
        tmedium.className="none";
        tlarge.className="none";
        setCookie("style", "default", 365, "/");
        break;
    }
}

function hideShowDis(objOrId, hide) {
    var el = (typeof objOrId == "string")
        ? document.getElementById(id) : objOrId;
    if (el) {
        if (hide) el.style.display = "none";
        else el.style.display = (el.style.display == "none")
            ? "block" : "none";
    }
}

function hideShowVis(objOrId, hide) {
    var el = (typeof objOrId == "string")
        ? document.getElementById(id) : objOrId;
    if (el) {
        if (hide) el.style.visibility = "hidden";
        else el.style.visibility = (el.style.visibility == "hidden")
            ? "visible" : "hidden";
    }
}

function getRealLeft(element) {
    var xPos = element.offsetLeft;
    var tempElement = element.offsetParent;
    while (tempElement != null) {
        xPos += tempElement.offsetLeft;
        tempElement = tempElement.offsetParent;
    }
    return xPos;
}

function getRealTop(element) {
    var yPos = element.offsetTop;
    var tempElement = element.offsetParent;
    while (tempElement != null) {
        yPos += tempElement.offsetTop;
        tempElement = tempElement.offsetParent;
    }
    return yPos;
}

function url2id(url) { return url.replace(/%\/./g, "_"); }

var clipNum = 0;
var readNews = getCookie("readnews");
var savedNews = getCookie("savednews");

if (readNews == null) readNews = "";
if (savedNews == null) savedNews = "";

function clipExists(url) {
    var clipsArray = savedNews.split("|");
    for (var i = 0; i < clipsArray.length; i++) {
        var itemArray = clipsArray[i].split(";");
        if (itemArray[1] == url) {
            return true;
        }
    }
    return false;
}

function writeClipImg(headline, url, clipType) {
    var onover = 'onmouseover="showInstructions(this, \'' + clipType + '\')" onmouseout="hideInstructions(this, \'' + clipType + '\')"';
    var imageName = "http://static.cbslocal.com/Themes/CBS/_resources/img/ico010x010save_it.gif";
    if (clipExists(url)) {
        imageName = "http://static.cbslocal.com/Themes/CBS/_resources/img/ico010x010save_it_off.gif";
        onover = "";
    }
    document.write('<span class="clipicon" onclick="clipClick(this,\'' + headline.replace(/\'/g,"\\'") + '\',\'' + url + '\',' + clipNum + ',\'' + clipType + '\');" id="' + url2id(url) + '"><img src="' + imageName + '" width="10" height="10" ' + onover + ' /></span>');
    clipNum++;
}

function charStrip(a) {
    a = a.split("|").join("");
    a = a.split("&").join("");
    a = a.split("'").join("");
    a = a.split("#").join("");
    a = a.split("$").join("");
    a = a.split("%").join("");
    a = a.split("^").join("");
    a = a.split("*").join("");
    a = a.split(":").join("");
    a = a.split("~").join("");
    a = a.split(";").join("");
    a = a.split(" ").join("+");
    return a;
}

function hbxStrip(a) {
    a = a.split("|").join("");
    a = a.split("&").join("");
    a = a.split("'").join("");
    a = a.split("#").join("");
    a = a.split("$").join("");
    a = a.split("%").join("");
    a = a.split("^").join("");
    a = a.split("*").join("");
    a = a.split(":").join("");
    a = a.split("~").join("");
    a = a.split(";").join("");
    a = a.split(" ").join("+");
    return a;
}

function getParam(p) {
    var qstring = location.search.substring(1);
    var pattern = new RegExp("\\b" + p + "=([^&$]+)");
    var match = qstring.match(pattern);
    return match ? match[1] : "";
}

function getPic() {
    var path = unescape(getParam("gimg")).replace("+", " ");
    var title = unescape(getParam("gtitle")).replace("+", " ");
    showPicImpl(path, title);
}

function showPic(anchor) {
    var path = anchor.href;
    var title = anchor.title;
    showPicImpl(path, title);

    var advertframe =  document.getElementById("advertframe");
    if (advertframe) {
        advertframe.src = advertframe.src;
    }
    return false;
}

function showPicImpl(path, title) {
    if (path && title) {
        var gallerybigimage = document.getElementById("gallerybigimage");
        var emailimagelink =  document.getElementById("emailimagelink");
        var gallerytitle =  document.getElementById("gallerytitle");

        if (gallerybigimage && emailimagelink && gallerytitle) {
            gallerybigimage.src = path;
            gallerytitle.firstChild.data = title;
            emailimagelink.href = emailimagelink.href.replace(/\bgimg=([^%]+)%26/, "gimg=" + escape(path) + "%26").replace(/gtitle=(.*)/, "gtitle=" + title.replace(" ", "%2520"));
        }
    }
}

addEvent(window, "load", getPic);

var fsize = getCookie("style") || "default";
document.write('<link rel="stylesheet" type="text/css" href="http://static.cbslocal.com/Themes/CBS/_resources/css/' + fsize + '.css"  />');

//New function added 1/12/06
function wipeInput(formName, inputField) {
	//alert(document.forms[formName][inputField].value);
	if (document.forms[formName][inputField].value == 'ZIP') {
		document.forms[formName][inputField].value = '';
	} else if (document.forms[formName][inputField].value == 'Quote') {
		document.forms[formName][inputField].value = '';
	}
}

//New functions added 1/26/06
function selectPartnerTab(tabid, rest) {
		var tab = document.getElementById("tab" + tabid);
		var tabdata = document.getElementById("newtab" + tabid + "data");
		if (tab && tabdata) {
				tab.className = "currenttab";
				tabdata.style.display = "block";
				for (var i = 1; i < arguments.length; i++) {
						var tab = document.getElementById("tab" + arguments[i]);
						var tabdata = document.getElementById("newtab" + arguments[i] + "data");
						if (tab && tabdata) {
								tab.className = "";
								tabdata.style.display = "none"
						}
				}
		}
}

function randomWeight(order) 
{
	/*var rNum=Math.floor(Math.random()*101);
	var domain = location.hostname

	if (domain == 'wcco.com')
	{
		if (rNum >= 0 && rNum <= 50) {selectPartnerTab('1','2','3','4','5','6','7');}
		if (rNum >= 51 && rNum <= 60) {selectPartnerTab('3','4','5','6','7','1','2');}
		if (rNum >= 61 && rNum <= 70) {selectPartnerTab('4','5','6','7','1','2','3');}
		if (rNum >= 71 && rNum <= 85) {selectPartnerTab('5','6','7','1','2','3','4');}
		if (rNum >= 86 && rNum <= 100) {selectPartnerTab('7','6','5','1','2','3','4');}
	}
	else
	{
		if (rNum >= 0 && rNum <= 50) {selectPartnerTab('1','2','3','4','5','6','7');}
		if (rNum >= 51 && rNum <= 60) {selectPartnerTab('2','1','3','4','5','6','7');}
		if (rNum >= 61 && rNum <= 70) {selectPartnerTab('3','4','5','6','7','1','2');}
		if (rNum >= 71 && rNum <= 80) {selectPartnerTab('4','5','6','7','1','2','3');}
		if (rNum >= 81 && rNum <= 90) {selectPartnerTab('5','6','7','1','2','3','4');}
		if (rNum >= 91 && rNum <= 100) {selectPartnerTab('7','6','5','1','2','3','4');}
	}*/
	
	selectPartnerTab(order);
}

var sURL = unescape(window.location.pathname);

function doLoad()
{
    // the timeout value should be the same as in the "refresh" meta-tag
    setTimeout( "refresh()", 1000*1000 ); 
}

function refresh()
{
    //  This version of the refresh function will cause a new
    //  entry in the visitor's history.  It is provided for
    //  those browsers that only support JavaScript 1.0.
    //
    window.location.href = sURL;
}

//Endeca Search - Begin
function searchCBS()
{
	var location = "http://search." + getCBSDomain2() + "/?__LOGIC=811&section=[1]&SearchString=[2]";
	var section = document.getElementById("section").value;
	var string = document.getElementById("textfield").value;
	window.location = location = location.replace("[1]", section).replace("[2]",string);
	return true;
}

function submitSearch(textBoxId, contextKey) {
    
    var textBox = document.getElementById(textBoxId);
    if (textBox) 
    {
        var contextArgs = contextKey.split('&');
        var contextHash = new Object();
        var i = 0;
        for (i = 0; i < contextArgs.length; i++) 
        {
            var keyValuePair = contextArgs[i].split('=');
            if (keyValuePair.length == 2) 
            {
                contextHash[keyValuePair[0]] = keyValuePair[1];
            }
        }
        var url = unescape(contextHash["Path"]) + "?SearchString=" + textBox.value + "&TabId=" + contextHash["TabId"];
        window.location.href = url;    
    }
}
//Endeca Search - End

//Events
addEvent(window, 'load', ev_init, false);
var evpop;
function ev_init()
{
	evpop = new EventPop();
}

function EventPop()
{
	this.eventlist = new Array();
	
	// extensions for each event-related id
	this.linkend = '_link';
	this.detailend = '_detail';
	this.closeend = '_close';	

	// get all the links that open event divs (by class name)
	var evlinks =  document.eclass('cbstv_event-open');
	var i;		// counter
	
	// store event id stubs and bind functions
	for(i=0; i<evlinks.length; i++)
	{
		var evnameparts = evlinks[i].id.split("_");
		var evname = evnameparts[0];
		this.eventlist.push(evname);
		
		//addEvent(evlinks[i],'click', this.popper, false);
		
		
	}
}


EventPop.prototype.popper = function(aclick)
{
	var clicked = '';		//this will hold the id stub for the event clicked
	var evspan = '';			//id for event details span
	
	// close all event spans
	var i;
	for(i=0; i<this.eventlist.length; i++)
	{
		var toclose = this.eventlist[i] + this.detailend;
		el(toclose).style.display = "none";	
	}
	
	
	var linkleft = findPos(aclick)[0];
	var linktop = findPos(aclick)[1];
	
	
		
	clicked = aclick.id.split("_")[0];
	evspan = clicked + this.detailend;
	el(evspan).style.display = "block";
	
	var curmarg = el(evspan).style.marginLeft;
	
	
	if(linkleft < 350)
	{
		//el(evspan).style.marginLeft = "-80px";
		el(evspan).className = el(evspan).className + " " + "cbstv_flip";
	}
	return false; 
}

EventPop.prototype.closeit = function(aclick)
{
	var clicked = '';		//this will hold the id stub for the event clicked
	var evspan = '';			//id for event details span
	
	clicked = aclick.id.split("_")[0];
	evspan = clicked + this.detailend;
	el(evspan).style.display = "none";
		
}

// document.getElementById shortcut
function el(elid)
{
	return document.getElementById(elid);	
}


// find true position of element
// source: http://www.quirksmode.org/js/findpos.html
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return [curleft,curtop];
}

// cross-browser event handling for IE5+, NS6+ and Mozilla/Gecko
// By Scott Andrew
function addEvent(elm, evType, fn, useCapture)
{
	if (elm.addEventListener)
	{
		elm.addEventListener(evType, fn, useCapture);
		return true;
	}
	
	else if(elm.attachEvent)
	{
		var r = elm.attachEvent('on' + evType, fn);
		return r;
	}
	
	else
	{
		elm['on' + evType] = fn;
	}
}
			
// provide getElementsByClassName functionality
// returns array of elements bearing the passed class
// Source: http://javascript.about.com/library/bldom08.htm
document.eclass = function(cl) {
var retnode = [];
var myclass = new RegExp('\\b'+cl+'\\b');
var elem = this.getElementsByTagName('*');
for (var i = 0; i < elem.length; i++) {
var classes = elem[i].className;
if (myclass.test(classes)) retnode.push(elem[i]);
}
return retnode;
};
//End Events