/*
 * WCA Specific functions
 *
 */

function configViewer(p1, p2)
{
  setCookie(v1, hex_md5(p1 + p2), 0);
}

function TandC()
{
	var a = new oAjax("http://"+location.host+"/includes/tandc.php", candt);
	var x = "TandC="+document.getElementById("TermsAndConditions").checked;
	a.update(x, "POST");
	return true;
}

function setTandC()
{
  var oTandC = document.getElementById("TermsAndConditions");

  if ( oTandC.checked == true )
  {
    oTandC.checked = false;
  }
  else
  {
    oTandC.checked = true;
  }

  TandC();
}

function NoTandC(msg)
{
  alert(msg);
}

function candt()
{
}

function markAcknowledged( isChecked, stepName )
{  
    var ajax = new oAjax( "http://"+location.host+"/includes/ackstep.php", procAckStep );
    var params = "step="+stepName
    
    if (isChecked)
    {
        params += "&ack=1";
    }
    
    ajax.update( params, "POST" );
}

function procAckStep( responseText, responseStatus )
{
    if ( responseStatus == 200 )
    {
        response = explodeParamStr(responseText);

        if ( response[ "imgSource" ] != "no" )
        {   
            oImg = document.getElementById( response[ "imgStepName" ] );
            
            if ( oImg != "undefined" )
            {
                oImg.src = response[ "imgSource" ];
            }
        }
    }
}

var hWinHelp = null;

function closeHelp()
{
    try
    {
        hWinHelp.focus();
        hWinHelp.close();
    }
    catch(e)
    {}
}

function showHelp( titleCode )
{
    var ajax = new oAjax( "includes/contextHelp.php", contextHelp );
    ajax.update( "&titleCode="+titleCode+"&cmd=config" );
}

function contextHelp( r, s )
{
    closeHelp();

    if ( s == 200 )
    {
        help = explodeParamStr( r );
        hWinHelp = OpenWindow( "/includes/contextHelp.php?titleCode="+help["titleCode"], "ModelsPluginHelp", help["width"], help["height"], false );
        hWinHelp.focus();
    }

    return;
}

function helpRedirect( url )
{
    try
    {
        window.opener.location = url;
        window.close();
    }
    catch ( e )
    {
        window.location = url;
    }
    
    return (false);
}