var blinkTO = 0;
var blinks = 0;

function blinkLights(el,switch_to){
  if(isNaN(document.getElementById(el).style.opacity)){
    setElOpacity(el,0);
  }
  if(switch_to == 'on')
    var v = document.getElementById(el).style.opacity * 100 - 12;
  else
    var v = document.getElementById(el).style.opacity * 100 + 10;
    
  if(v > 100 && switch_to == 'off') {
    setElOpacity(el, 100);
    setTimeout(bundleFunctionEl(null, blinkLights, [el, 'on']), 100);
  }
  else if(v < 0 && switch_to == 'on') {
    setElOpacity(el, 0);
    if(blinks == 1){
      blinks = 0;
      setTimeout(bundleFunctionEl(null, blinkLights, [el, 'off']), 3000);
    }
    else{
      blinks++;
      setTimeout(bundleFunctionEl(null, blinkLights, [el, 'off']), 100);
    }
  }
  else{
    setElOpacity(el, v);
    setTimeout(bundleFunctionEl(null, blinkLights, [el, switch_to]), 10);
  }
}

function setElOpacity(el, value) {
  document.getElementById(el).style.opacity = value / 100;
  document.getElementById(el).style.filter = "alpha(opacity=" + value + ")";
}

function bundleFunctionEl(context, func, args) {
  context = context || null;
  if(typeof func == "string" && context)
    func = context[func];
  if(!args)
    args = [];
  else if(!(args instanceof Array))
    args = [args];
  return function() {
    return func.apply(context, args);
  };
}

function getStyle(el, cssprop){
 if (el.currentStyle) //IE
  return el.currentStyle[cssprop]
 else if (document.defaultView && document.defaultView.getComputedStyle) //Firefox
  return document.defaultView.getComputedStyle(el, "")[cssprop]
 else //try and get inline style
  return el.style[cssprop]
}

var act_pos = 0;
var tOut_id = 0;

function slideDiv(el,to_pos){
  if(to_pos == 'undefined'){
    clearTimeout(tOut_id);
    to_pos = current_pos;
  }
  else if(to_pos == 'start'){
    to_pos = current_pos;
    if(ubrowser == "msie"){
      to_pos -= 0;
    }
    document.getElementById(el).style.marginLeft = to_pos+"px";
    clearTimeout(tOut_id);
    return;
  }

  if(ubrowser == "msie"){
    to_pos -= 0;
  }
  var pos = parseInt(getStyle(document.getElementById(el),"marginLeft"));
  act_pos = pos;
  
  if(act_pos < to_pos)
    pos += 6;
  else if(act_pos > to_pos)
    pos -= 12;
  
  if(pos == to_pos){
    document.getElementById(el).style.marginLeft = to_pos+"px";
    clearTimeout(tOut_id);
    return;
  }
  else{
    document.getElementById(el).style.marginLeft = pos+"px";
    if(ubrowser == "msie"){
      to_pos += 0;
    }
    tOut_id = setTimeout(bundleFunctionEl(null, slideDiv, [el, to_pos]), 10);
  }
    
}

function changecss(myclass,element,value) {
	var CSSRules
	if (document.all) {
		CSSRules = 'rules'
	}
	else if (document.getElementById) {
		CSSRules = 'cssRules'
	}
	for (var i = 0; i < document.styleSheets[0][CSSRules].length; i++) {
		if (document.styleSheets[0][CSSRules][i].selectorText == myclass) {
			document.styleSheets[0][CSSRules][i].style[element] = value
		}
	}	
}
