function GetXmlHttpObject()
{   
	 if(window.ActiveXObject)
		return new ActiveXObject("Microsoft.XMLHTTP");	
	else if(window.XMLHttpRequest)
		{
			d=document;
			return new XMLHttpRequest();
		}	 
	else
		return null;
}

function GetXmlHttp()
	{
		var oXmlHttp=false;
		/*@cc_on @*/
		/*@if (@_jscript_version >= 5)
		// JScript gives us Conditional compilation, we can cope with old IE versions.
		// and security blocked creation of the objects.*/
		try {
			oXmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
		try {
			oXmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			oXmlHttp = false;
		}
		}
		/*@end @*/
	
		if (!oXmlHttp && typeof XMLHttpRequest!='undefined') 
		{
			oXmlHttp = new XMLHttpRequest();
		}
		
		return oXmlHttp;
	}	
function GetXMLTagValue(xmlobj,tagname)
{  
    if(tagname=='') return '';
    if(xmlobj.getElementsByTagName(tagname).length>0)
    {
        if(xmlobj.getElementsByTagName(tagname)[0].firstChild)
            return xmlobj.getElementsByTagName(tagname)[0].firstChild.nodeValue;
    }
    return '';
}
function getKeyCode(evt)
{
	if (evt) 
		return evt.keyCode ;
	else  
		return event.keyCode;		
}
function getDate(DateId,txtId)
{
	var date=document.getElementById(DateId).innerHTML;
	date=date.replace('[',"");
	date=date.replace(']',"");
	document.getElementById(txtId).value=date;
	return false;
}
function launchCenter(url, name, width, height, scrollbar) {
	if (width==0){width=screen.width-10};
	if (height==0){height=screen.height-30};
	
	var str = "height=" + height + ",innerHeight=" + height;
	str += ",width=" + width + ",innerWidth=" + width;
	
	if (window.screen) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;
		var xc = (aw - width);
		var yc = (ah - height);
		var xc = (aw - width)/2;
		var yc = (ah - height)/2;
		
		str += ",left=" + xc + ",screenX=" + xc;
		str += ",top=" + yc + ",screenY=" + yc;
		str += ",hotkeys=0,menubar=0,resizable=1,scrollbars=" + scrollbar + ",status=0";
	}
	return window.open(url, name, str);
}

/*************************************************************************************************
Usuage:
var fadewinobj= new FadeWin();
fadewinobj.fadeobj=document.getElementById('Div tag name');

fadewinobj.fadepoint  : this is optional value with in the range of (0 - 100)
fadewinobj.fadespeed  : this is optional value with in the range of (1 - 100) Note : do not give 0, object wont be visible at all

Recommeded:
	please specify the width and height of the div
-------------------
**************************************************************************************************/
function FadeWin()
{
	this.fadeobj=null;
	this.fadepoint=0;
	this.fadespeed=10;
	this.fadeopen=function()
	{	
	
	   
		if(this.fadeobj!=null)
		{
			if(this.fadeobj.style.height=='')
				this.fadeobj.style.height='100%'
			if(this.fadeobj.style.width=='')
				this.fadeobj.style.width='100%'
			this.fadepoint+=this.fadespeed;
			try
			{
			    this.fadeobj.style.MozOpacity=this.fadepoint/100;
			}
			catch(e){}
			try
			{
			    this.fadeobj.style.filter = "alpha(opacity=" +this.fadepoint+ ")";
			}
			catch(e){}
			if(this.fadeobj.style.display=='none')
				this.fadeobj.style.display='block'				
			if(this.fadeobj.style.visibility=='hidden')
				this.fadeobj.style.visibility='visible'	
				 //alert(this.fadeobj.style.visibility)			
			if(this.fadepoint>=100) return false;
			
			var pThis = this;
			
			var f = function(){pThis.fadeopen();}
			this.timerID = window.setTimeout(f,100);
		}
	}
	
}			

/*************************************************************************************************
Usuage:
var CrossOpenobj= new CrossOpen();
CrossOpenobj.fadeobj=document.getElementById('Div tag name');

fadewinobj.startpoint  : this is optional value with in the range of (0 - 100)
fadewinobj.speed  : this is optional value with in the range of (1 - 100) Note : do not give 0, object wont be visible at all

-------------------
**************************************************************************************************/
function CrossOpen()
			{
				this.Object=null;
				this.startpoint=0;
				this.fadespeed=8;
				this.ObjectMaxHeight=96;
				this.ObjectMaxWidth=96;
				
				this.crossOpen=function()
				{	
					if(this.Object!=null)
					{					
						this.startpoint+=this.fadespeed;
						try
						{
							this.Object.style.width=this.startpoint+'%';
							this.Object.style.height=this.startpoint+'%';
						}
						catch(e){}
						
						if(this.Object.style.display=='none')
							this.Object.style.display='block'				
						if(this.Object.style.visibility=='hidden')
							this.Object.style.visibility='visible'				
						if(this.startpoint>=this.ObjectMaxHeight) return false;
						
						var pThis = this;
						var f = function(){pThis.crossOpen();}
						this.timerID = window.setTimeout(f,1);
					}
				}
				
			}
		
			

function Get_Cookie(name) {
  var start = document.cookie.indexOf(name + '=');
  var len = start + name.length + 1;
  if ((!start) && (name != document.cookie.substring(0,name.length)))
    return null;
  if (start == -1)
    return null;
  var end = document.cookie.indexOf(';',len);
  if (end == -1) end = document.cookie.length;
  
  if(end == start){
  	return '';
  }
  return unescape(document.cookie.substring(len,end));
}

function Set_Cookie( name, value, expires, path, domain, secure ) 
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct 
expires time, the current script below will set 
it for x number of days, to make it for hours, 
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
( ( path ) ? ";path=" + path : "" ) + 
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}

function Delete_Cookie(name,path,domain) {
  if (Get_Cookie(name))
    document.cookie =
      name + '=' +
      ( (path) ? ';path=' + path : '') +
      ( (domain) ? ';domain=' + domain : '') +
      ';expires=Thu, 01-Jan-1970 00:00:01 GMT';
}

/*
returns an array of cookie values from a single cookie
*/
function get_sub_cookies(cookie){
	var cookies = new Array();
	var end ='';
	if(cookie && cookie != ''){
		end = cookie.indexOf('#')
		while(end > -1){
			var cur = cookie.substring(0, end);
			 cookie = cookie.substring(end + 1, cookie.length);
			var name = cur.substring(0, cur.indexOf('='));
			var value = cur.substring(cur.indexOf('=') + 1, cur.length);
			cookies[name] = value;
			
			end = cookie.indexOf('#')
		}
	}
	return cookies;
}

function subs_to_cookie(cookies){
	var cookie = '';
		for (var i in cookies)
		{
			cookie += i  + '=' + cookies[i] + '#';
		}
	return cookie;
}

function GotoMaps(map,addr,csz,country) {
    GotoMaps(map,addr,csz,country,'','','');
}

function GotoMaps(map,addr,csz,country,city,state,zip) {
    var url, title;
    switch(map) {
    case 'google':
        url = 'http://maps.google.com/?q=loc%3A'+addr+','+csz+','+country;
        break;
    case 'yahoo':
        url = 'http://maps.yahoo.com/maps_result?addr='+addr+"&csz="+csz+"&country="+country;
        break;
    case 'mapquest':
        url = 'http://www.mapquest.com/maps/map.adp?searchtype=address&country='+country +'&searchtab=home&formtype=address&popflag=0&address='+addr+'&city='+ city + '&state='+ state + '&zipcode='+ zip;
        break;
    }
    window.open(url,'_maps','width=900,height=500px,left=50,top=50,scrollbars=yes,resize=yes,resizable=yes,menubar=no,toolbar=no,directories=no');

}


function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}			
function AlignCenter(obj)
{
    obj.style.left=((document.documentElement.offsetWidth-obj.offsetWidth)/2)+"px"
    var height =(document.body.clientHeight-obj.offsetHeight)/2;
    obj.style.top=(document.body.scrollTop+height)+'px';
/*
    var x=(document.documentElement.offsetWidth-obj.offsetWidth)/2;
    var y=(document.body.offsetHeight-obj.offsetHeight)/2;
    y+=document.body.scrollTop;
    obj.style.left=x+'px';
    obj.style.top=y+"px"
    */
}

function HideSelectBox(bool)
{
    if(navigator.appVersion.indexOf('MSIE')!=-1 && navigator.appVersion.indexOf('MSIE 7.0')!=-1)
    {
        var select=document.getElementsByTagName('select');
        for(var i=0;i<select.length;i++)
        {
            if(bool)
            {
                if(select[i].style.visibility != 'hidden')
                {
                    select[i].setAttribute('hide','true')
                    select[i].style.visibility='hidden';
                }
            }
            else
            {   
                if(select[i].getAttribute('hide'))
                {
                    select[i].removeAttribute('hide')
                    select[i].style.visibility='visible';
                }
            }
        }
    }
}
/****************************************** Document on click **************************************************
Usage:  To add this functionality 
        appendtoClickList(refference of div/span object)
        
        if that object was closed because of document.onclick then this will raise an event called  close event , in order to use this functionality
        eg:
        <div id=test onclose="ur functionname alone don't use '()' ">
        that function should have 1 parameter 
        eg:
            <div id=test onclose="CallMeOnClose">
            appendtoClickList(document.getElementById('test'))
            function CallMeOnClose(obj)
            {
                removefromClickList(obj)
                alert('')
            }
        
        To remove this functionality 
        removefromClickList(refference of div/span object)
        
        functions:
        var obj = new controlName();
        obj.getValue() for value;
        obj.getText for Text;
        
*/    

var clickobjs= new Array();
function appendtoClickList(obj)
{
    obj.setAttribute("show",true);   
    for(i=0;i<clickobjs.length;i++)
    {
        if(clickobjs[i]==obj)removefromClickList(clickobjs[i]);
    }
    clickobjs[clickobjs.length]=obj;
}
function removefromClickList(obj)
{
    for(var i=0;i<clickobjs.length;i++)
    {
        if(clickobjs[i]==obj)
        {
            clickobjs.splice(i,1);                
            break;
        }
    }
}
document.onclick = function(e) 
{   
    for(i=clickobjs.length-1;i>=0;i--)
    {
        if(clickobjs[i].getAttribute("show")+''=='false')
        {
            var X,Y,W,H,mouseX,mouseY;                
            H=clickobjs[i].offsetHeight;
            W=clickobjs[i].offsetWidth;
            try{mouseX=e.pageX;     mouseY=e.pageY; }
            catch(e){mouseX=event.clientX; mouseY=event.clientY;}
            X=findPosX(clickobjs[i]);
            Y=findPosY(clickobjs[i]);
            W=W+X;
            H=H+Y;
            if((mouseX<=X|| mouseX>=W) || (mouseY <=Y || mouseY>=H))
            {
                clickobjs[i].style.display='none';
                if(clickobjs[i].getAttribute('onclose')!=null)
                {
                    setTimeout(clickobjs[i].getAttribute('onclose')+'('+clickobjs[i].id+')',10);
                }
                removefromClickList(clickobjs[i]);
            }
       }
       else
        clickobjs[i].setAttribute("show",false);
   }
}
/****************************************** End of Document on click ***************************************************/ 
/*******************************************Context Menu ***********************************************
Usage:
    var obj = new ContextMenu(menudiv reference, only on particular area (pass the area object name as reference this is optional));
*/
 function ContextMenu(menuref,targetobject)
 {
    this.ie5=document.all&&document.getElementById;
    this.ns6=document.getElementById&&!document.all;
    this.Menubar;
    this.TargetObject;
    var obj=this; 
    if (this.ie5||this.ns6)
    {
        this.Menubar=menuref;
        this.TargetObject=targetobject;
        document.oncontextmenu=function(e)
        {   
            if(obj.Menubar)
            {
                var mousex=obj.ie5? event.clientX : e.clientX;
                var mousey=obj.ie5? event.clientY : e.clientY;
                mousex+=document.body.scrollLeft;
                mousey+=document.body.scrollTop;
                
                if(obj.TargetObject)
                {
                   var x=findPosX(obj.TargetObject)
                   var y=findPosY(obj.TargetObject)
                   var w=obj.TargetObject.offsetWidth+x;
                   var h=obj.TargetObject.offsetHeight+y;
                   if((mousex<=x|| mousex>=w) || (mousey <=y || mousey>=h))
                   {
                       obj.Menubar.style.visibility="hidden";
                       obj.Menubar=null;
                       document.oncontextmenu=null; 
                       return;
                   }
                }
                
                appendtoClickList(obj.Menubar);    
                obj.Menubar.setAttribute("show",false);
                obj.Menubar.style.visibility="hidden";
                var rightedge=obj.ie5? document.body.clientWidth-event.clientX : window.innerWidth-e.clientX;
                var bottomedge=obj.ie5? document.body.clientHeight-event.clientY : window.innerHeight-e.clientY   ;
                obj.Menubar.style.display="inline";
                
                 if (bottomedge<obj.Menubar.offsetHeight)
                 {
                    obj.Menubar.style.top=mousey-obj.Menubar.offsetHeight;//obj.ie5? document.body.scrollTop+event.clientY-obj.Menubar.offsetHeight : window.pageYOffset+e.clientY-obj.Menubar.offsetHeight;
                 }
                else
                    obj.Menubar.style.top=mousey;//obj.ie5? document.body.scrollTop+event.clientY : window.pageYOffset+e.clientY;        
                if (rightedge<obj.Menubar.offsetWidth)
                    obj.Menubar.style.left=mousex-obj.Menubar.offsetWidth ; //obj.ie5? document.body.scrollLeft+event.clientX-obj.Menubar.offsetWidth : window.pageXOffset+e.clientX-obj.Menubar.offsetWidth;
                else
                    obj.Menubar.style.left=mousex;  //obj.ie5? document.body.scrollLeft+event.clientX : window.pageXOffset+e.clientX;
                
                obj.Menubar.style.visibility="visible";
                obj.Menubar=null;
                document.oncontextmenu=null;
            }
            return false
        }    
    }    
 }  
 /*******************************************Context Menu ************************************************/
 
 	function showLoading(bool,refobject)
	{ 
	    if(bool)
	    { 
	        
	        if(refobject)
	        {
	            if(refobject.style.position=='absolute')
	            {
	                document.getElementById('_Loadingdiv').style.left=refobject.style.left;
	                document.getElementById('_Loadingdiv').style.top=refobject.style.top;
	            }
	            else
	            {
	                document.getElementById('_Loadingdiv').style.left=findPosX(refobject);
	                document.getElementById('_Loadingdiv').style.top=findPosY(refobject);
	            }
	        }
	        document.getElementById('_Loadingdiv').style.display='inline';	        
	    }
	    else
	        document.getElementById('_Loadingdiv').style.display='none';
	    
	}
	function highlight(field) {
        field.focus();
        field.select();
    }
	
function MessageBuilder(object,MessageString,left,top)
{
                document.getElementById('tblPopupMessage').style.visibility='visible';
                document.getElementById('tdErrorMessage').innerHTML=MessageString;   
                document.getElementById('divMessage').style.display='block';
                document.getElementById('divMessage').style.left=findPosX(object)+ left +'px';
            //  document.getElementById('divMessage').style.zIndex=document.getElementById('sessionshadowscreen').style.zIndex+10;
                document.getElementById('divMessage').style.top=findPosY(object)-document.getElementById('tdErrorMessage').offsetHeight-top+'px';
}
	

	 function getKeyCode(evt)
{    
    if (evt) 
	    return evt.keyCode ;
	else  
	    return event.keyCode;		
}
 
//function y2k(number) { return (number < 1000) ? number + 1900 : number; }
//function isValidDate(day,month,year) 
//{
// checks if date passed is valid
// will accept dates in following format:
// isDate(dd,mm,ccyy), or
// isDate(dd,mm) - which defaults to the current year, or
// isDate(dd) - which defaults to the current month and year.
// Note, if passed the month must be between 1 and 12, and the
// year in ccyy format.
// var today = new Date();
// year = ((!year) ? y2k(today.getYear()):year);
// month = ((!month) ? today.getMonth():month-1);
// if (!day) return false
//   var test = new Date(year,month,day);
//   if ( (y2k(test.getYear()) == year) &&
//         (month == test.getMonth()) &&
//         (day == test.getDate()) )
//        return true;
//    else
//        return false
//}


 

	