function popUp(url,name,width,height,options) {
  width  = parseInt(width);
  height = parseInt(height);

  settings = "height=" + height + ",";
  settings += ",width=" + width + ",";

  if (options.indexOf("toolbar") != -1)
    settings += "toolbar=yes,";
  else
    settings += "toolbar=no,";

  if (options.indexOf("status") != -1)
    settings += "status=yes,";
  else
    settings += "status=no,";

  if (options.indexOf("location") != -1)
    settings += "location=yes,";
  else
    settings += "location=no,";

  if (options.indexOf("directories") != -1)
    settings += "directories=yes,";
  else
    settings += "directories=no,";

  if (options.indexOf("menubar") != -1)
    settings += "menubar=yes,";
  else
    settings += "menubar=no,";

  if (options.indexOf("scrollbars") != -1)
    settings += "scrollbars=yes,";
  else
    settings += "scrollbars=no,";

  if (options.indexOf("resizable") != -1)
    settings += "resizable=yes,";
  else
    settings += "resizable=no,";

  var nnn=window.open(url,name,settings);

}

function toggleDisplay(id) {
  if (toggleDisplay.arguments.length > 1) {
    if (!document.ZNcurrentFull) {
      document.ZNcurrentFull = new Array();
    }

    if (!document.ZNcurrentFull[toggleDisplay.arguments[1]]) {
      document.ZNcurrentFull[toggleDisplay.arguments[1]] = new Object();
    }

    currentList = document.ZNcurrentFull[toggleDisplay.arguments[1]];
  } else {
    if (!document.ZNcurrentFull) {
      document.ZNcurrentFull = new Object();
    }

    currentList = document.ZNcurrentFull;
  }

  if (currentList.value == id) {
    document.getElementById(id + '_full').style.display = 'none';
    document.getElementById(id + '_brief').style.display = 'block';
    currentList.value = "";

  } else {
    if (currentList.value) {
      document.getElementById(currentList.value + '_full').style.display = 'none';
      document.getElementById(currentList.value + '_brief').style.display = 'block';
    }

    document.getElementById(id + '_brief').style.display = 'none';
    document.getElementById(id + '_full').style.display = 'block';
    currentList.value = id;
  }
}


function showHide(id) {
  if (document.getElementById(id).style.visibility == "visible")
    document.getElementById(id).style.visibility = 'hidden';
  else
    document.getElementById(id).style.visibility = 'visible';
}

var to = "";

function showHideDelay(id) {
  if (document.getElementById(id).style.visibility == "visible")
    to = setTimeout('showHide("' + id + '")',500);
}

function clearDelay() {
  if (to)
    clearTimeout(to);
}
/*
function stripe(id) {
  var even = false;
  var evenColor = arguments[1] ? arguments[1] : "#ffffce";
  var oddColor = arguments[2] ? arguments[2] : "#fff";
  var table = document.getElementById(id);
  if (! table) { return; }
  var tbodies = table.getElementsByTagName("tbody");

  for (var h = 0; h < tbodies.length; h++) {
    var trs = tbodies[h].getElementsByTagName("tr");
      
    for (var i = 0; i < trs.length; i++) {
      if (! trs[i].style.backgroundColor) {
        var tds = trs[i].getElementsByTagName("td");

        for (var j = 0; j < tds.length; j++) {
          var mytd = tds[j];
          if (! mytd.style.backgroundColor) {
            mytd.style.backgroundColor = even ? evenColor : oddColor;
          }
        }
      }
      even =  ! even;
    }
  }
}

*/

function stripe(id,color1,color2) {
  var even = false;
  if(!color1)
        color1 = "#ffffce";
  if(!color2)
        color2 = "#fff";
  var evenColor = arguments[1] ? arguments[1] : color1;
  var oddColor = arguments[2] ? arguments[2] : color2;
  var table = document.getElementById(id);
  if (! table) { return; }
  var tbodies = table.getElementsByTagName("tbody");

  for (var h = 0; h < tbodies.length; h++) {
    var trs = tbodies[h].getElementsByTagName("tr");

    for (var i = 0; i < trs.length; i++) {
      if (! trs[i].style.backgroundColor) {
        var tds = trs[i].getElementsByTagName("td");

        for (var j = 0; j < tds.length; j++) {
          var mytd = tds[j];
          if (! mytd.style.backgroundColor) {
           if(mytd.id != 'NoStripe')
        //      if(mytd.class!="noStripe")
            mytd.style.backgroundColor = even ? evenColor : oddColor;

          }
        }
      }
      even =  ! even;
    }
  }
}
function getFile(url, passData) {
        if (window.XMLHttpRequest) { // Mozilla, Safari, ...
            AJAX = new XMLHttpRequest();
            if (AJAX.overrideMimeType) {
                AJAX.overrideMimeType('text/xml');
                // See note below about this line
            }
        } else if (window.ActiveXObject) { // IE
            try {
                AJAX = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    AJAX = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }
  if (AJAX) {
    AJAX.open("POST", url, false);
    AJAX.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    AJAX.send(passData);
    return AJAX.responseText;
  } else {
     return false;
  }
}

function DeleteWPC(WPCID) {
var answer = confirm('Are You Sure You Want to Delete this Category');
	if(answer==true) { 
		var post = "WPCID="+ WPCID;
		var fileFromServer = getFile('deleteWP.php', post);
		document.getElementById('deleteWP').innerHTML = fileFromServer ;
                setTimeout('ToWhitePapers()',10);		
	}
}

function ToWhitePapers() {
       window.location = 'whitepapers.php';
}

function DeleteBC(WPCID) {
	var answer = confirm('Are You Sure You Want to Delete this Category');
	if(answer==true) {
	        var post = "WPCID="+ WPCID;
	        var fileFromServer = getFile('deleteB.php', post);
	        document.getElementById('deleteWP').innerHTML = fileFromServer ;
                setTimeout('ToBrochures()',10);
	}
}

function ToBrochures() {
       window.location = 'brochures.php';
}

function OrderWPC(WPCID,OrgOrder,NewOrder,location) {
//	var NewOrder = document.getElementById(WPCID+'_CATEGORY');
//	var NWval = NewOrder.options[NewOrder.selectedIndex].value;	 

	 var post = "WPCID=" + WPCID;
//	 post += "&OrgOrder=" + OrgOrder;
	 post +=  "&NewOrder="+NewOrder;
	 post += "&OrgOrder=" + OrgOrder;

        var fileFromServer = getFile(location, post);
        document.getElementById('deleteWP').innerHTML = fileFromServer;
	if(location == 'deleteWP.php') {
        	window.location = 'whitepapers.php';
	} else {
		window.location = 'brochures.php';
	}
}

function DeleteWP(WPID,location) {
var answer = confirm('Are You Sure You Want to Delete this Document');
if(answer) {
        var post = "WPID="+ WPID;
        var fileFromServer = getFile(location, post);
        document.getElementById('deleteWP').innerHTML = fileFromServer ;
        if(location == 'deleteWP.php') {
                window.location = 'whitepapers.php';
        } else {
                window.location = 'brochures.php';
        }

}
}

function EditTradeShow(TSID) {
        var post = "TSID="+ TSID;
        var fileFromServer = getFile('tradeshowsajx.php', post);
        document.getElementById('tsedit').innerHTML = fileFromServer;

}




function DeleteTradeShow(TSID) {
        if(confirm('Are you sure you want to delete this Trade Show?')) {
                document.DTS.DelID.value=TSID;
    		setTimeout('SubmitDeleteForm()',100);
        }
}

function SubmitDeleteForm() {
	document.DTS.submit();
}

function ChangeTSView(view) {
	if(view == 0 ) {
		window.location = 'tradeshows.php';
	}
        if(view == 1) {
                window.location = 'tradeshows.php?view=Old';
        }
	if(view == 2) {
		window.location = 'tradeshows.php?view=All';
	}
}


function ChangeEView(view) {
        if(view == 0 ) {
                window.location = 'events.php';
        }
        if(view == 1) {
                window.location = 'events.php?view=Old';
        }
        if(view == 2) {
                window.location = 'events.php?view=All';
        }
}


function MovieTab(tabnum,maxtab,catcount) {
	for(var idx=1; idx <= maxtab; idx++) {
		document.getElementById("mtab"+idx).className = "mtab_off";
	}
	document.getElementById("mtab"+tabnum).className = "mtab_on";
	MPAjax("tab="+tabnum,catcount);
}

var stretch = new Array();
function MPAjax(postVal,catcount) {
        var http_request = false;

        if (window.XMLHttpRequest) { // Mozilla, Safari, ...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
                // See note below about this line
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }
        http_request.onreadystatechange = function() { alertContents3(http_request,catcount); };
        http_request.open('POST', 'mediaajx.php', true);
        http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        http_request.send(postVal);

    }
    function alertContents3(http_request,catcount) {


        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                document.getElementById('movies').innerHTML = http_request.responseText;
		for(var idx=0;idx<catcount;idx++) {
			stretch[idx] = new fx.Combo('stretch'+idx, {height: true, opacity: false,duration: 300});
                        	// Hide them to begin with
                        	stretch[idx].hide();
		}
            } else {
                alert('There was a problem with the request.');
            }

        }

    }
function MovieShow(disp) {
document.getElementById('stretch'+disp).style.display='block';

var state  = document.getElementById("mhide"+disp+"_state");
if(state.value > 0 && slideState) {
	stretch[disp].toggle();
        document.getElementById("mhide"+disp+"_tag").innerHTML= 
                        '<table align=right><tr><td> '+
                         ' <a href="javascript:void(0)" '+
			 '  style="color:#000333;border:none"><b>HIDE</b></a></td>'+
                         ' <td><a href="javascript:void(0)"  style="color:#000333;border:none"> '+
                         ' <img src="/images/videoplayer/mhidebox.gif" ></a></td></tr></table>';
	slideState = setTimeout('ShowHide("'+disp+'")',500);
} else {
	stretch[disp].toggle();
	document.getElementById("mhide"+disp+"_tag").innerHTML=  
                        '<table align=right><tr><td> '+
                         ' <a href="javascript:void(0)" '+ 
                         '  style="color:#000333;border:none"><b>SHOW</b></a></td>'+
                         ' <td><a href="javascript:void(0)"  style="color:#000333;border:none"> '+
                         ' <img src="/images/videoplayer/mshowbox.gif" ></a></td></tr></table>';
      
	 slideState = setTimeout('ShowHide("'+disp+'")',500);
}


}

function ShowHide(disp) {
	var state  = document.getElementById("mhide"+disp+"_state");
	if(state.value > 0) {
        document.getElementById("mhide"+disp+"_tag").innerHTML= 
			'<table align=right><tr><td> '+
	                ' <a href="javascript:void(0)" OnClick="MovieShow('+disp+')" ' +
			' style="color:#000333;border:none"><b>SHOW</b></a></td>'+
	                ' <td><a href="javascript:void(0)" OnClick="MovieShow('+disp+')" style="color:#000333;border:none"> '+
                        ' <img src="/images/videoplayer/mshowbox.gif" ></a></td></tr></table>';
	        state.value = 0;
	} else {
        document.getElementById("mhide"+disp+"_tag").innerHTML=
                         '<table align=right><tr><td> '+
                         '  <a href="javascript:void(0)" OnClick="MovieShow('+disp+')" '+
			 '  style="color:#000333;border:none"><b>HIDE</b></a></td>'+
                         ' <td><a href="javascript:void(0)" OnClick="MovieShow('+disp+')" style="color:#000333;border:none">'+
                         ' <img src="/images/videoplayer/mhidebox.gif" ></a></td></tr></table>';

	        state.value=1;
	}
	slideState = 1;	
}

function ChangeVideo(postVal) {
        var http_request = false;

        if (window.XMLHttpRequest) { // Mozilla, Safari, ...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
                // See note below about this line
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }
        http_request.onreadystatechange = function() { alertContents2(http_request); };
        http_request.open('POST', 'flashajx.php', true);
        http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        http_request.send(postVal);

    }
    function alertContents2(http_request) {


        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                document.getElementById('flashplayer').innerHTML = http_request.responseText;
            } else {
                alert('There was a problem with the request.');
            }

        }

    }


// IF AGENTS ARE AVAILABLE:
function agents_available(img) {
	if(!img) {
		document.getElementById('smartbutton').innerHTML = '<A HREF="" style="border:none;" onClick="window.open(\'https://www.ntscorp.com/livechat/index.php?cs=1\',\'custclient\',\'width=510,height=320,scrollbars=0\');return false;"><IMG SRC="/images/ntslivechat_on_grey.gif"></A>';
	} else {
                document.getElementById('smartbutton').innerHTML = '<A HREF="" style="border:none;" onClick="window.open(\'https://www.ntscorp.com/livechat/index.php\',\'custclient\',\'width=510,height=320,scrollbars=0\');return false;"><IMG SRC="/images/'+img+'"></A>';
	}
	return true;
}

// IF AGENTS ARE NOT AVAILABLE:
function agents_not_available(img) {
	if(img) {
		document.getElementById('smartbutton').innerHTML = '<IMG SRC="/images/'+img+'">';
 	} else {
                document.getElementById('smartbutton').innerHTML = '<IMG SRC="/images/ntslivechat_off_grey.gif">';
 	}
 	return true;
}

function makeRequest(url, span, postval) {
        var http_request = false;
        if (window.XMLHttpRequest) { // Mozilla, Safari, ...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
                // See note below about this line
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }
        if(span != 'newach' && span !='newabout' && span != 'StanSpan') {
                document.getElementById(span).innerHTML = '<a name= "TR"></a> '+
                '<br><br<br><br><br><br><br><br><br><br> <p align=center><img src="/images/indicator_white.gif"></p> ' +
                ' <br><br<br><br><br><br><br><br><br><br> <br><br<br><br><br><br><br><br><br><br> <br><br> <br> ';
        }
        http_request.onreadystatechange = function() { alertContents(http_request,span); };
        http_request.open('POST', url, true);
        http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        http_request.send(postval);

    }

    function alertContents(http_request,span) {
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                document.getElementById(span).innerHTML = http_request.responseText;
            if(span !='newach' && span !='newabout' && span !='aboutcont') {
               stripe(span);
            }
                childwindow = null;

            } else {
               alert('There was a problem with the request.'+http_request.status);
          }

        }
   }

