/* Copyright 2006 Clinaero, Inc
* ALL RIGHTS RESERVED
*/
var currentMenuDropdown;
var currentMenuSource;
var isIE = window.navigator && window.navigator.userAgent && window.navigator.userAgent.indexOf ( "MSIE " ) != -1;
// setting these dynamically causes a flash in IE...
// so I set them in the beginning and use a proxy.
document.onmousemove = docmousemove;
document.onmouseup = docmouseup;
onmousemoveproxy = false;
onmouseupproxy = false;
function docmousemove( e ) {
    if ( onmousemoveproxy ) return onmousemoveproxy( e );
}
function docmouseup( e ) {
    if ( onmouseupproxy ) return onmouseupproxy( e );
}
function domenu( event, clickItemName, xoffset, yoffset ) {
    var e = getEvent( event );
    cancelEvent( e );
    var menuDivName = clickItemName + "DD";
    var menuDiv = document.getElementById(menuDivName);
    if ( currentMenuDropdown && currentMenuDropdown!= menuDiv ) currentMenuDropdown.style.display="none";
    var clickItem = document.getElementById(clickItemName);
    if ( menuDiv.style.display == "none" )    {
        var x = findPosX( clickItem) + xoffset;
        var y = findPosY( clickItem) + yoffset;
        var el = document.getElementById("allpage");
        if ( el ) y -= findPosY( el );
        menuDiv.style.left = x+ "px";
        menuDiv.style.top = y + "px";
        menuDiv.style.display = "";
        menuDiv.zIndex = 1;
    }
    currentMenuSource = clickItem;
    currentMenuDropdown = menuDiv;
    onmousemoveproxy = undomenu;
}
function refreshWindow() {
    if ( window.location.replace ) {
        window.location.replace(unescape(window.location.pathname));
    } else {
        window.location.reload( false );
    }
}
function undomenu( event ) {
    var e = getEvent( event );
    cancelEvent( e );
    var t = getEventSrc( e );
    if ( ! hasParent( t, currentMenuDropdown ) && ! hasParent( t, currentMenuSource ) ) {
        currentMenuDropdown.style.display = "none";
        onmousemoveproxy = false;
    }
}
function hasParent( el, parent ) {
    var p = el;
    while ( p != null ) {
        if ( p == parent ) return true;
        p = p.parentNode;
    }
    return false;
}
function findPosX(obj) {
    var curleft = 0;
    if (obj.offsetParent)
    {
        while (obj.offsetParent)
        {
            curleft += obj.offsetLeft;
            obj = obj.offsetParent;
        }
    }
    else if (obj.x)
        curleft += obj.x;
    return curleft;
}
function findPosY(obj, nooffset) {
    var curtop = 0;
    if (obj.offsetParent)
    {
        while (obj.offsetParent)
        {
            curtop += obj.offsetTop;
            obj = obj.offsetParent;
        }
    }
    else if (obj.y)
        curtop += obj.y;
    return curtop;
}
// do it both ways to work with IE and Firefox
function setClass( element, className ) {
  if ( element ) {
      element.setAttribute( "class", className );
      element.setAttribute( "className", className );
  }
}

function setId( element, idName ) {
  if ( element ) {
      element.setAttribute( "id", idName );
  }
}

function getEventSrc( e ) {
    if ( e.srcElement ) return e.srcElement;
    else return e.target;
}
function getEvent(e) {
  if (typeof e == 'undefined') e = window.event;
  if (typeof e.layerX == 'undefined') e.layerX = e.offsetX;
  if (typeof e.layerY == 'undefined') e.layerY = e.offsetY;
  return e;
}
function cancelEvent( e ) {
    // for Moz
    if (e.stopPropagation) {
        e.stopPropagation();
    }
    if (e.preventDefault) {
        e.preventDefault();
    }
    // for IE
    e.cancelBubble = true;
    e.returnValue = false;
}
function clickAnchor(event, t) {
    var e = getEvent(event);
    if (!t) t = getEventSrc( e );
    if ( t.tagName == "A" ) {
        cancelEvent( e);
        document.location = t.getAttribute("href");
    } else {
        var allHrefs = t.getElementsByTagName("A");
        if ( allHrefs.length > 0 ) {
           cancelEvent( e);
           document.location = allHrefs[0].getAttribute("href");
        } else {
        	var allSpans = t.getElementsByTagName("SPAN");
	        if ( allSpans.length > 0 && allSpans[0].getAttribute("onclick")) {
	           cancelEvent( e);
	           eval(allSpans[0].getAttribute("onclick"));
	        }
        }
    }
}
/***cookie***/
function createCookie(name,value,days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}
function getHeight( element ) {
    var x,y;
    var test1 = element.scrollHeight;
    var test2 = element.offsetHeight
    if (test1 > test2) // all but Explorer Mac
    {
        x = element.scrollWidth;
        y = element.scrollHeight;
    }
    else // Explorer Mac;
         //would also work in Explorer 6 Strict, Mozilla and Safari
    {
        x = element.offsetWidth;
        y = element.offsetHeight;
    }
    return y;
}
function getWidth( element ) {
    var x,y;
    var test1 = element.scrollHeight;
    var test2 = element.offsetHeight
    if (test1 > test2) // all but Explorer Mac
    {
        x = element.scrollWidth;
        y = element.scrollHeight;
    }
    else // Explorer Mac;
         //would also work in Explorer 6 Strict, Mozilla and Safari
    {
        x = element.offsetWidth;
        y = element.offsetHeight;
    }
    return x;
}


function placeFooter() {
    var footer = document.getElementById("footer");
    if ( footer ) {
        footer.style.display = "none";
        var y = getHeight( document.body ) - 40;
        var e = document.getElementById( "article" );
        if ( e == null ) e = document.getElementById("articleHtml");
        if ( e != null ) {
           // var xp = findPosX( e );
            //if ( xp < 50 ) { footer.style.display = ""; footer.style.position = ""; return; }
            var y2 = getHeight( e ) - 90;
            if ( y2 > y ) y = y2;
        }
        var w = (curStyleSheetTitle=="normal"?950:765) - 60;
        footer.style.top = (y ) + "px";
        var l = "-140px";
        footer.style.left = l;
        footer.style.width = w + "px";
        footer.style.display = "";
    }
}
var descriptionLink;
var descriptionDiv;
function hideDescription() {}
function hideDescription2() {
    if ( descriptionDiv ) descriptionDiv.parentNode.removeChild( descriptionDiv );
    descriptionDiv = false;
    descriptionLink = false;
}
function showDescription(event, url, txt, title ) {
    var e = getEvent( event );
    cancelEvent( e );
    var el = getEventSrc( e );
    if ( el != descriptionLink ) {
        hideDescription2();
        var xoffset = 5 + (isIE?-185:0);
        var yoffset = 19;
        var x = findPosX( el) + xoffset;
        var y = findPosY( el) + yoffset;
        var divouter = document.createElement("div");
        setClass( divouter, "descPopupOuter");
        var div = document.createElement("div");
        setClass( div, "descPopup");
        var divShadow = document.createElement("div");
        setClass( divShadow, "descPopupShadow");
        div.style.zIndex = "1";
        div.style.left = "-5px";
        div.style.top = "-5px";
        divouter.style.left = (x)+"px";
        divouter.style.top = (y) +"px";
        div.innerHTML = txt  + "<div style=\"height:5px\">&nbsp;</div><span class=\"popupLink\" onmouseover=\"this.style.textDecoration='underline'\" onmouseout=\"this.style.textDecoration='none'\" style=\"font-family: Arial\" >Click " +title+ " to read this eMedTV article.</span>";
        div.onclick = function (e) {
            e = getEvent( e );
            document.location = url;
        }
        divouter.appendChild(div);
        divouter.appendChild(divShadow);
        document.body.appendChild( divouter );
        descriptionDiv = divouter;
        descriptionLink = el;
        onmousemoveproxy = undoDescription;
        var h = getHeight(div);
        var w = getWidth( div );
        divouter.style.height = h + "px";
        divouter.style.width = w + "px";
        divShadow.style.height = h + "px";
        divShadow.style.width = w + "px";
        setOpacity( divShadow, 20 );
        //document.getElementById("testing").innerHTML = "X: " + x + "  Y: " + y + " W: " + getWidth( el) + " W: " + getHeight( el);
    }
}
function undoDescription( event ) {
    var e = getEvent( event );
    cancelEvent( e );
    var t = getEventSrc( e );
    if ( ! hasParent( t, descriptionDiv ) && ! hasParent( t, descriptionLink ) ) {
        hideDescription2();
        onmousemoveproxy = false;
    }
}
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 getPageUrlForPage( pagenum ) {
    s = getPageUrl();
    if (pagenum > 0 ) s = s.replace(".html", "-p" + (pagenum+1) + ".html");
    return s;
}
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

function createPages( nprow, separate ) {
    var lblcell = document.createElement( "td" );
    lblcell.setAttribute("id", "colNextBackHeader" );
    lblcell.innerHTML = "<h4>Pages:</h4>";
    nprow.appendChild( lblcell );
    pagescellTd = document.createElement("td");
    pagescellTd.setAttribute("id", "colNextBackLeft" );
    pagescell = document.createElement("p");
    setClass( pagescell, "nextBack" );
    pagescellTd.appendChild( pagescell );
    if ( getCurrentPage() > 0 ) {
       var u = "/" + getPageUrlForPage( getCurrentPage() - 1 );
       var a = document.createElement("a");
       a.setAttribute("href", u );
       setClass( a, "tblNextBack" );
       var i = document.createElement("img");
       i.setAttribute("src", "/images/v2/backarrow.png");
       setClass( i, "nextBack");
       a.appendChild( i );
       a.appendChild( document.createTextNode("Previous") );
       pagescell.appendChild( a );
    }
    /// for each page do one with a 1 on it.
    for ( var i=1;i<=getPageCount(); i++ ) {
       var elm;
       if ( i != getCurrentPage() + 1 ) {
          elm = document.createElement("a");
          elm.setAttribute("href", "/"+getPageUrlForPage( i-1 ) );
          setClass( elm, "tblNextBack-js" );
       } else {
          elm = document.createElement("span");
          setClass( elm, "nolink-js" );
       }

       elm.appendChild( document.createTextNode(""+i) );
       pagescell.appendChild( elm );
       if ( separate  ) pagescell.appendChild( document.createTextNode( " | ") );
    }
    if ( getCurrentPage() < getPageCount() - 1 ) {
       var u = "/" + getPageUrlForPage( getCurrentPage() + 1 );
       var a = document.createElement("a");
       a.setAttribute("href", u );
       setClass( a, "tblNextBack" );
	   setClass( a, "tblNextBack-js" );
       var i = document.createElement("img");
       i.setAttribute("src", "/images/v2/nextarrow.png");
       setClass( i, "nextBack");
       a.appendChild( document.createTextNode("Next") );
       a.appendChild( i );
       pagescell.appendChild( a );
    }
	
    nprow.appendChild (pagescellTd);
	
}

function printPage() {
    window.print();
}

function emailPage(event) {
    var loc = window.location.href;
    var title = document.title;
    var popup = window.open("about:blank", "EmailWindow", "width=380,height=250");
    //popup.document.title = title;
    var doc = popup.document;
    doc.open();
    doc.write( "<html><head><title>Email " + title + "</title><script language=\"javascript\" >" +
    "\n  function validateEmailForm() { "+
    "\n    var re = new RegExp(\"^([\\\\w,-,\\\\.,_]+)@([\\\\w,-]+)(\\\\.)([\\\\w,\\\\.]+)$\");"+
    "\n    if ( !re.exec( document.forms['emailForm']['email'].value )) {"+
    "\n      alert( \"Please add a valid email address.\");"+
    "\n      return false;"+
    "\n    }"+
    "\n    if ( !re.exec( document.forms['emailForm']['youremail'].value )) {"+
    "\n      alert( \"Please add your correct email address.\");"+
    "\n      return false;"+
    "\n    }"+
    "\n    return true;"+
    "\n  }" +
    "</script>" +
    "<link href=\"/pub_style/common.css\" rel=\"stylesheet\" type=\"text/css\"  />" +
    "<link href=\"/pub_style/articles.css\" rel=\"alternate stylesheet\" type=\"text/css\" title=\"normal\" /></head>");
    doc.write( "<body>  <form action='emailform.html' method='post' onsubmit='return validateEmailForm()'  name='emailForm' ><table><tr><td><strong>Title:</strong></td><td> " + title + "</td></tr>");
    doc.write( "<tr><td><strong>Email To:</strong></td><td> <input type=\"text\" name=\"email\" /></td></tr>");
    doc.write( "<tr><td><strong>Your name:</strong></td><td> <input type=\"text\" name=\"sender\" /></td></tr>");
    doc.write( "<tr><td valign=\"top\"><strong>Message:</strong></td><td><textarea name=\"message\"></textarea></td></tr>");
    doc.write( "<tr><td><strong>Your email:</strong></td><td> <input type=\"text\" name=\"youremail\" /></td></tr>");
    //doc.write( "<tr><td>URL: </td><td>" + loc + "</td></tr>");
    doc.write( "<tr><td><input type=\"submit\" value=\"Send\"/></td></tr></table>");
    doc.write( "<input type=\"hidden\" name=\"title\" value=\""+title+"\" /><input type=\"hidden\" name=\"url\" value=\""+loc+"\" ></form>");
    doc.write( "</body></html>");
    doc.close();
}


function bookmarkPage() {
    if( window.external && typeof(window.external.AddFavorite) != "undefined" ) { // IE Favorite
        window.external.AddFavorite( window.location.href,  document.title + " (eMedTV Article)");
    }
}
function showBabyNames() {
    window.location = "http://baby-names.emedtv.com/baby-builder.html";
}

/**
 * SWFObject v1.4.4: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * **SWFObject is the SWF embed script formerly known as FlashObject. The name was changed for
 *   legal reasons.
 */
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(swf, id, w, h, ver, c, useExpressInstall, quality, xiRedirectUrl, redirectUrl, detectKey){
    if (!document.getElementById) { return; }
    this.DETECT_KEY = detectKey ? detectKey : 'detectflash';
    this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY);
    this.params = new Object();
    this.variables = new Object();
    this.attributes = new Array();
    if(swf) { this.setAttribute('swf', swf); }
    if(id) { this.setAttribute('id', id); }
    if(w) { this.setAttribute('width', w); }
    if(h) { this.setAttribute('height', h); }
    if(ver) { this.setAttribute('version', new deconcept.PlayerVersion(ver.toString().split("."))); }
    this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion();
    if(c) { this.addParam('bgcolor', c); }
    var q = quality ? quality : 'high';
    this.addParam('quality', q);
    this.setAttribute('useExpressInstall', useExpressInstall);
    this.setAttribute('doExpressInstall', false);
    var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location;
    this.setAttribute('xiRedirectUrl', xir);
    this.setAttribute('redirectUrl', '');
    if(redirectUrl) { this.setAttribute('redirectUrl', redirectUrl); }
}
deconcept.SWFObject.prototype = {
    setAttribute: function(name, value){
        this.attributes[name] = value;
    },
    getAttribute: function(name){
        return this.attributes[name];
    },
    addParam: function(name, value){
        this.params[name] = value;
    },
    getParams: function(){
        return this.params;
    },
    addVariable: function(name, value){
        this.variables[name] = value;
    },
    getVariable: function(name){
        return this.variables[name];
    },
    getVariables: function(){
        return this.variables;
    },
    getVariablePairs: function(){
        var variablePairs = new Array();
        var key;
        var variables = this.getVariables();
        for(key in variables){
            variablePairs.push(key +"="+ variables[key]);
        }
        return variablePairs;
    },
    getSWFHTML: function() {
        var swfNode = "";
        if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture
            if (this.getAttribute("doExpressInstall")) { this.addVariable("MMplayerType", "PlugIn"); }
            swfNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'"';
            swfNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
            var params = this.getParams();
             for(var key in params){ swfNode += [key] +'="'+ params[key] +'" '; }
            var pairs = this.getVariablePairs().join("&");
             if (pairs.length > 0){ swfNode += 'flashvars="'+ pairs +'"'; }
            swfNode += '/>';
        } else { // PC IE
            if (this.getAttribute("doExpressInstall")) { this.addVariable("MMplayerType", "ActiveX"); }
            swfNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'">';
            swfNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />';
            var params = this.getParams();
            for(var key in params) {
             swfNode += '<param name="'+ key +'" value="'+ params[key] +'" />';
            }
            var pairs = this.getVariablePairs().join("&");
            if(pairs.length > 0) {swfNode += '<param name="flashvars" value="'+ pairs +'" />';}
            swfNode += "</object>";
        }
        return swfNode;
    },
    write: function(elementId){
        if(this.getAttribute('useExpressInstall')) {
            // check to see if we need to do an express install
            var expressInstallReqVer = new deconcept.PlayerVersion([6,0,65]);
            if (this.installedVer.versionIsValid(expressInstallReqVer) && !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 elementId == 'string') ? document.getElementById(elementId) : elementId;
            n.innerHTML = this.getSWFHTML();
            return true;
        }else{
            if(this.getAttribute('redirectUrl') != "") {
                document.location.replace(this.getAttribute('redirectUrl'));
            }
        }
        return false;
    }
}

/* ---- detection functions ---- */
deconcept.SWFObjectUtil.getPlayerVersion = function(){
    var PlayerVersion = new deconcept.PlayerVersion([0,0,0]);
    if(navigator.plugins && navigator.mimeTypes.length){
        var x = navigator.plugins["Shockwave Flash"];
        if(x && x.description) {
            PlayerVersion = new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
        }
    }else{
        // do minor version lookup in IE, but avoid fp6 crashing issues
        // see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
        try{
            var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
        }catch(e){
            try {
                var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
                PlayerVersion = new deconcept.PlayerVersion([6,0,21]);
                axo.AllowScriptAccess = "always"; // throws if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this code)
            } catch(e) {
                if (PlayerVersion.major == 6) {
                    return PlayerVersion;
                }
            }
            try {
                axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
            } catch(e) {}
        }
        if (axo != null) {
            PlayerVersion = new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
        }
    }
    return PlayerVersion;
}
deconcept.PlayerVersion = function(arrVersion){
    this.major = arrVersion[0] != null ? parseInt(arrVersion[0]) : 0;
    this.minor = arrVersion[1] != null ? parseInt(arrVersion[1]) : 0;
    this.rev = arrVersion[2] != null ? parseInt(arrVersion[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;
}
/* ---- get value of query string param ---- */
deconcept.util = {
    getRequestParameter: function(param) {
        var q = document.location.search || document.location.hash;
        if(q) {
            var pairs = q.substring(1).split("&");
            for (var i=0; i < pairs.length; i++) {
                if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) {
                    return pairs[i].substring((pairs[i].indexOf("=")+1));
                }
            }
        }
        return "";
    }
}
/* fix for video streaming bug */
deconcept.SWFObjectUtil.cleanupSWFs = function() {
    if (window.opera || !document.all) return;
    var objects = document.getElementsByTagName("OBJECT");
    for (var i=0; i < objects.length; i++) {
        objects[i].style.display = 'none';
        for (var x in objects[i]) {
            if (typeof objects[i][x] == 'function') {
                objects[i][x] = function(){};
            }
        }
    }
}
// fixes bug in fp9 see http://blog.deconcept.com/2006/07/28/swfobject-143-released/
deconcept.SWFObjectUtil.prepUnload = function() {
    __flash_unloadHandler = function(){};
    __flash_savedUnloadHandler = function(){};
    if (typeof window.onunload == 'function') {
        var oldUnload = window.onunload;
        window.onunload = function() {
            deconcept.SWFObjectUtil.cleanupSWFs();
            oldUnload();
        }
    } else {
        window.onunload = deconcept.SWFObjectUtil.cleanupSWFs;
    }
}
if (typeof window.onbeforeunload == 'function') {
    var oldBeforeUnload = window.onbeforeunload;
    window.onbeforeunload = function() {
        deconcept.SWFObjectUtil.prepUnload();
        oldBeforeUnload();
    }
} else {
    window.onbeforeunload = deconcept.SWFObjectUtil.prepUnload;
}
/* add Array.push if needed (ie5) */
if (Array.prototype.push == null) { Array.prototype.push = function(item) { this[this.length] = item; return this.length; }}

/* add some aliases for ease of use/backwards compatibility */
var getQueryParamValue = deconcept.util.getRequestParameter;
var FlashObject = deconcept.SWFObject; // for legacy support
var SWFObject = deconcept.SWFObject;

/*******************
*
*   Nifty corners
*
*/
function NiftyCheck()
{
if(!document.getElementById || !document.createElement)
    return(false);
var b=navigator.userAgent.toLowerCase();
if(b.indexOf("msie 5")>0 && b.indexOf("opera")==-1)
    return(false);
return(true);
}

function Rounded(selector,bk,color,size){
var i;
var v=getElementsBySelector(selector);
var l=v.length;
for(i=0;i<l;i++){
    AddTop(v[i],bk,color,size);
    AddBottom(v[i],bk,color,size);
    }
}

function RoundedTop(selector,bk,color,size){
var i;
var v=getElementsBySelector(selector);
for(i=0;i<v.length;i++)
    AddTop(v[i],bk,color,size);
}

function RoundedBottom(selector,bk,color,size){
var i;
var v=getElementsBySelector(selector);
for(i=0;i<v.length;i++)
    AddBottom(v[i],bk,color,size);
}

function AddTop(el,bk,color,size){
var i;
var d=document.createElement("b");
var cn="r";
var lim=4;
if(size && size=="small"){ cn="rs"; lim=2}
d.className="rtop";
d.style.backgroundColor=bk;
for(i=1;i<=lim;i++){
    var x=document.createElement("b");
    x.className=cn + i;
    x.style.backgroundColor=color;
    d.appendChild(x);
    }
el.insertBefore(d,el.firstChild);
}

function AddBottom(el,bk,color,size){
var i;
var d=document.createElement("b");
var cn="r";
var lim=4;
if(size && size=="small"){ cn="rs"; lim=2}
d.className="rbottom";
d.style.backgroundColor=bk;
for(i=lim;i>0;i--){
    var x=document.createElement("b");
    x.className=cn + i;
    x.style.backgroundColor=color;
    d.appendChild(x);
    }
el.appendChild(d,el.firstChild);
}

function getElementsBySelector(selector){
var i;
var s=[];
var selid="";
var selclass="";
var tag=selector;
var objlist=[];
if(selector.indexOf(" ")>0){  //descendant selector like "tag#id tag"
    s=selector.split(" ");
    var fs=s[0].split("#");
    if(fs.length==1) return(objlist);
    return(document.getElementById(fs[1]).getElementsByTagName(s[1]));
    }
if(selector.indexOf("#")>0){ //id selector like "tag#id"
    s=selector.split("#");
    tag=s[0];
    selid=s[1];
    }
if(selid!=""){
    objlist.push(document.getElementById(selid));
    return(objlist);
    }
if(selector.indexOf(".")>0){  //class selector like "tag.class"
    s=selector.split(".");
    tag=s[0];
    selclass=s[1];
    }
var v=document.getElementsByTagName(tag);  // tag selector like "tag"
if(selclass=="")
    return(v);
for(i=0;i<v.length;i++){
    if(v[i].className==selclass){
        objlist.push(v[i]);
        }
    }
return(objlist);
}
function addEventHandler( htmlObject, handlerName, callback ){
  //htmlObject.setAttribute(handlerName, callback); works with firefox, but not IE.
  htmlObject[handlerName] = new Function ( callback ); // seems to work with both
}
var Tabs = function() {}

function tabClicked( e ) {
  e = getEvent( e );
  var el = getEventSrc(e);
  var tabs;
  while ( !(tabs = el.tabs) ) {
    if ( el.parentNode ) el = el.parentNode;
  }
  tabs.click( el );
}
Tabs.prototype.initialize = function(tabList, mainFrame, onclick) {
    this.tabList = tabList;
    this.mainFrame = mainFrame;
    this.mainDocument = mainFrame.document;
    this.onclick = onclick;
    this.initTabs();
}

Tabs.prototype.click = function( el ) {
    var tabIx = -1;
    for ( var i=0;i<this.tabList.length;i++ ) {
        if ( el == this.tabList[i] ) {
            tabIx = i;
            break;
        }
    }
    if ( tabIx != -1 ) {
        if ( this.canShowTab( tabIx ) ) {
            this.showTab( tabIx );
        }
        this.tabShown( tabIx );
        if ( this.onclick ) this.onclick( tabIx );
    }
}
Tabs.prototype.canShowTab = function( ix ) {
    return true;
}
Tabs.prototype.tabShown = function( ix ) {
    return true;
}
Tabs.prototype.showTab = function( ix ) {
    var six = -1;
    var x = 30;
    for ( var i=0;i<this.tabList.length;i++ ) {
        var s = ix == i;
        setClass( this.tabList[i], s?"selTab":"unselTab" );
        this.tabList[i].style.left = (x) + "px";
        this.tabList[i].style.zIndex = s?100:2;
        x += ((s?242:242) - 8);
        if ( s ) six = ix;
    }
    return true;
}
Tabs.prototype.initTabs = function() {
    var s = true;
    var x = 30;
    for ( var i=0;i<this.tabList.length;i++ ) {
        this.tabList[i].tabs = this;
        this.tabList[i].onclick = tabClicked;
        setClass( this.tabList[i], s?"selTab":"unselTab" );
        this.tabList[i].style.left = (x) + "px";
        x += ((s?242:242) - 8);
        s = false;
    }
}

function PageQuery(q) {

  if(q.length > 1) this.q = q.substring(1, q.length);
  else this.q = null;
  this.keyValuePairs = new Array();
  if(q) {
      for(var i=0; i < this.q.split("&").length; i++) {
          this.keyValuePairs[i] = this.q.split("&")[i];
      }
  }

  this.getKeyValuePairs = function() { return this.keyValuePairs; }

  this.getValue = function(s) {
    for(var j=0; j < this.keyValuePairs.length; j++) {
    if(this.keyValuePairs[j].split("=")[0] == s)
      return this.keyValuePairs[j].split("=")[1];
    }
    return false;
  }

  this.getParameters = function() {
    var a = new Array(this.getLength());
    for(var j=0; j < this.keyValuePairs.length; j++) {
      a[j] = this.keyValuePairs[j].split("=")[0];
    }
    return a;
  }

  this.getLength = function() { return this.keyValuePairs.length; }
}

var pageQuery = false;

function getQueryString(key){
    if ( !pageQuery ) pageQuery = new PageQuery(window.location.search);
    if ( pageQuery.getValue(key) )
    return unescape(pageQuery.getValue(key));
    else return null;
}
var popupCategory;
var flyouttop;
var lastpopup;
function showpopupcategories(elid) {
    if ( elid == lastpopup ) return;
    lastpopup = elid;
    if ( popupCategory != null ) {
        popupCategory.style.display = "none";
        popupCategory = null;
    }
    var el = document.getElementById(elid);
    if ( el.parentNode ) el.parentNode.removeChild( el );
    var linkel = document.getElementById(elid + "_link");
    var y = findPosY( linkel );
    var x = findPosX( linkel );
    el.style.left = (x-3) + "px";
    el.style.top = (y-3) + "px";
    el.style.display = "";
    setOpacity( el, 85);
    document.body.appendChild( el );
    //el.onmouseout = popupCategoryMouseOut;
    popupCategory = el;
    flyouttop = document.getElementById("flyouttop");
    flyouttop.style.left = (x-3) + "px";
    flyouttop.style.top = (y-3) + "px";
    flyouttop.style.display = "";
    if ( flyouttop.parentNode != document.body )  {
        flyouttop.parentNode.removeChild( flyouttop );
        document.body.appendChild( flyouttop );
    }



}
function hidepopupcategories() {
    if ( popupCategory ) {
        popupCategory.style.display = "none";
        popupCategory = null;
    }
    if ( flyouttop ) {
        flyouttop.style.display = "none";
        flyouttop = null;
    }
}


function showSpecialPage( pageName ) {
       document.location = "http://www.emedtv.com/"+pageName+".html";
}

var specialScrollbars = new Array();
function addSpecialScrollbar(id) {
	specialScrollbars.push(id);
}

var preloadArr = new Array();

function preloadImage( w, h, url ) {
	var i = new Image( w, h );
	i.src = url;
	preloadArr.push(i);
	return i;
}

function preloadImageUrl( url ) {
	var i = new Image();
	i.src = url;
	preloadArr.push(i);
	return i;
}
function spanLinkFooterHover() {
	  $("div#home-footer-bottom-wrapper span.footer-span").hover(function () {
      $(this).css({textDecoration:"underline"});
    }, function () {
      $(this).css({textDecoration:"none"});
    });
	$("div#home-footer-bottom-wrapper span.footer-span").click(function() {
		$linkParameter = this.getAttribute("alt");
		showSpecialPage($linkParameter);
	})
	
}
addLoadEvent(spanLinkFooterHover);