var GLastWidth = 1180;
var GLastHeight = 750;



function     clearObject(theObject)
{
        var TBtheObject = getMtkElementById(theObject);
        TBtheObject.value = '';
} 
    

function goToTab(arg)
{
    window.location.href = 'Yala.aspx?' + arg;
}

function getWindowSize()
{
    var winSize       = new Object();

    winSize.width   = 640;
    winSize.height  = 480;

     if (navigator.appName.indexOf("Netscape")!=-1) 
     {
        winSize.width = window.innerWidth;
        winSize.height  = window.innerHeight;
     }
     else if (navigator.appName.indexOf("Microsoft")!=-1) 
     {
        winSize.width  = document.documentElement.clientWidth;
        winSize.height = document.documentElement.clientHeight;
     }
    
     return winSize;
}

function screenResize()
{
    return;
    var Ids = new Array();
    Ids.push('Panel2');
    Ids.push('MTMap');
    Ids.push('MT_MapContainermap');
    Ids.push('MT_Mapmap');
    
    reportSize(Ids);
}
function reportSize(listId) 
{
		  var myWidth = 0, myHeight = 0;
		  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;
		          }
		        }
		  }
		  var difWidth  = myWidth - GLastWidth;
		  var difHeight = myHeight - GLastHeight;
		  GLastWidth  =  myWidth ;
		  GLastHeight =  myHeight;
		  
		  for(var i=0;i<listId.length;i++)
          {
            var elem = getMtkElementById(listId[i]);
            var width = elem.style.width.substring(0,elem.style.width.length-2);
            var height = elem.style.height.substring(0,elem.style.height.length-2);
            
            elem.style.width  =(width*1 + difWidth) + "px";
            elem.style.height =(height*1 + difHeight) + "px";
            
          }
}

function initAutoComplete(id,context)
{ 
    var contextValue = '';
    var autoComplete = $find(id); 
    if (!autoComplete) 
        return; 

    var target = autoComplete.get_element(); 
    if (!target) 
        return; 

    
    // Dynamically assign the context and change the color when processing 
    autoComplete.add_populating(function() 
    { 
    
        var idCont = context[0];
        var userContext = getMtkElementById(idCont); 
        
        if (!userContext) 
            return;
        contextValue = userContext.value;
            
        for (i=1;i<context.length;i++)
        {
            idCont = context[i];
            userContext = getMtkElementById(idCont); 
            if (!userContext) 
                return;
            contextValue = contextValue + "#!*" + userContext.value;
        }
      autoComplete.set_contextKey(contextValue); 
    }); 

} 
                    
function PressBut(id,mode) {
	var object = getMtkElementById(id).style; 
	if(mode == "in")
	    object.borderWidth = "1px";
	else
	    object.borderWidth = "0px";
}

function Cover(bottom, top, ignoreSize) 
{
        var location = Sys.UI.DomElement.getLocation(bottom);
        top.style.position = 'absolute';
        top.style.top = location.y + 'px';
        top.style.left = location.x + 'px';
        if (!ignoreSize) {
            top.style.height = bottom.offsetHeight + 'px';
            top.style.width = bottom.offsetWidth + 'px';
        }
}


function getResultFromRequest(req,tag)
{
    var data  = new Array();
    var rootNode = req.responseXML.getElementsByTagName(tag);

    if(rootNode)
    {
        for(var i=0;i<rootNode.length;i++)
          data.push(rootNode.item(i).firstChild.nodeValue);
    }

    return data;
}
            

function OnError(result)
{
    //alert('error : ' + result.get_message());
    GSelectedPhone = GUserPhone = -1;
}

function getMtkElementById(id)
{
    for (var i=0;i<document.getElementsByTagName('*').length;i++) 
    { 
        if (document.getElementsByTagName('*')[i].id.indexOf(id,0) != -1) 
            return document.getElementsByTagName('*')[i];
    }
    return null;
}
                            
function FindID(id) 
{ 
    if(document.getElementById) 
		    return document.getElementById(id); 
		    
	if(document.layers) 
		return document.layersid; 

	if(document.all && !document.getElementById) 
		return document.allid; 
}

function FindID2(doc,id) 
{ 
    if(doc.getElementById) 
		return doc.getElementById(id); 
		
	if(doc.layers) 
		return doc.layersid; 

	if(doc.all && !doc.getElementById) 
		return doc.allid; 
}



/******************************************************************************************/
/////////////////////     TRACEEEEEEEEE    //////////////////////////////////////////////////
/******************************************************************************************/
function ClearTrace()
{
    var obj1  = getMtkElementById("LabelTrace");
    obj1.innerHTML = "";
}
function Trace(str )
{
        var obj1  = getMtkElementById("LabelTrace");
        obj1.innerHTML += " <b>" + str + "</b> ";
}
        
function postBackHiddenField(hiddenFieldID,val) 
{
        var hiddenField = getMtkElementById(hiddenFieldID);
        if (hiddenField) {
            hiddenField.value = val;
            __doPostBack(hiddenFieldID,'');
        }
        //Pbar.showBar();
}




