function printDiv(expert, title, body) {
   var a = window.open('', '', 'width=980,height=800,scrollbars=1');
   a.document.open("text/html");
   a.document.write("<img style=\"padding-left:0;padding-top:0\" src=\"http://st1.uzmantv.com/www.uzmantv.com/images/print_header.PNG\">");
   a.document.write("	<br /><br />");
   a.document.write("<div style=\"font-size:18px;font-family: Verdana, serif;\">");
   a.document.write(title);
   a.document.write("</div>");
   a.document.write("<div style=\"font-size:18px;font-family: Verdana, serif;\">");
   a.document.write(expert);
   a.document.write("</div>");
   a.document.write("<div style=\"padding-right:30px;\">");
   a.document.write(document.getElementById(body).innerHTML);
   a.document.write("</div>");
   a.document.close();
   a.print();
}

function showTermsOfVideoWatch() {
   var a = window.open('', '', 'width=522,height=390,scrollbars=1');
   a.document.open("text/html");
   a.document.write("<img style=\"padding-left:0;padding-top:0\" src=\"http://st1.uzmantv.com/www.uzmantv.com/images/terms_of_use_header.PNG\">");
   a.document.write("	<br />");
   a.document.write("<div style=\"font-size:18px;font-family: Verdana, serif;\">");
   a.document.write("VİDEO İZLEMEYE DAİR YASAL UYARI:");
   a.document.write("</div>");
   a.document.write("<div style=\"padding-right:30px;font-size:12px;font-family: Verdana, serif;\">");
   a.document.write("<br />");
   a.document.write("uzmantv.com sağlık, hukuk, eğitim, teknoloji, internet, astroloji v.b. birçok farklı alanda, farklı uzmanlara ait, çeşitli bilgi ve tavsiyelere yer veren bir internet sitesidir. ");
   a.document.write("	<br /><br />");
   a.document.write("Uzmanlara ait ses ve görüntülerin yer aldığı videolardaki içerikler sadece \"bilgilendirme\" amaçlıdır.");
   a.document.write("	<br /><br />");
   a.document.write("uzmantv.com, hiç bir koşul ve şart altında, uzman tarafından verilen tavsiye, görüş, tahmin ve bilgilerin güvenliğini, doğruluğunu veya tamlığını taahhüt veya garanti etmemektedir. ");
   a.document.write("Sitede yer alan videoların içeriklerindeki bilgi, tahmin ve tavsiye niteliğindeki verilerin herhangi bir amaçla kullanılması veya uygulanması neticesinde meydana gelebilecek olan her türlü doğrudan veya dolaylı, maddi veya manevi zarar, ziyan, hasar, ölüm, hastalık gibi sonuçlardan uzmantv.com'un herhangi bir sorumluluğu bulunmamaktadır.");
   a.document.write("	<br /><br />");
   a.document.write("uzmantv.com sitesinde yer alan videolara, site üyeleri tarafından görüş ve düşüncelerini paylaşmak amacıyla yapılan yorumlardan dolayı doğabilecek sorumluluk, sözkonusu fikir ve düşüncelerini açıklayan site üyelerine ait olup, uzmantv.com'un görüş ve düşünceleri denetleme yükümlülüğü bulunmamaktadır.");
   a.document.write("	<br /><br />");
   a.document.write("uzmantv.com sitesinde yer alan videoların tamamı veya herhangi bir kısmı,  uzmantv.com'un bilgisi dışında hiçbir şekilde kopyalanamaz, değiştirilemez, çoğaltılamaz ve yeniden yayınlanamaz.");
   a.document.write("	<br /><br />");
   a.document.write("</div>");
   a.document.write("<div align='right' style=\"padding-right:30px;\">");
   a.document.write("<img onClick='window.close()' style='cursor:pointer' src='http://st1.uzmantv.com/www.uzmantv.com/images/buton_kapat.gif'>");
   a.document.write("</div>");
   a.document.close();
}

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 eraseCookie(name) {
   createCookie(name, "", -1);
}

function expand(toHide, next) {
   var toShow = next ? nextSibling(toHide) : previousSibling(toHide);

   toHide.style.display = "none";
   // alert(toShow.style.display + " " + (toShow == toHide));
   toShow.style.display = "block";
}

function nextSibling(node) {
   var next = node;
   // ignore text nodes
   do
      next = next.nextSibling;
   while (next && next.nodeType != 1);
   return next;
}

function previousSibling(node) {
   var prev = node;
   // ignore text nodes
   do
      prev = prev.previousSibling;
   while (prev && prev.nodeType != 1);
   return prev;
}

function changeSrc(img, src) {
   img.src = src;
}

var stars;
var comments = new Array("Kötü", "Fena değil", "İdare eder", "Güzel", "Mükemmel");
var rated = false;

function showStars(star, emptyStarSrc, fullStarSrc) {
   if (rated) return;
   stars = new Array(5);
   for (var i = 0; i != 5; i++)
      stars[i] = document.getElementById("star" + i).src;
   var rating = parseInt(star.id.charAt(4));
   for (var i = 0; i <= rating; i++)
      document.getElementById("star" + i).src = fullStarSrc;
   for (var i = rating + 1; i < 5; i++)
      document.getElementById("star" + i).src = emptyStarSrc;
   var cmt = document.getElementById("ratingComment");
   cmt.innerHTML = comments[rating];
   cmt.parentNode.align = "left";
}

function clearStars() {
   if (rated) return;
   for (var i = 0; i != 5; i++)
      document.getElementById("star" + i).src = stars[i];
   var cmt = document.getElementById("ratingComment");
   cmt.innerHTML = "Lütfen puan verin:";
   cmt.parentNode.align = "left";
}

function rate(v, u, e, c, r) {
   if (rated) return;
   rated = true;
   var xmlHttp = getHttpRequest();
   if (xmlHttp == null) return;

   xmlHttp.onreadystatechange = function() {
      if (xmlHttp.readyState == 4) {
         document.getElementById("ratingComment").innerHTML = xmlHttp.responseText;
         for (var i = 0; i != 5; i++)
            document.getElementById("star" + i).className = "";
      }
   }

   var param = 'v=' + encodeURIComponent(v);
   param += '&u=' + encodeURIComponent(u);
   param += '&e=' + encodeURIComponent(e);
   param += '&c=' + encodeURIComponent(c);
   param += '&r=' + encodeURIComponent(r);

   xmlHttp.open('POST', '/app/rate.tv', true);
   xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
   xmlHttp.send(param);
}

function getHttpRequest() {
   var xmlHttp = null;
   try {
      xmlHttp = new XMLHttpRequest();
   } catch (e) {
      var progIds = ['Microsoft.XMLHTTP', 'MSXML2.XMLHTTP', 'MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0']
      var success = false;
      for (var iterator = 0; (iterator < progIds.length) && ( ! success); iterator ++) {
         try {
            xmlHttp = new ActiveXObject(progIds[iterator]);
            success = true;
         } catch (e) {
         }
      }
      if (! success) {
         return null;
      }
   }
   return xmlHttp;
}

function activateFlashObjects() {
   var fls = document.getElementsByTagName("object");
   for (var a = 0; a < fls.length; a++)
      fls[a].outerHTML = fls[a].outerHTML;
}

var videoPageLinkIds = new Array("send", "embed");
var activateMethods = new Array(activateSend, activateEmbed);

function activateForm(index, scroll) {
   var sender = document.getElementById(videoPageLinkIds[index]);
   // alert(sender.id);
   sender.parentNode.parentNode.style.background = "url(http://st1.uzmantv.com/www.uzmantv.com/images/launchbar1.gif) repeat-x left top";
   sender.onclick = deactivateForm;
   sender.className = "active";
   for (var i = 0; i != videoPageLinkIds.length; i++) {
      if (i == index) continue;
      var dom = document.getElementById(videoPageLinkIds[i]);
      dom.className = "inactive";
      dom.onclick = activateMethods[i];
      document.getElementById(videoPageLinkIds[i] + "Form").style.display = "none";
   }
   document.getElementById(videoPageLinkIds[index] + "Form").style.display = "block";
   document.getElementById("newsfoot").style.display = "block";
   document.getElementById("msg").innerHTML = "";

   if (scroll)
      window.scrollTo(0, findPosY(sender));
}

function deactivateForm() {
   var dom;
   for (var i = 0; i != videoPageLinkIds.length; i++) {
      alert(videoPageLinkIds[i]);

      dom = document.getElementById(videoPageLinkIds[i]);
      dom.className = "inactive";
      dom.onclick = activateMethods[i];
      document.getElementById(videoPageLinkIds[i] + "Form").style.display = "none";
      // alert(i + ":" + dom + " onclick:" + dom.onclick);
   }
   dom.parentNode.parentNode.style.backgroundImage = "none";
   document.getElementById("newsfoot").style.display = "none";
   document.getElementById("msg").innerHTML = "";
   // alert(document.getElementById("newsfoot").style.display);
}
function activateSend() {
   activateForm(0);
}
function activateEmbed() {
   activateForm(1);
}



function changeSrcAndTxt(e, id, src, td) {
   document.getElementById(id).src = "http://st1.uzmantv.com/www.uzmantv.com/images/" + src;
   if (td)
      e.style.textDecoration = "none";
   else
      e.style.textDecoration = "underline";
}


/* in Favorites page, we should know which video is in action  */
function onUnFavOverInFavorites(id) {
   changeSrcAndTxt(document.getElementById('favorite_' + id), 'img_' + id, 'ikon_favori_cikart.gif', true);
}
function onUnFavOutInFavorites(id) {
   changeSrcAndTxt(document.getElementById('favorite_' + id), 'img_' + id, 'ikon_favori_cikart.gif', false);
}

function hideElement(id) {
   document.getElementById(id).style.display = 'none';
   DeleteCookie('referer_url', '/', '');
}

function DeleteCookie(name, path, domain) {
   document.cookie = name + "=" +
                     ( ( path ) ? ";path=" + path : "") +
                     ( ( domain ) ? ";domain=" + domain : "" ) +
                     ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function checkChars(ta, L) {
   var len = ta.value.length;
   if (len > L) {
      ta.value = ta.value.substring(0, L);
      document.getElementById(ta.id + "chars").innerHTML = "0";
      return;
   }
   document.getElementById(ta.id + "chars").innerHTML = L - len;
}

function validateEmail(email) {
   var at = "@";
   var dot = ".";
   var lat = email.indexOf(at);
   var lstr = email.length;
   var ldot = email.indexOf(dot);
   if (email.indexOf(at) == -1) return false;
   if (email.indexOf(at) == -1 || email.indexOf(at) == 0 || email.indexOf(at) == lstr) return false;
   if (email.indexOf(dot) == -1 || email.indexOf(dot) == 0 || email.indexOf(dot) == lstr) return false;
   if (email.indexOf(at, (lat + 1)) != -1) return false;
   if (email.substring(lat - 1, lat) == dot || email.substring(lat + 1, lat + 2) == dot) return false;
   if (email.indexOf(dot, (lat + 2)) == -1) return false;
   return email.indexOf(" ") == -1;
}

function validate(fromemail, to) {

   var err = "";
   if (fromemail != null) {
      if (fromemail == undefined || fromemail == "")
         err += "Lütfen e-posta adresinizi giriniz.\n";
      else if (!validateEmail(fromemail))
         err += "Lütfen geçerli e-posta adresinizi giriniz.\n";
   }
   if (to == undefined || to == null || to == "")
      err += "Lütfen gönderilecek e-posta adreslerini giriniz.\n"
   if (err != "") {
      alert(err);
      return false;
   }
   to = to.replace(";", ",").replace(/[\s\n\r]/g, "");
   var emails = to.replace(";", ",").replace(/[\s\n\r]/g, "").split(",");
   //alert(emails);
   var comma = "";
   var ok = false;
   for (var i = 0; i < emails.length; i++) {
      var e = emails[i];
      if (e == "" && ok) continue;
      if (!validateEmail(e)) {
         err += comma + "'" + e + "'";
         comma = ", ";
      }
      ok = true;
   }
   if (err.length != 0) {
      alert(err + " e-posta adres(ler)i geçerli değil.\n");
      return false;
   }
   return true;
}

function sendQuestion(video, urlTitle) {
   var ebox = document.getElementById("t3");
   var fromemail = ebox == undefined ? null : ebox.value;
   var message = document.getElementById("t4").value;
   var err = "";
   if (fromemail != null) {
      if (fromemail == undefined || fromemail == "")
         err += "Lütfen e-posta adresinizi giriniz.\n";
      else if (!validateEmail(fromemail))
         err += "Lütfen geçerli e-posta adresinizi giriniz.\n";
   }
   if (message.length == 0) err += "Lütfen sorunuzu giriniz.\n";
   if (err.length > 0) {
      alert(err);
      return;
   }
   var xmlHttp = getHttpRequest();
   if (xmlHttp == null) return;

   var msg = 'video=' + encodeURIComponent(video);
   if (fromemail != undefined && fromemail != null && fromemail != "")
      msg += '&from=' + encodeURIComponent(fromemail);
   msg += '&message=' + encodeURIComponent(message);
   msg += '&urlTitle=' + encodeURIComponent(urlTitle);

   xmlHttp.onreadystatechange = function() {
      if (xmlHttp.readyState == 4) {
         var res = xmlHttp.responseText;
         if (res.length < 10) return;
         //&gt;s/&lt;
         if (res.substr(0, 10) == "&lt;s/&gt;") {
            deactivateForm();
            // reset form
            if (ebox != undefined && ebox != null) ebox.value = "";
            document.getElementById("t3").value = "";
            document.getElementById("t4").value = "";
         }
         document.getElementById("msg").innerHTML = res.substr(10, res.length - 10);
      }
   }
   xmlHttp.open('POST', '/app/sendQuestion.tv', true);
   xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
   xmlHttp.send(msg);
}

var lastSelectedUrl = '';
var lastSelectedLink = '';
var newExpertsHTML = new Array(3);
var popularExpertsHTML = new Array(3);

function getExperts(url, index, div, id) {

   if (id == "newExperts") {
      if (newExpertsHTML[index] != null) {
         document.getElementById(div).innerHTML = newExpertsHTML[index];
         document.getElementById("newExperts").style.fontWeight = "bold";
         document.getElementById("popularExperts").style.fontWeight = "normal";
         document.getElementById("nextButton").style.visibility = "visible";
         document.getElementById("prevButton").style.visibility = "visible";
         lastSelectedUrl = url;
         lastSelectedLink = id;
         return;
      }
   } else {
      if (popularExpertsHTML[index] != null) {
         document.getElementById(div).innerHTML = popularExpertsHTML[index];
         document.getElementById("newExperts").style.fontWeight = "normal";
         document.getElementById("popularExperts").style.fontWeight = "bold";
         document.getElementById("nextButton").style.visibility = "visible";
         document.getElementById("prevButton").style.visibility = "visible";
         lastSelectedUrl = url;
         lastSelectedLink = id;
         return;
      }
   }

   var xmlHttp = getHttpRequest();
   if (xmlHttp == null) return;
   xmlHttp.onreadystatechange = function() {
      if (xmlHttp.readyState == 4) {
         document.getElementById(div).innerHTML = xmlHttp.responseText;
         document.getElementById("nextButton").style.visibility = "visible";
         document.getElementById("prevButton").style.visibility = "visible";
         lastSelectedUrl = url;
         lastSelectedLink = id;
         if (id == "newExperts") {
            document.getElementById("newExperts").style.fontWeight = "bold";
            document.getElementById("popularExperts").style.fontWeight = "normal";
            newExpertsHTML[index] = xmlHttp.responseText;
         } else {
            document.getElementById("newExperts").style.fontWeight = "normal";
            document.getElementById("popularExperts").style.fontWeight = "bold";
            popularExpertsHTML[index] = xmlHttp.responseText;
         }
      }
   }
   xmlHttp.open("GET", url + '&p=' + index, true);
   xmlHttp.send(null);
}

function getNextExperts(index, div) {

   var nextIndex = 1;

   if (lastSelectedUrl == '') {
      lastSelectedUrl = 'app/js/experts/topexpert.tv?sort=atd';
      lastSelectedLink = 'newExperts';
   }
   else {
      nextIndex = Number(index) + 1;
   }

   if (nextIndex < 3)
      getExperts(lastSelectedUrl, nextIndex, div, lastSelectedLink);
   else
      getExperts(lastSelectedUrl, 0, div, lastSelectedLink);
}

function getPreviousExperts(index, div) {

   var nextIndex = 1;

   if (lastSelectedUrl == '') {
      lastSelectedUrl = 'app/js/experts/topexpert.tv?sort=atd';
      lastSelectedLink = 'newExperts';
   }
   else {
      nextIndex = Number(index) - 1;
   }

   if (nextIndex != -1)
      getExperts(lastSelectedUrl, nextIndex, div, lastSelectedLink);
   else
      getExperts(lastSelectedUrl, 2, div, lastSelectedLink);
}

function findPosY(obj) {
   var curtop = 0;
   if (obj.offsetParent) {
      while (obj.offsetParent) {
         curtop += obj.offsetTop
         obj = obj.offsetParent;
      }
   }
   else if (obj.y)
      curtop += obj.y;
   return curtop;
}
function selectTextArea(id) {
   var ta = document.getElementById(id);
   ta.focus();
   ta.select();
}

// if the user moves mouse on Kategoriler menu then we show a popup 
// if the mouse is out then we should not hide popup immediately, rather we
// should keep a timer and hide it after 500 msec. we keep this timer because
// if the user moves move on and out consecutively then it disturbs the user.
// in this 500 msec time we check whether the user has moved the mouse on again
// so the previous timer will be cancelled and a new timer will start.. 
// the variable currentTimerId is used for this purpose
var showPopup = 0;
var currentTimerId = 0;

function menuOver(index, id) {
   showPopup = 1;
   currentTimerId += 1;
   document.getElementById(id).src = 'http://st1.uzmantv.com/www.uzmantv.com/images/ustmenu' + index + '_o.gif';
   document.getElementById(id + 'Popup').style.display = 'block';
}

function menuOut(index, id) {
   showPopup = 0;
   setTimeout("hidePopup('" + index + "','" + id + "','" + currentTimerId + "')", 500);
}

function hidePopup(index, id, cid) {
   // if the mouse is out and this is the last timer then hide popup
   // so intermediate timers will be ignored
   if (showPopup == 0 && cid == currentTimerId) {
      document.getElementById(id).src = 'http://st1.uzmantv.com/www.uzmantv.com/images/ustmenu' + index + '.gif';
      document.getElementById(id + 'Popup').style.display = 'none';
   }
}
function highlightBorder(id) {
   document.getElementById(id).style.borderColor = 'red';
   document.getElementById(id).style.cursor = 'pointer';
}
function unlightBorder(id) {
   document.getElementById(id).style.borderColor = '#E1E1E1';
}
function selectAnswer(id, url) {
   document.getElementById(id).style.backgroundColor = 'red';
   document.getElementById(id).style.color = 'white';
   setTimeout('redirect(\'' + url + '\')', 200);
}
function redirect(url) {
   location.href = url;
}

/*
 function embedFlash(id) {
 document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="450" height="404" id="player" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="v/player.swf?v=' + id + '" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><param name="WMode" value="Transparent"><embed src="v/player.swf?v=' + id + '" wmode="transparent" quality="high" bgcolor="#ffffff" width="450" height="404" name="player" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>');
 }
 */


function google_ad_request_done(google_ads) {
   var s = "";
   var i;
   if (google_ads.length == 0) {
      return;
   }
   var horizontal = false;
   if (banner_google_width / banner_google_height > 2) {
      horizontal = true;
   }
   if (google_ads[0].type == "flash") {
      s += "<a href=\"" + google_info.feedback_url + "\" style=\"color:gray;font-size:12px\">Google Reklamlar\u0131</a><br/>" + "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"" + " codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" WIDTH=\"" + google_ad.image_width + "\" HEIGHT=\"" + google_ad.image_height + "\"> <PARAM NAME=\"movie\" VALUE=\"" + google_ad.image_url + "\">" + "<PARAM NAME=\"quality\" VALUE=\"high\">" + "<PARAM NAME=\"AllowScriptAccess\" VALUE=\"never\">" + "<PARAM NAME=\"wmode\" VALUE=\"transparent\">" + "<EMBED src=\"" + google_ad.image_url + "\" WIDTH=\"" + google_ad.image_width + "\" HEIGHT=\"" + google_ad.image_height + "\" TYPE=\"application/x-shockwave-flash\"" + " AllowScriptAccess=\"never\" " + " PLUGINSPAGE=\"http://www.macromedia.com/go/getflashplayer\" wmode=transparent></EMBED></OBJECT>";
   } else if (google_ads[0].type == "image") {
       s += "<a target=\"_blank\" style=\"color:#999999; font-size:85%; font-family:Verdana, serif;\" href=\"" + google_info.feedback_url + "\" style=\"color:000000\">Google Reklamlar\u0131</a><br/>";
      s += "<a href=\"" + google_ads[0].url + "\" target=\"_blank\" title=\"go to " + google_ads[0].visible_url + "\" onmouseout=\"window.status=''\" onmouseover=\"window.status='go to " + google_ads[0].visible_url + "';return true\"><img border=\"0\" src=\"" + google_ads[0].image_url + "\"width=\"" + google_ads[0].image_width + "\"height=\"" + google_ads[0].image_height + "\"></a>";
      
   } else {
      /*
       if (banner_google_width < 120) {
       adTextHeight = 110;
       } else if (banner_google_width < 200) {
       adTextHeight = 90;
       } else {
       adTextHeight = 57;
       }

       s += "<!--" + adTextHeight + "-->";
       */
      s += "<div class=\"rectangle_ad_unit\" ";
      //var spacing;
      if (banner_google_width) {
         s += "style=\"max-width:570px; width:570px;padding:7px; \"";
         /*
          var textHeight = google_ads.length * adTextHeight;
          spacing = 10;
          } else {
          spacing = 15;
          */
      }
      s += ">";
       s += "<div><a class=\"add_origin\" target=\"_blank\" href=\"" + google_info.feedback_url + "\">Google Reklamlar\u0131</a></div>";
      if (horizontal) {
         s += "<table><tr align=\"left\">";
      }
      for (i = 0; i < google_ads.length; ++i) {
         if (horizontal) {
            s += "<td valign=\"top\">";
         } else {
            if (i > 0) {
               //s += "<br style=\"line-height:" + spacing + "px;\" />";
               //s += "<br style=\"line-height:10px;\" />";
            }
         }
         s += "<div style=\"margin-top:10px\"><a class=\"ad_block\" target=\"_blank\" href=\"" + google_ads[i].url + "\" onmouseout=\"window.status=''\" onmouseover=\"window.status='go to " + google_ads[i].visible_url + "';return true\"><strong>" + google_ads[i].line1 + "</strong></a> <a style=\"margin-left:5px\" class=\"ad_block\" target=\"_blank\" href=\"" + google_ads[i].url + "\"><em>" + google_ads[i].visible_url + "</em></a></div> <div class=\"ad_lines\"><span class=\"ad_line_1\">" + google_ads[i].line2 + "</span> <span class=\"ad_line_2\">" + google_ads[i].line3 + "</span></div>";
         if (horizontal) {
            s += "</td>";
         } else {
         }
      }
      if (horizontal) {
         s += "</tr></table>";
      }

      s += "</div>";
   }
   document.write(s);
   return;
}






