function getElement(id) {
	var obj;
	if (document.getElementById) {
		obj = document.getElementById(id);
	}
	else if (document.layers) {
		obj = document.layers.id;
	}
	else if (document.all) {
		obj = document.all.id;
	}

	return obj;
}
function manipulateObjectClass(obj, mode, class1, class2) {
	if (obj != null) {
		switch (mode) {
		case 'check':
			return new RegExp('\\b'+class1+'\\b').test(obj.className)
			break;
		case 'add':
			if(!manipulateObjectClass(obj,'check',class1)){
				obj.className+=obj.className?' '+class1:class1;
			}
			break;
		case 'remove':
			var rep=obj.className.match(' '+class1)?' '+class1:class1;
			obj.className=obj.className.replace(rep,'');
			break;
		case 'swap':
			obj.className=!manipulateObjectClass(obj,'check',class1)?obj.className.replace(class2,class1): obj.className.replace(class1,class2);
			break;
		}
	}
}

function getFormFields(parent, type) {
	var Elements = parent.getElementsByTagName(type);
	return Elements;
}

function showHideByID(id) {
	var obj = getElement(id);
	if (obj != null) {
		if(manipulateObjectClass(obj,'check','hiddenContent')) {
			manipulateObjectClass(obj,'remove','hiddenContent');
		} 
		else {
			manipulateObjectClass(obj,'add','hiddenContent');
		}
	}
}



/*----------*/


function hide(id)
{
    var obj;  
    if (document.getElementById)
	{	    
	    obj = document.getElementById(id);		    
	    if (obj != null)    	    
		{
		    obj.style.visibility = 'hidden';
		    obj.style.display ='none';
		}
	}	  
       
    else  if (document.layers)
	{	    
	    obj = document.layers.id;
	    if (obj != null)    	    
		{	    	   
		    obj.visibility = 'hide';
		    obj.display = 'none';
		}
	}
	else if (document.all)
	{	    
	    obj = document.all.id;	 
	    if (obj != null)    	    
		{   
		    obj.style.visibility = 'hidden';
		    obj.style.display = 'none';
		}
	}
}
 
function show(id)
{
    var obj;  
    if (document.getElementById)
	{	    
	    obj = document.getElementById(id);	 
	    if (obj != null)    	    
		{   	    
		    obj.style.visibility = 'visible';
		    obj.style.display ='block';
	    }
	}	  
       
    else  if (document.layers)
	{	    
	    obj = document.layers.id;	
	    if (obj != null)    	    
		{  	       
		    obj.visibility = 'show';
		    obj.display = 'block';
		}
	}
	else if (document.all)
	{	    
	    obj = document.all.id;
	    if (obj != null)    	    
		{      
		    obj.style.visibility = 'visible';
		    obj.style.display = 'block';
		}
	}

}

function showtbl(id)
{    
    var obj;  
    if (document.getElementById)
	{	    
	    obj = document.getElementById(id);	 
	    if (obj != null)    	    
		{   	    
		    obj.style.visibility = 'visible';
		    if (browser == 'Internet Explorer'){obj.style.display ='block';}
		    else {obj.style.display ='table';}
	    }
	}	  
       
    else  if (document.layers)
	{	    
	    obj = document.layers.id;	
	    if (obj != null)    	    
		{  	       
		    obj.visibility = 'show';
            if (browser == 'Internet Explorer'){obj.style.display ='block';}
		    else {obj.style.display ='table';}
		}
	}
	else if (document.all)
	{	    
	    obj = document.all.id;
	    if (obj != null)    	    
		{      
		    obj.style.visibility = 'visible';
            if (browser == 'Internet Explorer'){obj.style.display ='block';}
		    else {obj.style.display ='table';}
		}
	}

}

function enableTable(id, enable, imagePath)
{
    var obj = getElement(id);      
	
	var attribute;
	if ( browser == 'Internet Explorer')
	    attribute = 'className';
	else
	    attribute = 'class';
	    
    
	var FormElements = getFormFields(obj,'input');
	
	for (var i=0;i<FormElements.length;i++)
	{	   	    
	    if (enable)
	    {
	        FormElements[i].disabled = '';
	    }
	    else
        {
            FormElements[i].disabled = 'disabled';
        }
	}	
	

    attribute = 'src';

	FormElements = getFormFields(obj,'img');
	for (var i=0;i<FormElements.length;i++)
	{	   	    	    
	    if (enable)
	    {	   	        
	        FormElements[i].setAttribute(attribute, imagePath + '/mesip/icons/fieldrequired.gif');
	    }
	    else
        {           
            FormElements[i].setAttribute(attribute, imagePath + '/mesip/icons/fieldrequired_disabled.gif');
        }
	}			
}

var active_con, active_option;
function showoptionbox(conid, boxid)
{   
    if (active_con != conid){hide(active_con);}
    
    if (active_option != boxid){hide(active_option);}
         
    if (browser != "Internet Explorer"){hideshow(conid);active_con=conid;}
    
    hideshow(boxid);
    active_option = boxid;
}

function hideinfoboxes()
{
    hide(active_con);
    hide(active_option);    
}

function toggletablerow(id)
{
    if (id!=active_option)
        hideinfoboxes();
    
    active_option = id;
    
    var obj;  
    if (document.getElementById)
	{	    
	    obj = document.getElementById(id);	 
	    if (obj != null)    	    
		{   	    
		    if (obj.style.visibility == 'hidden' || obj.style.visibility =='' )
		    {
		        obj.style.visibility = 'visible';
		        if (browser == 'Internet Explorer'){obj.style.display ='block';}
		        else {obj.style.display ='table-row';}
		    }
		    else
		    {
		        obj.style.visibility = 'hidden';
		        obj.style.display ='none';
		    }
	    }
	}	  
       
    else  if (document.layers)
	{	    
	    obj = document.layers.id;	
	    if (obj != null)    	    
		{  	       
		    if (obj.style.visibility == 'hide'  || obj.style.visibility =='' )
		    {				    
		        obj.visibility = 'show';
		        if (browser == 'Internet Explorer'){obj.style.display ='block';}
		        else {obj.style.display ='table-row';}
		    }
		    else
		    {
		        obj.visibility = 'hide';
		        obj.display = 'none';
		    }
		}
	}
	else if (document.all)
	{	    
	    obj = document.all.id;
	    if (obj != null)    	    
		{      
		    if (obj.style.visibility == 'hidden' || obj.style.visibility =='' )
		    {	
		        obj.style.visibility = 'visible';
		        if (browser == 'Internet Explorer'){obj.style.display ='block';}
		        else {obj.style.display ='table-row';}
		    }
		    else
		    {
		        obj.style.visibility = 'hidden';
		        obj.style.display = 'none';		    
		    }
		}
	}    
}

function hideshow(id)
{
    var obj;  
    if (document.getElementById)
	{	    
	    obj = document.getElementById(id);	 
	    if (obj != null)    	    
		{   	    
		    if (obj.style.visibility == 'hidden' || obj.style.visibility =='' )
		    {
		        obj.style.visibility = 'visible';
		        obj.style.display ='block';
		    }
		    else
		    {
		        obj.style.visibility = 'hidden';
		        obj.style.display ='none';
		    }
	    }
	}	  
       
    else  if (document.layers)
	{	    
	    obj = document.layers.id;	
	    if (obj != null)    	    
		{  	       
		    if (obj.style.visibility == 'hide'  || obj.style.visibility =='' )
		    {				    
		        obj.visibility = 'show';
		        obj.style.display ='block';
		    }
		    else
		    {
		        obj.visibility = 'hide';
		        obj.display = 'none';
		    }
		}
	}
	else if (document.all)
	{	    
	    obj = document.all.id;
	    if (obj != null)    	    
		{      
		    if (obj.style.visibility == 'hidden' || obj.style.visibility =='' )
		    {	
		        obj.style.visibility = 'visible';
		        obj.style.display ='block';		       
		    }
		    else
		    {
		        obj.style.visibility = 'hidden';
		        obj.style.display = 'none';		    
		    }
		}
	}    
}
