
aTooltipsToShow = Array();

function recolor_href(oHref,total)
{

    for(var i=0; i<total;i++)document.getElementById('ap'+i).style.color = "#999"
    oHref.style.color = "#29323B"

}


function removeElementById(id){
    var oTmp = document.getElementById(id);

    if(oTmp)oTmp.parentNode.removeChild(oTmp);
}


function create_AJAX_loading(msg,idparam){

						var oErrorDiv = document.createElement('div')
       					//oErrorDiv.style.display='none'
       					if(typeof(idparam) == 'string')oErrorDiv.setAttribute('id',idparam)
          				else oErrorDiv.setAttribute('id','overall_error_msg')
          				oErrorDiv.style.fontSize = '10px'
          				oErrorDiv.style.padding = '2px'
          				var oImg = document.createElement('img')
          				oImg.setAttribute('src','images/loading.gif');
          				oImg.style.verticalAlign = 'middle';
          				oImg.style.padding = '5px';
          				oErrorDiv.appendChild(oImg)
          				oErrorDiv.appendChild(document.createTextNode(msg))
          				
          				return oErrorDiv;

}

 function createXMLHttpRequest() {
   try { return new XMLHttpRequest(); } catch(e) {}
   try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
   try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
   alert("XMLHttpRequest not supported");
   return null;
 }
 
 fade_distance_step = 15
 fade_time_step = 100
 
 function fadeIn(elem,runState,opacity){
 	
 	var oTmp = document.getElementById(elem);
 	
 	if(oTmp){
 		if(runState){
 			setOpacity(oTmp,opacity)
 			if(opacity<100)window.setTimeout('fadeIn("'+elem+'",true,'+(opacity+fade_distance_step)+')',fade_time_step);
 		} else {
  			setOpacity(oTmp,0)
 			oTmp.style.display='block'
			window.setTimeout('fadeIn("'+elem+'",true,'+fade_distance_step+')',fade_time_step);	
 		}
 	}
 	
 }
 
 aFading = Array();
 function animateStyleColor(elem,tag,fromC,toC,runState,opacity,delay,dist){
 	var oTmp = document.getElementById(elem);
 	if(aFading[elem] == true && runState!=true)return;
 	
 	if(!isInt(delay))delay = fade_time_step;
 	if(!isInt(dist))dist = fade_distance_step;
 	
 	
 	//alert(getColorStep(fromC,toC,(opacity+fade_distance_step)));
 	if(oTmp){
 		if(runState){
 			oTmp.style[tag] = getColorStep(fromC,toC,(opacity+fade_distance_step));
 			//alert(oTmp.style[tag]);
 			if(opacity<100)window.setTimeout('animateStyleColor("'+elem+'","'+tag+'","'+fromC+'","'+toC+'",true,'+(opacity+dist)+')',delay);
 			else aFading[elem] = false;
 		} else {
 			oTmp.style[tag] = fromC;
 			aFading[elem] = true;
  			window.setTimeout('animateStyleColor("'+elem+'","'+tag+'","'+fromC+'","'+toC+'",true,'+dist+')',delay);	
 		}
 	}
 
 }
 
 function setOpacity(obj, opacity) {
  opacity = (opacity >= 100)?99.9999:opacity;
  
  if(/MSIE/.test(navigator.userAgent) && (!obj.hasLayout))obj.style.zoom=1 
 obj.style.filter = "alpha(opacity:"+opacity+")";

  
  //alert(obj.style.filter)
  
  //obj.style.KHTMLOpacity = opacity/100;
  //obj.style.MozOpacity = opacity/100;
  obj.style.opacity = opacity/100;
}

function getColorStep(ColorA, ColorB, percentage)
{
	if(percentage>=100)return ColorB;
	
	if (ColorA.charAt(0)=='#') ColorA = ColorA.substring(1);
	if (ColorB.charAt(0)=='#') ColorB = ColorB.substring(1);


	var r = HexToInt(ColorA.substring(0,2));
	var g = HexToInt(ColorA.substring(2,4));
	var b = HexToInt(ColorA.substring(4,6));
	var r2 = HexToInt(ColorB.substring(0,2));
	var g2 = HexToInt(ColorB.substring(2,4));
	var b2 = HexToInt(ColorB.substring(4,6));


	var rStep = Math.round((r2 - r) * (percentage/100));
	var gStep = Math.round((g2 - g) * (percentage/100));
	var bStep = Math.round((b2 - b) * (percentage/100));

	var ret = "#" + IntToHex(r+rStep) + IntToHex(g+gStep) + IntToHex(b+bStep);
	
	return ret;
}

function IntToHex(n) 
{
	var result = n.toString(16);
	if (result.length==1) result = "0"+result;
	return result;
}

function HexToInt(hex) 
{
	return parseInt(hex, 16); 
}

  function is_num(Field) 
    {
   if (Field.value=='')
      {
      return true;
      }
    theNum = parseFloat(Field.value);
    //alert(Field.value)
    if (Field.value != '' + theNum && Field.value != '' + theNum+'.' && Field.value != '')
       {
       //alert();
       return false;
       }
    return true;
    }
 function isInt(x) {
   var y=parseInt(x);
   if (isNaN(y)) return false;
   return x==y && x.toString()==y.toString();
 } 
