﻿// JScript File
 function getIdforGroupControls(originalId,tagname,type) 
 {
  var obj=document.getElementsByTagName(tagname);
  for(i=0;i<obj.length;i++)
  {
   if(type!="notype")
        {
              if(obj[i].type==type)
                {
                     
                    var objId=obj[i].id;
                    var objString=objId.split('_');
                    var splittedId=objString[objString.length-2]+'_'+objString[objString.length-1];
                    if(originalId==splittedId)
                    {
                      return objId;
                    }
                }
       }
    else
        {
                   var objId=obj[i].id;
                    var objString=objId.split('_');  
                     var splittedId=objString[objString.length-1]+objString[objString.length-2];
                    if(originalId==splittedId)
                    {
                      return objId;
                    }
        }
  } 
} 

function getId(originalId,tagname,type)      
 {
  var obj=document.getElementsByTagName(tagname);
  for(i=0;i<obj.length;i++)
  {
   if(type!="notype")
        {
          if(obj[i].type==type)
            {                 
                var objId=obj[i].id;
                var objString=objId.split('_');
                var splittedId=objString[objString.length-1];
                if(originalId==splittedId)
                {
                  return objId;
                }
            }
       }
    else
        {
            var objId=obj[i].id;
            var objString=objId.split('_');  
            var splittedId=objString[objString.length-1];
            if(originalId==splittedId)
            {
              return objId;
              break;
            }
        }
  } 
} 

//=============================Add By Ritesh =================================

//====================Function to get Country Code Form Master Page===============
function js_getCountryCode()
{
    var dllCountry = document.getElementById(getId("dllCountry","select","notype"));
     //alert(dllCountry);
    var CountryCode = dllCountry.options[dllCountry.selectedIndex].value;
    return CountryCode;
}

//=================================Trap Mouse Event===========================
function MouseEvent(e)
{
    if(e)
    {
        this.e = e;
    }
    else
    {
        this.e = window.event;
    }
    
    if(e.pageX)
    {
        this.x = e.pageX;
    }
    else
    {
        this.x = e.clientX;
    }
    
    if(e.pageY)
    {
        this.y = e.pageY;
    }
    else
    {
        this.y = e.clientY;
    }
    
    if(e.target)
    {
        this.target = e.target;
    }
    else
    {
        this.target = e.srcElement;
    }
    
    //alert("e " + this.e);
   // alert("target " + this.target);
    alert("this.x " + this.x);
    alert("this.y " + this.y);
}

//===========================Get Windows ScrollBar Position==================
function js_scrollTop() {
	return js_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}

function js_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}
//===========================Get Windows ScrollBar Position End==================

//=============================Function for replace text=================================
  function replace(string,text,by) {
  // Replaces text with by in string
      var strLength = string.length, txtLength = text.length;
      if ((strLength == 0) || (txtLength == 0)) return string;

      var i = string.indexOf(text);
      if ((!i) && (text != string.substring(0,txtLength))) return string;
      if (i == -1) return string;

      var newstr = string.substring(0,i) + by;

      if (i+txtLength < strLength)
          newstr += replace(string.substring(i+txtLength,strLength),text,by);

      return newstr;
  }
function bookmark(url, description)
{
netscape="Function not available in Netscape. Click OK then press CTRL-D to add a bookmark."

if (navigator.appName=='Microsoft Internet Explorer')
{
window.external.AddFavorite(url, description);
}
else if (navigator.appName=='Netscape')
{
alert(netscape);
}
}

//====================================Function for show hint============================
function js_ShowHideHint(Countrolid,showhide) 
{
	var inputs = Countrolid;//document.getElementById(Countrolid);
	//alert(inputs);
	if(showhide ==1)
	{
		// test to see if the hint span exists first
		if (inputs.parentNode.getElementsByTagName("span")[0]) 
		{
		    // the span exists!  on focus, show the hint			
			inputs.parentNode.getElementsByTagName("span")[0].style.display = "block";
		}
	}
	else
	{
	    if (inputs.parentNode.getElementsByTagName("span")[0]) 
		{
		    // when the cursor moves away from the field, hide the hint			
		    inputs.parentNode.getElementsByTagName("span")[0].style.display = "none";
		}			
	}
}
//=======================================End==================================================

//this function checks to see if an enter key was presssed when
// the user is entering text in a text box
function checkEnterKey(e,submitButtonName){
var key;
//if the browser is IE
if (window.event)
key = window.event.keyCode;
//if its firefox, Opera, etc..
else
key = e.which;
//if the keycode equals the code for the enter key
if (key == 13){
document.getElementById(submitButtonName).click();
return false;}
return true;}