﻿// JScript File

var CONTROL_PREFIX = 'ctl00_MiddleContent_';


function CleanASPNETID(elementID)
{
   return CustomReplace(elementID,CONTROL_PREFIX,'');
}


function AlertError(functionName,ex)
{
   if (ex.description == null)
   {
     alert("Exception: " + functionName + '\n' + ex.message); 
     return;
   }
   
   alert("Exception: " + functionName + '\n' + ex.description); 
}

function LaunchUrl(url)
{
 
   var args='';
   
   args ='toolbar=0,location=0,status=1,menubar=0,';
   args += 'scrollbars=1,resizable=1,width=900,height=650';  
   var contact=window.open(url,'Window',args);  
   
}

function LaunchUrl(url,width,height)
{
 
  var args = '';
      args='toolbar=0,location=0,status=1,menubar=0,';
      args += 'scrollbars=1,resizable=1,width=' + width + ',height=' + height;  
      var contact=window.open(url,'Window',args);  
       
}

 function SetCheckBox(elem)
 {
   var id = CustomReplace(elem.id,'checkbox','');
   var txt = document.getElementById(id);
    
   if (elem.checked == true)
      { txt.value = '1'; }
   else
      { txt.value = '0'; }
 
   return true; 
} 



function GetDropDownListValue(sFieldName)
{
  try
  {
    Idx = document.frmSubmit[sFieldName].selectedIndex;
    return document.frmSubmit[sFieldName].options[Idx].value;
  }
  catch (exception) { return '0'; }	 
}

function CustomReplace(sOrgVal,sSearchVal,sReplaceVal)
{
   var sVal;
   try
   {
      sVal = new String(sOrgVal);
      if (sVal.length < 1) { return sVal; }
      var sRegExp = eval("/" + sSearchVal + "/g");
	  sVal = sVal.replace(sRegExp,sReplaceVal);
   }
   catch (exception) { AlertError('CustomReplace',exception); }
   return sVal;
 }

function MaximizeWindow()
{
 
   window.moveTo(0,0);
   
   if (document.all)
   {
      top.window.resizeTo(screen.availWidth,screen.availHeight);
      return;
   }
 
   if (document.layers || document.getElementById)
   {
     if (top.window.outerHeight<screen.availHeight || top.window.outerWidth < screen.availWidth)
     {
       top.window.outerHeight = screen.availHeight;
       top.window.outerWidth = screen.availWidth;
     }
   }
   
}

function PreventKeys(e)
{
  var key = (navigator.appName == "Netscape") ? e.which : e.keyCode;
  switch (key)
  {
     case 13:
             e.keyCode = 9;
			 break;
  }
   return true;
}
 
function ValidateRequired(sField)
{     
  if (sField.value.length == 0)  { return false;}      
  return true; 
} 

function ValidateFieldLength(elem,maxLength)
{     
  if (maxLength < 1) { return true; }
  if (elem.value.length > maxLength)
  {
     alert('This entry can only hold a maximum of ' + maxLength + ' characters.\n\nThe data entry value has been trimmed to fit.');
     elem.value = elem.value.substring(0,maxLength);
     return false;
  }     
  return true; 
} 



 function TopMenuBarOnMouseOut(elem,isSelected)
     {
        try
        {
           
          
          
          if (elem.src.indexOf('evaluate') > 0)
          {
            if (isSelected != 'true')
            {
             elem.src = topSurveyBarEvaluateStatic.src;
            }
            else
            {
             elem.src = topSurveyBarEvaluateActive.src;
            }
            return;
          }
          
          if (elem.src.indexOf('background') > 0)
          {
            if (isSelected != 'true')
            {
             elem.src = topSurveyBarBackgroundStatic.src;
            }
            else
            {
             elem.src = topSurveyBarBackgroundActive.src;
            }
            return;
          }
          
          if (isSelected != 'true')
          {
            elem.src = topSurveyBarResultsStatic.src;
          }
          else
          {
             elem.src = topSurveyBarResultsActive.src;
          }
          
        }
        catch (Exception) { }
     }
     
     function TopMenuBarOnMouseOver(elem,isSelected)
     {
        try
        {
      
       
          if (elem.src.indexOf('evaluate') > 0)
          {
           
             elem.src = topSurveyBarEvaluateHover.src;
          
            return;
          }
          
                
          if (elem.src.indexOf('background') > 0)
          {
           
             elem.src = topSurveyBarBackgroundHover.src;
          
            return;
          }
         
          elem.src = topSurveyBarResultsHover.src;
          
          
        }
        catch (Exception) { }
     }
     
     var topSurveyBarEvaluateStatic = new Image();
     var topSurveyBarEvaluateHover = new Image();
     var topSurveyBarEvaluateActive = new Image();
     var topSurveyBarResultsStatic = new Image();
     var topSurveyBarResultsHover = new Image();
     var topSurveyBarResultsActive = new Image();
     var topSurveyBarBackgroundStatic = new Image();
     var topSurveyBarBackgroundHover = new Image();
     var topSurveyBarBackgroundActive = new Image();
     
     topSurveyBarEvaluateStatic.src='/sharedfiles/btn_evaluate_static.gif';
     topSurveyBarEvaluateActive.src='/sharedfiles/btn_evaluate_active.gif';
     topSurveyBarEvaluateHover.src ='/sharedfiles/btn_evaluate_hover.gif';
     
     topSurveyBarResultsStatic.src='/sharedfiles/btn_results_static.gif';
     topSurveyBarResultsActive.src='/sharedfiles/btn_results_active.gif';
     topSurveyBarResultsHover.src ='/sharedfiles/btn_results_hover.gif';
     
     topSurveyBarBackgroundStatic.src='/sharedfiles/btn_background_static.gif';
     topSurveyBarBackgroundActive.src='/sharedfiles/btn_background_active.gif';
     topSurveyBarBackgroundHover.src ='/sharedfiles/btn_background_hover.gif';

