﻿// JScript File
//
//Removes left and right hand side spaces from the given
//string.
//
function Trim(tstrInput)
{
 return (tstrInput.replace(/^[\n\r\t ]*|[\n\r\t ]*$/g,""));
// CHANDRESH_20070505_1305
}

//
// Detects Browser 
//
function GetBrowserInfo()
{
 var userAgent = navigator.userAgent.toLowerCase();
 if( eval( userAgent.indexOf('msie') != -1 ) )
 {
 return "IE";
 }
 else if( eval(navigator.product == 'Gecko') )
 {
 return "FF";
 }
}
//
//Hide all the key events except "back" and "delete" key.
//
function CheckDateChar(eObj)
{
 var oKey;
 
 if( navigator.userAgent.toLowerCase().indexOf("msie") != -1 )
 { 
  oKey = eObj.keyCode;
 }
 else if( navigator.product == "Gecko" )
 {
  oKey = eObj.which;
 }
 
 if(oKey == 0 || oKey == 8)
 {
  return true;
 }
 return false;
 
}

//
//Function will be used to open music window contains music
//flash file.
//
function OpenMusicWindow(sUrl,Musicid,bIsHidden)
{
 if(Musicid != 0)
 {
 sUrl = sUrl + "/MusicPlayer.aspx?MusicID=" + Musicid ;
 var WindowParameters = "left=" + (window.screen.width / 3) + ",top="+window.screen.height / 3+",width=290,height=155,tollbars";
  var oWin = window.open(sUrl,'music',WindowParameters);
  if(bIsHidden == true)
  { 
  window.focus();  
// return true;
  }else
  {  
  oWin.focus(); 
  }
 }
  return false;
}
//
// validateEmail : function will be used to validate Email Address 
// IsRequired is true for Mandatory fields otherwise false
//
function validateEmail(sClientId,txtEmail,IsRequired)
{ 
 var sInputStr = String(document.getElementById(sClientId + '_' + txtEmail ).value) ; 
 { 
 var oREEmail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})$/;
 if (Trim(sInputStr) == "" && IsRequired == true)
 {
 return " Please provide email address."
 }
 else if ( sInputStr.search(oREEmail ) == -1 )
 {
// return "Please enter E-mail address in the following format,e.g. <b>user@hostname.com</b>."
  return " Specified email address is not in correct format."
 }
 else  
 { 
 return " ";   
 }
 }
} 
//
// fnGetKeyCode
//
function fnGetKeyCode(oEventObject)
{
  try
  { 
   if(GetBrowserInfo() == "IE")
   {
 return oEventObject.keyCode;
 }
 else
 {
 return oEventObject.which;
 }
  }
  catch(oException)
  {
  
  }
}
//
// fnGetOffsetTop 
//
function fnGetOffsetTop(oEl)
{
 var iTop = oEl.offsetTop;
 while((oEl = oEl.offsetParent) != null)
 { iTop += oEl.offsetTop;  }
// alert("Parent: " + iTop)
 return iTop;
}
//
// fnGetOffsetLeft 
//
function fnGetOffsetLeft(oEl)
{
 var iLeft = oEl.offsetLeft;
 while ((oEl = oEl.offsetParent) != null)
  { iLeft += oEl.offsetLeft;  }
// alert("Parent: " + iTop)
 return iLeft;
}