﻿// JScript File

// Functions that makes layers show and hide.
// Function Call :
// < a href = "#" onclick = "ShowLayer('spanReadMore', 'readMoreDivID', '[ read more ]', '[ read less ]');" > < span id = "spanReadMore" > [ read more ] < / span > < / a >
function ShowLayer(actionSpanTagID, divToHideID, spanTagInnerTextShow, spanTagInnerTextHide)
{

   // actionSpanTagID - for the buttong calling this function.
   // divToHideID - item to be hidden.
   // spanTagInnerTextShow - Text to be written when the div is visible
   // spanTagInnerTextShow - Text to be written when div is invisble

   var divObject, spanObject;
   // Variables that hold the Div and the Span Tag Object.

   // Browser Compatibilty Starts --------------------------------------
   if( document.getElementById ) // this is the way the standards work
   divObject = document.getElementById( divToHideID );
   else if( document.all ) // this is the way old msie versions work
   divObject = document.all[divToHideID];
   else if( document.layers ) // this is the way nn4 works
   divObject = document.layers[divToHideID];

   if( document.getElementById ) // this is the way the standards work
   spanObject = document.getElementById( actionSpanTagID );
   else if( document.all ) // this is the way old msie versions work
   spanObject = document.all[actionSpanTagID];
   else if( document.layers ) // this is the way nn4 works
   spanObject = document.layers[actionSpanTagID];
   // Browser Compatibilty Ends --------------------------------------

   // Code to show and hide the desire Div Tag
   if (divObject.style.display == 'none')
   {
      divObject.style.display = 'block';
      spanObject.innerHTML = spanTagInnerTextHide;
   }
   else
   {
      divObject.style.display = 'none';
      spanObject.innerHTML = spanTagInnerTextShow;
   }
}

function search(txtToBeValidated)
{
  window.location = "search.aspx?criteria=" + document.getElementById(txtToBeValidated).value.toString();
}

function changeCheckBox(img_name)
{
   if (document[img_name].src.toString().substring(document[img_name].src.toString().lastIndexOf('/') + Number(1), document[img_name].src.toString().length) == "chkEmpty.jpg" )
   {
      document[img_name].src = "assets/images/chkChecked.jpg";
   }
   else
   {
      document[img_name].src = "assets/images/chkEmpty.jpg";
   }
}

// Checking only valid character on textboxes
var newValue = "";
function validCharactersChecker(sText)

{
   var ValidChars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";
   var IsNumber = true;
   var Char;
   var Stext2;

   newValue = "";
   for (i = 0; i < sText.length; i ++ )
   {
      Char = sText.charAt(i);
      if (ValidChars.indexOf(Char) == - 1)
      {
         // sText = sText.replace(Char, "_");
         // textbox.value = sText;
         IsNumber = false;
      }
      else
      {
         newValue = newValue + Char.toString();
      }
   }
   // newValue = sText;
   return IsNumber;
}

function isCharacterValid(txtToBeValidated)
{
   if(validCharactersChecker(document.getElementById(txtToBeValidated).value) == false)
   {
      document.getElementById(txtToBeValidated).value = newValue;
   }
}
