﻿// JScript File
//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------
var globalLastZIndex = 1000;
var globalInCallProcess = false;

   
    //----------------------------------------------------------------------------------------------------
    //----------------------------------------------------------------------------------------------------
    function GetZIndex()
    {
        var zIdx = globalLastZIndex;
        globalLastZIndex = globalLastZIndex+1;
        return zIdx;
    }
    //----------------------------------------------------------------------------------------------------
    //----------------------------------------------------------------------------------------------------
    function ReleaseZIndex()
    {
        globalLastZIndex = globalLastZIndex-1;
    }
    
    //--------------------------------------------------------------------------------
    // RefreshControl( string sIDCtrl, string sContent )
    //--------------------------------------------------------------------------------
    function RefreshControl( sIDCtrl, sContent )
    {
        var aCtrl = $get( sIDCtrl );
        if ( null == aCtrl )
            return false;
        aCtrl.innerHTML = "";
        aCtrl.innerHTML = sContent;
        return true;
    }
    function RefreshControlImg( sIDCtrl, sContent )
    {
        var aCtrl = $get( sIDCtrl );
        if ( null == aCtrl )
            return false;
        aCtrl.src = "";
        aCtrl.src = sContent;
        return true;
    }
    //--------------------------------------------------------------------------------
    // CreatePopup( string sCtrlID : int iX, iY, iWidth, iHeight, zIdx : string sContent )
    //--------------------------------------------------------------------------------
    function CreatePopup( sCtrlID, iX, iY, iWidth, iHeight, zIdx, sContent )
    {
        var aDiv = CreateDiv( sCtrlID, iX, iY, iWidth, iHeight, zIdx );
        aDiv.innerHTML = sContent;
        ShowDivOrSpan( aDiv, true );
        return true;
    }
    //--------------------------------------------------------------------------------
    // CreateDiv( string sCtrlID : int iX, iY, iWidth, iHeight, zIdx )
    //--------------------------------------------------------------------------------
    function CreateDiv( sCtrlID, iX, iY, iWidth, iHeight, zIdx )
    {
        var aDiv = document.createElement( "div" );
        aDiv.id = sCtrlID;
        aDiv.style.display="none";
        aDiv.style.position="absolute";        
        document.body.appendChild( aDiv );
        //TODO Center
        var posX = iX;
        if ( -1 == posX )
            posX = 100; //TODO Horizontal center
        var posY = iY;
        if ( -1 == posY )
            posY = 100; //TODO Vertical center
        // Move the div
        Sys.UI.DomElement.setLocation(aDiv, posX, posY);
        // Size the div
        //TODO Sys.UI.DomElement.setBounds
        if ( iWidth > 0 )
            aDiv.style.width = iWidth;
        if ( iHeight > 0 )
            aDiv.style.height = iHeight;
        aDiv.style.zIndex = zIdx;
        return aDiv;
    }

    //--------------------------------------------------------------------------------
    // CreatePopupOverChild( string sCtrlID, sChildID : int  iWidth, iHeight : string sContent )
    //--------------------------------------------------------------------------------
    function CreatePopupOverChild( sCtrlID, sChildID, iWidth, iHeight, sContent )
    {
        var iX = -1;
        var iY = -1;
        var aChild = $get( sChildID );
        var vLocation = null;
        if ( null != aChild )
        {
            vLocation = Sys.UI.DomElement.getLocation(aChild);
        }
        if ( null != vLocation )
        {
            iX = vLocation.x-1;
            iY = vLocation.y-1;
        }
        var zIdx = GetZIndex();
        return CreatePopup( sCtrlID, iX, iY, iWidth, iHeight, zIdx, sContent );
    }    
    //--------------------------------------------------------------------------------
    // ClosePopup( string sCtrlID )
    //--------------------------------------------------------------------------------
    function ClosePopup( sCtrlID )
    {
        var aDiv = FindDivOrSpan( sCtrlID );
        if ( null == aDiv )
            return false;
        ReleaseZIndex();       
        document.body.removeChild( aDiv );
        return true;
    }
    //--------------------------------------------------------------------------------
    // ShowPopup( string sPopupID )
    //--------------------------------------------------------------------------------
    function ShowPopup( sCtrlID )
    {
        var aCtrl = FindDivOrSpan( sCtrlID );
        if ( null != aCtrl )
        {
            ShowDivOrSpan( aCtrl, true );
            return true;
        }
        return false;
    }
    //--------------------------------------------------------------------------------
    // HidePopup( string sCtrlID )
    //--------------------------------------------------------------------------------
    function HidePopup( sCtrlID )
    {
        var aCtrl = FindDivOrSpan( sCtrlID );
        if ( null != aCtrl )
        {
            ShowDivOrSpan( aCtrl, false );
            return true;
        }
        return false;
    }
    //--------------------------------------------------------------------------------
    // FindDivOrSpan( string sIDCtrl )
    //--------------------------------------------------------------------------------
    function FindDivOrSpan( sIDCtrl )
    {
        if ( null == sIDCtrl )
            return null;
        var aCtrl = document.getElementById( sIDCtrl );
        if ( null === aCtrl )
            return null;
        if ( false == IsDivOrSpan( aCtrl ) )
            return null;
        return aCtrl;
    }
    //--------------------------------------------------------------------------------
    // ShowDiv( div aCtrl, bool bShow  )
    //--------------------------------------------------------------------------------
    function ShowDivOrSpan( aCtrl, bShow )
    {
        if ( false == bShow )
            aCtrl.style.display="none";
        else
        {
            if ( true == IsDiv( aCtrl ) )
            {
                aCtrl.style.display="block";
            }
            else
            {
                aCtrl.style.display="inline";
            }
           
        }
    }
    //--------------------------------------------------------------------------------
    // IsDivOrSpan( div/span element aCtrl )
    //--------------------------------------------------------------------------------
    function IsDivOrSpan( aCtrl )
    {
        if ( null === aCtrl )
            return false;
        if ( true == IsDiv( aCtrl ) )
            return true;
        if ( true == IsSpan( aCtrl ) )
            return true;
        return false;
    }
    //--------------------------------------------------------------------------------
    // IsDiv( div/span element aCtrl )
    //--------------------------------------------------------------------------------
    function IsDiv( aCtrl )
    {
        if ( null === aCtrl )
            return false;
        if ( aCtrl.tagName == "DIV" ||
             aCtrl.tagName == "div" ||
             aCtrl.tagName == "IFRAME" ||
             aCtrl.tagName == "iframe" )
            return true;
        return false;
    }
    //--------------------------------------------------------------------------------
    // IsSpan( div/span element aCtrl  )
    //--------------------------------------------------------------------------------
    function IsSpan( aCtrl )
    {
        if ( null === aCtrl )
            return false;
        if ( aCtrl.tagName == "SPAN" ||
             aCtrl.tagName == "span" ) 
            return true;
        return false;
    }
    
    
    var Global_MenuContextArg = "";
    //--------------------------------------------------------------------------------
    //--------------------------------------------------------------------------------
    function ShowContexMenu( MenuID, ControlID, PgArgs )
    {
        if ( null === MenuID )
            return false;
        if ( null === ControlID )
            return false;
        if ( null === PgArgs )
            return false;
        Global_MenuContextArg = PgArgs;
        var aMenu = $get( MenuID );
        if ( null == aMenu )
            return false;
        var aChild = $get( ControlID );
        if ( null == aChild )
            return false;
        
        var vLocation = Sys.UI.DomElement.getLocation(aChild);
        var posX = vLocation.x-120;
        var posY = vLocation.y-1;
        
        Sys.UI.DomElement.setLocation(aMenu, posX, posY);
        
        ShowDivOrSpan( aMenu, true );

        return true;        
    }
   

    //--------------------------------------------------------------------------------
    //--------------------------------------------------------------------------------
    function OnSelectItem( sItemID , sHiddenFieldID , sSelectStyle, sNormalStyle, sHiddenSelectID, sKey )
    {
        var aHiddenSelect = $get( sHiddenSelectID );
        if ( null != aHiddenSelect )
        {
            if ( null != sKey )
                aHiddenSelect.value = sKey;
            else
                aHiddenSelect.value = "";
        }
        var aItem = $get( sItemID );
        if ( null == aItem )
            return true;
        var aCurrentSel = null;
        var aHidden = $get( sHiddenFieldID );
        if ( null != aHidden )
        {
            var sIDCurrent = aHidden.value;
            if( sItemID == sIDCurrent)
                return true;
            if ( null != sIDCurrent && "" !=  sIDCurrent)
                aCurrentSel = $get( sIDCurrent );
            if ( null !=  aCurrentSel )
                aCurrentSel.className = sNormalStyle;
            aHidden.value = sItemID;
        }
        aItem.className = sSelectStyle;
        return true;
    }
    
    //--------------------------------------------------------------------------------
    //--------------------------------------------------------------------------------
    function OnRollOver( sItemID , sHiddenFieldID , sStyle)
    {
        var aItem = $get( sItemID );
        if ( null == aItem )
            return true;
        var aCurrentSel = null;
        var aHidden = $get( sHiddenFieldID );
        if ( null != aHidden )
        {
            var sIDCurrent = aHidden.value;
            if( sItemID == sIDCurrent)
                return true;
//            if ( null != sIDCurrent && "" !=  sIDCurrent)
//                aCurrentSel = $get( sIDCurrent );
        }
        aItem.className = sStyle;
        return true;
    }

// JScript File
var bdvFr = "";
var RegistredReturnControl = "";
var FormIDToValidate = "";
var SkzJSParams = [];

//-------------------------------------------------------------------------------
//-------------------------------------------------------------------------------

var myWidth = 0, myHeight = 0;

//-------------------------------------------------------------------------------
//-------------------------------------------------------------------------------
function SetSize()
{
	if( typeof( window.innerWidth ) == 'number' )
	{
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	}
	else if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
	{
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
		
	}
	else if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
	{
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
}
//-------------------------------------------------------------------------------
//-------------------------------------------------------------------------------
function prepareIE(height, overflow)
{
	aBody = document.getElementsByTagName('body')[0];
	if ( null != aBody )
	{
	    aBody.style.height = height;
	    aBody.style.overflow = overflow;
    }
	htm = document.getElementsByTagName('html')[0];
	if ( null != htm )
	{
	    htm.style.height = height;
	    htm.style.overflow = overflow; 
	}
}
//-------------------------------------------------------------------------------
//-------------------------------------------------------------------------------
function CreateDivOverPage( sCtrlID , CssStyle)
{
    SetSize();
    var aDiv = document.createElement( "div" );
    aDiv.id = sCtrlID;
    aDiv.style.display="none";
    aDiv.style.position="absolute"; 
    aDiv.className = CssStyle;   
    aDiv.style.zIndex = GetZIndex();
   
    if (CssStyle == 'popupcontent')
    {  
		aDiv.className = CssStyle; 
		aDiv.style.top = "0px";   
		aDiv.style.left = "0px"; 
		//aDiv.style.width =  "100%";//myWidth  + "px";
		//aDiv.style.height = "100%";//myHeight + "px";
    }
    document.body.appendChild( aDiv );
         
        return aDiv;
}


//////////////////////////////////////////////////////////////////
//Close Pop Up page

function ClosePopupPage(paras,url)
{ 
try
{

   if(paras==null)
      paras==false;
   // RefreshPage();
   // var ModalPopUp = document.getElementById('pf');
   // document.body.removeChild( ModalPopUp );
    aDiv = FindDivOrSpan( 'popupcontent' );
    document.body.removeChild( aDiv );
    aDiv = FindDivOrSpan( 'lightbox' );
    document.body.removeChild( aDiv );
    
    ReleaseZIndex();   
    ReleaseZIndex();
    ReleaseZIndex();  

    if(url!=null)
    {
        var href=window.location.href;
        var index=href.lastIndexOf('/');
        href=href.substr(0,index) + '/' + url;
        var browser=new CheckBrowser();
        window.location.href=href;
        if(browser.name=="Safari")
            window.location.reload();
    }
    else
    if(paras)
    RefreshPage(); 
     
 }
 catch(ex)
 {
 } 
}
function IsBr()
{
    return window.navigator.appVersion.toLowerCase().indexOf("msie")!=-1?"IE":window.navigator.appVersion.toLowerCase().indexOf("safari")!=-1?"SA":"OR";
}
   
function SetScrollTopIE()
{
   
   if(document.documentElement)
        document.documentElement.scrollTop=0;
   if(parent.document.documentElement)
        parent.document.documentElement.scrollTop=0;
   if(parent.parent.document.documentElement)
        parent.parent.document.documentElement.scrollTop=0;
   if(parent.parent.parent.document.documentElement)
        parent.parent.parent.document.documentElement.scrollTop=0;
   if(parent.parent.parent.parent.document.documentElement)
        parent.parent.parent.parent.document.documentElement.scrollTop=0;
}

function SetScrollTopNT()
{
   
   if(document.body)
        document.body.scrollTop=0;
   if(parent.document.body)
        parent.document.body.scrollTop=0;
   if(parent.parent.document.body)
        parent.parent.document.body.scrollTop=0;
   if(parent.parent.parent.document.body)
        parent.parent.parent.document.body.scrollTop=0;
   if(parent.parent.parent.parent.document.body)
        parent.parent.parent.parent.document.body.scrollTop=0;
}

function SetScrollTop()
{
    if(IsBr()=="SA")  SetScrollTopNT();
    else SetScrollTopIE();
}

//////////////////////////////////////////////////////////////////
////CreatePopup()
    function PopupPage(sSrc)
    {
        SetScrollTop();        
        createModal();
        
        var aDiv =  CreateDivOverPage('lightbox' ,  'lightbox' );
        aDiv.style.display="none";
        aDiv.style.position="absolute";
        aDiv.style.top="40px";
        aDiv.style.width="100%";
        aDiv.style.background="transparent";
        aDiv.style.textAlign="center";
        var aFrame = document.createElement( "iframe" );
        bdvFr = "bdv" +new Date().getTime();
        aFrame.id = bdvFr ;
        aFrame.src = sSrc 
        aFrame.style.width =  1+"px";
        aFrame.style.height = 1+"px";
        aFrame.frameBorder = 0 ;
        aFrame.scrolling="no";
        aFrame.style.zIndex = GetZIndex();
        aFrame.allowTransparency = true;
        aDiv.appendChild( aFrame );
        
        
        if(document.getElementById('popupcontent'))
        {
            var Hider = document.getElementById('popupcontent');

            var arrayPageSize	= getPageSize();
                 
                
                Hider.style.height = (100  + arrayPageSize[1]) + 'px';
                 
            Hider.style.width = (arrayPageSize[0] + 'px' );  
        }        
       
        ShowDivOrSpan( aDiv, true );
        return true;
    }


// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

function createModal()
{
		var objBody			= document.getElementsByTagName("body").item(0);
		var zIndex			= GetZIndex();
		var arrayPageSize	= getPageSize();
		var arrayPageScroll = getPageScroll();
		var objOverlay 		= document.createElement("div");
		
		objOverlay.setAttribute('id','popupcontent');
		objOverlay.style.display 	= 'none';
		objOverlay.style.position	= 'absolute';
		objOverlay.style.top		= '0';
		objOverlay.style.left		= '0';
		objOverlay.style.zIndex		= zIndex;
	 	objOverlay.style.width		= '100%';
	 	objOverlay.style.height		= (arrayPageSize[1] + 'px');
	 	objOverlay.style.minHeight	= '100%';
		
		objOverlay.style.backgroundColor = "#000000";
		
		
			if (navigator.appVersion.indexOf("MSIE")!=-1)
			{
				objOverlay.style.filter = "alpha(opacity=80)";
			}
			else
			{
	 			objOverlay.style.opacity = .80 ;
			}
			
			
		objBody.appendChild(objOverlay);
		objOverlay.style.display = '';
		
		
}

///////////////////////////////////////////////////////////////////
////ResizeModalPopUp PopUpFrame

function ResizeModalPopUp()
{ 
var ModalPopUp = null ;
if( bdvFr != ""  && bdvFr!= null)
{
ModalPopUp = document.getElementById(bdvFr);
}else{
ModalPopUp = document.getElementById("pf");
}
    if ( null == ModalPopUp )
        return false;
var Height,Width;
    if( typeof( window.innerWidth ) == 'number' )
    {
        //Non-IE
        Width = ModalPopUp.contentWindow.document.documentElement.scrollWidth;
        
       // alert("Width"  +  ModalPopUp.contentWindow.innerWidth) ;
       // alert("clientWidth"  +  ModalPopUp.contentWindow.document.body.clientWidth) ;
       // alert("scrollWidth"  +  ModalPopUp.contentWindow.document.body.scrollWidth) ;
       // alert("scrollWidth - normal"  +  ModalPopUp.contentDocument.scrollWidth) ;
        
        Height = ModalPopUp.contentWindow.document.body.clientHeight;
    }
    else
    {
        Width = ModalPopUp.contentWindow.document.body.scrollWidth;
        Height = ModalPopUp.contentWindow.document.body.scrollHeight;
    }
    

    ModalPopUp.style.height = Height+40+ "px";
    ModalPopUp.style.width  = Width + 10+"px";
          
       
}

///////////////////////////////////////////////////////////////////
////ResizeEmbededPage

function ResizeEmbededPage()
{ 
    return ResizeEmbededPageByName( "IfrEmbed" )
}

function ResizeEmbededPageByName( frmName )
{ 
    //var ModalPopUp = document.getElementById('IfrEmbed');
    var aFrame = document.getElementById( frmName );
    if ( null == aFrame )
        return false;
    var Height,Width;
    if( typeof( window.innerWidth ) == 'number' )
    {
       // Width = ModalPopUp.contentWindow.document.documentElement.scrollWidth;
        Height = aFrame.contentWindow.document.body.clientHeight;
    }
    else
    {
   
        //Width = ModalPopUp.contentWindow.document.body.scrollWidth;
        Height = aFrame.contentWindow.document.body.scrollHeight;
         
    }
    aFrame.style.height = Height+ "px";
   // ModalPopUp.style.width  = Width + "px";
   return true;
}



//--------------------------------------------------------------------------------
// TrackModalPopup(   ) Set the modal Pop Up over the Hiden region while Scrolling
//--------------------------------------------------------------------------------
  
window.onscroll = TrackScroll;

function TrackScroll()
{
    if(document.getElementById('popupcontent'))
    {
        var Hider = document.getElementById('popupcontent');

        var arrayPageSize	= getPageSize();
        var arr = getPageScroll();
  
        Hider.style.height		= (arrayPageSize[0] + arr[1]) + 'px';
        Hider.style.width		= (arrayPageSize[0] + 'px' );
    }

}


//--------------------------------------------------------------------------------
// TrackModalPopup(   ) Set the modal Pop Up over the Hiden region
//--------------------------------------------------------------------------------
window.onresize = TrackModalPopup;
function TrackModalPopup()
{
    if(document.getElementById('popupcontent'))
    {
        var Hider = document.getElementById('popupcontent');
       // var ac = document.getElementById('MainPage');
        var arrayPageSize	= getPageSize();
        Hider.style.height		= (arrayPageSize[1] + 'px');
        Hider.style.width		= '100%';
    }

}

//--------------------------------------------------------------------------------
// GetHtmlSkzControl( Html Element  ) return x , y , w , y 
//--------------------------------------------------------------------------------
function GetHtmlSkzControl(element) {

    var result = new Object();
		result.x = 0;
		result.y = 0;
		result.width = 0;
		result.height = 0;
	
		//element = document.getElementById(element);
	
    if (element.offsetParent) {
        result.x = element.offsetLeft;
        result.y = element.offsetTop;
        var parent = element.offsetParent;
        while (parent) {
            result.x += parent.offsetLeft;
            result.y += parent.offsetTop;
            var parentTagName = parent.tagName.toLowerCase();
            if (parentTagName != "table" &&
                parentTagName != "body" && 
                parentTagName != "html" && 
                parentTagName != "div" && 
                parent.clientTop && 
                parent.clientLeft) {
                result.x += parent.clientLeft;
                result.y += parent.clientTop;
            }
            parent = parent.offsetParent;
        }
    }
    else if (element.left && element.top) {
        result.x = element.left;
        result.y = element.top;
    }
    else {
        if (element.x) {
            result.x = element.x;
        }
        if (element.y) {
            result.y = element.y;
        }
    }
    if (element.offsetWidth && element.offsetHeight) {
        result.width = element.offsetWidth;
        result.height = element.offsetHeight;
    }
    else if (element.style && element.style.pixelWidth && element.style.pixelHeight) {
        result.width = element.style.pixelWidth;
        result.height = element.style.pixelHeight;
    }
	
return result;
}



// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
function  getPageSize()
	{
		var xScroll, yScroll;
		
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = document.body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		
		
		
		var windowWidth, windowHeight;
		if (self.innerHeight) {	// all except Explorer
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
	
		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){	
			pageWidth = windowWidth;
		} else {
			pageWidth = xScroll;
		}
	
		arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
		return arrayPageSize;
	}


// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
function getPageScroll()
	{
		var yScroll;
	
		if (self.pageYOffset) {
			yScroll = self.pageYOffset;
		} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
			yScroll = document.documentElement.scrollTop;
		} else if (document.body) {// all other Explorers
			yScroll = document.body.scrollTop;
		}
	
		arrayPageScroll = new Array('',yScroll) 
		return arrayPageScroll;
	}
	
/////////////////////////////////////////////////////////
///Hide Select Elements

function hideSelects(visibility){
    var selects = document.getElementsByTagName('select');
		for(var i2 = 0; i2 < selects.length; i2++) {
			selects[i2].style.visibility = visibility;
		}
}
////////////////////////////////////////////////////
//Open Language tool Bar
function toggleDisplay(divName){
    var tempDiv = document.getElementById(divName);
    if(tempDiv.style.display=="block"){
        tempDiv.style.display="none";
        return false;
    }else if(tempDiv.style.display=="none"){
        tempDiv.style.display="block";
        return true;
    }
}
function toggleDisplay1(divName){
    var tempDiv = document.getElementById(divName);
        tempDiv.style.display="block";
       
    
}


function MenuMouseoutHandler(event , idelement)
{
//var div = document.getElementById(idelement);

var toElement = null;
if (event.relatedTarget)
toElement = event.relatedTarget;
else if (event.toElement)
toElement = event.toElement;

//while (toElement && toElement.id != submenuId)
//toElement = toElement.parentNode;
while (toElement && toElement.tagName != "DIV")
toElement = toElement.parentNode;


        if(!toElement)
        {
        HidePopup(idelement);
        }
}


function stopBubble(e)
{
if(!e)var e=window.event;
e.cancelBubble=true;
if(e.stopPropagation)e.stopPropagation();
}


function mouseLeaves (element, evt) { 
   if (typeof evt.toElement != 'undefined' && typeof element.contains != 
'undefined') { 
     return !element.contains(evt.toElement); 
   } 
   else if (typeof evt.relatedTarget != 'undefined' && evt.relatedTarget) { 
     return !contains(element, evt.relatedTarget); 
   } 



} 


function RefreshPage()
{

    //window.location = window.location.href.replace("#","");
    window.location.reload();
}

function contains (container, containee) { 
   while (containee) { 
     if (container == containee) { 
       return true; 
     } 
     containee = containee.parentNode; 
   } 
   return false; 

} 


/////////////////////////////////////////////////////////
// GetDocument Reference For PopupFrame or Embeded Page

function getIFrameDocument(aID) {
  var rv = null; 
  if (document.getElementById(aID).contentDocument){
  // others
    rv = document.getElementById(aID).contentDocument;
  } else {
  // IE
    rv = document.frames[aID].document;
  }
  return rv;
}

/////////////////////////////////////////////////////////
// LoadPage Into The Maste Document
function LoadPage(src , params)
{
    if( null == src || "" == src)
        return false;
     if( null == params )
         params = "";   
     
      window.location =  src  + "?" + params;
}


function pageLoad(sender, args)
{
        if(!args.get_isPartialLoad())
        {
            if(RegistredReturnControl != ""){
                
                    if($get(RegistredReturnControl.ID))
                    {
                        $addHandler(document, "keydown", onKeyDown);
                    }
            }
        }
}

function onKeyDown(e)
{   
    if(e && e.keyCode == Sys.UI.Key.enter)
	{
	   // if(event.srcElement.id == RegistredReturnControl.ID)
	    //{
	        if(FormIDToValidate != "")
	        {
	        var bool = ISkzjs.Form.validate(FormIDToValidate);
	        if(bool)
                on__doPostBack(RegistredReturnControl.Name,'');
            }
       // }
    }
} 

//////////////////////////////////////////////////////////////////////////////////

function RemoveElementById(idelmt)
{
	if( typeof idelmt != 'undefined')
	{
 	   var elmt = document.getElementById(idelmt);
 	   if(elmt)
	   {
	   	 (elmt.parentNode).removeChild( elmt );
	   }
	}
}

/////////////////////////////////////////////////////////

function RemoveElementByValue( ArrName, Key )
{
  var idx = getIndexByValue(ArrName, Key);
  
  
  if(idx == -1)
    return false;
  
		for (var i = 0; i < ArrName.length; i++)
		{
			var lsit = ArrName[i];
			
			if(idx == i)
			{
			        var aClick = document.getElementById(lsit.ID);
					if(aClick)
					{
					    aClick.onclick();
					}
					break;
			}else if(idx > i)
			{
				RemoveElementById(lsit.ID);
			}
		}
  return true;
}

/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////

function SelectElementByValue( ArrName, Key )
{
  var idx = getIndexByValue(ArrName, Key);
  
  
  if(idx == -1)
    return false;
  
		for (var i = 0; i < ArrName.length; i++)
		{
			var lsit = ArrName[i];
			
			if(idx < i)
			{
				RemoveElementById(lsit.ID);
			}
			
			if(idx == i)
			{
				    var aClick = document.getElementById(lsit.ID);
					if(aClick)
					{
					aClick.onclick();
					}
					break;
			}
		}
  return true;
}
/////////////////////////////////////////////////////////
function  getIndexByValue( ArrName, Value)
{
    var index = -1;
	for (var i = 0; i < ArrName.length; i++)
		{
			var lsit = ArrName[i];
			
			if(Value == lsit.Value)
			{
				index = i ;
				break;
			}
		}
		
		
	return index;
}
/////////////////////////////////////////////////////////
function  getItemValue( ArrName, Key)
{
    var Value = null;
	for (var i = 0; i < ArrName.length; i++)
		{
			var lsit = ArrName[i];
			
			if(Key == lsit.ID)
			{
				Value = lsit.Value ;
				break;
			}
		}
		
		
	return Value;
}

/////////////////////////////////////////////////////////
function  getItem( ArrName, Key)
{
    var Value = null;
	for (var i = 0; i < ArrName.length; i++)
		{
			var lsit = ArrName[i];
			
			if(Key == lsit.ID)
			{
				Value = lsit ;
				break;
			}
		}
		
		
	return Value;
}

