
/** these are for the IE6 layer over windowed control fudge **/
var searchSection = '';
var IE6 = navigator.userAgent.toLowerCase().indexOf('msie 6') > -1;
/***************************************************/

function AS(obj,e){
	var point = new Point();
	point = getAbsolutePosition(obj);

	var Vadj = 0;
	var Hadj = 0;
	if (document.getElementById("menu")) {
	    Vadj = -35; //Adjustment for FishEye Menu
	    Hadj = -3
	}
	
    var dv = obj.attributes['dv'].value;
	       		
	document.getElementById(dv).style.top = (point.y + 18 + Vadj).toString() + 'px'; 
    document.getElementById(dv).style.left = (point.x + 0 + Hadj).toString() + 'px'; 
	
	SendQuery(obj);
}
function AS2(obj,e){

	var point = new Point();
	point = getAbsolutePosition(obj);
	
	var Vadj = 0;
	var Hadj = 0;
	if (document.getElementById("menu")) {
	    Vadj = -35; //Adjustment for FishEye Menu
	    Hadj = -3
	}
	
    var dv = obj.attributes['dv'].value;
    
	document.getElementById(dv).style.top = (point.y + 18 + Vadj).toString() + 'px'; 
    document.getElementById(dv).style.left = (point.x + 0 + Hadj).toString() + 'px'; 	
           		
	//document.getElementById(dv).style.top = (point.y + 20).toString() + 'px'; 
    //document.getElementById(dv).style.left = (point.x - 70).toString() + 'px'; 
	
	SendQuery(obj);
}
function clearAS(obj,e){
	//var dv = obj.dv;
	//HideDiv(dv);
		
}
function getAbsolutePosition(element){
    var ret = new Point();
    for(; 
        element && element != document.body;
        ret.translate(element.offsetLeft, element.offsetTop), element = element.offsetParent
        );
        
    return ret;
}

function Point(x,y){
        this.x = x || 0;
        this.y = y || 0;
        this.toString = function(){
            return '('+this.x+', '+this.y+')';
        };
        this.translate = function(dx, dy){
            this.x += dx || 0;
            this.y += dy || 0;
        };
        this.getX = function(){ return this.x; }
        this.getY = function(){ return this.y; }
        this.equals = function(anotherpoint){
            return anotherpoint.x == this.x && anotherpoint.y == this.y;
        };
}

// Ajax Code for Proxima
// D. Archer 7-Jun-06
<!--

//Global XMLHTTP Request object		
var req;
var currentDiv;


function Initialize()
{
	try
	{
		req=new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			req=new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(oc)
		{
			req=null;
		}
	}
    //Creating object of XMLHTTP in Mozilla and Safari
	if(!req&&typeof XMLHttpRequest!="undefined")
	{
		req=new XMLHttpRequest();
	}
}

function SendQuery(obj)
{
	Initialize();
	
	var key = obj.value;
	var ctrl = obj.id;
	var entity = obj.attributes['entity'].value;
	var searchtype = obj.attributes['st'].value;
    var xurl = obj.attributes['xurl'].value;

    var tmaster = obj.attributes['TaskMasterID'].value;    
    var slang = obj.attributes['SourceLanguage'].value;
    var tlang = obj.attributes['TargetLanguage'].value;
    var comp = obj.attributes['Component'].value;
    var subj = obj.attributes['SubjectMatter'].value;
          
    var RID=0;
    
    if (obj.attributes['ctrl']) {
     var RIDctrlname = obj.attributes['ctrl'].value;
     RID = document.getElementById(RIDctrlname).options[document.getElementById(RIDctrlname).selectedIndex].value;
     }
    
	var url= xurl+'?k='+key + '&c=' + ctrl + '&e=' + entity + '&st=' + searchtype + '&TaskMasterID=' + tmaster +
                '&SourceLanguage=' + slang + '&TargetLanguage=' + tlang + '&Component=' + comp + '&SubjectMatter=' + subj+ '&RID=' + RID;
	//alert (url);
    currentDiv = obj.attributes['dv'].value;
    
	if(req!=null)
	{
		req.onreadystatechange = Process;
		req.open("GET", url, true);
        req.send(null);
	}	
}

function Process()
{
	if (req.readyState == 4) 
        {  
        // only if "OK"
			if (req.status == 200) 
			{
				if(req.responseText=="")
					HideDiv(currentDiv);
				else
				{
				    //obj.value = 'match';
					ShowDiv(currentDiv);					
					document.getElementById(currentDiv).innerHTML = req.responseText;
					
					//after doing the search then if browser is IE6 place the iframe under the Div -- more searchSections can be added if appropriate
					if ((IE6) && (searchSection == 'HR_PROFILE'))
                    {
                        DoIframe(currentDiv);        
                    }
				
				}
			}
			else 
			{
				document.getElementById(currentDiv).innerHTML="There was a problem retrieving data:<br>"+req.statusText;
			}
		}
}

function ShowDiv(divid) 
{
   //alert(currentObj.position.left);
   
   if (document.layers) document.layers[divid].visibility="show";
   else 
   
   var oDiv = document.getElementById(divid);
   oDiv.style.visibility="visible";
   
   
}


function HideDiv(divid) 
{
   if (document.layers) 
   {
   document.layers[divid].visibility="hide";
   }
   else 
   {
      document.getElementById(divid).style.visibility="hidden";
      
      
       if (IE6)
       { 
          //hides any iframes created by DoIframe         
          if (searchSection == 'HR_PROFILE')
          {
              var iframes = document.getElementsByTagName('iframe');
              for (var i = 0; i < iframes.length; i++)
              { 
                    if (iframes[i].id.indexOf('iframe_') > -1)
                    {
                        iframes[i].style.visibility = 'hidden';
                    }
              }    
          }
           
       } 
      
    }
}


function esx(obj,target) 
{
    if(obj.attributes['id1'].value=='x') //Cancel and Revert to stored value
    {
        document.getElementById(target).value=document.getElementById(target + '_lkval').value;
        HideDiv(document.getElementById(target).attributes['dv'].value);    
    }
    else if(obj.attributes['id1'].value=='-') //Just close the pop-up
    {
        HideDiv(document.getElementById(target).attributes['dv'].value);    
    }
    else //Pick selected value
    {
        document.getElementById(target).value=obj.attributes['id2'].value;
        document.getElementById(target + '_lkid').value=obj.attributes['id1'].value;
        document.getElementById(target + '_lkval').value=obj.attributes['id2'].value;
        //obj.lockmatch='1';
        HideDiv(document.getElementById(target).attributes['dv'].value);    
    }
}
function esxInternalAsg(obj,target) 
{
        document.getElementById(target).value=obj.attributes['id2'].value;
        document.getElementById(target + '_lkid').value=obj.attributes['id1'].value;
        document.getElementById(target + '_lkval').value=obj.attributes['id2'].value;
        document.getElementById('AssignmentRate_XTR').value=obj.attributes['id3'].value;
        HideDiv(document.getElementById(target).attributes['dv'].value);    
}
function esxExternalAsg(obj,target) 
{
        document.getElementById(target).value=obj.attributes['id2'].value;
        document.getElementById(target + '_lkid').value=obj.attributes['id1'].value;
        document.getElementById(target + '_lkval').value=obj.attributes['id2'].value;
        document.getElementById('AssignmentRate_XTR').value=obj.attributes['id3'].value;
        
        
        setSelectListToValue(obj.attributes['id5'].value,'AssignmentUOM');
        setSelectListTextToValue(obj.attributes['id4'].value,'AssignmentCurrency');
        
        //var Obj = document.getElementById('AssignmentUOM');
        //Obj.options[Obj.selectedIndex].value = obj.attributes['id5'].value;        
        //alert(Obj.options[Obj.selectedIndex].value);
        
        
        //document.getElementById('AssignmentCurrency').selectedIndex = obj.attributes['id4'].value;
        //document.getElementById('AssignmentUOM').selectedIndex = obj.attributes['id5'].value;
        doit();
        HideDiv(document.getElementById(target).attributes['dv'].value);    
}
function checksx(obj) {
/**
if (obj.lockmatch=='0') {
    obj.value='';
    HideDiv(obj.dv);
}
**/
}



//this function receives a string which is the id of the div to apply the iframe to
//the function can behave differently according the global variable searchSection which must be set in the page which contains the div
function DoIframe(divid)
{

    var oDiv = document.getElementById(divid);
    
//    var w = (oDiv.style.width == '') ? oDiv.offsetWidth : parseInt(oDiv.style.width);
//    var h =  (oDiv.style.height == '') ? oDiv.offsetHeight : parseInt(oDiv.style.height);
//   

    if (searchSection == 'HR_PROFILE')
    {
        //get the height of the inner table
        var innerTableHeight = oDiv.childNodes[0].offsetHeight; 

        if (innerTableHeight < 180)
            oDiv.style.height = innerTableHeight + 'px';   
        else
            oDiv.style.height = '180px';   
          
        oDiv.style.width = '240px';
    }
    else if (searchSection == 'NEW_PROJECT_WIZARD')
    {
        oDiv.style.height = '200px';

        if (oDiv.id == 'wizard1$MSDTargetLanguagesdiv')
            oDiv.style.height = '170px';
    }
    else if (searchSection == 'DMS')
    {
        if (oDiv.style.width == '')
        {
            if (divid == 'menu_child')
            {
                oDiv.style.width = (oDiv.offsetWidth + 55) + 'px';
            }
            else
            {
                oDiv.style.width = oDiv.offsetWidth + 'px';
            }
         }
        
        if (oDiv.style.height == '')
        {
             oDiv.style.height = (oDiv.offsetHeight - 12) + 'px';
        }                          
       
    
    }
    
    oDiv.style.zIndex = 0;
    oDiv.style.position = 'absolute';
    
    
    
    var iFrame = GetIFrameHTML(oDiv); 
    oDiv.insertAdjacentHTML("beforeBegin", iFrame);                 
}

//returns a string of HTML based with the properties of the iframe based on the properties of the div to which it will sit under
function GetIFrameHTML(oDiv)
{           
     
     var iFrame = '<iframe  id="iframe_' + oDiv.id + '" src="about:blank" scrolling="no" frameborder="0" style="position:absolute;left:' + parseInt(oDiv.style.left) + 'px;top:' + parseInt(oDiv.style.top) + 'px;'
            iFrame += 'width:' + parseInt(oDiv.style.width) + 'px;height:' + parseInt(oDiv.style.height) + 'px;z-index:0;visibility:visible;height:' + parseInt(oDiv.style.height) + 'px"></iframe>';
     
    return iFrame;
}
    
  // -->
