﻿
var _DEFAULT_FONT_SIZE = 9;

function DoNothing()
{
    window.status = "";
}

function PrintArticle()
{
    window.print();
}

function AdjustTextSize(mode)
{          
    var currentSize = parseInt(GetFontSize());       
    if(currentSize == null || isNaN(currentSize))
        currentSize = _DEFAULT_FONT_SIZE;

    if(mode == 0)
    {
        currentSize -= 1;
        
        if(currentSize < 7)
            currentSize = 7;
    }
    else
    {
        currentSize += 1;
        
        if(currentSize > 11)
            currentSize = 11;        
    }
           
    // Set Cookie    
    SetFontSize(currentSize);
    
    // Set Div's class name
    var content = document.getElementById("ctl00_primarycontentcontainer");    
    content.className = "primarycontent defaultfont" + currentSize;           
}

function GetFontSize()
{
    var results = document.cookie.match('customfont=([^;]*)');
  
    if(results != null)
        return results[1];
    
    return null;
}

function SetFontSize(size)
{
    var expiryDate = new Date();
    expiryDate.setFullYear(2020, 01, 01);
    
    document.cookie = "customfont=" + size + "; expires=" + expiryDate.toGMTString() + "; path=/";
}

function ProcessKeyDown(e, ctrlPrepend)
{
    var keyCode = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
    
	if (keyCode == 13)
	{
		ProcessCenterSearch(ctrlPrepend);
		return false;
	}		
}

function ProcessCenterSearch(ctrlPrepend)
{
    var stateID = 0;
    var stateName = "";
    var postalCode = "";    
          
    ddlState = document.getElementById(ctrlPrepend + "ddlState");
    
    postalCode = document.getElementById(ctrlPrepend + "txtPostalCode").value;
  
    if(postalCode == "enter zip")
        postalCode = "";
  
    // If zip code has been entered
    if(postalCode.length > 0)
    {
        stateID = -1;
        stateName = -1;
        window.location = "centersearchresult.aspx?stateid=" + stateID + "&statename=" + stateName + "&postalcode=" + postalCode;        
        
        return false;
    }   
    // If state was selected
    else if(ddlState.value != "Select a State") 
    {
       stateID = ddlState.value;
       stateName = ddlState.options[ddlState.selectedIndex].text;
       window.location = "centersearchresult.aspx?stateid=" + stateID + "&statename=" + stateName + "&postalcode=" + postalCode;       
       
       return false;
    }
    else    
    {
        alert("Enter a Valid State");
        return false;
    }    
}

function ProcessSiteSearch(e)
{
    var keyCode = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
    
	if (keyCode == 13)
	{
        var txtSiteSearch = document.getElementById("ctl00_txtSiteSearch");
        window.location = "sitesearchresult.aspx?keyWord=" + txtSiteSearch.value;
	}			       
}

function IsEmail(source, arguments)
{       
    if(arguments.Value && arguments.Value.match(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/) )
        arguments.IsValid = true;
    else
        arguments.IsValid = false;        
}

function IsPhone(source, arguments)
{       
    if(arguments.Value && arguments.Value.match(/^[0-9]\d{2}-\d{3}-\d{4}$/))
        arguments.IsValid = true;
    else
        arguments.IsValid = false;
}

function OpenMapPopup(city, state, address, zip, country)
{
    var mapUrl = "http://www.mapquest.com/maps/map.adp?city={0}&state={1}&address={2}&zip={3}&country={4}&zoom=7";
    mapUrl = mapUrl.replace("{0}", city);
    mapUrl = mapUrl.replace("{1}", state);
    mapUrl = mapUrl.replace("{2}", address);
    mapUrl = mapUrl.replace("{3}", zip);
    mapUrl = mapUrl.replace("{4}", country);            
    
    window.open(mapUrl, 'new', 'resizable=yes,width=800,height=600,scrollbars=yes');
}

function OnWatermarkFocus(elementId, defaultText, cssclass)
{ 
   if (document.getElementById(elementId).value == defaultText)
   {
      document.getElementById(elementId).className = (cssclass == null ? "zipnormal" : cssclass + "normal");
      document.getElementById(elementId).value = "";
   }
}

function OnWatermarkBlur(elementId, defaultText, cssclass)
{
   var textValue = document.getElementById(elementId).value;

   if (textValue == defaultText || textValue.length == 0)
   {
      document.getElementById(elementId).className = (cssclass == null ? "zip" : cssclass);
      document.getElementById(elementId).value = defaultText;
   }
   else
      document.getElementById(elementId).className = (cssclass == null ? "zipnormal" : cssclass + "normal");
}