function display_pf_1 (div_id, img_id, type, obj_url) {
   var so = new SWFObject("/flash/pf-1.swf", div_id, "100", "100", "6", "#ffffff");
   so.addVariable("img_id",  img_id);
   so.addVariable("type",    type);
   so.addVariable("obj_url", obj_url);
   so.write(div_id);
}

var browser, verStr = navigator.appVersion, app = navigator.appName, version = parseFloat(verStr);

function test_browser () {
  if ((app.indexOf('Netscape') != -1) && version >= 5) {
    browser = "netscape";
  }
  else if ((app.indexOf('Microsoft') != -1) && version >= 4) {
    browser = "ie";
  }
}

var body_content = new Array("bodycontent", "preloader");

function show_sub(show_which_sub, var_array, mode) {

  if (mode == "preloader") {
    for (i = 0; i < eval(var_array + ".length"); i++) {
      if (eval(var_array + "[i]") != show_which_sub) {
        hide_sub(eval(var_array + "[i]"), mode);
      }
    }
  }

  if (show_which_sub != "") {
    if (browser == "netscape") {
      if (document.getElementById(show_which_sub).style.display == 'block') {
        document.getElementById(show_which_sub).style.display = 'none';
      }
      else {
        document.getElementById(show_which_sub).style.display = 'block';
      }
    }
    else if (browser == "ie") {
      show_menu_1 = eval(show_which_sub);
      if(show_menu_1.style.display == 'block'){
        show_menu_1.style.display = 'none';
      }
      else {
        show_menu_1.style.display = 'block';
      }
    }
  }

}

function hide_sub(which_sub, mode) {
  if (browser == "netscape") {
    document.getElementById(which_sub).style.display = 'none';
  }
  else if (browser == "ie") {
    show_menu_1 = eval(which_sub);
    show_menu_1.style.display = 'none';
  }
}

function auto_hide() {
  show_sub("");
}

function setPointer(theRow, thePointerColor, theNormalBgColor)
{
  var theCells = null;

  if (thePointerColor == '' || typeof(theRow.style) == 'undefined') {
      return false;
  }
  if (typeof(document.getElementsByTagName) != 'undefined') {
      theCells = theRow.getElementsByTagName('td');
  }
  else if (typeof(theRow.cells) != 'undefined') {
      theCells = theRow.cells;
  }
  else {
      return false;
  }

  var rowCellsCnt  = theCells.length;
  var currentColor = null;
  var newColor     = null;
  // Opera does not return valid values with "getAttribute"
  if (typeof(window.opera) == 'undefined'
      && typeof(theCells[0].getAttribute) != 'undefined' && typeof(theCells[0].getAttribute) != 'undefined') {
      currentColor = theCells[0].getAttribute('bgcolor');
      newColor     = (currentColor.toLowerCase() == thePointerColor.toLowerCase())
                   ? theNormalBgColor
                   : thePointerColor;
      for (var c = 0; c < rowCellsCnt; c++) {
          theCells[c].setAttribute('bgcolor', newColor, 0);
      } // end for
  }
  else {
      currentColor = theCells[0].style.backgroundColor;
      newColor     = (currentColor.toLowerCase() == thePointerColor.toLowerCase())
                   ? theNormalBgColor
                   : thePointerColor;
      for (var c = 0; c < rowCellsCnt; c++) {
          theCells[c].style.backgroundColor = newColor;
      }
  }

  return true;
} // end of the 'setPointer()' function

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function hide_radio_bts() {
  for (i = 0; i < document.forms.length; i++) {
    var frm = document.forms[i];
    for(x=0; x< frm.length; x++){
      if (frm.elements[x].type == "select-one") {
        frm.elements[x].style.visibility = "hidden";
      }
      if (frm.elements[x].type == "select-multiple") {
        frm.elements[x].style.visibility = "hidden";
      }
    }
  }
}
function show_radio_bts() {
  for (i = 0; i < document.forms.length; i++) {
    var frm = document.forms[i];
    for(x=0; x< frm.length; x++){
      if (frm.elements[x].type == "select-one") {
        frm.elements[x].style.visibility = "visible";
      }
      if (frm.elements[x].type == "select-multiple") {
        frm.elements[x].style.visibility = "visible";
      }
    }
  }
}

test_browser();

var active_menu = "";
function display_menu(menu_id) {

  if (active_menu != "") {
    if (active_menu != menu_id) {
      document.getElementById(active_menu).style.display = "none";
    }
  }
  document.getElementById(menu_id).style.display = "block";
  active_menu = menu_id;

}

function display_rec(row_id) {

  if (document.getElementById(row_id).style.display == "none") {
    document.getElementById(row_id).style.display = "block";
  }
  else {
    document.getElementById(row_id).style.display = "none";
  }

}

function urank(eid, step, max_rank) {

  if (browser == 'ie') {
    e = window.event;
    if (e.ctrlKey) {
      step = step * 5;
    }
  }

  rank = Number(document.getElementById(eid).value) + step;

  if (rank < 1) {
    rank = 1;
  }
  if (rank > max_rank) {
    rank = max_rank;
  }

  document.getElementById(eid).value = rank;
  document.getElementById("d" + eid).value = rank + "/" + max_rank;

}

function page_rank(var_name, value, eid, max_rank, mode, external, divid) {
  var str;
  if (mode == "view") {
    str = "<input type=\"text\" value=\"" + value + "/" + max_rank + "\" size=\"5\" readOnly class=\"rank\" id=\"d" + eid + "\">";
    str += "<input type=\"hidden\" name=\"" + var_name + "\" value=\"" + value + "\" id=\"" + eid + "\">";
  }
  else {
    str = "<img src=\"images/d.gif\" width=\"16\" height=\"16\" title=\"down...\" align=\"absmiddle\" border=\"0\" onClick=\"urank('" + eid + "', -1, " + max_rank + ");\" /> ";
    str += "<input type=\"text\" value=\"" + value + "/" + max_rank + "\" size=\"5\" readOnly class=\"rank\" id=\"d" + eid + "\">";
    str += "<input type=\"hidden\" name=\"" + var_name + "\" value=\"" + value + "\" id=\"" + eid + "\">";
    str += " <img src=\"images/u.gif\" width=\"16\" height=\"16\" title=\"up...\" align=\"absmiddle\" border=\"0\" onClick=\"urank('" + eid + "', 1, " + max_rank + ");\" />";
  }
  //for calling javascript in ajax
  if(external == 1){
    document.getElementById(divid).innerHTML = str;
  }
  else{
    document.write(str);
  }
}

function status(var_name, value, eid, mode, external, divid) {
  var str;
  if (mode == "edit") {
    img = "ina.gif";
    alt_tit = "Status Inactive";
    if (value == 1) {
      img = "act.gif";
    alt_tit = "Status Active";
    }
    str = "<img src=\"images/" + img + "\" width=\"16\" height=\"16\" title=\"" + alt_tit + "\" title=\"" + alt_tit + "\" / id=\"s" + eid + "\" onClick=\"change_status('" + eid + "')\">";
  }
  else {
    img = "ina-2.gif";
    alt_tit = "Status Inactive";
    if (value == 1) {
      img = "act-2.gif";
    alt_tit = "Status Active";
    }
    str = "<img src=\"images/" + img + "\" width=\"16\" height=\"16\" title=\"" + alt_tit + "\" title=\"" + alt_tit + "\" / id=\"s" + eid + "\">";
  }
  str += "<input type=\"hidden\" name=\"" + var_name + "\" value=\"" + value + "\" id=\"" + eid + "\">";

  //for calling javascript in ajax
  if(external == 1){
    document.getElementById(divid).innerHTML = str;
  }
  else{
    document.write(str);
  }
}

function change_status(eid){

  status = document.getElementById(eid).value;

  if (status == 1) {
    document.getElementById(eid).value = 0;
    document.getElementById('s' + eid).src = "images/ina.gif";
    //document.getElementById('s' + eid).alt = "inactive";
  }
  else {
    document.getElementById(eid).value = 1;
    document.getElementById('s' + eid).src = "images/act.gif";
    //document.getElementById('s' + eid).alt = "active";
  }

}

function featured(var_name, value, eid, mode) {

  if (mode == "edit") {
    img = "fea-1.gif";
    alt_tit = "Not Featured Item";
    if (value == 1) {
      img = "fea-2.gif";
    alt_tit = "Featured Item";
    }
    document.write("<img src=\"images/" + img + "\" width=\"16\" height=\"16\" title=\"" + alt_tit + "\" title=\"" + alt_tit + "\" / id=\"f" + eid + "\" onClick=\"change_featured('" + eid + "')\">");
  }
  else {
    img = "fea-3.gif";
    alt_tit = "Not Featured Item";
    if (value == 1) {
      img = "fea-4.gif";
    alt_tit = "Featured Item";
    }
    document.write("<img src=\"images/" + img + "\" width=\"16\" height=\"16\" title=\"" + alt_tit + "\" title=\"" + alt_tit + "\" / id=\"f" + eid + "\">");
  }
  document.write("<input type=\"hidden\" name=\"" + var_name + "\" value=\"" + value + "\" id=\"" + eid + "\">");

}

function change_featured(eid){

  featured_val = document.getElementById(eid).value;

  if (featured_val == 1) {
    document.getElementById(eid).value = 0;
    document.getElementById('f' + eid).src = "images/fea-1.gif";
    //document.getElementById('s' + eid).alt = "inactive";
  }
  else {
    document.getElementById(eid).value = 1;
    document.getElementById('f' + eid).src = "images/fea-2.gif";
    //document.getElementById('s' + eid).alt = "active";
  }

}

function edit_button(url, alt, external, divid) {
  var str;
  str = "<a href=\"" + url + "\"><img src=\"images/modify.gif\" width=\"16\" height=\"16\" title=\"" + alt + "\" border=\"0\" /></a>";
  //for calling javascript in ajax
  if(external == 1){
    document.getElementById(divid).innerHTML = str;
  }
  else{
    document.write(str);
  }

}

function delete_button(url, alt, external, divid) {
  var str;
  str = "<a href=\"" + url + "\" onClick=\"return confirm('Are you sure?');\"><img src=\"images/delete.gif\" width=\"16\" height=\"16\" title=\"" + alt + "\" border=\"0\" /></a>";

  //for calling javascript in ajax
  if(external == 1){
    document.getElementById(divid).innerHTML = str;
  }
  else{
    document.write(str);
  }
}

function delete_image(url, alt, external, divid) {
  var str;
  str = "<a href=\"" + url + "\" onClick=\"return confirm('Are you sure?');\"><img src=\"images/del_image.gif\" width=\"16\" height=\"16\" title=\"" + alt + "\" border=\"0\" /></a>";

  //for calling javascript in ajax
  if(external == 1){
    document.getElementById(divid).innerHTML = str;
  }
  else{
    document.write(str);
  }

}

function update_flash() {

  objects = document.getElementsByTagName("object");
  for (var i = 0; i < objects.length; i++)  {
      objects[i].outerHTML = objects[i].outerHTML;
  }

}

function row_over(row_id, row_color) {
  document.getElementById(row_id).style.backgroundColor = row_color;
}

function char_count(eid, maxlen, max_lines) {

  var inputstr;
  var strlen;
  var charleft;
  var numcr;
  var temp = new Array();

  if (document.getElementById(eid).value != "") {
    inputstr = document.getElementById(eid).value;
    strlen = inputstr.length;

    if (strlen > maxlen) {
      document.getElementById(eid).value = document.getElementById(eid).value.substring(0,maxlen);
      charleft = 0;
      alert("Exceeds maximum number of characters!");
    }
    else {
      charleft = maxlen - strlen;
    }

    document.getElementById('charleft' + eid).innerHTML = charleft + " / " + maxlen;

  }

  if (max_lines > 0) {

    var temp2 = document.getElementById(eid).value.split('\r\n');
    var temp_val = "";
    counter = 0;
    if (temp2.length > max_lines) {
      alert("Exceeds maximum number of lines!");
      for (i = 0; i < max_lines; i++) {
        temp_val = temp_val + temp2[i];
        if (i < (max_lines - 1)) {
          temp_val = temp_val + "\n";
        }
      }
      document.getElementById(eid).value = temp_val;
    }

  }

}

side_menu_style = "block"

function show_admin_menu() {

  if (side_menu_style == "block") {
    document.getElementById('side_menu').style.display = "none";
    document.getElementById('mnctrl').src = "images/opn.gif";
    side_menu_style = "none";
  }
  else {
    document.getElementById('side_menu').style.display = "block";
    document.getElementById('mnctrl').src = "images/cls.gif";
    side_menu_style = "block";
  }

}


function country_js(var_name, value, id, css) {

  country_names = new Array (
    "Australia", "New Zealand", "Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua And Barbuda",
    "Argentina", "Armenia", "Aruba", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados",
    "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bosnia Hercegovina", "Botswana", "Bouvet Island",
    "Brazil", "British Indian Ocean Territory", "Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde",
    "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo",
    "Congo, The Democratic Republic Of", "Cook Islands", "Costa Rica", "Cote D'Ivoire", "Croatia", "Cuba", "Cyprus", "Czech Republic", "Czechoslovakia", "Denmark",
    "Djibouti", "Dominica", "Dominican Republic", "East Timor", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia",
    "Ethiopia", "Falkland Islands (Malvinas)", "Faroe Islands", "Fiji", "Finland", "France", "French Guiana", "French Polynesia", "French Southern Territories", "Gabon",
    "Gambia", "Georgia", "Germany", "Ghana", "Gibraltar", "Greece", "Greenland", "Grenada", "Guadeloupe", "Guam",
    "Guatemela", "Guernsey", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Heard and McDonald Islands", "Honduras", "Hong Kong", "Hungary",
    "Iceland", "India", "Indonesia", "Iran (Islamic Republic Of)", "Iraq", "Ireland", "Isle Of Man", "Israel", "Italy", "Jamaica",
    "Japan", "Jersey", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea, Democratic People's Republic Of", "Korea, Republic Of", "Kuwait", "Kyrgyzstan",
    "Lao People's Democratic Republic", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libyan Arab Jamahiriya", "Liechtenstein", "Lithuania", "Luxembourg", "Macau",
    "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Martinique", "Mauritania",
    "Mauritius", "Mayotte", "Mexico", "Micronesia, Federated States Of", "Moldova, Republic Of", "Monaco", "Mongolia", "Montserrat", "Morocco", "Mozambique",
    "Myanmar", "Namibia", "Nauru", "Nepal", "Netherlands", "Netherlands Antilles", "Neutral Zone", "New Caledonia", "Nicaragua",
    "Niger", "Nigeria", "Niue", "Norfolk Island", "Northern Mariana Islands", "Norway", "Oman", "Pakistan", "Palau", "Panama",
    "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Pitcairn", "Poland", "Portugal", "Puerto Rico", "Qatar", "Reunion",
    "Romania", "Russian Federation", "Rwanda", "Saint Helena", "Saint Kitts And Nevis", "Saint Lucia", "Saint Pierre and Miquelon", "Saint Vincent and The Grenadines", "Samoa", "San Marino",
    "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands", "Somalia",
    "South Africa", "South Georgia and The Sandwich Islands", "Spain", "Sri Lanka", "Sudan", "Suriname", "Svalbard and Jan Mayen Islands", "Swaziland", "Sweden", "Switzerland",
    "Syrian Arab Republic", "Taiwan, Province Of China", "Tajikista", "Tanzania, United Republic Of", "Thailand", "Togo", "Tokelau", "Tonga", "Trinidad and Tobago", "Tunisia",
    "Turkey", "Turkmenistan", "Turks and Caicos Islands", "Tuvalu", "USSR", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States",
    "United States Minor Outlying Islands", "Uruguay", "Uzbekistan", "Vanuatu", "Vatican City State", "Venezuela", "Vietnam", "Virgin Islands (British)", "Virgin Islands (US)", "Wallis and Futuna Islands",
    "Western Sahara", "Yemen, Republic of", "Yugoslavia", "Zaire", "Zambia", "Zimbabwe"
  );

  document.write("<select name=\"" + var_name + "\" id=\"" + id + "\" class=\"" + css + "\">");
  for (i = 0; i < country_names.length; i++) {
    document.write("<option value=\"" + country_names[i] + "\">" + country_names[i] + "</option>");
  }
  document.write("</select>");
  document.getElementById(id).value = value;

}
function spacer(){
  w_height     = getViewportHeight();
  min_height   = w_height - 180;

  body_height  = document.getElementById("bodycontent").offsetHeight;
  if(body_height < min_height){
    document.getElementById("bodycontent").style.height = min_height + "px";
  }

}
function resize_iframe()
{

  var height=window.innerWidth;
  if (document.body.clientHeight){
    height=document.body.clientHeight;
  }
  document.getElementById("help_menu").style.height    = parseInt(height -  document.getElementById("help_menu").offsetTop-8)+"px";
  document.getElementById("help_content").style.height = parseInt(height -  document.getElementById("help_menu").offsetTop-8)+"px";
}
var active_box ="livebox";
function publishbox(current_box)
{
  if(active_box !="" && active_box != current_box){
    document.getElementById(active_box).style.display = "none";
  }
    document.getElementById(current_box).style.display = "block";
    active_box = current_box;
}

function submit_form(form_name, cmd) {
  if (document.getElementById('cmd')) {
    document.getElementById('cmd').value = cmd;
  }
  document.getElementById(form_name).submit();
  for (i = 0; i < document.forms.length; i++) {
    var frm = document.forms[i];
    for(x=0; x< frm.length; x++){
      if (frm.elements[x].type == "button") {
        frm.elements[x].disabled = true;
      }
    }
  }
}

active_faq = "";
function show_answer(faq_id) {

  if (active_faq != "") {
    document.getElementById(active_faq).style.display = "none";
  }
  document.getElementById(faq_id).style.display = "block";
  active_faq = faq_id;

}

var active_menu   = "";
var active_level  = "";
var active_top    = "";

function show_menu(which_menu, menu_level, top_menu) {

  if (menu_level == active_level) {
    document.getElementById(active_menu).style.display = "none";
  }
  if (menu_level < active_level) {
    if(document.getElementById(active_top)){
      document.getElementById(active_top).style.display = "none";
      document.getElementById(active_menu).style.display = "none";
    }
  }

  if (document.getElementById(which_menu).style.display != "block") {
    document.getElementById(which_menu).style.display = "block";
    active_menu = which_menu;
    active_level = menu_level;
    active_top = top_menu;
  }

}
function blurQ(r){
    var q = document.getElementById('comment_form');
    if(q.value == ''){
        q.style.color = '#a3a396';
        q.value = r;
    }
}

function focusQ(r){
    var q = document.getElementById('comment_form');
    q.style.color = '#a3a396';
    if(q.value == r) q.value = '';
}
function check_source() {
  document.getElementById('other_source').style.display = "none";
  if (document.getElementById('source').value == "Other") {
    document.getElementById('other_source').style.display = "block";
  }
}

function load_presenter (presenter) {
  var presenter_ids = new Array();
  presenter_ids["Aaron"]    = 114;
  presenter_ids["Bethany"]  = 106;
  presenter_ids["Briony"]   = 107;
  presenter_ids["Candy"]    = 116;
  presenter_ids["Carolyne"] = 117;
  presenter_ids["Cindy"]    = 108;
  presenter_ids["Eli"]      = 119;
  presenter_ids["Hanna"]    = 118;
  presenter_ids["Helen"]    = 120;
  presenter_ids["James"]    = 122;
  presenter_ids["John"]     = 113;
  presenter_ids["Karolina"] = 123;
  presenter_ids["Lara"]     = 127;
  presenter_ids["Laura"]    = 125;
  presenter_ids["Lilian"]   = 126;
  presenter_ids["Shaun"]    = 128;
  presenter_ids["Tina"]     = 105;
  presenter_ids["Wil"]      = 104;
  presenter_ids["Jordie"]   = 254;
  presenter_ids["Lisa"]     = 311;
  presenter_ids["Susie"]    = 312;
  presenter_ids["Sara D"]   = 313;
  presenter_ids["Cedric"]   = 314;
  presenter_ids["Mark"]     = 315;
  presenter_ids["Justin"]   = 316;
  presenter_ids["Karen"]    = 317;
  presenter_ids["Madeline"] = 318;
  presenter_ids["Kate"]     = 319;
  presenter_ids["Steve"]    = 320;
  presenter_ids["Peter"]    = 321;
  presenter_ids["Chloe"]    = 322;
  presenter_ids["Nathan"]   = 323;
  presenter_ids["Sarah L"]  = 324;
 
  presenter_id = presenter_ids[presenter];
  
  filmtime.play({id:presenter_id, align:'bl'});

}

active_presenter = "";
function update_player(presenter) {
  if (active_presenter != "" && active_presenter != presenter) {
    document.getElementById(active_presenter).innerHTML = "reinitializing player...";
    var so = new SWFObject("/flash/audio_player.swf", active_presenter, "150", "35", "6", "#ffffff");
    so.addParam("wmode", "transparent");
    so.addVariable("presenter", active_presenter);
    so.write(active_presenter);
  }
  active_presenter = presenter;
}

var home_content_shown = false
function show_hide_home_content () {
  if (!home_content_shown) {
    document.getElementById('home_content').style.display = "block";
    home_content_shown = true;
  }
  else {
    document.getElementById('home_content').style.display = "none";
    home_content_shown = false;
  }
}

var embed_config = "";
var embed_src = "";

function build_embed_code(){
  var embed_width  = document.getElementById('embed_width').value;
  var embed_height = document.getElementById('embed_height').value;

  if(embed_width == "" || embed_height == ""){
    alert("Please enter a valid size");
    return false;
  }

  var str = '<embed type="application/x-shockwave-flash" src="' + embed_src + '" wmode="transparent" flashvars="config=' + embed_config + '" allowfullscreen="true" allowscriptaccess="always" height="' + embed_height + '" width="' + embed_width + '"></embed>';

  document.getElementById('embed_code').value =  str;
  document.getElementById('embed_code').select();
}