var xmlhttp

if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
{
  try {
        xmlhttp = new XMLHttpRequest ();
  }
  catch (e) {
  xmlhttp = false}
}

var mnmxmlhttp = Array ();
var xvotesString = Array ();
var mnmPrevColor = Array ();
var responsestring = Array ();
var myxmlhttp = Array ();
var responseString = new String;


function emailto (original_id, htmlid, address_count)
{
     email_message = document.getElementById('email_message' + htmlid).value;
window.alert('test1');
     email_address = document.getElementById('email_address_1_' + htmlid).value;
        if (address_count > 1){
                for ($i = 2; $i <= address_count; $i++) {
                        if(document.getElementById('email_address_' + $i + '_' + htmlid).value != "") {
                                email_address = email_address + ', ' + document.getElementById('email_address_' + $i + '_' + htmlid).value;
                        }
                }
        }

        if (xmlhttp) {
                url = "portal/modules/stories/recommend.php";
                mycontent = "email_address=" + escape(email_address) + "&email_to_submit=submit&email_message=" + escape(email_message) + "&original_id=" + original_id + "&backup=0";
                target2 = document.getElementById ('emailto-' + htmlid);
                target2.innerHTML = "<br>Sending, please wait....";

                mnmxmlhttp[htmlid] = new myXMLHttpRequest ();
                if (mnmxmlhttp) {
                        mnmxmlhttp[htmlid].open ("POST", url, true);
                        mnmxmlhttp[htmlid].setRequestHeader ('Content-Type',
                                           'application/x-www-form-urlencoded');

                        mnmxmlhttp[htmlid].send (mycontent);
                        errormatch = new RegExp ("^ERROR:");
                        target1 = document.getElementById ('emailto-' + htmlid);
                        mnmxmlhttp[htmlid].onreadystatechange = function () {
                                if (mnmxmlhttp[htmlid].readyState == 4) {
                                        xvotesString[htmlid] = mnmxmlhttp[htmlid].responseText;

                                        if (xvotesString[htmlid].match (errormatch)) {
                                                xvotesString[htmlid] = xvotesString[htmlid].substring (6, xvotesString[htmlid].length);
                                                target2 = document.getElementById ('emailto-' + htmlid);
                                                target2.innerHTML = xvotesString[htmlid];                                     
                                        } else {
                                                target2 = document.getElementById ('emailto-' + htmlid);
                                                target2.innerHTML = xvotesString[htmlid];
                                        }
                                }
                        }
                }
        }
}


function myXMLHttpRequest ()
{
  var xmlhttplocal;
  try {
        xmlhttplocal = new ActiveXObject ("Msxml2.XMLHTTP")}
  catch (e) {
        try {
        xmlhttplocal = new ActiveXObject ("Microsoft.XMLHTTP")}
        catch (E) {
          xmlhttplocal = false;
        }
  }

  if (!xmlhttplocal && typeof XMLHttpRequest != 'undefined') {
        try {
          var xmlhttplocal = new XMLHttpRequest ();
        }
        catch (e) {
          var xmlhttplocal = false;
        }
  }
  return (xmlhttplocal);
}



function show_recommend(htmlid, linkid, instpath)
{
        var emailtodisplay=document.getElementById('emailto-' + htmlid).style.display ? '' : 'none';
        document.getElementById('emailto-' + htmlid).style.display = emailtodisplay;

        if (xmlhttp) {
                url = "/portal/modules/stories/recommend.php";
                mycontent = "draw=small&htmlid=" + htmlid + "&linkid=" + linkid;
                target2 = document.getElementById ('emailto-' + htmlid);
                target2.innerHTML = "<br>Loading, please wait....";
                mnmxmlhttp[htmlid] = new myXMLHttpRequest ();

                if (mnmxmlhttp) {
                        mnmxmlhttp[htmlid].open ("POST", url, true);
                        mnmxmlhttp[htmlid].setRequestHeader ('Content-Type',
                                           'application/x-www-form-urlencoded');

                        mnmxmlhttp[htmlid].send (mycontent);
                        errormatch = new RegExp ("^ERROR:");
                        target1 = document.getElementById ('emailto-' + htmlid);
                        mnmxmlhttp[htmlid].onreadystatechange = function () {
                                if (mnmxmlhttp[htmlid].readyState == 4) {
                                        xvotesString[htmlid] = mnmxmlhttp[htmlid].responseText;
                                        if (xvotesString[htmlid].match (errormatch)) {
                                                xvotesString[htmlid] = xvotesString[htmlid].substring (6, xvotesString[htmlid].length);
                                                target2 = document.getElementById ('emailto-' + htmlid);
                                                target2.innerHTML = xvotesString[htmlid];                                     
                                        } else {
                                                target2 = document.getElementById ('emailto-' + htmlid);
                                                target2.innerHTML = xvotesString[htmlid];
                                        }
                                }
                        }
                }
        }
}


function blk1stylecontrol(t){
  for (i=1;i<=4;i++){
    tdelement =document.getElementById('blk1tag'+i);                  // ts controls the style of td element
    tr = document.getElementById('blk1div'+i);                // tr controls the display of div element
    ta = document.getElementById('blk1anchor'+i);                // ta controls the style of anchor tag
    if(t==i){
      tdelement.className = "tabstyle";
      ta.className="blklinkstyle2";
      tdelement.style.borderBottom="1px solid #FFFFFF";
      tr.style["display"]="block";
      tr.style["visibility"]="visible";
    }
    else{
      // window.alert("I am in else part" + ts);
      tdelement.className="blktabstyle";
      ta.className="blklinkstyle";
      tdelement.style.borderBottom="1px solid #B5D6EF";
      tr.style["display"]="none";
      tr.style["visibility"]="hidden";
    }
  }
}

function blk2stylecontrol(t){
  for (i=1;i<=4;i++){
    tdelement =document.getElementById('blk2tag'+i);                  // ts controls the style of td element
    tr = document.getElementById('blk2div'+i);                // tr controls the display of div element
    ta = document.getElementById('blk2anchor'+i);                // ta controls the style of anchor tag
    if(t==i){
      tdelement.className = "tabstyle";
      ta.className="blklinkstyle2";
      tdelement.style.borderBottom="1px solid #FFFFFF";
      tr.style["display"]="block";
      tr.style["visibility"]="visible";
    }
    else{
      // window.alert("I am in else part" + ts);
      tdelement.className="blktabstyle";
      ta.className="blklinkstyle";
      tdelement.style.borderBottom="1px solid #B5D6EF";
      tr.style["display"]="none";
      tr.style["visibility"]="hidden";
    }
  }
}

function blk3stylecontrol(t){
  for (i=1;i<=4;i++){
    tdelement =document.getElementById('blk3tag'+i);                  // ts controls the style of td element
    tr = document.getElementById('blk3div'+i);                // tr controls the display of div element
    ta = document.getElementById('blk3anchor'+i);                // ta controls the style of anchor tag
    if(t==i){
      tdelement.className = "tabstyle";
      ta.className="blklinkstyle2";
      tdelement.style.borderBottom="1px solid #FFFFFF";
      tr.style["display"]="block";
      tr.style["visibility"]="visible";
    }
    else{
      // window.alert("I am in else part" + ts);
      tdelement.className="blktabstyle";
      ta.className="blklinkstyle";
      tdelement.style.borderBottom="1px solid #B5D6EF";
      tr.style["display"]="none";
      tr.style["visibility"]="hidden";
    }
  }
}

function blk4stylecontrol(t){
  for (i=1;i<=4;i++){
    tdelement =document.getElementById('blk4tag'+i);                  // ts controls the style of td element
    tr = document.getElementById('blk4div'+i);                // tr controls the display of div element
    ta = document.getElementById('blk4anchor'+i);                // ta controls the style of anchor tag
    if(t==i){
      tdelement.className = "tabstyle";
      ta.className="blklinkstyle2";
      tdelement.style.borderBottom="1px solid #FFFFFF";
      tr.style["display"]="block";
      tr.style["visibility"]="visible";
    }
    else{
      // window.alert("I am in else part" + ts);
      tdelement.className="blktabstyle";
      ta.className="blklinkstyle";
      tdelement.style.borderBottom="1px solid #B5D6EF";
      tr.style["display"]="none";
      tr.style["visibility"]="hidden";
    }
  }
}

function blk5stylecontrol(t){
  for (i=1;i<=2;i++){
    tdelement =document.getElementById('blk5tag'+i);                  // ts controls the style of td element
    tr = document.getElementById('blk5div'+i);                // tr controls the display of div element
    ta = document.getElementById('blk5anchor'+i);                // ta controls the style of anchor tag
    if(t==i){
      tdelement.className = "tabstyle";
      ta.className="blklinkstyle2";
      tdelement.style.borderBottom="1px solid #FFFFFF";
      tr.style["display"]="block";
      tr.style["visibility"]="visible";
    }
    else{
      // window.alert("I am in else part" + ts);
      tdelement.className="blktabstyle";
      ta.className="blklinkstyle";
      tdelement.style.borderBottom="1px solid #B5D6EF";
      tr.style["display"]="none";
      tr.style["visibility"]="hidden";
    }
  }
}

function blk6stylecontrol(t){
  for (i=1;i<=2;i++){
    tdelement =document.getElementById('blk6tag'+i);                  // ts controls the style of td element
    tr = document.getElementById('blk6div'+i);                // tr controls the display of div element
    ta = document.getElementById('blk6anchor'+i);                // ta controls the style of anchor tag
    if(t==i){
      tdelement.className = "tabstyle";
      ta.className="blklinkstyle2";
      tdelement.style.borderBottom="1px solid #FFFFFF";
      tr.style["display"]="block";
      tr.style["visibility"]="visible";
    }
    else{
      // window.alert("I am in else part" + ts);
      tdelement.className="blktabstyle";
      ta.className="blklinkstyle";
      tdelement.style.borderBottom="1px solid #B5D6EF";
      tr.style["display"]="none";
      tr.style["visibility"]="hidden";
    }
  }
}


function blk7stylecontrol(t){
  for (i=1;i<=4;i++){
    tdelement =document.getElementById('blk7tag'+i);                  // ts controls the style of td element
    tr = document.getElementById('blk7div'+i);                // tr controls the display of div element
    ta = document.getElementById('blk7anchor'+i);                // ta controls the style of anchor tag
    if(t==i){
      tdelement.className = "tabstyle";
      ta.className="blklinkstyle2";
      tdelement.style.borderBottom="1px solid #FFFFFF";
      tr.style["display"]="block";
      tr.style["visibility"]="visible";
    }
    else{
      // window.alert("I am in else part" + ts);
      tdelement.className="blktabstyle";
      ta.className="blklinkstyle";
      tdelement.style.borderBottom="1px solid #B5D6EF";
      tr.style["display"]="none";
      tr.style["visibility"]="hidden";
    }
  }
}



