var divShow = ""
function trim(s) 
 {
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
  return s;
}
var xmlHttp;
function GetXmlHttpObject(){
  var xmlHttp=null;
  try{
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
  }
  catch (e){
    // Internet Explorer
    try{
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e){
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    }
  return xmlHttp;
}

function stateChanged_Showoff(){
	if (xmlHttp.readyState==4){ 
		var str = xmlHttp.responseText;
		document.getElementById("divShowoff").innerHTML = str;
		divShow = "";
	}
}

function ShowOff(url, divID) {
	divShow = divID;
	xmlHttp = GetXmlHttpObject()
	if (xmlHttp==null){alert ("Your browser does not support AJAX!"); return;} 
	xmlHttp.onreadystatechange=stateChanged_Showoff;
	xmlHttp.open("POST",url, true);
	xmlHttp.send(null);
	Showoff_Time(url, divID);
}

function Showoff_Time(url, divID){
	t = setTimeout("ShowOff('" + url + "', '" + divID + "')", 60000);
}

function stateChanged_VIP(){
	if (xmlHttp.readyState==4){ 
		var str = xmlHttp.responseText;
		document.getElementById("vipshow").innerHTML = str;
		//alert("Test" + document.getElementById("vipshow").innerHTML);
	}
}

function VIP(url, divID) {
	xmlHttp = GetXmlHttpObject()
	if (xmlHttp==null){alert ("Your browser does not support AJAX!"); return;} 
	xmlHttp.onreadystatechange=stateChanged_VIP;
	xmlHttp.open("POST",url, true);
	xmlHttp.send(null);
	VIP_Time(url, divID);
}

function VIP_Time(url, divID){
	t = setTimeout("VIP('" + url + "', '" + divID + "')", 40000);
}

 //The original javascript came from http://www.sunburnt.com.au/publications/design/javascript-fade-effects
        //I modified it to work with my code

        //set the opacity of the element (between 0.0 and 1.0)       
        function setOpacity(id, level) {            
            var element = document.getElementById(id); 
            element.style.display = 'inline';           
            element.style.zoom = 1;
            element.style.opacity = level;
            element.style.MozOpacity = level;
            element.style.KhtmlOpacity = level;
            element.style.filter = "alpha(opacity=" + (level * 100) + ");";
        }

        function fadeIn(id, steps, duration, interval, fadeOutSteps, fadeOutDuration){
            var fadeInComplete;      
            for (i = 0; i <= 1; i += (1 / steps)) {
              setTimeout("setOpacity('" + id + "', " + i + ")", i * duration); 
              fadeInComplete = i * duration;             
            }
            //set the timeout to start after the fade in time and the interval to display the 
            //message on the screen have both completed            
            setTimeout("fadeOut('" + id + "', " + fadeOutSteps + ", " + fadeOutDuration + ")", fadeInComplete + interval);           
        }

        function fadeOut(id, steps, duration) {         
            var fadeOutComplete;       
            for (i = 0; i <= 1; i += (1 / steps)) {
              setTimeout("setOpacity('" + id + "', "  + (1 - i) + ")", i * duration);
              fadeOutComplete = i * duration;
            }      
            //completely hide the displayed message after the fade effect is complete              
            setTimeout("hide('" + id + "')", fadeOutComplete);     
        }   

        function hide(id){
            document.getElementById(id).style.display = 'none'; 
			document.getElementById(id).innerHTML = "";    
        }
		
function stateChanged_VIP1(){
	if (xmlHttp.readyState==4){ 
		var str = xmlHttp.responseText;
		document.getElementById("vipshow").innerHTML = str;
		//alert("Test" + document.getElementById("vipshow").innerHTML);
	}
}

function VIP1(url, divID) {
	xmlHttp = GetXmlHttpObject()
	if (xmlHttp==null){alert ("Your browser does not support AJAX!"); return;} 
	xmlHttp.onreadystatechange=stateChanged_VIP1;
	xmlHttp.open("POST",url, true);
	xmlHttp.send(null);
	VIP_Time1(url, divID);
}

function VIP_Time1(url, divID){
	t = setTimeout("VIP1('" + url + "', '" + divID + "')", 35000);
}	

function fadein_Loop(){
	ft = setTimeout("fadein_Timer()", 34000);
}	

function fadein_Timer(){
	fadeIn('mydiv', 20, 1200, 16000, 25, 2000);
	fadein_Loop();
}	

function stateChanged_VIP2(){
	if (xmlHttp.readyState==4){ 
		var str = xmlHttp.responseText;
		document.getElementById("vipshow2").innerHTML = str;
		//alert("Test" + document.getElementById("vipshow").innerHTML);
	}
}

function VIP2(url, divID) {
	xmlHttp = GetXmlHttpObject()
	if (xmlHttp==null){alert ("Your browser does not support AJAX!"); return;} 
	xmlHttp.onreadystatechange=stateChanged_VIP2;
	xmlHttp.open("POST",url, true);
	xmlHttp.send(null);
	VIP_Time1(url, divID);
}

function VIP_Time2(url, divID){
	t = setTimeout("VIP2('" + url + "', '" + divID + "')", 45000);
}	

function fadein_Loop2(){
	ft = setTimeout("fadein_Timer2()", 44000);
}	

function fadein_Timer2(){
	fadeIn('mydiv2', 20, 1200, 16000, 25, 2000);
	fadein_Loop2();
}	