/*
#
#  GreatWebScripts    http://www.GreatWebScripts.com
#
#  Copyright (c)2006, GreatWebScripts . All rights reserved.
#
#  No portion of this content may be copied, distributed or reproduced for any
#  reason without the express written consent of the owner. Federal copyright
#  law prohibits unauthorized reproduction by any means and imposes severe fines
#  for violation.
#

#
#  $RCSfile: ratings.js,v $ $Revision: 1.9 $   $Date: 2008-02-04 19:01:53-05 $
#
*/

// Constants (Constant values defined in _Global.php
var GWS_NO               = 0;
var GWS_LOGFILE_NONE     = 0;


function CombineCategory (src_cat, element)
{
  var x = document.getElementById (element);
  var dest_cat = x.options[x.selectedIndex].text;

  // Verify the source and destination are the the same
  if (src_cat != dest_cat)
  {
    if (confirm ("Do you want to move all review in Category '" + src_cat + "' to Category '" + dest_cat + "'?"))
       return x.options[x.selectedIndex].value;
  }

  else
  {
    alert ("Select a different 'Combine with' category to move the reviews");
    return false;
  }

} // end CombineCategory


/*               */
/* Delete Visits */
/*               */

// Global: delete_visits
var delete_submit = false;

//
// onSubmit for delete_visits.
//
function delete_visits_OnSubmit ()
{
  // Copy over to a local and reset the delete flag
  delete_submit_save = delete_submit;
  delete_submit = false;

  // Return the local copy
  return delete_submit_save;

} // end delete_visits_OnSubmit


//
// onClick for delete visits
function delete_visits_OnClick (delete_type, deleteid, date)
{

  delete_submit = false;

  // Save off the parameters for the onSubmit function to call

  if  (delete_type == 'Normal')
    delete_prompt = '' + deleteid;
  else if (delete_type == 'Super')
    delete_prompt = '' + deleteid + ' all earlier Visit Records';
  else
    delete_prompt = '';

  if (delete_prompt.length > 0)
    delete_submit = confirm ("Do you want to Delete Visit Record #" + delete_prompt + "?");

} // end delete_visits_OnClick

// Handles updates to Site Active field
function changeSiteActive ()
{
  // Extract the value set
  var selectedIndex       = window.document.Configuration.UMS_GAME_ENABLED.selectedIndex;
  var selectedIndex_value = window.document.Configuration.UMS_GAME_ENABLED.options[selectedIndex].value;

  // and determine what to do
  if (selectedIndex_value == GWS_NO)
  {
      window.document.Configuration.GAME_NOT_ACTIVE_MESSAGE.disabled = false;
      window.document.Configuration.GAME_NOT_ACTIVE_MESSAGE.className = "textbox-active";
  } // end if

  else
  {
      window.document.Configuration.GAME_NOT_ACTIVE_MESSAGE.disabled = true;
      window.document.Configuration.GAME_NOT_ACTIVE_MESSAGE.className = "textbox-inactive";
  } // end else to if

} // end changeSiteActive


// Handles updates to Logging field
function changeLoggingState ()
{
  // Extract the value set
  var selectedIndex       = window.document.Configuration.GWS_LOGFILE_STATUS.selectedIndex;
  var selectedIndex_value = window.document.Configuration.GWS_LOGFILE_STATUS.options[selectedIndex].value;

  // and determine what to do
  if (selectedIndex_value == GWS_LOGFILE_NONE)
  {
      window.document.Configuration.GWS_MAX_RECORDS_IN_LOG_FILE.disabled = true;
      window.document.Configuration.GWS_MAX_RECORDS_IN_LOG_FILE.className = "textbox-active";

      window.document.Configuration.GWS_DAYS_PURGE_LOG_FILE.disabled = true;
      window.document.Configuration.GWS_DAYS_PURGE_LOG_FILE.className = "textbox-active";

      window.document.Configuration.LOGENTRIES_PER_PAGE.disabled = true;
      window.document.Configuration.LOGENTRIES_PER_PAGE.className = "textbox-active";

      window.document.Configuration.TRANS_LOG.disabled = true;
      window.document.Configuration.TRANS_LOG.className = "textbox-active";
  } // end if

  else
  {
      window.document.Configuration.GWS_MAX_RECORDS_IN_LOG_FILE.disabled = false;
      window.document.Configuration.GWS_MAX_RECORDS_IN_LOG_FILE.className = "textbox-inactive";

      window.document.Configuration.GWS_DAYS_PURGE_LOG_FILE.disabled = false;
      window.document.Configuration.GWS_DAYS_PURGE_LOG_FILE.className = "textbox-inactive";

      window.document.Configuration.LOGENTRIES_PER_PAGE.disabled = false;
      window.document.Configuration.LOGENTRIES_PER_PAGE.className = "textbox-inactive";

      window.document.Configuration.TRANS_LOG.disabled = false;
      window.document.Configuration.TRANS_LOG.className = "textbox-inactive";
  } // end else to if
} // end changeLoggingState


// upddate country on ratings_site table

var xmlhttp;

function updateCountry(in_s, in_c)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
var url="saveCountry.php";
url=url+"?s="+in_s;
url=url+"&c="+in_c;
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function stateChanged()
{
if (xmlhttp.readyState==4)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}
